Agri IoT :: Prototype 3 : Overview & Actuator


With prototype 3 of Agri IoT, attempt is to proceed further by creating a actuator node that can be controlled from Openhab. Pro mini 3,3v 8Mhz is selected because of its small form, low power consumption and NRF24L01+ will work with it as a radio. A 4 CH 5V relay module is used to switch on/off devices and to power the whole setup a breadboard 3.3v/5v power supply is used Mysensors v2.0 API is used to build and connect the blocks.  Prototype 3 actuator node setup is covered in this article, rest is in Agri IoT :: Prototype 2 : Gateway & Controller 

Prototype 1&2 is covered in below articles,

  1. Agri IoT :: Prototype 1 : Overview
  2. Agri IoT :: Prototype 2 : Overview

Objective ::

Actuator node should,

  • Be able to switch on/off the supply to devices according to input from Openhab2 controller

Components ::

  • Arduino pro mini 3.3v 8Mhz
  • NRF24L01+
  • CP2102 USB to TTL Serial
  • Relay module 5v
  • Breadboard power supply 3.3v/5v

How to ::

Idea is to power on actuator in the node with one of the Arduino digital out,



  • 1st relay input should be connected to the digital pin 3 of Arduino pro mini.
  • Relay power should be provided by 5v ourput of breadboard power supply.


  • Connection should be made as described here
9 CE
13 SCK
  • Power to arduino and radio should be provided by 3.3v output of breadboard powersupply


Connect the arduino via Mini usb cable. Make sure you select the right options as mentioned here

Upload the sketch to actuator node. If you want to manually set the node ID specific the below line above #include <Mysensor.h>

#define MY_NODE_ID 2 // node id 
#include <MySensors.h>

Testing & Troubleshooting::

Use Arduino IDE serial monitor and set the baud rate to 115200.  You can find sensor node related debug output there.

Reference ::

Update : 21/05/2017

Lessons learned the hardway : If your actuator node is disconnecting and staying of the grid it can be because of the noise from the relay module. The message similar to below in your node serial output denotes this.


Things that helped me to fix this

  • Check the earth line of your electrical connections with a tester and make sure there is no current leakage and its well grounded
  • Connect the relay module to a separate 5v DC power supply, make sure you have the ground lines connected across
  • Move the relay board away from the arduino/radio
  • Add a decoupling capacitor to the radio as described here . This helps to smooth en the spikes if any
  • Add the below line to your arduino code before #include <MySensors.h> . This will help in resetting the radio in case of connection issues.

Agri IoT :: Prototype 1 : Controller

This article is a part of a series that I’m doing based on building a agriculture IoT system. With prototype 1 intention is to build a minimal system with basic components.

Prototype 1 is covered in below articles,

  1. Agri IoT :: Prototype 1 : Overview
  2. Agri IoT :: Prototype 1 : Sensor
  3. Agri IoT :: Prototype 1 : Gateway
  4. Agri IoT :: Prototype 1 : Controller

Objectives ::

Controller should,

  • Be manageable with web/gui interface.
  • Open in nature ( for custom modifications )
  • Compatible to multiple Hardware gw/sensors ( no vendor lock in )
  • Cost effective
  • Should work without internet

Based on these OpenHab2 was selected.


  • PC running Debian Jessie


OpenHab2:  is a vendor neutral opensource solution  that can be used as a intranet of things controller


  • Java

Check and make sure java version installed is 1.8 or greater.

# sudo apt-get install software-properties-common
# sudo add-apt-repository "deb xenial main"
# apt-get update
# install oracle-java8-installer
# java -version
  • Openhab
 # wget -qO - '' | sudo apt-key add -
 # echo 'deb stable main' | sudo tee /etc/apt/sources.list.d/openhab2.list
 # apt-get update
 # apt-get install openhab2
  • Install mqtt binding

Access http://<controller_ip>:8080/ and select Standard which is the recommended setup
After installation access http://<controller_ip>:8080/paperui/index.html#/extensions under Bindings >> MQTT Binding >> Intall

Make sure the installation got completed by loging to Apache karaf

ssh openhab@localhost -p 8101
Default pass : habopen
openhab> log:tail

Mosquitto : Light weight MQTT broker ideal for IoT setups

# wget
# apt-key add mosquitto-repo.gpg.key
# cd /etc/apt/sources.list.d/
# wget
# apt-get update
# apt-get install mosquitto mosquitto-clients


Edit /etc/openhab2/services/mqtt.cfg and add below lines to it to allow openhab2 connect to the mqtt broker mosquitto


Edit /etc/openhab2/sitemaps/agri.sitemap and add below lines to it

sitemap demo label="Main Menu"
Frame label="MQTT" {
Text item=Agri_moisture

Edit /etc/openhab2/items/agri.items and add below lines to it

Group All
Number Agri_moisture "Moisture [%.1f ]" <moisture> {mqtt="<[broker:mygateway1-out/1/1/1/0/37:state:default]"}


View the sensor output on http://<controller_ip>:8080/basicui/app?sitemap=agri

Testing & Troubleshooting::

Find the logs for openhab2 and mosquito  in the below locations,