MQTT Broker gateway
-
I have ENC28J60-I/SO connected by ethernetcable to my Asus RT-n66u in LAN 4. But It will not show up in my router... On my ENC28J60 there is a red light on D1 and the ethernet port has a green light and a yellow flashing light.
Serial monitor says "
Started!
0;0;3;0;9;read: 20-20-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
0;0;3;0;9;read: 20-20-0 s=255,c=3,t=6,pt=1,l=1:0
0;0;3;0;9;send: 0-0-20-20 s=255,c=3,t=6,pt=0,l=1,st=ok:M
0;0;3;0;9;read: 20-20-0 s=255,c=3,t=11,pt=0,l=18:Temperature Sensor
0;0;3;0;9;read: 20-20-0 s=255,c=3,t=12,pt=0,l=3:1.0. But nothing more. I have followed the MQTT gateway guide and set an static ip in the sketch.. DHCP is on in my router.
The only thing I see in my router is : That the cable is connected to something and that its 10 Half duplex.
I have also tried to connect it to other LAN ports but no difference
What could be wrong?
-
I have ENC28J60-I/SO connected by ethernetcable to my Asus RT-n66u in LAN 4. But It will not show up in my router... On my ENC28J60 there is a red light on D1 and the ethernet port has a green light and a yellow flashing light.
Serial monitor says "
Started!
0;0;3;0;9;read: 20-20-0 s=255,c=0,t=17,pt=0,l=5:1.4.1
0;0;3;0;9;read: 20-20-0 s=255,c=3,t=6,pt=1,l=1:0
0;0;3;0;9;send: 0-0-20-20 s=255,c=3,t=6,pt=0,l=1,st=ok:M
0;0;3;0;9;read: 20-20-0 s=255,c=3,t=11,pt=0,l=18:Temperature Sensor
0;0;3;0;9;read: 20-20-0 s=255,c=3,t=12,pt=0,l=3:1.0. But nothing more. I have followed the MQTT gateway guide and set an static ip in the sketch.. DHCP is on in my router.
The only thing I see in my router is : That the cable is connected to something and that its 10 Half duplex.
I have also tried to connect it to other LAN ports but no difference
What could be wrong?
@msebbe Did you try to ping the gateway static IP?
-
@msebbe Did you try to ping the gateway static IP?
@celonunes
Yes, both from windows cmd and from the router ui with this result:
PING 192.168.1.197 (192.168.1.197): 56 data bytes
--- 192.168.1.197 ping statistics ---
5 packets transmitted, 0 packets received, 100% packet lossCould be that I have not changed the MAC adress cause I tried to figure out how to do it but I dont understand this part from the MQTT gateway sketch:
*1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.
#define TCP_PORT 1883 // Set your MQTT Broker Listening port. IPAddress TCP_IP ( 192, 168, 1, 197 ); // Configure your static ip-address here uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 }; // Mac-address - You should change this! see note *2 above! -
@celonunes
Yes, both from windows cmd and from the router ui with this result:
PING 192.168.1.197 (192.168.1.197): 56 data bytes
--- 192.168.1.197 ping statistics ---
5 packets transmitted, 0 packets received, 100% packet lossCould be that I have not changed the MAC adress cause I tried to figure out how to do it but I dont understand this part from the MQTT gateway sketch:
*1 -> NOTE: Keep first byte at x2, x6, xA or xE (replace x with any hex value) for using Local Ranges.
#define TCP_PORT 1883 // Set your MQTT Broker Listening port. IPAddress TCP_IP ( 192, 168, 1, 197 ); // Configure your static ip-address here uint8_t TCP_MAC[] = { 0x02, 0xDE, 0xAD, 0x00, 0x00, 0x42 }; // Mac-address - You should change this! see note *2 above!@msebbe Which library your are using for the ENC28J60? The UIPEthernet has some examples you could try to test if your module is working.
-
@Chaotic said:
The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?
That's right.
@celonunes
Just wanted to say I was able to get this working.Also found a nice little MQTT utility that makes it easy to see the messages being sent from the broker/openhab.
I'm sure I'll have more questions but most of my hardware is still on a boat from china so will be a little while till I discover them.
-
@msebbe Which library your are using for the ENC28J60? The UIPEthernet has some examples you could try to test if your module is working.
@celonunes In the Mqtt broker sketch, Ethernet.h was included. I suppose it should be UIPEthernet.h for me? So I tried that but nothing.
I had better luck with the UIPEthernet examples, there my arduino shows up with an ip and mac adress.. Hmmm.
edit:
So after using UIPEthernet "Advanced chat server" sketch, the MAC and IP showed up in my router. When I then tried with the MQTT sketch with UIPEthernet.h it would not work. So then I tried to copy the MAC and IP I used in the chat server sketch into the Mqtt sketch and bom! I can now ping it, so I guess it works now?
edit2: Should it say anything more then "Started!" on serial monitor? Like "on ip 192.168.1.197" or something like that? Since Im now trying the MQTT in pidome as I know how to use pidome better. Pidome states;
Connected: Yes, with 192.168.1.197:1883 at topic: MyMQTT/# (without subscribe promise)
Last receive time: 00-00-0000 00:00
Last send time: 00-00-0000 00:00This is what Serial monitor says http://i61.tinypic.com/i252kn.png
But when I use device discovery it cannot find the temperature sensor that could be found using the serial gateway :/
-
Hi everyone,
Finally got this working but had a couple of quetions
Does the MQTT Broker gateway not handle requests for time? I currently have a node that I'm using as an alarm clock which has a RTC module. I had hoped to be able to update the time via the gateway and polling the time from one of my computers which are connected to NTP servers but the message never seems to get put on a MQTT message so I can't have a computer respond to it.
-
@celonunes In the Mqtt broker sketch, Ethernet.h was included. I suppose it should be UIPEthernet.h for me? So I tried that but nothing.
I had better luck with the UIPEthernet examples, there my arduino shows up with an ip and mac adress.. Hmmm.
edit:
So after using UIPEthernet "Advanced chat server" sketch, the MAC and IP showed up in my router. When I then tried with the MQTT sketch with UIPEthernet.h it would not work. So then I tried to copy the MAC and IP I used in the chat server sketch into the Mqtt sketch and bom! I can now ping it, so I guess it works now?
edit2: Should it say anything more then "Started!" on serial monitor? Like "on ip 192.168.1.197" or something like that? Since Im now trying the MQTT in pidome as I know how to use pidome better. Pidome states;
Connected: Yes, with 192.168.1.197:1883 at topic: MyMQTT/# (without subscribe promise)
Last receive time: 00-00-0000 00:00
Last send time: 00-00-0000 00:00This is what Serial monitor says http://i61.tinypic.com/i252kn.png
But when I use device discovery it cannot find the temperature sensor that could be found using the serial gateway :/
@msebbe It doesn't print your ip, those numbers after "Started!" is related to mqtt packages showing that PiDome is connected.
For the device discovery, there are probably a lot of other people who can help you with that because I don't know much about PiDome. -
Hi everyone,
Finally got this working but had a couple of quetions
Does the MQTT Broker gateway not handle requests for time? I currently have a node that I'm using as an alarm clock which has a RTC module. I had hoped to be able to update the time via the gateway and polling the time from one of my computers which are connected to NTP servers but the message never seems to get put on a MQTT message so I can't have a computer respond to it.
@Chaotic MQTT Broker gateway doesn't handle time requests.
-
@Chaotic said:
The MQTT Broker is the MQTT server so if I wanted to use this with openhab on a pi I would just need the MQTT plugin and then point it to the IP of the gateway?
That's right.
@celonunes Ok, thanks! I got the discovery working by just rebuilding the same sensor from scratch!
Sorry for so many questions.. But I have now changed to Openhab and got it working with my MQTT gateway. Now Another problem appear:
http://i60.tinypic.com/2d2eqzk.png[/IMG
I would like to display the temperature in °C like in your guide sketch (wich I am using) but instead it looks like in the picture. Same thing about humidity, why is it like this?
Edit: For anyone wondering, I solved the issue with the degree symbol not showing up properly by replacing "°C" with "& deg;C" without space between & deg
-
Hi Folks,
New to mysensors and am impressed. I've been playing with OpenHAB and MQTT so this sounds like an interesting project. My question though, which might have been answered but I'm finding it hard to find the answer, is - is this bidirectional? As in if I had a 'sensor' on the Arduino network and that went over the radio network, hit the gateway and then got picked up by OpenHAB, could I then, if I had a 'actuator' or a 'do-er' node on the network, send a message to MQTT from OpenHAB to change the status of that actuator device? So for instance to start a motor controlling blinds for instance? Or is it a read only system?
Thanks
-
Hi Folks,
New to mysensors and am impressed. I've been playing with OpenHAB and MQTT so this sounds like an interesting project. My question though, which might have been answered but I'm finding it hard to find the answer, is - is this bidirectional? As in if I had a 'sensor' on the Arduino network and that went over the radio network, hit the gateway and then got picked up by OpenHAB, could I then, if I had a 'actuator' or a 'do-er' node on the network, send a message to MQTT from OpenHAB to change the status of that actuator device? So for instance to start a motor controlling blinds for instance? Or is it a read only system?
Thanks
It works both ways.
-
Thanks :)
-
How can I implement MQTT for MQ-2 Gas sensor the correct way? In the mysensor sketch there is only one child ID and one V_VAR1 but 3 different outputs: LPG, CO and Smoke? I'm only receiving CO value and not all 3 in openhab.
@kunall There is V_VAR1-5 actually
V_VAR1 24 Custom value V_VAR2 25 Custom value V_VAR3 26 Custom value V_VAR4 27 Custom value V_VAR5 28 Custom valuePersonally I would set up each value you want as a S_CUSTOM if you can't figure out another sensor type that fits.
For smoke you can use S_SMOKE
For Air Quality S_AIR_QUALITY
Not sure what you'd want to use for CO2 through -
@kunall There is V_VAR1-5 actually
V_VAR1 24 Custom value V_VAR2 25 Custom value V_VAR3 26 Custom value V_VAR4 27 Custom value V_VAR5 28 Custom valuePersonally I would set up each value you want as a S_CUSTOM if you can't figure out another sensor type that fits.
For smoke you can use S_SMOKE
For Air Quality S_AIR_QUALITY
Not sure what you'd want to use for CO2 through -
How to Set-up MQTTGateway with OpenHAB
What is MQTTGateway:
MQTTGateway will act as a broker, a server. And any MQTT clients should be able to connect to it (Please let me know if you experience problems).
MQTTGateway is a very simple implementation. It will not care if the client subscribes to anything or not.
Every node package it receives it will publish to the client. Sketch name and version is also implemented.
Most clients handle this well and just ignores messages it hasn't been subscribed yet.
There are some settings in MQTT that can be good to take a look at.
You will need to configure TCP_IP and TCP_PORT.
MQTTGateway will also give nodes an ID between MQTT_FIRST_SENSORID and MQTT_LAST_SENSORID. The last position is stored in EEprom.As standard MQTT_SEND_SUBSCRIPTION is enabled. This basically means that the broker will send a empty payload to the node upon a subscribe package. This can be useful. Just keep in mind that you can receive empty payload packages.
The MQTTGateway will also present its SketchName and SketchVersion.
Lets get started!
First follow https://github.com/openhab/openhab/wiki/Quick-Setup-an-openHAB-Server You can setup and try with DEMO configuration first.Then we need to unpack org.openhab.binding.mqtt into addons folder * NOTE (During development of MQTTGateway I found a bug inside openhab mqtt client which is solved in 1.6.0 nightly build. Use this nightly addon if you experience problems)
-
openhab.cfg
All you need to do here is to addmqtt:mysensor.url=tcp://192.168.0.234:1883
mqtt:mysensor.clientId=MQTT
ClientID does not matter at all (just keep it short). And IP and Port is self explanatory.
Now you can start OpenHAB, it will connect but nothing more will happen.
This is because we hasn't subscribed to anything and OpenHAB will just ignore every incoming package.So here comes a sample configuration of OpenHAB.
-
items/test.items
Group all
Group node1 (all)
Group node2 (all)
Group sketch (all)Number node1_temp "Temp [%.1f °C]" (node1,all) {mqtt="<[mysensor:MyMQTT/20/10/V_TEMP:state:default]"}
Number node1_humid "Humid [%.1f %%Rh]" (node1,all) {mqtt="<[mysensor:MyMQTT/20/11/V_HUM:state:default]"}Switch node2_sw1 "sw2" (node2,all) {mqtt=">[mysensor:MyMQTT/21/1/V_LIGHT:command:ON:1],>[mysensor:MyMQTT/21/1/V_LIGHT:command:OFF:0]"}
Switch node2_sw2 "sw2 send + recieve example" (node2,all) {mqtt=">[mysensor:MyMQTT/21/2/V_LIGHT:command:ON:1],>[mysensor:MyMQTT/21/2/V_LIGHT:command:OFF:0],<[mysensor:MyMQTT/21/2/V_LIGHT:command:MAP(1on0off.map)]"}String sketch20 "Sketch name 20 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/20/255/V_SKETCH_NAME:state:default]"}
String sketch21 "Sketch name 21 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/21/255/V_SKETCH_NAME:state:default]"}
String sketch22 "Sketch name 22 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/22/255/V_SKETCH_NAME:state:default]"}
String sketch23 "Sketch name 23 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/23/255/V_SKETCH_NAME:state:default]"}
String sketch24 "Sketch name 24 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/24/255/V_SKETCH_NAME:state:default]"}
String sketch25 "Sketch name 25 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/25/255/V_SKETCH_NAME:state:default]"}
String sketch26 "Sketch name 26 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/26/255/V_SKETCH_NAME:state:default]"}
String sketch27 "Sketch name 27 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/27/255/V_SKETCH_NAME:state:default]"}
String sketch28 "Sketch name 28 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/28/255/V_SKETCH_NAME:state:default]"}
String sketch29 "Sketch name 29 [%s]" (sketch,all) {mqtt="<[mysensor:MyMQTT/29/255/V_SKETCH_NAME:state:default]"}
We also need to create a sitemap :
-
sitemap/test.sitemap
sitemap demo label="Menu"
Frame label="test" {
Group item=node1 label="Temp hum node"
Group item=node2 label="Switch node"
Group item=sketch label="Sketch names"
Group item=all label="Everything"
}
and a simple transformation file :
-
transform/1on0off.map
1=ON
0=OFF
If everything worked and I didn't forget anything just fire up :
http://[Openhab]:8080/openhab.app?sitemap=test
After you restart one of your node's the data and sketch name should be visible.
Openhab will forget everything after every restart. Use persistence to fix this (https://github.com/openhab/openhab/wiki/rrd4j-Persistence)@Damme
how to run MySensors ( MQTT gateway) on the arduino due + Wiznet5100 + NRf24l01?
Get the error:Arduino: 1.5.8 (Windows 8), Board: "Arduino Due (Programming Port)" In file included from Z:\arduino-1.5.8-new\libraries\DigitalIO/DigitalIO.h:31:0, from EthernetGateway.ino:41: Z:\arduino-1.5.8-new\libraries\DigitalIO/DigitalPin.h:30:20: fatal error: avr/io.h: No such file or directory #include <avr/io.h> ^ compilation terminated. Ошибка компиляции. This report would have more information with "Show verbose output during compilation" enabled in File > Preferences. -
-
@celonunes Nope. I figured it out. In my openhab config file there was space prior to my MQTT related lines
" mqtt:mysensor.url=tcp://192.168.1.134:1883"
" mqtt:mysensor.clientId=OpenhabMQTT"
Instead of
"mqtt:mysensor.url=tcp://192.168.1.134:1883"
"mqtt:mysensor.clientId=OpenhabMQTT"Removed the space and now I get my light sensor output value. I still don't get the sketch name coming through but I'll look into that later.
@hooraysimpsons this solved my problem too! Everything else in my setup was a quick job but problem solving this issue took half a day. It should be more widely circulated..
-
Ok,forget my last post, I have a new problem:
When I uplaod the EthernetGW Sketch to my arduino nano I can see MQTT messages coming in from one node int the arduino serial monitor. So now I uploaded the MQTTGW sketch to my nano because I would like to use openhab. But after uploading the sketch all info I get from serial monitor is "Started!", nothing else is showing up.
I can still ping the MQTT gateway but it seems like it´s not receiving any mqtt message, at least no the state of my node. Could you please help and support me here? Thanks in advance!