MONITOR YOUR GARDEN

1,144

27

2

Posted in TechnologyArduino

Introduction: MONITOR YOUR GARDEN

Monitor Your Garden from anywhere, use local display to monitor the soil conditions locally or use Mobile to monitor from remote. The circuit uses soil moisture sensor, coupled with temperature and humidity to make aware about soil ambient conditions.

Step 1: Components :

  1. Arduino uno
  2. Nodemcu
  3. Temperature & Humidity sensor DHT 11
  4. Soil Moisture sensor - FC28
  5. Battery bank 10000mah (for Powering arduino & nodemcu)
  6. Nokia LCD 5110
  7. Resitor (5 x 10k , 1 x 330ohms)
  8. Potentiometer Rotary type (to adjust LCD brightness) 0-100K
  9. Jumper wires
  10. Breadboard

Step 2: BASIC SENSOR : Soil Moisture FC 28

In order to measure Moisture, we are using soil moisture sensor FC 28, the basic principle for which is as under:-

The specifications of the FC-28 soil moisture sensor are as follows:
Input Voltage: 3.3 – 5V

Output Voltage: 0 – 4.2V

Input Current: 35mA

Output Signal: Both Analog and Digital

The FC-28 soil moisture sensor has four pins:
VCC: Power

A0: Analog Output

D0: Digital Output

GND: Ground

Analog Mode
To connect the sensor in the analog mode, we will need to use the analog output of the sensor. When taking the analog output from the soil moisture sensor FC-28, the sensor gives us a value from 0 to 1023. The moisture is measured in percentage, so we will map these values from 0 to 100 and then we will show these values on the serial monitor. You can set different ranges of the moisture values and turn the water pump on or off according to it.

The Module also contains a potentiometer which will set the threshold value. This threshold value will be compared by the LM393 comparator. The output LED will light up and down according to this threshold value.

The code for interfacing with soil moisture sensor is taken up in further steps

Step 3: Understanding MQTT : for Remote Data Publishing

Before we begin further , let us first go through the Remote data publishing for IOT


MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol, designed for constrained devices and low-bandwidth, high-latency or unreliable networks. The design principles are to minimise network bandwidth and device resource requirements whilst also attempting to ensure reliability and some degree of assurance of delivery. These principles also turn out to make the protocol ideal of the emerging “machine-to-machine” (M2M) or “Internet of Things” world of connected devices, and for mobile applications where bandwidth and battery power are at a premium.

Source : http://mqtt.org/faq

MQTT[1] (MQ Telemetry Transport or Message Queuing Telemetry Transport) is an ISO standard (ISO/IEC PRF 20922)[2] publish-subscribe-based messaging protocol. It works on top of the TCP/IP protocol. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited.

Source : https://en.wikipedia.org/wiki/MQTT

Step 4: MQTT : Setting Up MQTT Broker Account

