How to make a smart irrigation system with Arduino UNO R4 WIFI board

How to make a smart irrigation system with Arduino UNO R4 WIFI board

Hello and welcome back. In this project, we will learn how to make a smart irrigation system with an Arduino UNO R4 WIFI board. For that, I mainly used the Arduino cloud. That’s my first experience. I think it’s most important for you. Additionally, I utilized a capacitive soil moisture sensor, a 5v one-channel relay, and a small water pump for the project. The Arduino UNO R4 WIFI board is the main character of this project. If you’re curious about this board and its usage, you can find more information through this link.

What’s the Arduino cloud?

It’s a cloud system provided by Arduino that allows us to develop various types of smart (IoT) projects. There are four plans available for using this cloud. I used the free plan for this project. You can extend it as you like. I think that’s better than Blynk Cloud. Because we have access to a wide range of widgets. This is especially valuable for beginners.

Key Features of this Cloud

  • Connect smart devices in minutes.
  • Create beautiful dashboards.
  • Control projects from anywhere in the world.
  • Alexa voice control.
With this Arduino Cloud, we can use the following boards.
  • Arduino MKR boards
  • Arduino WIFI Nano boards
  • Arduino Pro boars
  • Arduino UNO R4 WIFI board
  • ESP32/ESP8266 boards

If you want to do this project with the Blynk app, please use this link.

Now, I’m going to introduce the NextPCB online Gerber viewer tool. That’s important for PCB designers. HQDFM is a free advanced online Gerber Viewer tool that can display and analyze Gerber files from PCB CAD software including Altium Designer, OrCad/Allegro, Eagle, KiCad, DipTrace, DesignSpark, EasyEDA, and many more. In addition to rendering Gerber files, HQDFM can perform in-depth Design for Manufacture (DFM) analysis on your design in seconds, providing valuable insights into how you can improve your PCB design and avoid costly mistakes. Try it out!

NextPCB-Reliable Multilayer PCB Manufacturer is offering a special discount for high-quality PCBs, starting at $1.9. Order now and get your reliable PCBs that last for a lifetime. Also, everyone can enjoy free PCB assembly for 5 boards.

OK let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, connect the relay module and soil moisture sensor to the Arduino UNO board.

How to make a smart irrigation system with Arduino UNO R4 WIFI board

Step 3

Thirdly, connect the Arduino board to the computer. And then, set up the Arduino Cloud. For that, follow the instructions below.

How to make a smart irrigation system with Arduino UNO R4 WIFI board
  • First, go to the Arduino Cloud website and create a new account using your email. Then, log in to your account.
  • Now, click the “Get started” button and select the IOT cloud.
  • Then, add your device to the cloud. For that, download and install the Arduino agent program. At this time, please remove other USB devices. Now, you can see the Arduino UNO R4 WIFI board.
  • Next, you can rename it as you like. Then, download the device ID and secret key PDF.
  • Now, download the latest firmware and run it on your computer. At this time remove the other USB devices. (except Arduino UNO R4 WIFI board)
  • OK, now click the “Things” tab and create two variables.
  • Name — “relay” / boolean / Declaration — “bool relay”
  • Name — “sensor” / Integer Number / Declaration — “int sensor” / Variable update policy — Periodically(1S)
  • Then, connect your device and enter your network details. Open the PDF for the secret key. (which you previously downloaded)
  • Next, click the sketch tab and delete this code. And then, copy and paste the following code on this sketch.
  • Code and circuit diagram — Download
/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/1ec5753c-648f-41d5-af31-9d5e97d6b133 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  int sensor;
  bool relay;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#define relayPin 2
#define wet 210
#define dry 510


void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 
  
  pinMode(relayPin,OUTPUT);
  digitalWrite(relayPin,HIGH);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  onRelayChange() ;
  onSensorChange();
}

void onSensorChange()  {
  // Add your code here to act upon Sensor change
  sensor = analogRead(A0);
  sensor =  map(sensor,dry,wet,0,100);
  
}

void onRelayChange()  {
    if(relay){
    digitalWrite(relayPin,LOW);
  }else{
    digitalWrite(relayPin,HIGH);
  }
}

How to make a smart irrigation system with Arduino UNO R4 WIFI board
  • Now, run the Arduino agent program and upload this code.
  • Finally, click on the Dashboard tab. Then add a button widget and a percentage widget. Also, select the bool variable for the button and the integer variable for the percentage widget. Now you can customize the web view and mobile view as you like.

Step 4

Now, remove the USB cable. Then, connect the water pipe to the mini water pump and connect this water pump to the relay module. For that, you can use the circuit diagram above.

Step 5

Next, connect the external 5VDC power supply to this system. For that, I used a 12VDC connector.

Step 6

OK, arrange this system as you like. Now, you can control this system using your web dashboard or mobile dashboard. You can download the Arduino Cloud app from the Play Store or Apps Store. And then, log in to your Arduino Cloud account. Now, you can see the mobile dashboard that you created earlier.

OK, enjoy this project. The full video guide is below. We hope to see you in the next project or tutorial.

How to make a smart irrigation system with Arduino UNO R4 WIFI board

Similar Posts

One Comment

  1. Hlw sir my name is mayur maind i am indan.
    To the help in this project smart irrigation system with Arduino UNO R4 WIFI board to how to make please contact me email:- [email protected] or mobile no :- 9145661807
    Thank you to suggest the best idea and project.

Leave a Reply

Your email address will not be published. Required fields are marked *