ESP8266 as WiFi gateway & controller & node

  • I was very excited to see mysensors ported to ESP8266, so I thought why not add a few more things. I am working on (yet another) weather station, but this one might end up slightly different than the norm.

    There will be an external unit, and an internal in the house. The external one is battery operated, with solar support and some really unique features, but I will leave this for a future post. For the internal unit, I've decided to use the ESP8266 (NodeMCU hardware flavour) since the port to mysensors was done by @Yveaux. However, I also want a display with external/internal weather conditions and forecasts. I'm a big fan of OpenHab, but in this case, why add more complexity if it's possible to avoid it.


    So starting with the ESP8266 gateway example on a NodeMCU with a nRF I've also added; an OLED screen and a DHT11and I have it forwarding both external and internal sensor values directly to a cloud service (e.g. to Thingspeak) without using a controller.

    I could not make DHT11 work on ESP8266 with current DHT mysensors library, so I pasted the adafruit DHT lib. Did not modify anything else in mysensors libraries, all necessary code is in the example, its messy but it works, so more of a proof of concept / hack. Here it is, in case anyone is interested.

    I'm new to mysensors, so any feedback is more than welcome :-)


  • Changed my repo to a forked "mysensors/Arduino" development branch, to simplify (future) comparisons/merges.

  • I've replaced DHT11 with DS18B20, until Si7021 arrives, as the inaccuracy of DHT11 hurts my eyes :-)
    I could not make OneWire compile with the mysensors OneWire library in place, as ESP8266 has it's own modified one. I guess one could merge them, or rename one, but I just removed the mysensors one completly as I do not currently use it.

    Also, it did not work on pin D0, had to use D1 (GPIO-05), so I changed the inclusion pin.

  • Hardware Contributor

    I'm pretty interested interested by your project (and intrigued by the "unique" features of the outside part)

    Right now I'm just starting with mysensors, but I eventually would like to replace my various 433MHz sensors with 2.4GHz.
    I'm starting simple by trying to add some environmental sensors on my ESP8266 GW (and I really like your idea of adding a small OLED screen, may try that too!).

    I see you have tested a bunch of sensors, did you tried a BME280 yet? (Temp/Hum/Baro) Any thoughts on it: accuracy, code size for GW + BME (+ OLED)? I was considering it instead of a Si7021 as well, why not!


  • Hi @emc2
    no I have not played with BME280 as it's more expensive than three dedicated sensors :-)

    Here is more light on the "unique" features of the ouside part;

    This is still work in progress, but you can get an idea.
    in terms of sensors, so far I am using:
    BMP180 - Temperature/Pressure
    Si7021 - Temperature/Humidity
    MPU-6050 - 6DOF inertial sensor (wind)
    TTP223B - Touch/capacitive sensor (rain)

  • Hero Member

    @nikil511 hi, I'm very interested in how you are planning to use the MPU6050 as wind sensor as well as the TTP223B as rain sensor. Do you have an example?

  • Hardware Contributor

    Pretty neat.

    I started playing with the BME280, true it's a couple of $ more expensive but so far I don't regret it. Having everything done by one sensor is convenient. Also sensitivity and accuracy are quite impressive.

  • @AWI no examples yet, but the concept is that the entire unit hangs from a string, and swings freely. Therefore wind moves the unit and the intertial sensors could potentially measure the speed and direction depending on aerodynamics of the body. I know it's challenging, but it will be also fun, and thats the whole point of DIY right? :-)
    As for rain, I will have a few wires running around the enclosure, so when a water-drop touches the case, it will be detected. I will actually use a multi channel capacitive sensor, in an attempt to measure rain fall.
    My plan is to setup everything so I can remotely monitor/log the data, place a real weather station next to my prototype and then try to "calibrate" make sense of the motion data and perform OTA firmware upgrades until the thing produces useful results.
    Will keep you posted.

  • Hero Member

    @nikil511 Very interesting idea. I know of (pretty scientifc) usage in wind tunnels. This could be my next challenge. Thanks for the info!

  • I am having some " long range" problems with nRF on this setup of mine, since the external unit ideally should go at the top of the building (e.g. a few floors away).

    There is a discussion on RadioHead library which could enable alternative RF chips,
    so I am wondering how complex will this be, to use the the RadioHead approach on both ends (arduino & esp8266) in order to replace the nRF24L01+ with something with a longer range.

    Furthermore, there is quite a buzz around LoRa lately so I have ordered a few Microchip RN2483 to play with in a point-to-point setup. I guess since those are serial modems, they can never become compatible with even if the LoRaWAN stack is not used, right ?

    My idea was that it would be useful to have mysensors protocol running on LoRa, and if possible an enhanced ver of mysensors protocol running on LoRaWAN in the future. (?) (e.g. city-wide instead of house-wide)

  • Admin

    You can use RF69 which has a longer range.

  • @hek I was under the impression RF69 was similar range to nRF24L01+ have not found any comparisons...
    (maybe I did not search enough)
    I am using the cheap Chinese ebay stuff, would something else with external antenna give dramatically better results ?
    What kind of antenna do you suggest (relatively small)
    e.g. will DIY helix/coil antenna do a good enough work at 868mhz with the RFM69? can you estimate range ?

    btw, what's your opinion on the LoRa hype? any interest utilizing LoRa in mysensors ?

    thanks! :-)

  • Admin

    I haven't read up enough on LoRa yet to have an opinion.

    RF69 works in a lower frequency thus longer range.

  • @nikil511 & @hek want to say thankyou for your code. Its been really useful. my eps8266 is now running as a controller and posting readings to thingkspeak. Without the need for a computer turned on, so its been really useful. thanks :)

    Are you still having range issues? I would recommend trying a to make a dipole first. They are simple and work well. They do need to be keep in the same polarisation or will attenuate the signal.
    If still having range issue you could try a direction antenna after that.

    Also if the floors have steel reo, that maybe blocking the signal, going for a longer wavelength frequency might not be the best option.

    Also FYI helix/coil antennas reduce signal strength. Unless the antenna needs to be compact, i would avoid that.

    If you still need help let me know

  • Hi @nikil511 great project... just wondering how difficult it would be to add an OLED to show the (local) temp and hum on the sensor node with your pro mini + NRF?
    The reason I ask is i'm looking to create a little setup for a friend who works for a charity. They run a community garden for refugees, and have just built a hot house (from funds raised in the community).
    They would like to monitor the temp and hum (and possibly control the shutters in future) of the hot house but also be able to send the data to the coordinator's mobile phone to remote monitor.
    This project came up when i was searching.
    It just would be helpful to display the local Temp and Hum in the hot house for them also when they or any other volunteers are in there.

Log in to reply

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.