This tutorial describes how to build a smart plant monitoring system with Arduino that controls the plant’s health status. With a smart plant monitoring system using Arduino, it is possible to check:
- temperature
- humidity
- light intensity
- soil moisture
All these parameters have effects on plant health. The idea that stands behind this Arduino project is monitoring the plant health status using a set of sensors.
Sensors, connected to Arduino, acquire information and then such information flows to the cloud using Ubidots IoT cloud platform. Moreover, we can connect to this Arduino smart plant monitoring system remotely using a browser. In this way, it is possible to verify the plant health remotely.
In this blog, we talked already about IoT ecosystem and you know already what it means. You should know how to use IoT cloud platforms to store and retrieve data.
Introduction to IoT Smart plant system
If you are new to IoT, it is useful, to know more about it, you read my article about What is Internet of things.
It is useful to recap briefly, Internet of things is defined as:
“The internet of things (IoT) is the network of physical objects—devices, vehicles, buildings and other items—embedded with electronics, software, sensors, and network connectivity that enables these objects to collect and exchange data. The IoT allows objects to be sensed and controlled remotely across existing network infrastructure”.
Especially relevant in an IoT project is the IoT cloud platforms that store data coming from dev boards like Arduino, Raspberry and so on. Using this data, IoT cloud platforms build charts and they have a built-in system to create some business rules on this information.
Moreover, Ubidots is an IoT cloud platform that not only stores data but enables users to create a dashboard to represent graphically the stored data.
What you will learn
In this tutorial, you will learn:
- how to use sensors to collect environment information using Arduino
- send data acquired to the cloud
- how to build an Arduino dashboard to monitor the plant health
If you want to know more about how works an IoT platform you can read my Practical Guide about how to use Ubidots with Arduino to build IoT projects
Arduino plant monitoring system project overview
Now it is time to describe this Arduino smart plant monitoring system in more detail. The image below shows the project at work:

This project uses Arduino Uno as development board and a set of sensors:
- DHT11
- YL-38 + YL-69
- TEMT6000
Anyway, you can use other boards such as ESP32 or ESP8266 or Wio Terminal.
DHT11: Temperature and humidity sensor
DHT11 is a sensor to measure temperature and pressure. It is a cheap sensor and suitable for Arduino. You can use a more accurate sensor but the way to use it is the same.
YL-38 + YL-69: Soil moisture sensor
YL-38 + YL-69 is a sensor to measure the soil moisture. It has to be inserted into the plant soil.
TEMT6000: Light intensity
TEMT6000 is a sensor to measure the light intensity so that we can know how light the plant is receiving.
The wiring part is very simple as it is clear in the picture below:

Moreover, in the picture above, it is clear that Arduino uses an ethernet shield to connect to the network, you can use also a WIFI shield it is almost the same approach.
Acquiring sensor readings using Arduino to monitor the plant health
Now that it is time to describe how to connect sensors to Arduino. The sketch is very simple:
void loop() {
float soilHum = analogRead(moisturePin);
soilHum = (1023 - soilHum) * 100 /1023;
Serial.println("Soil Humidty: " + String(soilHum));
// Read light float
volts = analogRead(lightPin) * 5.0 / 1024.0;
float amps = volts /10000.0;
float microamps = amps * 1000000;
float lux = microamps * 2.0;
Serial.println("Lux: " + String(lux));
float h = dht.readHumidity();
float temp = dht.readTemperature();
..
}
Code language: C++ (cpp)
where the dht
variable is defined as:
#define DHTTYPE DHT11
..
// DHTPIN is the pin number connected to DHT11 data output
DHT dht(DHTPIN, DHTTYPE);
Code language: PHP (php)
As a result, if we load the sketch into Arduino and run it you will know the values read by sensors using the serial monitor.
Arduino cloud: Send the sensor readings to the cloud to monitor the plant health
Another step is sending the data read to the cloud. In this IoT project tutorial as IoT cloud platform, we use Ubidots. If you are new to this platform and don’t know how to use it, I suggest you read this tutorial about how to connect Arduino to Ubidots. This project defines 4 variables holding values read from the sensor. Moreover, using this variable we create the dashboard.

