Agri IoT :: Prototype 1 : Gateway

This article is a part of a series that I’m doing based on building a agriculture IoT system.

Objectives ::

Gateway should,

  • Be mobile and compact ( not too many wires )
  • Capable enough to connect to sensor and controller ( RF and Wifi )
  • Have enough mem to expand the code. ( for future needs if any )

Based on the above  NodeMuc was selected which has ESP8266 a wifi chip and a capable microcontroller . Please check out mysensors docuemtation here for other gateway types.

Components ::

  • NodeMuc ESP8266
  • NRF24L01+
  • Micro usb cable.

Howto::

Hardware:

Connect NodeMuc and NRF24L01+ as described here.

NodeMCU Radio
GND GND
3V3 VCC
D2 CE
D8 CSN/CS
D5 SCK
D7 MOSI
D6 MISO

Completed setup would look like below. I’m using micro USB cable to power the gateway.

Software:

Install esp8266 board support on your Arduino IDE . Tools >> Board >> Board Manager is where you can install it. Once installed select NodeMuc board with Tools >> Board

The example mysensor GatewayESP8266MQTTClient code  ( You can find the same also on Examples >> Mysensor >> GatewayESP8266MQTTClient ) can be used with minor changes to program Gateway. Please change the below parts in the code according to your environment.


// Set WIFI SSID and password
#define MY_ESP8266_SSID "MySSID"
#define MY_ESP8266_PASSWORD "MyVerySecretPassword"

// Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
#define MY_IP_ADDRESS 192,168,178,87

// If using static ip you need to define Gateway and Subnet address as well
#define MY_IP_GATEWAY_ADDRESS 192,168,178,1
#define MY_IP_SUBNET_ADDRESS 255,255,255,0
// MQTT broker ip address.
#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68

Testing & Troubleshooting::

Use Arduino IDE serial monitor and set the baud rate to 9600 . You can find gateway related debug output there, you’ll find sensor radio messages also if you have followed the sensor setup part.