Friday, 7 October 2016

MySensors Gateway using ESP8266

MySensors Gateway Wemos D1 R1 / Hobby Components ESP8266-D1
Picture of Hobby Components ESP8266-D1 with NRF24L01+ and DS18B20.
Hobby Components ESP8266-D1 with NRF24L01+ and DS18B20.

My current "home automation" project is connecting a bunch of temperature sensors (primary based on Maxim DS18B20) to Arduino and similar boards, to get detailed temperature data from different rooms. I have been experimenting with a number of ways of doing this. Initially I hacked together various Arduino code bits myself, but when I had to start looking at network transport encodings, it felt like reinventing wheels a bit much, so that lead to looking into MySensors.

I wanted to try setting up a MySensors gateway on my Hobby Components ESP8266-D1 which meant I needed to connect a NRF24L01+ radio. This allows my Arduino Uno boards to send their temperature measurements to the gateway for wherever they end up in the end.

The board pinout on this board is different from the base MySensors documentation for an ESP8266 (which is based on NodeMCU), so I had to map board to radio pins myself. Nothing magical, but might be useful for somebody else to save some time.

I don't know if I will end up using MySensors in the long term, but it looks interesting rather than spending too much time coding "everything" myself.

I got it working talking to a MySensors Arduino Uno connected to an DS18B20, so the pinout below has been tested - but of course USE AT YOUR OWN RISK.

Hardware

The Hobby Components ESP8266-D1 seems to have the same pinout as Wemos D1 R1 (not R2 - that has different pinout), but I haven't fully confirmed this.

The NRF24L01+ radio is on the radio side connected as described on the MySensors Wiring page, though my cable has brown instead of black for ground / GND.

Pinout table

Board PIN SPI / Type Color ES8266 PIN
GND GND Brown GND
VCC VCC 3.3V Red VCC
D4 CE Orange GPIO4
D5 SCK Green GPIO14
D6 MISO Violet GPIO12
D7 MOSI Blue GPIO13
D10 CSN/CS Yellow GPIO15

Credit / Source

The pinout for Wemos D1 R1 was constructed by mapping board pin to ESP8266 pins using PDF from "roboticboyer" in https://github.com/esp8266/Arduino/issues/1748#issue-139829277.

Mapping for what MySensors ESP8266 gateway expected to use came from the source in GatewayESP8266.ino which maps GPIO pins from ES8266 to nRF24L01+ pins / SPIO names.