ESP8266 WiFi gateway port for MySensors



  • @Yveaux said:

    @DrJeff said:

    @Yveaux No you did not scare me away

    A, damn ! Maybe next project then? 👊

    The problem lies mainly in the vast amount of ESP variants and how to wire them to be able to download and to connect the radio.

    Sorry it was supposed to be "No you didn't scare", me auto correct!
    I'm going to build this for sure!
    🙂


  • Mod

    @Andy-Pep said:

    i like the way it reboots when connection is lost

    I cannot replay this situation:

    • Tried disabling my WiFI network on the router. Gateway keeps running and restores connection correctly when WiFI is enabled again. No reboot observed.
    • Tried disconnecting telnet session. No reboot.

    What did you do to cause a reboot?



  • Yes great work is right. thank you



  • Ok I will test it in few days.
    Do you think is it possible to have an ESP gateway with RF24 and RF69 ? ESP have more memroy (ESP12E)


  • Mod

    @Fabien connecting two radios should work, although MySensors does not natively support it.



  • Hi, let me ask a silly question just to confirm if I understand how this would work.

    This gateway would receive Nodes data throght NRF or RF69 and then send it to controller via wifi? The way back would be, receiving controller commands/data via wifi and get to the nodes through NRF or RF69.

    Is this right?

    Thanks!


  • Mod

    @gonzalonal said:

    Hi, let me ask a silly question just to confirm if I understand how this would work.

    This gateway would receive Nodes data throght NRF or RF69 and then send it to controller via wifi? The way back would be, receiving controller commands/data via wifi and get to the nodes through NRF or RF69.

    Is this right?

    Thanks!

    Correct!



  • Doesn't work here with stage version of ESP8266-Arduino (can't install stable version, I have checksum error). I use this module http://www.electrodragon.com/product/nodemcu-lua-amica-r2-esp8266-wifi-board/
    Can't load at 9600 bauds (how can you change uplaod baud rate ?)
    Crash on init and reboot :

    ESP8266 MySensors Gateway
    Connecting to Livebox-577E
    ...Connected!
    IP: 192.168.1.23
    
    Exception (3):
    epc1=0x40206955 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40244cd2 depc=0x00000000
    
    ctx: cont 
    sp: 3ffea540 end: 3ffea780 offset: 01a0
    
    >>>stack>>>
    3ffea6e0:  a8e1fcff 000000a8 3ffe9294 40206b7c  
    3ffea6f0:  00000001 3ffe9290 3ffe9294 402036d0  
    3ffea700:  00000000 00000000 3ffe91fc 40204910  
    3ffea710:  0000007f 3ffea7ac 40201cac 3ffe9760  
    3ffea720:  40202320 00000001 00000000 40201d4f  
    3ffea730:  1701a8c0 00ffffff 0101a8c0 3ffea7ac  
    3ffea740:  3ffe873d 3ffe9474 3ffe972c 4020266f  
    3ffea750:  3ffe8c08 1701a8c0 00000000 00000000  
    3ffea760:  3fffdc20 00000000 3ffea7a4 40201d1f  
    3ffea770:  00000000 00000000 3ffe9760 40100374  
    <<<stack<<<
    
     ets Jan  8 2013,rst cause:2, boot mode:(3,6)
    
    load 0x4010f000, len 1264, room 16 
    tail 0
    chksum 0x42
    csum 0x42
    ~ld
    

  • Mod

    @Fabien said:

    Doesn't work here with stage version of ESP8266-Arduino (can't install stable version, I have checksum error).

    What do you mean by stage version and checksum error exactly?
    Tonight @hek merged the gateway code for ESP to master 1.5. Could you try with that version?

    I use this module http://www.electrodragon.com/product/nodemcu-lua-amica-r2-esp8266-wifi-board/

    Seems identical to the one I ordered. Until I receive it I cannot replay your exact case. I did test & develop using separate ESP12 module, while your board has ESP12E, I guess. Can you confirm this?

    Can't load at 9600 bauds (how can you change uplaod baud rate ?)

    Don't bother about the download speed. I only suggest to start at low speed as it seems to download more reliably. Did download finish without errors?

    Crash on init and reboot :

    ESP8266 MySensors Gateway
    Connecting to Livebox-577E
    ...Connected!
    IP: 192.168.1.23
    
    Exception (3):
    epc1=0x40206955 epc2=0x00000000 epc3=0x00000000 excvaddr=0x40244cd2 depc=0x00000000
    
    ctx: cont 
    sp: 3ffea540 end: 3ffea780 offset: 01a0
    
    >>>stack>>>
    3ffea6e0:  a8e1fcff 000000a8 3ffe9294 40206b7c  
    3ffea6f0:  00000001 3ffe9290 3ffe9294 402036d0  
    3ffea700:  00000000 00000000 3ffe91fc 40204910  
    3ffea710:  0000007f 3ffea7ac 40201cac 3ffe9760  
    3ffea720:  40202320 00000001 00000000 40201d4f  
    3ffea730:  1701a8c0 00ffffff 0101a8c0 3ffea7ac  
    3ffea740:  3ffe873d 3ffe9474 3ffe972c 4020266f  
    3ffea750:  3ffe8c08 1701a8c0 00000000 00000000  
    3ffea760:  3fffdc20 00000000 3ffea7a4 40201d1f  
    3ffea770:  00000000 00000000 3ffe9760 40100374  
    <<<stack<<<
    
     ets Jan  8 2013,rst cause:2, boot mode:(3,6)
    
    load 0x4010f000, len 1264, room 16 
    tail 0
    chksum 0x42
    csum 0x42
    ~ld
    

    Apparently you did connect to WiFi correctly and got an IP address.
    Debugging this module is hard; I add serial print statements at strategic places to drill down to the cause of such access violations.
    It would really help if you can get some more info on where it crashes by adding these print statements.
    Otherwise you'll probably have to wait until we get to a common hardware setup.


  • Mod

    @Fabien My bad, mea culpa 👊
    Have been so busy getting the stuff to compile for all different platforms that this bug sneaked in... That's why you should always verify if your code still works, after building it 😉

    Anyway, see this pull request for the fix.
    Once it is merged to master, could you please try again?

    I'm also experiencing some random disconnects, so expect a new update soon...


  • Admin

    Opps 😊

    Started Jenkins build of the PR.


  • Mod

    @hek You probably got so accustomed to building it 😫


  • Admin

    The build server must earn its cost 🙂


  • Mod

    I prepared a new pull request which deals with some occasional watchdog timeouts (causing a reset) when clients connect or disconnect.
    It also allows multiple clients to connect simultaneously to the ESP gateway.
    Please update to this version once it's integrated in master.



  • With pull #186, it works better ...
    Connection ok, can see messages form sensors on the serial line.
    Connecting with MYSController, got "Gateway startup complete." on the serial link but nothing on MYSController. Pinging works ...
    Perhaps somme problems with ESP and Livebox ... I have this problem before with some sketch and I must made an AP on my Odroid ... I will try later.


  • Admin

    MySensors/Arduino#186 Merged



  • Can this be built with esp8266-03? I got a couple of those sitting here waiting to get used? It looks like I can swap Pin 4 for Pin 16 (or 18 in this picture) Is there something I'm missing?

    upload-84b2ef8e-b204-4e47-88a7-ddcd10405227


  • Mod

    @DrJeff GPIO16 is a strange IO pin on some modules as it might be triggering the nReset line. Should work for this ESP-03 though.
    Make sure to use the latest MySensors library and please post your experiences here so we can bundle them.


  • Mod

    NodeMcu boards are in!
    Fast shipment & very well packed:

    2015-09-05 13.26.54.jpg
    2015-09-05 13.27.51.jpg

    I can upload at 921600 baud (!) without manual reset/bootload from Arduino IDE and LED blink sketch is working.
    Next is connecting nRF24 and see if ESP gateway is running without problems.

    I'll keep you informed!


  • Mod

    Works like a charm!

    This is the NodeMcu board used (Called NodeMcu Devkit v1.0 by the NodeMcu Team. Schematics and layout can be found here)

    Radio connection (using MySensors default coloring scheme. IRQ is unused and can be left unconnected):
    nrfTop.png
    NODEMCU_DEVKIT_V1.0_PINMAP.png
    2015-09-05 14.49.01.jpg

    The standard ESP8266 Gateway sketch can be used without modification (except for SSID & password).

    • Install CP2102 drivers from here.
    • Connect NodeMCU board.
    • Load the Esp8266Gateway.ino sketch (See Compiling the gateway in the top post)
    • Download the sketch. This NodeMcu board can be flashed automaticlly and doesn't need botload/reset buttons to be pressed.
    • Open the serial console and watch the board connecting to yout WiFi network.
    • Note the IP address assigned to it.
    • Now any application capable of communicating with the regular MySensors Ethernet gateway should be able to communicate with the ESP Gateway.
    • Enjoy!

    Optional step: If you want to use the onboard red LED (GPIO16) to blink when radio activity/error takes place, then change the following:

    MyConfig.h

    #define WITH_LEDS_BLINKING
    

    Esp8266Gateway.ino

    #ifdef WITH_LEDS_BLINKING
    #define RADIO_ERROR_LED_PIN 16  // Error led pin
    #define RADIO_RX_LED_PIN    16  // Receive led pin
    #define RADIO_TX_LED_PIN    16  // the PCB, on board LED
    #endif
    

  • Admin

    Thanks @Yveaux,

    I'll probably copy (most) of the previous post to the main site.


  • Mod

    @hek said:

    I'll probably copy (most) of the previous post to the main site.

    Yeah, no probs. I already thought you would.
    Maybe you should 'MySensor' the devkit pinout a little to have it fit in.



  • Hi

    Excellent build and exactly what I have been looking for. I just got my ESP-12 this week and I am about to build this. I just have one question, what is the "Inclusion mode" for? I tried to figure it out by look at the sketch and it's not quite clear.

    Thank you for everything you have done to get this to where it's at.

    Mike


  • Mod

    @Mike-Cayouette I copied the implementation from the Ethernet gateway.
    I thought it was meant as a function to allow clients to join the network within a certain timeframe after pressing the button.
    When looking at the code I'm not sure it does anything at all...
    Maybe @hek can shed some light on the issue?


  • Admin

    It doesn't do much on the gateway side. As @Yveaux says it allows you to have a physical button in the gateway to enable inclusion mode. After some (configurable) time it disables inclusion mode. The enabled/disabled status is sent to controller side. But no filtering of presentation messages occurs on the gateway.

    So it is really up to the controller to respect the inclusion mode status (whether or not to create new devices).


  • Admin

    @Yveaux
    Please PM me any updates needed on this:
    http://www.mysensors.org/build/esp8266_gateway



  • Hi @Yveaux ,

    I finally received my NodeMCU (but from http://doit.am/) did you had to flash any firmware (like the NodeMCU one) in order to be able to use it from Arduino IDE or it is just flash the .ino and it's ready to go?

    Regards


  • Mod

    @Daniel-Oliveira by downloading from the Arduino ide you will overwrite any firmware already in the flash. No manual steps are required. Just connect and download from Arduino ide.



  • Thank you for the quick response @Yveaux & @hek

    I started working on the gateway today but I seem to be having a problem. I already had IDE version 1.6.5 installed with the board manager enabled. I've been creating some sensors on some ESP-01 for a few weeks without a problem. I replaced the MySensors folder I had in my library folder with the most recent one. My old sketches still compile but when I try to compile the ESP8266Gateway sketch I get the following error.

    Esp8266Gateway.cpp.o: In function `incomingMessage(MyMessage const&)':
    Esp8266Gateway.cpp:(.text+0x74): undefined reference to `vsnprintf_P'
    Esp8266Gateway.cpp.o: In function `output(char const*, ...)':
    Esp8266Gateway.cpp:(.text+0xb6): undefined reference to `vsnprintf_P'
    MySensors/MyHwESP8266.cpp.o: In function `hw_writeConfig(int, unsigned char)':
    MyHwESP8266.cpp:(.text+0x138): undefined reference to `snprintf_P'
    MySensors/MyHwESP8266.cpp.o: In function `MyHwESP8266::MyHwESP8266()':
    MyHwESP8266.cpp:(.text+0x16f): undefined reference to `snprintf_P'
    MySensors/MyHwESP8266.cpp.o: In function `MyHwESP8266::debugPrint(bool, char const*, ...)':
    MyHwESP8266.cpp:(.text+0x19a): undefined reference to `vsnprintf_P'
    MyHwESP8266.cpp:(.text+0x1b3): undefined reference to `vsnprintf_P'
    collect2: error: ld returned 1 exit status
    Error compiling.
    

    All I changed in the ESP8266Gateway example sketch was the SSID and Password.

    Regards,

    Mike


  • Mod

    @Mike-Cayouette said:

    undefined reference to `vsnprintf_P'

    Can you check the boardmanager which version of ESP Arduino you have installed?
    Mine's like this:

    upload-fbb1d613-848e-4c2d-8076-8eb684d07141

    I use the 'stable' version, located at http://arduino.esp8266.com/stable/package_esp8266com_index.json

    Maybe your installation is inclomplete; you could try removing & reinstalling Arduino for ESP.



  • @Yveaux said:

    Can you check the boardmanager which version of ESP Arduino you have installed?

    That was the problem, I was running an older version, I upgraded it and now it show's the same as your version.

    Thanks again,

    Mike



  • Just wanted to say thank you! It works great after hooking it up on my breadboard, now I can finally include MySensors in my sensor network 8-)


  • Mod

    @jvandenbroek Great to hear it's working fine! Have fun!



  • Great work. Just starting out with mysensors and looking forward to implementing this. Waiting for my hardware to arrive 🙂


  • Mod

    @gmccarthy said:

    Great work.

    Your icon suggests differently 😆



  • I'm having problems compiling this - I must be missing something but can't figured out what.

    Error:

    Esp8266Gateway.ino:77:25: fatal error: ESP8266WiFi.h: No such file or directory

    I've downloaded the mysensor library and unzipped it.

    My sketchbook location is: C:\Users\xxxxx\Documents\Arduino

    Under C:\Users\xxxxx\Documents\Arduino\libraries\MySensors\examples\Esp8266Gateway
    Ads

    The esp8266gateway.ino file is present.

    Update: Pffft....try selecting the generic ESP8266 module 🙂



  • Built Mine 😃 works great the only problem I had was uploading the code from a Mac OSX Mavericks so I opened a Win7 VM I keep for these type of problems and all is good. Thanks! @Yveaux 👏

    My Gateway has shrunk...SteUtUS.jpg


  • Mod

    @DrJeff said:

    Built Mine

    Great to hear you got things running!
    @hek is also on Mac and he managed to download directly. Maybe you can discuss your issues with him so we can update the install instructions if something special is required for Mac.

    My Gateway has shrunk...!

    Sure did, and it's wireless now 😆


  • Admin

    @DrJeff

    I managed to upload on mac, but had to fiddle around before I got it working.

    Added this text after my experience.
    "This NodeMCU board normally can be flashed automatically and shouldn't need bootload/reset buttons to be pressed. If you see error, try changing baudrate from from 9600 to 57600. Still problems? Hold flash and press reset. Start upload in IDE while keeping flash-button pressed until upload starts."



  • @hek Yes I tried those but it's probably the driver install it was acting a little finicky so it was quicker to flip over to the VM. 🙂



  • @DrJeff
    I remember that there was an error in the boardmanager-package for MacOS. You need to change the file-permissions to executable:

    sudo chmod +x ~/Library/Arduino15/packages/esp8266/tools/esptool/0.4.4/esptool 
    

  • Hero Member

    I followed the steps above, and I'm even able to upload sketches, however I only get this in serial monitor:

    load 0x4010f000, len 1264, room 16 
    

    Bad module maybe?

    EDIT: After choosing the right board (v.1.0) and applying the fix above from @fleinze, it seems it is working now...



  • Hi,

    I'm having problems running ESP8266 gateway. When I reset my nodes or trying send command from controller to node (dimmer, realy etc.) my gateway reset itself. I try using different ESP-s (I'm using ESP-12), power supplys and radio modules.

    On serial monitor I get this error:

    error.jpg


  • Mod

    @krajcl What catches my eye is the client command echoed by the gateway: "Client 0: 44;255;3;0;6;"
    The 0 at the end seems to be missing -- This could be a gateway issue (are you using the standard ESP gateway sketch, or did you make any modifications?) which causes e.g. the command parser to crash.

    Could you give a more detailed description of your setup? Which controller are you using, what does the network look like (nr. of sensors, repeaters etc.).



  • @Yveaux I'm using standard ESP gateway sketch (I reinstalled Arduino IDE, download latest mysensors library). At the moment I'm using MYSController as controler (for testing), I only have one node active (standard humidity sketch - only changed node id).


  • Mod

    @krajcl The last command from the controller seems to be a response to the sensor to indicate metric or imperial units are used (internal command 6). The payload should be either 'M' or 'I'.
    I'm not familiar with MYSController, but is there some setting influencing the unit system? Can you check if it has a valid value?
    I can't replay the situation right now, so anything you can do yourself to track the problem would really help.



  • @Yveaux This is result with Domoticz as controller and new node (relay), same result:

    error2.jpg


  • Hero Member

    I'm definitely not a expert at all on the topic, but could it be that a ftdi-usb adapter doesn't provide enough power to ESP, and it eventually hangs when wi-fi transmissions drawn too much power? (according to the specs, ~150mA when transmitting) .

    Just trying to help with some (probably dumb) brainstorming. 😉



  • Do you need to the NodeMCU to implement this?
    I have an arduino uno and ESP-01. How do I wire these up?

    After doing some more reading looks like the esp-01 does not have enough pins. Dont think I can use it 😞


  • Mod

    @krajcl Does it only crash when sending this particular message?



  • @Yveaux I tried function (clear routing table) in MYSConroller. This is result:

    Client 0: 0;0;3;0;10;C
    Client 0: 6;0;3;0;10;C

    ctx: cont
    sp: 3ffeabe0 end: 3ffeaf20 offset: 01b0

    When I try this function for gateway, evrything works fine, but for other nodes - gateway resets


  • Mod

    @krajcl When this message is addressed to the gateway (0;0;3;0;10;C) it does not get sent over the air by the radio.
    When you send it to node 6 (6;0;3;0;10;C), it will send the message to the node, using the radio.

    Can you please answer this: Will it crash with just any message sent to the nodes using the radio, or only when sending internal messages to nodes (internal messages to nodes have the first value unequal to 0 and the third value set to 3, like 6;x;3;x;x;x) ?



  • @Yveaux it doesn't matter, what I send, resets every time


  • Mod

    @krajcl Ah, ok! That helps!
    For me, and a lot of other people on this forum, sending messages just works with the ESP.
    Maybe @rvendrame is pointing in the right direction? How are you powering the ESP?



  • Is it possible to set a fixed IP adress and bypass DHCP? My router sometimes messes up his DHCP-table and reassigns all adresses. Then I would have to correct the IP in my controller which I want to avoid.


  • Mod

    @Anduril The ESP8266 Arduino port uses the same API as the standard Arduino WiFi library.
    This means you should be able to use WiFi.config() to set a fixed IP address.

    Change the following line in Esp8266Gateway.ino

      (void)WiFi.begin(ssid, pass);
    

    into something like (untested!):

      IPAddress ip(192, 168, 0, 123);  /* Set to whatever IP address you'd like the gateway to have */
      WiFi.config(ip);
      (void)WiFi.begin(ssid, pass);
    

    Please report back your experience!



  • I got this working on an 0.9 version of the nodeMCU ( the Yellow board ). It has some code upload issues, which are slightly worse on OS X than Linux, but usually a couple of tries with holding down the button as @hek mentioned usually does the trick. I do not have any TCP/IP clients pointed at it currently, but I also get lots of watch dog timer resets, which seem somewhat random, as it will run and log messages for somewhere between 15 mins and 10 hours.

    It is just being powered by USB and I have not swapped NRF modules yet, so one of those may likely be the culprit, but just wanted to chime in with a (mostly) successful setup.

    thanx



  • Hello all,
    is there anybody setup MQTT gateway and it's working fine? how many node wifi gateway can handle?
    Could you please share me Wifi MQTT Gateway code.
    Thank you all and have a nice day


  • Mod

    @kimnguu204 said:

    is there anybody setup MQTT gateway and it's working fine?

    Currently there is no MQTT WiFi gateway, but it shouldn't be very hard to create one by combining the WiFi Gateway with the MQTT gateway.

    how many node wifi gateway can handle?

    The same as any other MySensors gateway (around 250).



  • I will report a successful first experience with MySensors using the esp8266 WiFi Gateway and a digital switch nRF24L01+ MySensors node.
    Thank you Yveaux and hek! nRF24L01+ nodes are the only way to go for battery power!
    I look forward to learning more about the MySensors architecture.
    I am currently using openHAB as my controller.

    For the MQTT library, I will vote for the https://github.com/Imroy/pubsubclient library if you decide to create a MQTT version of the WiFi Gateway. I have this library installed on 8 esp8266 nodes operating for over two months without any problems.

    The knolleary version has had some recent updates since I installed the lmroy version, so it may work fine with Mosquitto MQTT 3.1.1 instead of MQTT 3.1 only.



  • Hi Friends

    I am having an issue with my NRF24L01+. If I change gw.begin() to anything like below,

    gw.begin(incomingMessage, 0, true, 0);

    I get an error "radio init fail"

    And I am now trying ESP-8266 12E module along with nrf24L01+ (genuine) transceiver to built wifi gateway, which I'll later use as gateway for openhab. I am having a similar issue, Here is the log I get through serial monitor.

    **Connecting to Ahmed
    ...........Connected!
    IP: 192.168.0.31
    0;0;3;0;9;radio init fail

    ctx: cont
    sp: 3ffebdf0 end: 3ffec010 offset: 01b0

    stack>>>
    3ffebfa0: 0000007f 3ffec03c 40201cac 3ffeaff0
    3ffebfb0: 40202320 00000001 00000000 40201d4f
    3ffebfc0: 1f00a8c0 00ffffff 0100a8c0 3ffec03c
    3ffebfd0: 3ffe9328 3ffead34 3ffec070 402026ef
    3ffebfe0: 3ffe98a8 1f00a8c0 00000000 00000000
    3ffebff0: 3fffdc20 00000000 3ffec034 40201d1f
    3ffec000: 00000000 00000000 3ffeaff0 40100398
    <<<stack<<<

    ets Jan 8 2013,rst cause:1, boot mode:(3,3)

    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld**

    This information runs in a loop again and again. I am using latest library from https://github.com/mysensors/Arduino/tree/master without editing the sample Esp8266Gateway sktech except user name and password. I have followed the connection instruction specified in sample sketch and sketch was successfully uploaded. I am using 101nf capacitors and 10K resistances as specified by https://www.youtube.com/watch?v=JA-0hs5rpMY.
    Everything is working fine except that error. May anyone help me out?


  • Mod

    @vickey the resets you're experiencing are caused by the failure to init the radio. This will cause the MySensors library to enter an endless loop. This will cause the watchdog to trigger and reset the ESP.
    Please try connecting the radio exactly as stated on the MySensors build page (when using NodeMcu hardware) or connect the same way as I did (see first post in this topic).
    Double check your radio connections.



  • I have checked all the wires and every thing is according to as par advised. I am using 2 separate 3.3 v voltage regulator to power up ESP-8266 12E and nrf24L01+ having common ground, using ESP-8266 breakout board without voltage regulator and nrf24l01+ breakout board with 3.3 v regulator powered by 5v supply.

    GPIO15 connected via 10K pulldown resistor to GND and also connected with CSN of nrf24l016, is this connection correct?

    Moreover, I am using USB to TTL adapter in place of FTDI and TX of ESP-8266 is connected with RX of TTL serial adapter and vice versa, GND of TTL serial adapter is also connected common GND. It's all the difference from your mentioned procedure.


  • Mod

    @vickey could the nrf24 be defective?
    Did you obtain the gateway & MySensors code from my github repository or from MySensors repository?



  • Sorry When I investigate the wiring throughly, MOSI and MISO was interchanged. Now it has started working but error has changed

    ESP8266 MySensors Gateway
    Connecting to Ahmed
    .......Connected!
    IP: 192.168.0.31
    0;0;3;0;9;gateway started, id=0, parent=0, distance=0
    0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0,sg=0:
    0;0;3;0;9;ver mismatch
    0;0;3;0;9;read: 0-0-0 s=0,c=0,t=0,pt=0,l=0,sg=0:
    0;0;3;0;9;ver mismatch

    I obtained the code for gateway & MySensors from MySensors repository on github.
    what would be the problem now?



  • I would like to use this tutorial for MySensors in the openHAB program:
    http://forum.mysensors.org/topic/1194/tutorial-openhab-with-serial-gateway

    I have the ESP8266 WiFi gateway working over a telnet session in Putty.

    Is there a way to have openHAB communicate over telnet like a hardwired serial interface?

    Has anyone used this yet?
    https://github.com/openhab/openhab/pull/2832


  • Mod

    @ridge sorry, can't help with that. Everything's MQTT over here 🙂



  • Thanks! Are you using this gateway with a controller or is it a proof of concept?

    It is fun to watch the states respond in a telnet session. I am having trouble finding any mention on how to use this with a controller.


  • Mod

    @ridge its use should be no different then when using the Ethernet gateway (because it is an Ethernet gateway 🙂 )
    I'm using it with OpenHab through MQTT and NodeRed through MQTT.



  • Is your setup using this gateway like:

    MySensors network <=>Gateway <=> Format conversion program <=> MQTT broker <=> openHAB

    For some reason, I had assumed that the results of the gateway could be used directly in openHAB.


  • Admin



  • Thanks hek, OpenHAB 1.7.1 is stable for me. I will probably wait for openHAB 2.0 to get closer to production status before wading in.

    I understand serial binding.
    I understand MQTT binding.

    I am missing something stupid easy in understanding ethernet binding.
    Do I include the http binding in the addons folder?

    A serial connected device is defined in an openHAB items file like:
    Switch HardwareButton "Bell" (Entrance) { serial="/dev/ttyS0" }

    I just cannot find an example of what an ethernet connected device would use in place of the "serial" definition.


  • Mod

    @ridge said:

    Is your setup using this gateway like:

    MySensors network <=>Gateway <=> Format conversion program <=> MQTT broker <=> openHAB

    Yes. Production gateway is currently (cabled) ethernet gateway, "Format conversion program" is this perl script and MQTT broker is Mosquitto.
    Perl script, Mosquitto and OpenHab run on Ubuntu 12.04LTS server PC.


  • Admin

    @ridge

    You could always use ser2net to emulate a serial port connected to the ethernet gateway from you openhab box.



  • Thank you hek and Yveaux. I thought I had missed something obvious. For the present with openHAB 1.7.1, a small piece of the wireless sensor data super highway of the future is still under construction! In that case I will certainly study the MySensors gateway to MQTT broker examples closely.



  • Hello guys,

    I am having issues with this installation. I got everything up and running but it simply doesn't connect to my WiFi Netgear router at home.

    I just enabled my hotspot on my cell phone and the gateway did connect successfully and started the gateway master with IP, etc assigned.

    When I try to connect to my home WiFi it just keeps on printing dot dot dot in the serial console.

    My Netgear has two networks with 2.4Ghz and 5Ghz. I tried both and none of them worked. They are configured with WPA2-PSK [AES] encryption for the passphrase and the passphrase has one special character included. The SSID is 5 characters long and the passphrase is 22 characters long which shouldn't be an issue.

    I don't get any error messages in the serial console and my router doesn't show anything in the logs either like the ESP gateway doesn't even try to connect. I don't know how to troubleshoot this from here.

    Any help would be appreciated.


  • Admin

    I also have both 5/2.4Ghz on my router.

    When ESP connects is seems to prefer 2,4 GHz / n / WPA2 if that helps.



  • This is what I have. 2,4 GHz / n / WPA2 (no TKIP but AES instead so I can go beyond 54Mbit) and it doesn't connect. Just dots coming up.


  • Mod

    @Pseudomizer Esp8266 is 2.4ghz only.
    You could try adding the following line just after hw_init() in the sketch:

    Serial.setDebugOutput(true);
    

    It will dump a lot of ESP WiFi related data, please post the output here. Maybe some will give a hint of what goes wrong.



  • Thanks a lot for this. This helped me troubleshoot the problem and I am surprised why it didn't connect. It couldn't find my SSID name because in the router it is all UPPER case but when I write it on any other machine Windows, Linux, etc to connect to, I always write it lower case with the exception of the first character.

    In this case I modified the sketch to have the SSID name all in UPPER case and voila it connected.

    Thanks again for the help here. Much appreciated.



  • I was very happy when it connected but now it is resetting itself constantly with this error message:

    wdt reset
    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld

    Any ideas why?



  • I missed one line of error code above:

    ets Jan 8 2013,rst cause:4, boot mode:(3,6)



  • I tried my Home Wifi and my Cell Hotspot. The crashes occur on both wifi networks. 😞



  • @Pseudomizer , Is the esp8266 on a breadboard or is it part of a commercial product like HUZZAH or nodemcu ? I ask because the esp devices can reset themselves from a brownout condition during the WiFi transmit if the power supply circuit is not up to handling the momentary 'high current draw' requirements of the radio. From reading www.esp8266.com, breadboard circuits have caused many hours of troubleshooting enjoyment with the esp8266 parts.

    I replace the battery packs on these with 2 Amp cell phone charger power supplies. I have 8 under power 24/7 for months with no problems. They are available from multiple vendors.
    http://www.aliexpress.com/item/Free-shipping-ESP8266-ESP-12-serial-WIFI-Industrial-stable-version-A-full-test-board-Full-IO/32260095422.html?spm=2114.01020208.3.49.0YGvDs&ws_ab_test=201556_7,201527_4_3_2_1_4_71_72_73_74_75,0_0



  • I followed the instructions exactly as shown here and I purchased that exact equipment.

    http://www.mysensors.org/build/esp8266_gateway

    nodemcu.jpg

    I even powered the NRF24L01+ from a different power source just to make sure that power fluctuation is not the issue but it didn't make any difference.

    I even tried transfer rates 115k, 57k and 9600 Baud but none of that made any difference either.

    I also downloaded the flash eeprom ino program to clear all the data but again, no difference.



  • I even reflashed the ESP8266 with those instructions and then loaded the mysensors ino but still the same outcome. 😞

    http://benlo.com/esp8266/esp8266QuickStart.html


  • Mod

    @Pseudomizer did you make any changes to the gateway sketch out the MySensors library/config?
    Could you post the output of the gateway just before the crash occurs (it might give an indication of where this crash occurs)



  • The only changes to the sketch are the SSID, the pass and the debug line

    Serial.setDebugOutput(true);

    as instructed. No other changes were made.

    Here the the debug output....you will see multiple resets in a row based on the internal watchdog timer.

    ESP8266 MySensors Gateway
    Connecting to MYWIFI
    scandone
    f 0, scandone
    .add 0
    aid 1
    pm open phy_2,type:2 0 0
    cnt

    connected with MYWIFI, channel 6
    dhcp client start...
    ......ip:192.168.1.222,mask:255.255.255.0,gw:192.168.1.1
    .Connected!
    IP: 192.168.1.222

    ets Jan 8 2013,rst cause:4, boot mode:(3,6)

    wdt reset
    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld

    ESP8266 MySensors Gateway
    Connecting to MYWIFI
    scandone
    f 0, scandone
    .add 0
    aid 1
    pm open phy_2,type:2 0 0
    cnt

    connected with MYWIFI, channel 6
    dhcp client start...
    .......ip:192.168.1.222,mask:255.255.255.0,gw:192.168.1.1
    .Connected!
    IP: 192.168.1.222

    ets Jan 8 2013,rst cause:4, boot mode:(3,6)

    wdt reset
    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld

    ESP8266 MySensors Gateway
    Connecting to MYWIFI
    scandone
    f 0, scandone
    .add 0
    aid 1
    pm open phy_2,type:2 0 0
    cnt

    connected with MYWIFI, channel 6
    dhcp client start...
    ......ip:192.168.1.222,mask:255.255.255.0,gw:192.168.1.1
    .Connected!
    IP: 192.168.1.222


  • Admin

    Triple-check your radio wiring.


  • Mod

    @hek said:

    Triple-check your radio wiring.

    Or try with a different radio. The crash seems to happen in the radio init part.



  • I just replaced the NRF with a new NRF and then again as I have 4 total. With every single one the same error.

    The wiring matches exactly the picture from mysensors.

    This is driving me crazy...



  • Hi, I tried the bridge with a rfm69hw module. It starts all well but does not receive any information. Neither shows startup information module .
    Where to put the DIO0 . I tried on several pins ( changing IRQ number) but no thoughts about doing anything.


  • Mod

    @miguelingles I didn't test with a rfm69hw module and I'm not aware of anybody else testing with this setup.
    Probably you have to test step by step what work and what not.
    Start with the radio initialization to see if the communication is ok, and go on from there.


  • Mod

    @Pseudomizer past few days @hek and I have been working on better diagnosis for the ESP8266 regarding radio communication failures.
    Please try if the version of MySensors development helps in diagnosing your problems.
    Make sure to uncomment the line

    //#define MY_DEBUG_VERBOSE
    

    in MyConfig.h and make the same changes to ssid & password as you did before.
    This version will dump diagnostics of NRF communications and a full register dump when starting up.
    Good luck!



  • Thanks a lot. This version provides much more details but at this stage of my learning progress I am not able to understand all those registers where I have to rely on your help guys. I assume that my password is not being exposed here.

    ESP8266 MySensors Gateway
    Connecting to ZEUS
    scandone
    f 0, scandone
    .add 0
    aid 1
    pm open phy_2,type:2 0 0
    cnt

    connected with ZEUS, channel 6
    dhcp client start...
    ......ip:192.168.1.222,mask:255.255.255.0,gw:192.168.1.1
    .Connected!
    IP: 192.168.1.222
    write_register(0x04,0x5F)
    write_register(0x06,0x23)
    write_register(0x06,0x03)
    write_register(0x00,0x0E)
    write_register(0x07,0x70)
    write_register(0x05,0x4C)
    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 0707070707
    RX_ADDR_P2-5 0xFF C4 C5 C6
    TX_ADDR 0x0E0E0E0E0E
    RX_PW_P0-6 0x00 00 20 00 00 00
    EN_AA 0x3B
    EN_RXADDR 0x07
    RF_CH 0x4C
    RF_SETUP 0x03
    CONFIG 0x0E
    DYNPD/FEATURE 0x3F 06
    Data Rate 1MBPS
    Model nRF24L01+
    CRC Length 16 bits
    PA Power PA_LOW
    write_register(0x01,0x3F)
    write_register(0x01,0x3B)
    write_register(0x1D,0x06)
    FEATURE=0x06
    write_register(0x1C,0x3F)
    write_register(0x05,0x4C)
    write_register(0x06,0x0
    ets Jan 8 2013,rst cause:4, boot mode:(3,7)

    wdt reset
    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld

    ESP8266 MySensors Gateway
    Connecting to ZEUS
    scandone
    f 0, scandone
    .add 0
    aid 1
    pm open phy_2,type:2 0 0
    cnt

    connected with ZEUS, channel 6
    dhcp client start...
    ......ip:192.168.1.222,mask:255.255.255.0,gw:192.168.1.1
    .Connected!
    IP: 192.168.1.222
    write_register(0x04,0x5F)
    write_register(0x06,0x23)
    write_register(0x06,0x03)
    write_register(0x00,0x0E)
    write_register(0x07,0x70)
    write_register(0x05,0x4C)
    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 0707070707
    RX_ADDR_P2-5 0xFF C4 C5 C6
    TX_ADDR 0x0E0E0E0E0E
    RX_PW_P0-6 0x00 00 20 00 00 00
    EN_AA 0x3B
    EN_RXADDR 0x07
    RF_CH 0x4C
    RF_SETUP 0x03
    CONFIG 0x0E
    DYNPD/FEATURE 0x3F 06
    Data Rate 1MBPS
    Model nRF24L01+
    CRC Length 16 bits
    PA Power PA_LOW
    write_register(0x01,0x3F)
    write_register(0x01,0x3B)
    write_register(0x1D,0x06)
    FEATURE=0x06
    write_register(0x1C,0x3F)
    write_register(0x05,0x4C)
    write_register(0x06,0x0
    ets Jan 8 2013,rst cause:4, boot mode:(3,7)

    wdt reset
    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld


  • Mod

    @Pseudomizer just had a quick look at your results. Radio config (and this communication) seem to be OK, but it restarts due to watchdog timeout.
    Hopefully tonight I can have a better look.



  • when I put the development package I can not compile anything (all gives me error). I tried it with a clean install and nothing.
    I think the problem is the IRQ pin DIØØ , if the ESP cpu does not recognize this interruption when the RF module receives data is unable to apply for the request .


  • Mod

    @miguelingles said:

    I think the problem is the IRQ pin DIØØ , if the ESP cpu does not recognize this interruption when the RF module receives data is unable to apply for the request .

    The irq pin from the nrf24 stays unconnected, like the build instructions clearly state!



  • but RF69 need irq.


  • Mod

    @miguelingles didn't know you were talking about rf69... Sorry but I cannot keep track of what everyone is using.


Log in to reply
 

Suggested Topics

  • 1
  • 198
  • 6
  • 2
  • 3
  • 10

62
Online

11.4k
Users

11.1k
Topics

112.6k
Posts