I have a relatively simple switch that sends data whenever the button is pressed (either 1 or 0). The message protocol it uses is MQTT. It is connected to Mosquitto via Wi-Fi and successfully sends data to it (i am able to see it using mosquitto_sub -v -t "#". However, I would like to be able to send this data to Orion Context Broker and then receive it using REST commands and store it using Fiware-Cygnus afterwards.
the topic that sensor publishes messages to is tt/sergo/demo/sw
the name of the sensor presented in mosquitto_sub when sensor is first connected: DMS-A01
the IP - address of sensor: 192.168.0.108
I have installed Iot-Agent UL, which is working, but I don't know how to make it listen to the specific sensor that sends data to Mosquitto.
I read the manuals but either missed something or did not find the solution to my problem.
I tried using the manual below, but could not apply it to my problem.
Connecting "thing" to Fiware
Thank you in advance, stack overflow community.
Before sending measures you need to do a provision operation for the device using the IOTA-UL API. That provision operation "creates" the device in the IOTA-UL and map it with the corresponding entity at CB. Then, you can start sending measures using MQTT.
You can have a look to this piece of documentation for more detail.
Related
All this is done in the Cooja simulation.
I need to develop a project in which I have a mote (or many) that acts like a sensor and sends data to a server which does computations and publishes the results on a topic using MQTT.
In both cases I assign IPs to motes using the rpl-border-router example provided by Contiki-NG.
I can publish fake data created by the server and publish it through the border router via MQTT; I can create a tree to send the values from the sensor motes to the server using UDP and compute what The problem is that I can't connect the two.
I don't attach the code because I want to understand the structure that I should use to accomplish this and the general idea behind the solution you propose, if possible
I tried two configurations but none works, because I think I don't have the right structure.
These are the two settings:
one mote per functionality: 1 sensor (1) sending data via UDP to a server (2), this server is set as root using NETSTACK_ROUTING.root_start(), which should publish data through MQTT via the rpl-border-router (3). I think the error here is that the server is set as root, while the rpl-border-router should, but then how can I send data to the server for computations?
use the rpl-border-router (1) as server also, so it computes the outcomes and publishes through MQTT, receiving the values via UDP from sensor mote (2). The problem here is the synchronization between MQTT broker assignment and IPv6 assignments, since both require IP
Thank you
I wanted to know if there is an example to do it the other way round, that is from Ably to MQTT.
I need this for my IoT application where I am trying to send an instruction to change the sensor value from the webpage -> ably-> MQTT broker-> my Arduino and wanted to try an example to implement the data transfer from Ably to MQTT. I was unable to find a reference example to build my code.
This is fairly straight forward with Ably. Most connections are bi-directional, so ably messages are translated into MQTT messages automatically.
You don't actually need a broker as we do that part as well.
Here is a sample project that does something similar with an arduino:
https://github.com/ably-labs/LED-Matrix-Jumper
There are a few other Adurino demos in the same Ably labs github org
For the past month, I have been working on two MQTT clients that will communicate with each other over a CloudMQTT broker.
The clients use the DAQIO LabVIEW MQTT library (found here https://github.com/DAQIO/LVMQTT). The basic operation is that one client (LaptopClient) will publish commands to the other client (USBClient), which will read the command, perform an action, and publish a message back to the origin.
The problem occurs when USBClient is unable to read the command. When USBClient is initialised and is waiting for LaptopClient to send a command, and LaptopClient sends a command, the "read subscribed topics" function of USBClient will present error 66, saying that the connection was closed.
What I've tried:
Using a local broker, instead of CloudMQTT
This resulted in no error, but I cannot use a local broker for the final product because I will not be able to connect from another computer over a wireless network.
Replacing LaptopClient's publish with mosquitto_pub (isolating USBClient)
This resulted in no error, USBClient was able to read the command and publish an acknowlegement.
Replacing USBClient's subscribe with mosquitto_sub (isolating LaptopClient)
This resulted in no error, LaptopClient was able to publish the command successfully.
Connecting to my phone's mobile hotspot
I tried this because I thought there might have been an issue with the network. It resulted in error code 1, which states that an input parameter was invalid. However, the only input parameter was the connection ID.
Replacing LaptopClient with default test client provided by DAQIO LabVIEW MQTT Library
I tried this to eliminate issues with the library. It resulted in no error.
It does not make sense to me, why does it work over a local broker but not online?
As you can see, the error occurs after reading the subscribed topics. Why does it work when either of the clients are replaced?
I have 2 nodeMCU modules, which I want to connect to an MQTT broker and send some data every 5 seconds.
The topology I am trying to achieve is sth like [router]<==[nodeMCU#1]<==[nodeMCU#2]
It looks like [nodeMCU#1] is a wifi extender, but at work we are planning on using multiple nodeMCU's to use in a mesh-like way for an IoT application.
On both of them I flashed the latest (float) release that I downloaded from here https://github.com/nodemcu/nodemcu-firmware/releases/tag/0.9.6-dev_20150704 using nodeMCU-flasher.
For this project wrote 2 lua scripts and I have uploaded them to the modules using ESPlorer.
For the first module it connects in STATIONAP mode to my work wifi, and creates its own network with SSID nodeMCUwifi, with a basic password of 10 characters "1234567890". After it connects the script sends random values to an MQTT topic.
For the second module connects to nodeMCUwifi correctly, it is assigned an IP address, but it cannot connect to the MQTT broker.
When I try to connect to nodeMCUwifi using my smartphone (just to test the connection, I have no intention of using this system for heavy internet load, only MQTT messages) I get a message "authentication error occured" even though I have typed the password correctly, or (in rarer cases)it connects but disconnects immediately.
I would appreciate any ideas to resolve this issue. Thank you.
EDIT: At the AP configuration I added the auth parameter set to 3, I am pasting a part of my code below.
cfg.ssid="ESP8266_"..node.chipid();
cfg.pwd="1234567890"
cfg.auth=3
wifi.ap.config(cfg);
Now my laptop and my smartphone connect to the wifi created by the module, but still have no connectivity to the internet. I can ping the module, but I can't ping 8.8.8.8 or the MQTT broker IP or anything else.
As I understand, [nodeMCU#1] creates a wifi network named nodeMCUwifi. Then the others are trying to connect to nodeMCUwifi. As You stated:
Now my laptop and my smartphone connect to the wifi created by the module, but still have no connectivity to the internet. I can ping the module, but I can't ping 8.8.8.8 or the MQTT broker IP or anything else.
I assume your laptop and smartphone connects to the nodeMCUwifi network. Now you want this [nodeMCU#1] act like layer 2 switch or something like router(since SOFTAP creates its own ip network).
With all this information on hand, I can say that the purpose you are trying to achieve is not possible with esp. Since esp has not enough resources to act like switch or similar. Also (currently) there is no software implemented in esp to achieve that.
However; if only you want the system to transfer certain type of traffic (such as MQTT) over a certain protocol (such as UDP) it is possible to relay the messages like a mesh structure but this will work one-way only. In this configuration the nodes will act more like repeater but on upper layers of OSI. For this idea i cannot provide sample code but I will provide pseudo-code below:
Configuration
> Each node must be configured to build a chain structure. That means each SOFTAP node should have different SSID or TCP settings. For example:
router(192.168.0.0)<----[NODE#1(SOFTAP0)]<----[NODE#2(SOFTAP1)]<---...
...
...
...<----[NODE#n(STATION)]
> Each node must have a TARGET IP address according to setup. This means every node will send the MQTT message to that address.
> If a node is configured as a SOFTAP, this means this system is a TARGET and must listen to a specific port.
> If a SOFTAP node receives some data on the port that is listening to, it should send the data immediately (or buffering) to its TARGET node.
> As a result of this chaining operation the message, no matter what is the source, will reach to the end of the chain.
CODE : SOFTAP
...soft ap config...
listento.port: udp.965
on("receive"):
create.conn:TARGET
send(DATA_RECEIVED)
close.conn:TARGET
CODE : STATION
...station config...
...Do some logic...
data=gather.data()
create.conn:TARGET
send(data)
close.conn:TARGET
I want to implement a demo application to listen data via TCP/IP.
Data Transmitter will transmit a series or ASCII char or a series of string all the time. It feeds data into TCP/IP address (eg. 127.0.0.1:22) This could be a GPS transmitter.
I want to implement a demo application for receiving data by clicking the start button and listening to the data via TCP/IP and display it accordingly.
Correct me if I am wrong, I don't think I can use Server/Client server for this purpose. I tried to create a client application with TIdTcpClient, it receives only one time data. I don't think Indy has a TCP listening component.
Thanks in advance.
If you wanna monitor network comunications between some device and some other program on your computer using of TIdTCPServer won't work. Why? Once Indy will read network data it will mark it as processed and delete it from network buffer. So that data probably won't even reach to the other program on your computer. Workaround for this is that you design your application to actually work similar as network bridge. Your application listens to the data on one port and then forwards that data on another port on which the other program is listening. But the main problem is that you have to make this to work both ways.
What you need is somekind of a component which is able to peek at the network data but don't interact with it. This is usually done on driver level.
Now if it is not abolutely necessary to have such functionality in your own software but you are only interested in getting the data I recomend you try Wireshark (http://www.wireshark.org/). Wireshark is a verry powerfull freware software which alows you to monitor all netwrok traffic on basically all protocols without causing any interuptions. In order for this software to work it instals special driver which serves for intercepting the network data.
Maybe you would want to use same driver in your application if this functionality needs to be in your application.
Based on your diagram I think that your implementation could also be based on a message-oriented middleware, using a message broker which receives the GPS transmitter or other data.
The message broker would then store the data internally and forward it to all interested clients which are connected. A typical messaging pattern in this case is a "Topic", which broadcasts the messages similar to a radio station.
So the middleware will ensure that the information will be collected (optionally also persisted to disk) and then guarantees the delivery to the receivers. This can be done even in a way where receivers which have been off-line for a while still receive the GPS messages created while they where not listening ('retroactive consumers').
There are many popular free open source message brokers, and most of them also can be used with Delphi.