Once the variables are configured in Ubidots, we have the variable id
:

Implement Arduino smart plant system
It is time to modify the Arduino sketch so that it sends the values to the Ubidots.
#include <SPI.>
#include <Ethernet.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
String tempVarId = "575475df7625423fd9da9c36";
String humVarId = "575475f1762542406cb10c43";
String lightVarId = "575475fc762542410358a0c3";
String soilVarId = "5754760576254241593d4d47";
String token = "xxxxx";
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[]="things.ubidots.com";
EthernetClient client;
IPAddress ip(192, 168, 1, 40); // Arduino IP Add
IPAddress myDns(8,8,8,8);
IPAddress myGateway(192,168,1,1);
int moisturePin = 0;
int lightPin = 3;
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.print("Starting...");
// Net connection...
}
void loop() {
float soilHum = analogRead(moisturePin);
soilHum = (1023 - soilHum) * 100 /1023;
Serial.println("Soil Humidty: " + String(soilHum));
// Read light
float volts = analogRead(lightPin) * 5.0 / 1024.0;
float amps = volts /10000.0;
float microamps = amps * 1000000;
float lux = microamps * 2.0;
Serial.println("Lux: " + String(lux));
float h = dht.readHumidity();
float temp = dht.readTemperature();
Serial.println("Temp: " + String(temp,2));
Serial.println("Hum: " + String(h,2));
sendValue(temp, h, lux, soilHum);
delay (60000);
}
void sendValue(float tempValue, float humValue, float lux, float soil)
{
Serial.println("Sending data...");
// if you get a connection, report back via serial:
int bodySize = 0;
delay(2000);
// Post single value to single var
String varString = "[{\"variable\": \"" + tempVarId + "\", \"value\":"
+ String(tempValue) + "}";
// Add other variables
Serial.println("Connecting...");
if (client.connect(server,80)) {
client.println("POST /api/v1.6/collections/values HTTP/1.1");
Serial.println("POST /api/v1.6/collections/values HTTP/1.1");
client.println("Content-Type: application/json");
Serial.println("Content-Type: application/json");
client.println("Content-Length: "+String(bodySize));
Serial.println("Content-Length: "+String(bodySize));
client.println("X-Auth-Token: "+token);
Serial.println("X-Auth-Token: "+token);
client.println("Host: things.ubidots.com\n");
Serial.println("Host: things.ubidots.com\n");
client.print(varString);
}
else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
boolean sta = client.connected();
Serial.println("Connection ["+String(sta)+"]");
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
Serial.println("Reading..");
while (client.available()) {
char c = client.read();
Serial.print(c);
}
client.flush();
client.stop();
}
Code language: PHP (php)
In conclusion, running the sketch and accessing the Ubidots dashboard we have:

