element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Design For A Cause 2021
  • Challenges & Projects
  • Design Challenges
  • Design For A Cause 2021
  • More
  • Cancel
Design For A Cause 2021
Blog Remote Agriculture Solution #05: Monitoring System
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: aaryan2134
  • Date Created: 27 May 2021 3:36 PM Date Created
  • Views 1193 views
  • Likes 2 likes
  • Comments 0 comments
  • arduino_nano_33_iot
  • iot system
  • arduino nano 33 iot
  • design for a cause design challenge
  • design_for_a_cause_2021
  • agriculture
Related
Recommended

Remote Agriculture Solution #05: Monitoring System

aaryan2134
aaryan2134
27 May 2021

Remote Agriculture Solution

Blog Links:

#01: Introduction

#02: Components and Design Structure

#03: Setting up the AgroBot

#04: Setting up Arduino Nano 33 IOT

#05: Monitoring System

#06: Irrigation System

#07: Pest Control System

#08: Linking Everything to Arduino Nano 33 IOT

#09: Time to See the Work in Action

#10: Future Improvements

 

In this blog, we will complete the setup of the farm monitoring system using Arduino Nano 33 IOT and various sensors.

 

This part of the project includes:

1. Measuring intensity of light using LDR

2. Measuring Temperature and Humidity using DHT 11

3. Measuring Soil Moisture using soil sensor

 

Finally, we need to graph these results using Blynk App by sending data over WiFi.

 

Measuring intensity of light using LDR:

 

 

  imageimage

We read analog value given by LDR using A0 pin. It gives a value between 0 - 1023.

 

The resistance of the Light Dependent Resistor (LDR) varies according to the amount of light that falls on it. The relationship between the resistance RL and light intensity Lux for a typical LDR is

image

image

Therefore, to calculate the intensity in lux, we use this formula

lux = (500*1024 / LDRvalue) - 500;

 

Measuring Temperature and Humidity using DHT 11:

For using DHT 11, we use EduIntro.h library.

I simply defined the DHT 11 pin as D7

 

 

DHT11 dht11(D7);  // creating the object sensor on pin 'D7'

Then, we can simply call these functions to get temperature and humidity

dht11.update();  //this meant to start the sensor

dht11.readCelsius();

dht11.readHumidity();

Measuring Soil Moisture using soil sensor:

Using the soil sensor works in a similar way like the LDR. It measures resistance to calculate moisture content. Higher resistance means less moisture.

So, we need to convert the analog value given by sensor(in between 0 - 1023) to moisture percentage.

I wrote this snippet of the code to do this.

I added 35 to account for resistance which was there even in 100% water.

  //calculating moisture percentage using analog value of the sensor

  moisture_value = analogRead(soil_pin);

  //converting to percentage

  moisture_value = (moisture_value * 100) / 1023;

  //using formula to account for resistance

  moisture_value = 35 + (100 - moisture_value);

Communicating to Blynk App:

We can simply define Virtual Pins to send data to Blynk App and use these lines of code. The rest of the setup needs to be done in the App.

//sending all values to the Blynk App using Virtual Pins

  Blynk.virtualWrite(V5, lux);

  Blynk.virtualWrite(V6, dht11.readCelsius());

  Blynk.virtualWrite(V7, dht11.readHumidity());

  Blynk.virtualWrite(V8, moisture_value);

Blynk App:

I used SuperChart widget for the monitoring system. It can plot data for 4 data streams which was enough for this task.

Remember to setup in the Super Chart widget:

 

  • V5 - Intensity
  • V6 - Temperature
  • V7 - Humidity
  • V8 - Moisture

 

Rest of the work is done automatically by Blynk. We just need to upload the code and wire the connections. Power up the Arduino Nano 33 IOT and run the App to see the charts.

 

Wiring:

Breadboard:

image

 

 

Schematic:

 

image

 

Code:

You can download the code from this link

https://github.com/aaryan2134/Remote-Agriculture-Solution/tree/main/Monitoring_system_code

 

//Remote Agriculture Solution
//Monitoring System
/*          Using Arduino Nano 33 IOT to monitor farm conditions using IOT
  Dev: Aaryan Arora
  For Design For A Cause 2021
*/
//libraries
#define BLYNK_PRINT SerialUSB
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
#include <EduIntro.h>
/* Used this library for getting temperature reading from DHT 11
  Can be downloaded from here or arduino library manager
  https://github.com/arduino/EduIntro
*/


DHT11 dht11(D7);  // creating the object sensor on pin 'D7'


//Use your authorization token after creating new project in Blynk App
char auth[] = "authorization token";


// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "your ssid";
char pass[] = "your password";


//constants
int LDRpin = A0; // select the input pin for LDR
int LDRvalue = 0; // variable to store the value coming from the LDR
int lux = 0;         //to store the intensity of light in lux


int soil_pin = A2; //soil sensor pin
int moisture_value ; //storing result from soil sensor


BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.


void myTimerEvent()
{
  //starting the DHT 11 sensor
  dht11.update();


  //Getting the LDR analog value
  LDRvalue = analogRead(LDRpin);
  //Using the formula for conversion from analog value to lux
  lux = (512000 / LDRvalue) - 500;


  //calculating moisture percentage using analog value of the sensor
  moisture_value = analogRead(soil_pin);
  //converting to percentage
  moisture_value = (moisture_value * 100) / 1023;
  //using formula to account for resistance
  moisture_value = 35 + (100 - moisture_value);
  
  //sending all values to the Blynk App using Virtual Pins
  Blynk.virtualWrite(V5, lux);
  Blynk.virtualWrite(V6, dht11.readCelsius());
  Blynk.virtualWrite(V7, dht11.readHumidity());
  Blynk.virtualWrite(V8, moisture_value);


}
void setup() {
  SerialUSB.begin(9600);
  Blynk.begin(auth, ssid, pass);
  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}


void loop() {
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

 

 

Hardware Setup:

imageimage

Software Setup:

 

Blynk App

image

Humidity Graph

image

 

Temperature Graph

image

 

Soil Moisture Graph

image

 

Light Intensity Graph

image

Connect with Me:

aaryan2134@gmail.com

Github - aaryan2134

My website

Linkedin

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube