ESP8266 WiFi gateway port for MySensors
-
Do you think we can use this board with MySensors (with NRF24 or RFM69) ?
https://github.com/hallard/NodeMCU-Gateway -
Hi,
If I want to use the GatewayESP8266MQTTClient sketch located in the development branch do I also need to use the mysensors libraries in that branch?
Thank you,
Mike
-
Hi,
If I want to use the GatewayESP8266MQTTClient sketch located in the development branch do I also need to use the mysensors libraries in that branch?
Thank you,
Mike
-
I created a simple ESP-MQTT sketch a while ago. I've only done some simple tests using it. Feedback appreciated.
@hek Thanks for the code. I have few questions in my mind. Firstly do I just have to upload this ESP8266MQTTClient.ino sketch on esp8266 12-E model? or does it needs anything to add in the sketch except SSID and password? I want to use ESP-8266-E and NRF24L01+ as gateway for openhab. If it is possible then, do I have to adopt the same procedure for configuring openhab as ethernet gateway? Secondly, Can I make two gateways using this sketch, is this possible? As I want to add sensors which are 500 meters away at my farmhouse.
-
This is a bit off topic, but hopefully not too off ;-)
What about a port of the MySensors library /API to ESP8266 ? Instead of two "boards" (Arduino nano plus nRF24L01+) only one would be required. For simple sensors an ESP-01 would be sufficient - about the size of a nRF24, but with much more muscle than an Arduino. Of course, running off a battery probably would not work because of the high power consumption of the ESP.Or am I asking for something which is already possible ?
Josh
-
@hek Thanks for the code. I have few questions in my mind. Firstly do I just have to upload this ESP8266MQTTClient.ino sketch on esp8266 12-E model? or does it needs anything to add in the sketch except SSID and password? I want to use ESP-8266-E and NRF24L01+ as gateway for openhab. If it is possible then, do I have to adopt the same procedure for configuring openhab as ethernet gateway? Secondly, Can I make two gateways using this sketch, is this possible? As I want to add sensors which are 500 meters away at my farmhouse.
@vickey said:
@hek Thanks for the code. I have few questions in my mind. Firstly do I just have to upload this ESP8266MQTTClient.ino sketch on esp8266 12-E model?
Yes
or does it needs anything to add in the sketch except SSID and password?
Entering SSID/PW should be enough.
I want to use ESP-8266-E and NRF24L01+ as gateway for openhab. If it is possible then, do I have to adopt the same procedure for configuring openhab as ethernet gateway?
I'm not an expert on openhab.. so I'll let someone else answer this one. But the ESP variant behaves exactly like the W5100 version.
Secondly, Can I make two gateways using this sketch, is this possible? As I want to add sensors which are 500 meters away at my farmhouse.
If openhab supports multiple gateways, sure. But you might wanna run sensor networks on different frequencies or changing MY_RF24_BASE_RADIO_ID.
Or am I asking for something which is already possible ?
Yes, the code runs directly on the ESP8266.
-
@hek I have installed GatewayESP8266MQTTClient sketch on my ESP-8266 12E.
Here is sketch I am using#include <EEPROM.h> #include <SPI.h> // Enable debug prints to serial monitor #define MY_DEBUG // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h #define MY_BAUD_RATE 9600 // Enables and select radio type (if attached) #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_GATEWAY_MQTT_CLIENT // Set this nodes topic prefix #define MY_MQTT_TOPIC_PREFIX "mygateway" // Set MQTT client id #define MY_MQTT_CLIENT_ID "mysensors-1" // Enable these if your MQTT broker requires usenrame/password //#define MY_MQTT_USER "admin" //#define MY_MQTT_PASSWORD "MyPassword" // Set WIFI SSID and password #define MY_ESP8266_SSID "Ahmed" #define MY_ESP8266_PASSWORD "MyPassword" // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,0,31 // If using static ip you need to define Gateway and Subnet address as well #define MY_IP_GATEWAY_ADDRESS 192,168,0,1 #define MY_IP_SUBNET_ADDRESS 255,255,255,0 // MQTT broker ip address. #define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 30 // The MQTT broker port to to open #define MY_PORT 1883 /* // Flash leds on rx/tx/err #define MY_LEDS_BLINKING_FEATURE // Set blinking period #define MY_DEFAULT_LED_BLINK_PERIOD 300 // Enable inclusion mode #define MY_INCLUSION_MODE_FEATURE // Enable Inclusion mode button on gateway #define MY_INCLUSION_BUTTON_FEATURE // Set inclusion mode duration (in seconds) #define MY_INCLUSION_MODE_DURATION 60 // Digital pin used for inclusion mode button #define MY_INCLUSION_MODE_BUTTON_PIN 3 #define MY_DEFAULT_ERR_LED_PIN 16 // Error led pin #define MY_DEFAULT_RX_LED_PIN 16 // Receive led pin #define MY_DEFAULT_TX_LED_PIN 16 // the PCB, on board LED */ #include <ESP8266WiFi.h> #include <MySensor.h> void setup() { } void presentation() { // Present locally attached sensors here } void loop() { // Send locally attech sensors data here }Here is the debug
0;0;3;0;9;Starting... scandone f 0, ....scandone state: 0 -> 2 (b0) .state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 1 cnt connected with Ahmed, channel 1 ip:192.168.0.31,mask:255.255.255.0,gw:192.168.0.1 .IP: 192.168.0.31 0;0;3;0;9;gateway started, id=0, parent=0, distance=0 0;0;3;0;9;Attempting MQTT connection...And it keeps attempinng for MQTT connection.
I have installed Domoticz on my RPi and added a hardware Mysensors Gateway with LAN interface with remote address i.e. 192.168.0.31 in my case and port 1883. Here is Domoticz log
2015-10-17 12:50:26.675 Hardware Monitor: Fetching data (System sensors) 2015-10-17 12:50:31.590 Error: MySensors: Error: Connection refused 2015-10-17 12:50:31.590 Error: TCP: Error: Connection refusedI don't have mosquitto installed in my Rpi.
May someone suggest me any solution.
-
@hek
Good morning. I had wired up my nodemcu a nRF24L01+, loaded the gateway sketch and bingo ! Zero problems, works like charm. Thanks a lot !!!I am using Domoticz as controller, with a serial USB gateway to connect my various sensors. In the serial console of the ESP8266 gateway I see that the messages of my sensors show up, but since I have not yet announced the gateway to Domoticz, there seems to be no interference. If I connect the ESP8266 gateway to a controller (in my case Domoticz), I guess that it will be required that the nodes need to choose the respective gateway (by using the parentNodeId) with which they like to communicate ? Currently, I am using parentNodeId = AUTO in all my nodes.
I will do some testing to get an idea of the reach of my WiFi compared to the reach of my serial USB gateway (I have a nRF24L01+ with external antanna and booster in my gateway, so I am able to "see" a portable node even outside my house and 50 m away.Again, thank you for this very useful extension of MySensors. I think I have not yet an estimate of the full potential of it
Cheers
Josh -
Hello,
I also tried to build a WiFi gateway today.
I get the following serial output when starting the gateway:ESP8266 MySensors Gateway Connecting to ************* ...Connected! IP: 192.168.1.218 0;0;3;0;9;gateway started, id=0, parent=0, distance=0Does this mean that everything is correct and I can integrate it into my FHEM solution?
Currently I'm working with a serial gatway. Do I have to modify something in my sensors when I switch to the new gateway? -
Hello,
I also tried to build a WiFi gateway today.
I get the following serial output when starting the gateway:ESP8266 MySensors Gateway Connecting to ************* ...Connected! IP: 192.168.1.218 0;0;3;0;9;gateway started, id=0, parent=0, distance=0Does this mean that everything is correct and I can integrate it into my FHEM solution?
Currently I'm working with a serial gatway. Do I have to modify something in my sensors when I switch to the new gateway?@gloob said:
I get the following serial output when starting the gateway:
Looking good! Congrats!
I have no experience using FHEM, but you should be able to use the WiFi gateway just like the regular ethernet gateway (as seen from FHEM).
So look around on this forum for any posts regarding usage of FHEM & ethernet gateway and you should be good. -
@hek
Good morning. I had wired up my nodemcu a nRF24L01+, loaded the gateway sketch and bingo ! Zero problems, works like charm. Thanks a lot !!!I am using Domoticz as controller, with a serial USB gateway to connect my various sensors. In the serial console of the ESP8266 gateway I see that the messages of my sensors show up, but since I have not yet announced the gateway to Domoticz, there seems to be no interference. If I connect the ESP8266 gateway to a controller (in my case Domoticz), I guess that it will be required that the nodes need to choose the respective gateway (by using the parentNodeId) with which they like to communicate ? Currently, I am using parentNodeId = AUTO in all my nodes.
I will do some testing to get an idea of the reach of my WiFi compared to the reach of my serial USB gateway (I have a nRF24L01+ with external antanna and booster in my gateway, so I am able to "see" a portable node even outside my house and 50 m away.Again, thank you for this very useful extension of MySensors. I think I have not yet an estimate of the full potential of it
Cheers
Josh@joshmosh You cannot have multiple gateways in a single MySensors network. The node-ID of the gateway is always hardcoded to 0.
If you want to run multiple networks, each should have a unique RF24_CHANNEL & RF24_BASE_RADIO_ID combination. For best results make sure to have a separate RF24_CHANNEL for each network, and don't use directly adjacent channels. -
Playing with AES signing and encryption I enabled verbose debug.
#define MY_DEBUG_VERBOSEThe sketch crashes with this setting but seems to work fine without verbose debug.
Is this a problem of my setup or a problem in the code?
The log pf the serial terminal:
write_register(0x04,0x5F) write_register(0x06,0x27) write_register(0x06,0x07) write_register(0x00,0x0C) write_register(0x07,0x70) write_register(0x05,0x4C) write_register(0x00,0x0E) write_register(0x00,0x0E) STATUS 0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 RX_ADDR_P0-1 0x0E0E0E0E0E 0303030303 RX_ADDR_P2-5 0xC3 C4 C5 C6 TX_ADDR 0x0E0E0E0E0E RX_PW_P0-6 0x00 00 00 00 00 00 EN_AA 0x3F EN_RXADDR 0x03 RF_CH 0x4C RF_SETUP 0x07 CONFIG 0x0E DYNPD/FEATURE 0x00 00 Data Rate 1MBPS Model nRF24L01+ CRC Length 16 bits PA Power PA_MAX write_register(0x01,0x3F) write_register(0x01,0x3B) write_register(0x1D,0x06) FEATURE=0x06 write_register(0x1C,0x03) write_regis -
Playing with AES signing and encryption I enabled verbose debug.
#define MY_DEBUG_VERBOSEThe sketch crashes with this setting but seems to work fine without verbose debug.
Is this a problem of my setup or a problem in the code?
The log pf the serial terminal:
write_register(0x04,0x5F) write_register(0x06,0x27) write_register(0x06,0x07) write_register(0x00,0x0C) write_register(0x07,0x70) write_register(0x05,0x4C) write_register(0x00,0x0E) write_register(0x00,0x0E) STATUS 0x0E RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0 RX_ADDR_P0-1 0x0E0E0E0E0E 0303030303 RX_ADDR_P2-5 0xC3 C4 C5 C6 TX_ADDR 0x0E0E0E0E0E RX_PW_P0-6 0x00 00 00 00 00 00 EN_AA 0x3F EN_RXADDR 0x03 RF_CH 0x4C RF_SETUP 0x07 CONFIG 0x0E DYNPD/FEATURE 0x00 00 Data Rate 1MBPS Model nRF24L01+ CRC Length 16 bits PA Power PA_MAX write_register(0x01,0x3F) write_register(0x01,0x3B) write_register(0x1D,0x06) FEATURE=0x06 write_register(0x1C,0x03) write_regis@FotoFieber said:
Is this a problem of my setup or a problem in the code?
I'll opt for the first, but lets see:
- What ESP hardware are you using?
- Which Arduino/ESP8266 port/MySensors version are you using?
- Did you define both DEBUG and MY_DEBUG_VERBOSE?
- What did you do to 'Play with AES signing and encryption' ?
- AES stuff is untested for ESP8266, however, you don't seen to get that far as it crashes during startup.
- My startup log (see here ) shows what it shoes during startup with DEBUG and MY_DEBUG_VERBOSE enabled.
-
@FotoFieber said:
Is this a problem of my setup or a problem in the code?
I'll opt for the first, but lets see:
- What ESP hardware are you using?
- Which Arduino/ESP8266 port/MySensors version are you using?
- Did you define both DEBUG and MY_DEBUG_VERBOSE?
- What did you do to 'Play with AES signing and encryption' ?
- AES stuff is untested for ESP8266, however, you don't seen to get that far as it crashes during startup.
- My startup log (see here ) shows what it shoes during startup with DEBUG and MY_DEBUG_VERBOSE enabled.
- ESP12E
- Development Version
- Defined both DEBUG AND VERBOSE
- Playing with AES:
#define MY_RF24_CHANNEL 13 #define MY_RF24_BASE_RADIO_ID ((uint64_t)0xF8A813FC09CL) #define MY_RF24_ENABLE_ENCRYPTION #define MY_RF24_ENCRYPTKEY secret.... #define MY_SIGNING_SOFT // Software signing enabled #define MY_SIGNING_SOFT_SERIAL secret.... // Key to use for HMAC calculation in soft signing (32 bytes) #define MY_SIGNING_SOFT_HMAC_KEY secretIt seems to work perfect without the verbose debug.
I will test now without AES. My gut tells me, I should look inside the AES stuff.
-
@joshmosh You cannot have multiple gateways in a single MySensors network. The node-ID of the gateway is always hardcoded to 0.
If you want to run multiple networks, each should have a unique RF24_CHANNEL & RF24_BASE_RADIO_ID combination. For best results make sure to have a separate RF24_CHANNEL for each network, and don't use directly adjacent channels.@Yveaux said:
@joshmosh You cannot have multiple gateways in a single MySensors network. The node-ID of the gateway is always hardcoded to 0.
If you want to run multiple networks, each should have a unique RF24_CHANNEL & RF24_BASE_RADIO_ID combination. For best results make sure to have a separate RF24_CHANNEL for each network, and don't use directly adjacent channels.@Yveaux
Thank you for this piece of information - I was not aware of this fact.
My idea was to reduce cost and parts count for sensors by using ESPs instead of nRF plus Arduino. Since I have Domoticz as controller, there is pehaps no need for an additional gateway, because Domoticz can handle TCP-attached sensors. Of course this would require to use WiFi instead of nRF24 as underlying transport for MySensors. My interpretation of some of hek's contributions is that he is working on it for realisation in version 1.6. -
- ESP12E
- Development Version
- Defined both DEBUG AND VERBOSE
- Playing with AES:
#define MY_RF24_CHANNEL 13 #define MY_RF24_BASE_RADIO_ID ((uint64_t)0xF8A813FC09CL) #define MY_RF24_ENABLE_ENCRYPTION #define MY_RF24_ENCRYPTKEY secret.... #define MY_SIGNING_SOFT // Software signing enabled #define MY_SIGNING_SOFT_SERIAL secret.... // Key to use for HMAC calculation in soft signing (32 bytes) #define MY_SIGNING_SOFT_HMAC_KEY secretIt seems to work perfect without the verbose debug.
I will test now without AES. My gut tells me, I should look inside the AES stuff.
@Yveaux
Downloaded the development branch again and used the sketch included as example. The sketch is hanging too. My gut was wrong, AES is not the problem. -
Hi.
I am having an issue with my ESP8266 gateway. I have tried all versions of mysensors including developmental versions, but my esp8266 does not show any serial debug, nor it gets connected to my router. I also enabled debug in configuration file. When I install AT firmware, it replies to AT command, it also works with nodemcu firmware, but it does not respond with Arduino firmware. May someone help me? -
Finally I got my NodeMCU and tried the WiFi gateway too. But I get the following messages (with Serial.setDebugOutput(true);):
ESP8266 MySensors Gateway Connecting to WLAN scandone f 0, ....scandone .add 0 aid 1 pm open phy_2,type:2 0 0 cnt ..................rm 0 pm close 7 0 0/9299504 ..reconnect f -240, ....scandone no WLAN found, reconnect after 1s .reconnect f 0, ....scandone .add 0 aid 1 pm open phy_2,type:2 0 0 cnt ................rm 0 pm close 7 0 0/8288631 ..reconnect f -240, ....scandone no WLAN found, reconnect after 1s .reconnect f 0, ....scandone .add 0 aid 1 pm open phy_2,type:2 0 0 cnt ................rm 0 pm close 7 0 0/8124923 ..reconnectAdditionally I tried to use
IPAddress ip(192, 168, 38, 18); /* Set to whatever IP address you'd like the gateway to have */ WiFi.config(ip);to avoid DHCP, but that gives error during compiling:
no matching function for call to 'ESP8266WiFiClass::config(IPAddress&)'Any hints how to solve?
Thanks
Edit:
to find the problem I tested to connect the ESP to the wifi-hotspot of my smartphone... worked. Is it maybe a problem if the password contain special characters which behave strange during compiling? -
@Anduril said:
no WLAN found, reconnect after 1s
That's a clear indication the ESP cannot connect to your WiFi accesspoint.
Is the SSID matching your accesspoint ('WLAN')?
Is the encryption supported by the ESP (see e.g. https://nurdspace.nl/ESP8266#Features -- not sure if it is accurate)
Weird characters in the password could be problematic (and of course the password is case-sensitive).Changing between DHCP/Fixed IP won't make a difference here, as the ESP doesn't even connect. IP configuration starts once connected.