ESP8266 WiFi gateway port for MySensors


  • Mod

    UPDATE: The official build guide for the ESP8266 gateway can now be found here.
    The description in this post is for reference only!


    Please find an early release of ESP8266 gateway support in my MySensors 1.5 branch:
    https://github.com/Yveaux/Arduino

    It has not been tested heavily, but seems to run stable at least with one sensor.
    Great feature of this setup is you can run a WiFi gateway with just an ESP8266 and nRF24L01+ radio, no further Arduino (ATMega328) is required!

    I'm releasing this now, hoping you can start experimenting with it and help development to get to a stable, official release asap.

    2015-08-26 12.22.13.jpg
    Setting things up:

    • Install Arduino IDE 1.6.5
    • Add support for ESP8266 to Arduino, see https://github.com/esp8266/Arduino (Installing with Boards Manager)
    • Get the code form my fork https://github.com/Yveaux/Arduino/archive/master.zip and extract the zip
    • Edit libraries/MySensors/MyConfig.h when you use e.g. a different datarate, channel or base radio ID.
    • Point your Arduino configuration to the extracted dir (File -> Preferences -> Sketchbook location)
    • Restart the Arduino IDE

    Compiling the gateway:

    • Open the WiFi gateway in the Arduino IDE (File -> Sketchbook -> Libraries -> MySensors -> Esp8266Gateway
    • Save it, to allow editing
    • Enter your SSID and WiFi password in the 'ssid' and 'pass' variables
    • Select the ESP8266 board you're targeting in Tools -> Board. I use an ESP12 module, which is a 'Generic ESP8266 Module' board target
    • Verify your sketch. It should compile without errors.

    Connecting the radio:

    • Make sure to use an ESP8266 module which breaks out pins GPIO 4, 12, 13, 14, 15 (e.g. ESP12 module)
    • Connect the radio as described in the header of the gateway code.
    • Connect the other signals as described in the header of the gateway code.
    • I mounted two switches (for reset & bootload) which your ESP8266 may already be equipped with (e.g. the NodeMCU boards have them most of the time)
    • I use an FTDI USB->Serial converter to connect the ESP8266 to my PC, which outputs levels at 3.3V. This is very important as the ESP8266 cannot officially handle 5V signals, and cheap USB->Serial converters often output at 5V levels. When in doubt, please check before connecting!
    • Power both the ESP8266 and the nRF24L01+ from a separate 3.3V power supply. The 3.3V supply from many USB->Serial converters is often too weak.
    • Decouple the power supply with a large capacitor (e.g. 1000uF) and 100nF, to buffer the input and suppress any noise.

    Downloading your sketch:

    • Start wit a low upload speed (e.g. 9600baud). It will take ages to download, but I sometimes have issues downloading at high speeds.
    • Press reset + bootload buttons.
    • Keep bootload pressed while releasing reset
    • After a few seconds release bootload.
    • The ESP8266 is now in bootload mode, and ready to download your code.
    • Choose Upload in the Arduino IDE
    • After some time (a lot of dots) upload should finish and your code starts. The serial monitor (115200 baud) shows the progress:
        ESP8266 MySensors Gateway
        Connecting to SSID
        ...........Connected!
        IP: 192.168.1.119
        0;0;3;0;9;gateway started, id=0, parent=0, distance=0
        0;0;3;0;9;read: 123-123-0 s=1,c=1,t=24,pt=5,l=4,sg=0:2810347
        123;1;1;0;24;2810347
    
    • This text will be preceded by some garbage from the bootloader (it outputs at a lower baudrate)
    • The IP address of the WiFI gateway will currently be obtained from a DHCP server.

    Now connect a telnet session (e.g. putty) to the IP address mentioned in the serial output (192.168.1.119 in this case), port 5003 and send some serial commands!


  • Hardware Contributor

    @Yveaux: wow! great work 👏 I will try this when I will have time. thx for your share.



  • @Yveaux Great work, well done! 👍
    I will give it a try as soon as possible, and post back.
    Thanks!



  • Great work!
    Wanted to see it for a long time.
    Now the way for making a mqtt with the esp8266 is shorter...


  • Mod

    @Mickey In principle the MQTT gateway should also run on the ESP8266, if you make the same changes to it as I did to the Ethernet gateway example (diff of the files should help a lot: https://www.diffchecker.com/eeo5ahzn).
    On the other hand, the pubsubclient (https://github.com/knolleary/pubsubclient) MQTT client implementation by knolleary is heavily tested and works fine on ESP8266 (I tested it myself).
    The ESP8266 has a lot more Flash & RAM available than an ATMega, so implementing MQTT should not be a problem.



  • @Yveaux said:

    diff of the files should help a lot: https://www.diffchecker.com/eeo5ahzn).

    Thanks for the heads up on this service Diff checker I didn't know of this site I will be using it! Thanks


  • Mod

    Just a quick update on the status of this port. Following has been fixed/implemented:

    • LED status updates
    • Inclusion mode
    • Message signing (untested) (hardware SHA204 not supported, but ESP8266 should be fast enough to do software signing)
    • RF69 support (untested -- RF69_IRQ_PIN & RF69_IRQ_NUM are hardcoded in rfm69.h. Make sure to adjust them first!)
    • External flash is not supported. It is however currently not used by gateway implementation, and ESP8266 should have sufficient flash onboard if required for some application.

    This means full MySensors functionality should now be supported (please let me know if I missed something).

    Only problem so far: I need YOU to test, test, test, test... 😉



  • Do you have a recommendation where and what to buy to build such a gateway?


  • Mod

    @gloob I only have a separate ESP12 module on a breakout board (white carrier board in the picture above) to fit it in a breakout board. The carrier board is really too wide for the breakout board, so I had to bring all signals to the side (white/purple wires). Then some reset/download buttons and resistors are still required to use the board...
    This setup is not ideal, IMO.

    I ordered some NodeMcu boards which seem to have all the required pullup/pulldown resistors onboard, a USB to serial converter and some electronics to automatically download from the Arduino IDE (no need to push reset & download buttons). Only thing needed to make it a gateway would be a connection to the nRF24 radio.
    As said, I just ordered the boards and they still have to prove their ease of use. They have to come from China, so it'll take a few weeks probably.


  • Hardware Contributor

    @Yveaux: I have two huzzah. but no time to play with for the moment. but your aliexpress link is very interesting. so cheap! I think I will order one to see. at this price...
    Some time ago, I tried to design a very basic esp GW, based on huzzah pinout. But I didn't have time to finish it, as esp was not mysensors compatible and tbowmo is doing something great too. And I feel more secure with a usb GW...
    Here : https://github.com/scalz/MySensors-HW/tree/development/MysensorsGW_huzzah
    But it tempts me to improve design (not finished), and test it with your work...


  • Mod

    @scalz Could be interesting to develop a MySensors WiFi gateway board in the future, based on an ESP module.
    That should certainly lower the bar for everyone.
    I understand this is a chicken-and-egg situation for the port to get stable, but hopefully using a board like the NodeMcu most MySensors users can get a working prototype.

    A short inventory of all the ESP modules/breakouts everyone on the forum owns could help in writing a more elaborate how-to on the subject, so please post your modules (and a link to some details when available)


  • Hardware Contributor

    @Yveaux: yes why not. The huzzah I have, are homemade as I had some esp8266-07 (with ceramic antenna and ipex connector) in stock, and it was sold out at adafruit. their files are opensource.
    https://www.adafruit.com/products/2471
    http://www.electrodragon.com/product/esp8266-wifi-board-full-ios-smd/
    but your aliexpress link is cheaper. I will look at the pinout if it is compatible or I will adapt and improve my old pcb project, for fun, and my learning curve 😉



  • I have up and running a mqtt gateway with esp8266 that is connected to ordinary serial gateway (with the arduino) I based it on 2 projects-
    ESPHTTPD and tuanpmt mqtt for esp and all is working fine and deliver the serial gateway messages to cloud based mqtt broker and I also have the benefit of configuring everything by webpages (mqtt params ,wifi params)and use all benefits of http server like serving pictures(favicon)and jquery for all web based configuration like this,and now after I see this project I like to remove the arduino and connect the esp directly to nrf but the native sdk is c and I use eclipse.
    Is it possible to pull all the relative mysensors code from this work (I see it's mainly in c++) and add it to the code in native esp mqtt (which is mainly in c)?


  • Mod

    @Mickey I'm afraid it's not that simple... MySensors is purely written in C++, and although this code could be rewritten in C it is a lot of work and requires decent C/C++/MySensors knowledge.
    Did you consider doing it the other way around and port your work to fit in this MySensors gateway?
    Could be a lot less work (depending on how much code you wrote yourself) as C code compiles (almost) without problems in the Arduino IDE.



  • @Yveaux said:

    @Mickey I'm afraid it's not that simple... MySensors is purely written in C++, and although this code could be rewritten in C it is a lot of work and requires decent C/C++/MySensors knowledge.
    Did you consider doing it the other way around and port your work to fit in this MySensors gateway?
    Could be a lot less work (depending on how much code you wrote yourself) as C code compiles (almost) without problems in the Arduino IDE.

    those esp projects I mention are very extensive to just port them.(mainly the httpd) but I once saw a guy here that made the mysensors code work on the native sdk ide but only wanted to sell the binaries and wouldn't share his code.



  • i have a few esp8266mod demo bords a node mcu 9.5 a few esp-01, when i get home i will throw a gateway together 🙂 and test all you like ..i do not mind doing alpha or beta testing if needed ..great work btw ...

    also has anyone used this beta .. looks very cool aswell 🙂 http://www.esp8266.com/viewtopic.php?f=29&t=4540

    kind regards
    andy


  • Mod

    @Mickey Maybe I don't really understand you application then... The web based configuration link points to a post about runnning gitlab, a local github. I dont get ít, sorry.
    Running a webserver next to the gateway code shouldn't be a problem. The ESP has a lot of spare flash and the Arduino port supports a complete filesystem to read/write to it (see http://arduino.esp8266.com/versions/1.6.5-1044-g170995a/doc/reference.html, section "File system object (SPIFFS)")
    What's to configure apart from SSID & password? This is just a gateway. Once online you can connect to it and stream all data to/from it using any client supporting the Ethernet gateway.


  • Mod

    @Andy-Pep said:

    i have a few esp8266mod demo bords a node mcu 9.5 a few esp-01, when i get home i will throw a gateway together 🙂 and test all you like ..i do not mind doing alpha or beta testing if needed ..great work btw ...

    Thanks! Please join me in testing this code!

    also has anyone used this beta .. looks very cool aswell 🙂 http://www.esp8266.com/viewtopic.php?f=29&t=4540

    Nice, but as I stressed in my previous post this seems like overkill for a gateway to me.
    Of course we can cram a lot of extra code and functionality in the ESP. It has a lot of power and someone might even build a whole home automation suite directly in it (anybody? 😉 )
    Let's get this gateway usable, stable and tested. From there you can use it as a base for other applications.



  • ok i have used a esp8266mod dev board for my test hooked it up flashed the sketch and domoticz is seeing it ok and relaying my sensor data .. not a painfull process at all 🙂 ..
    will update tomorrow to see if it fails or goes fubar ..but so far so good :P)


  • Mod

    @Andy-Pep Awesome! Good to hear its running without any troubles so far! 👍
    Maybe I frightened people by writing a too elaborate description how to set things up 😵



  • to me it was very easy to hook up and get working ..well done Yveaux you have given my collection of esp's a new life 🙂 when my phone recharges ill take a pic and upload it ..i like the way it reboots when connection is lost .. handy feature 🙂

    well done kudos to you 🙂



  • @Yveaux No you did not scare me away but I'm in loss of time to do this. I look forward to setting my esp gateway up in a week or so. 🙂


  • Mod

    @Andy-Pep said:

    i like the way it reboots when connection is lost .. handy feature

    I wasn't aware of that. Most errors result in watchdog timeouts or access violations and cause a reboot. The Ethernet client has to be robust against this.
    We need extensive testing to catch these kinds of errors and assure they are handled in a defined way.


  • Mod

    @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.



  • ok.

    ill put a serial interface on to it and keep it running for debug data ..ill post up the next 3 hours of data later on this evening ..



  • @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

    Yveaux created this issue in MySensors/Arduino

    closed Master #186



  • 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.


 

346
Online

7.5k
Users

8.4k
Topics

90.4k
Posts