Where to go from here? This project is useful in several scenarios whenever we have to monitor the soil and plant status. We can expand this project adding new features so that we can easily integrate it with other systems. For example, we can implement a notification system using Firebase so that we can send an alert when some parameters are out of the specified range. Moreover, we could add an Arduino API interface so that we can read the plant status parameters using external systems.
Finally, at the end of this IoT project tutorial, you gained, hopefully, the knowledge about reading data sensors. Moreover, you learned how to send sensor readings to the cloud.
Looks good, I’ll have to try as an alternative to Xively!
Here you go 🙂
https://personal.xively.com/feeds/785942547
Thx looks great. If you like you can post here how to do it. It would be very interesting for this blog readers.
I would be happy to look at doing that, it would take some work and time to “massage” and tidy the code glued together to make things work into a more suitable result for “publication”, and gather some links and credits, but that would also be a very worthwhile exercise for me!
Cheers and Kind Regards,
Azeo
Xively is an interesting product. Let me know the link of your project when it is ready.
your work surprised me a lot always. If I do, If I can, I’d like to make some lecture note using YOUR AWESOME WORK to Korean users~~. good~ 😉
Of corse you can. If you can you could add a reference to this original post. Thank you very much. As you can notice the wiznet shield is always in my projects.
Very cool project and very useful for real life applications!
Have you ever thought on using an ESP8266 instead of an Arduino? This way you can reduce even more the price of your design.
I want to add a water pump in my project, then how the code should i make?
You can use a simple relay to turn off or on the pump. When the soil is too dry you can turn on a pin and control the pump
I downloaded the sketch, but it won’t compile. It says that the dht.h file doesn’t exist or can’t be found. How can I go about fixing this?
Hi Mr. Francesco
Ive put the arduino sketch in the IDE but its says error for board arduino GENUINO UNO
what board are you using if i may ask please its urgent
Can you tell me the error you have?
It says “Error compiling for board Arduino/Genuino Uno.”
Thank you for answering sir ?
And sir may I say I really admire your work I’ve read almost every article here …. Im an electronic and communication engineer student and I’ve been studying your articles for months ,I’m inspired to make my graduation project an IOT project based on your work, but I have very limited knowledge in Arduino programming like Ethernet client codes and so …..
So if you can suggest a book or an online course or anything so I can improve my skills I’d be very very thankful ..
hello. do you have the schematic diagram for this project?
I do not have it right now, but I will create it soon. Thank you for your support
hello. do you have a schematic diagram of connecting wire for this project? thank you.
hello. I’m successfully doing this project. i just wanted to know if whether i can change ethernet shield to wifi shield? what type of wifi shield is compatible with this? wifi shield esp8266? do you have code for replace the ethernet to wifi?
Yes you can. You could use a Wifi shield compatible with Arduino or an ESP8266. If you use a compatible shield you have to change the way you initialize the shield. If you use an ESP8266 you have to check the pins where the sensors are connected.
Hi,
Nice to meet you.
We are the WIZnet Team in India.
We have been searching some application references in which WIZnet solution is applied and found your project “IoT project tutorial: How to build a Smart plant monitoring system using IoTINTERNET”. In the project, Wiznet chip W5500 or W5100 is used (Arduino Ethernet shield). Your development looks very cool & smart.
Recently we have developed WIZnet Museum (http://wiznetmuseum.com) site. This is an academic-purposed collection of open projects, tutorials, articles and etc from our global customers.
If you are O.K. we would like to introduce your project and device in here. Hopefully, you will allow this.
Hopefully, keep contacting us for the friendship.
Thank you very much
Wiznet team, India
Yes, of course, It would be nice if you could add a backlink to the original page in my blog.
Thank you very much for your attention.
Good day sir, i am student and your work amaze me a lot and i have a plan to make it as our iot project. It is possible to combined all light,soil,humidity and temperature in a one and where can i buy all materials needed.
Hope you will answer my question sir, thank you.
Hi,
of course, you can add several sensors to Arduino but if you want to use only one sensor that measures all these properties it is not available (afaik). You can buy the sensors on several web site like amazon, electrodragon.com and so on.
Hi,
Really impressed and I really want to thank you for sharing this.
As we know if we won’t wake up and think about our environment and the climate believe me a dead future is ahead. I am working on a project on this and very soon about to form an NGO to work on very grass root level to bring some changes. Please let me know if you can give your precious time in mentoring us when needed. Have few questions for now – is it possible to setup one single centralized system in a area to collect plant data for every plant in that specified are, without setting up seoarate aruduino for each plant is this possible to make one single system connected with the sensors connected to every plant?
I would be very thankful if you can guide us.
Hi,
Can u please share the circuit diagram of this project??
Hi,
Please upload the circuit diagram. I am unable to understand from picture.
Hi I’m looking for the diagram but i can’t find it at the moment. Hope to find it soon!
Can you provide the pin connections?
Hey If I have to use ESP8266 instead of et/wifi shield then what changes needs to be done?
If you use the ESP8266 you have to change the PIN connections and the WiFi settings. You can use an Arduino pinout and compare it with ESP8266 pinout and change the connections accordlingly.