There are various MQTT broker account, for this tutorial, i have used cloudmqtt ( https://www.cloudmqtt.com/)

CloudMQTT are managed Mosquitto servers in the cloud. Mosquitto implements the MQ Telemetry Transport protocol, MQTT, which provides lightweight methods of carrying out messaging using a publish/subscribe message queueing model.

Following steps needs to be performed for setting up the cloudmqtt account as broker

  • Create an account and login to the control panel
  • press Create+ to create a new instance
  • To get started we need to sign up for a customer plan, we can try CloudMQTT for free with the plan CuteCat.
  • After creating "instance ", the next step is to create user and further assign permission to user for accessing messages (via ACL rules)

The complete guide to set up MQTT broker account in cloudmqtt can be accessed by following the link : - https://www.cloudmqtt.com/docs.html

All above steps are put one by one in following slides

Step 5: MQTT : Creating an Instance

I have created an Instance with name " myIOT"

plan : Cute plan

Step 6: MQTT : Instance Info

The instance is immediately provisioned after sign up and you can view the instance details, such as connection information, at the details page. You can also reach the Management interface from there. Sometimes you need to use a specify a connection URL

Step 7: MQTT : Adding User

Create a user with name “nodemcu_12” and give a password

Step 8: MQTT : Assigning ACL Rule

After creation of new user (nodemcu_12) save the new user, now further ACL is to be provided to the new user. In the attached picture, it can be seen that, i have provided both read and write access to the user.

Please note : Topic is to be added as shown in format (this is further required for read and write from node to MQTT client)

Step 9: Nodemcu : Configuring

In this particular project, i have used nodemcu from Knewron Technologies , more information can be obtained by following the link : -(https://www.dropbox.com/s/73qbh1jfdgkauii/smartWiFi%20Development%20Module%20-%20User%20Guide.pdf?dl=0)

It may be seen that , NodeMCU is an eLua based firmware for the ESP8266 WiFi SOC from Espressif. Nodemcu from knewron is preloaded with firmware, so we have to just load the app software namely : -

  • init.lua
  • setup.lua
  • config.lua
  • app.lua

All the above lua scripts can be downloaded from Github by following the link : Download from Github

From the above lua scripts, modify the config.lua scripts with MQTT host name, password, wifi ssid etc.

In order to download the above scripts to nodemcu , we have to use a tools such as "ESPlorer" , refer to docs for more information : https://nodemcu.readthedocs.io/en/master/en/upload/

Working with ESPlorer is described in next step

Step 10: Nodemcu : Uploading Lua Scripts to Nodemcu With ESPlorer_1

  • Click the Refresh button
  • Select the COM(Communication) port & baud rate (Commonly used 9600)
  • Click Open

Step 11: Nodemcu : Uploading Lua Scripts to Nodemcu With ESPlorer_II

Step 12: Nodemcu : Uploading Lua Scripts to Nodemcu With ESPlorer_III

Save & compile button would send all the four lua scripts to nodemcu, after this nodemcu is ready to talk to our arduino.

Gathering the CHIP ID info :

Every nodemcu has a chip id (probably some no.) , this chip id is further required to publish message to the MQTT broker, in order to know about the chip ID click the button Chip id in "ESPlorer"

Step 13: Nodemcu : Configuring the Arduino to Talk With Nodemcu

The below mentioned code determines the soil moisture, temp and humidity and further displays the data on nokia LCD 5110, and serially.

Arduino code

Than connect Arduino RX ---Nodemcu TX

Arduino TX ---Nodemcu RX

The above code also includes ways to use softserial library, by which DO pins can also be used to work as serial pins, i have used RX/TX pins to connect to nodemcu serial port.

Caution :As nodemcu works with 3.3V it is advised to use level shifter, however i have connected directly without any levelshifter and the performance seems just right for above application.

Step 14: Nodemcu : Setting Up MQTT Client in Android

The final step for viewing the information on mobile with android client :-

There are variety of MQTT android application, i have used the one from google play with following link :

.https://play.google.com/store/apps/details?

The configuration for android app is quite simple and one has to configure the following

  • MQTT Host address along with port no
  • MQTT user name and address
  • MQTT broker node address

After adding above details, connect the application , if the application is connected to MQTT broker, than all the inputs status / serial communication data from arduino appears as log.

Step 15: Additional Steps : Working With Nokia LCD 5110

Following are the pin configuration for LCD 5110

1) RST – Reset

2) CE – Chip Enable

3) D/C – Data/Command Selection

4) DIN – Serial Input

5) CLK – Clock Input

6) VCC – 3.3V

7) LIGHT – Backlight Control

8) GND – Ground

As shown above connect arduino to LCD 5110 in above order with 1-10 K resistor in between.

Following are the pin to pin connections for LCD 5110 to Arduino uno

  • CLK - Arduino Digital pin 3
  • DIN - Arduino Digital pin 4
  • D/C - Arduino Digital pin 5
  • RST - Arduino Digital pin 6
  • CE - Arduino Digital pin 7

Further "BL" pin of LCD 5110 can be used along with potentimeter (0-100K) to control the brightness of LCD

The library used for above code is : -Download the PCD8544 from below mentioned link https://github.com/carlosefr/pcd8544/archive/master.zip

The integration of DHT11 , temperature and humidity sensor with arduino can be looked into from following link DHT11.

Step 16: The Final Assembling

The last step is to Assemble all the above in a box preferably, for supply i have used 10000mah powerbank to power both the Arduino as well as Nodemcu.

We can also use wall socket charger for long duration , if desired.

Share

    Recommendations

    • Spotless Contest

      Spotless Contest
    • Microcontroller Contest

      Microcontroller Contest
    • Space Challenge

      Space Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    2 Comments

    Thank you