---
# System prepended metadata

title: Monitoring a plant on a budget.

---


 
 
# Monitoring a plant on a budget.

Olof Thorelli - ot222dg

## Project overview
This is a tutorial for building a cheap bluetooth connected device which measures the soil humidity of a plant and display the results on a graph in your web browser. It also triggers a LED-lamp to light up when the soil of the plant needs water. The developer board I have used is a cheap Arduino copy called "Geekcreit® UNO R3 ATmega328P" and it have been developed in "Arduino Software (IDE)".  

If you are new to projects like this, which I am, you need to spend time learning wiring, programming etc. In that case the project might take somewhere around 15-30 hours. In my case it took even longer because I tried to incorporate a WIFI-module called ESP8266 which turned out to be broken in the end (the reason I switched to bluetooth).

I also tried to calibrate a ultrasonic sensor which, despite collecting 100 readings, gave inaccurate results. The reason for trying to incorporate the ultra sonic sensor was to measure the plants growth over time.
 

- [X] Title
- [X] Your name and student credentials (xx666x)
- [X] Short project overview
- [X] How much time it might take to do (approximation)
 
 
 
### Objective
 
My girlfriend have more plants at home then we have acual space to put them so I tried to build something related to plants. I choose the sensors which were the cheapest and seemed easiest to use and understand. Even if it's not very advanced right now, the data from the device could be the starting point for me to try to fully automate a watering system in the future. 

My main goal with this project was to challenge myself with learning more about connected devices. Before starting this project I knew nothing about sensors, wiring, breadboards, Arduino etc. It had given me he insight that you shouldn't be scared of trying new things. 
 
 
- [x] Why you chose the project
- [x] What purpose does it serve
- [x] What insights you think it will give
 
 
### Material
 
 I have bought most things from China, which requires you to wait a bit before it gets delivered....  
 
 #### Total cost of project: 28$ (including shipping)
 
 #### List:
 
* **Geekcreit® UNO R3 ATmega328P**: 

A chinese copy of the developer board Arduino Uno. 

Brought from Ebay for around 5$. 

Digital I / O: 0 - 13 Analog I / O: 0 - 5 Support ISP download function Input voltage: DC 5V ~ 9V (No external power supply when connected to the computer) Output voltage: DC 5V / 3.3V Using Atmel Atmega328 microprocessor controller.



![](https://imgur.com/gGTxLLP.jpg)

* **iHaospace Soil Hygrometer Humidity Detection Module**: 

 Measures the humidity of the a plants soil. 
 
 Bought from Ebay for around 2$

![](https://imgur.com/lopEjVc.jpg)

* **Breadboard, LED-lamp, jump wires, transistor**: 

Bought a packet which includes:

Breadboard for connecting your jump wires with transistors into the GeekCreit or sensors.

LED-lamp for displaying when the soil is dry. 

Jump wires to connect everything, both M-M, M-F, F-F.

Packet was bought from Ebay for around 7$. 

(It's more then enough for just this project.)

![](https://imgur.com/cShwO0Y.jpg)

* **Bluetooth-module**: 

A module for making your developer board transmit data wireless through Bluetooth. 

Brought from Kjell&Co for around 12$. 

![](https://imgur.com/F3FEcMU.jpg)


 
 - [X] List of material
- [X] What the different things (sensors, wires, controllers) do - short specifications
- [X] Where you bought them and how much they cost
### Computer setup

I used Arduino’s own software, Arduino Software (IDE) from https://www.arduino.cc/, which is a free software and supports the board I am using (with the help of downloading some packages). It uses Arduino’s own programming languages which is simular to C++. 

The code is uploaded to the GeekCreit through a USB-cable. It is important that the RX and the TX doesn't have anything connected to them while you try to upload, disconnect them first, otherwise it won't work. 

I needed to install a driver called "ch341ser.zip" and have the GeekCreit connected at the same time as the driver was running to make the developer board work on Arduino Software (IDE) because it's not the official board I am using. 

I also installed Node.js to get Node-RED to work. I followed one of the many good guides on the internet to set it up. 
 
- [X] Chosen IDE
- [X] How the code is uploaded
- [X] Steps that you needed to do for your computer. Installation of Node.js, extra drivers, etc.
 
 
### Putting everything together
 
* **LED-lamp**: 

PIN 13 on the GeekCreit is connected with the breadboard on the same colomn as one leg of the resistor. On the same colomn as the other leg of the resistor, connect the longest leg of the LED-lamp. Connect the short leg of the LED-lamp with GND (Ground) on the GeekCreit. 

![](https://imgur.com/HEdZIKs.jpg)



* **iHaospace Soil Hygrometer Humidity Detection Module**: 

Connect A0 with A0 on the GeekCreit, connect GND with GND on GeekCreit and connect VCC with 5v on the GeekCreit. It doesn't matter which order you put the last two cables which goes into the sensor.

![](https://imgur.com/d5KXNn3.jpg)

* **Bluetooth-module (HC-06)**:

Connect VCC of the bluetooth-module with 3,5V of the GeekCreit. Connect GND of the bluetooth-module with GND of the GeekCreit. Connect TXD of the bluetooth-module with RX of the GeekCreit. Connect RXD of the bluetooth-module with TX of the GeekCreit. (You cannot upload anything to the GeekCreit when the cables RX and TX are connected to your GeekCreit, so you need to remove those first.)

![](https://imgur.com/ZIOawat.jpg)

 
- [X] Circuit diagram (can be hand drawn)

 
 
### Platform
 
 
 I used Arduino's own software, Arduino Software (IDE) from https://www.arduino.cc/, which is a free software and supports the board I am using (with the help of downloading some packages). It uses Arduino's own programming languages which is simular to C++. I'm not very used to programming but the software was easy to use and to set up. It's installed locally on the computer. It handles the communication between the GeekCreit and the code you want to upload. It also has a built-in monitor so you can see if any data is transmitted. 

 
 
 

 
- [X] Describe platform in terms of functionality
 

### The code
 
Import your code here, and don&#39;t forget to explain what you have done!
 
 
```python=6
int sensorPin = A0; 
 # the pin for the soil sensor.


int sensorValue;
# The value which is being measured.


int limit = 300;
# The limit I am setting for when the soil is to dry.


void setup() {
 Serial.begin(9600);
 pinMode(13, OUTPUT);
 # The setup for the LED-lamp which is connected to PIN 13 and is an output. 
 
}

void loop() {{


 sensorValue = analogRead(sensorPin); 
   # sets the sensorValue to the analog reading from the sensor pin A0.
   

 Serial.println("Analogt Värde : ");
  # You can put any text you want instead of "Analogt Värde :" which will be printed after the measured value.
 
 

 Serial.println(sensorValue);
  # Prints the value from A0
  
  
 if (sensorValue>limit) {
 digitalWrite(13, HIGH); 
 }
 else {
 digitalWrite(13, LOW); 
 }
 
 #If the sensorValue is higher then limit (300), then PIN 13 is set on high and the LED-lamp turns on, if not the PIN 13 is set low and the LED-lamp turns off.
 
 delay(10000); 
 
 #Delay the reading with 10000 milliseconds which equals to 10 seconds.
 
}

}
 
# 
 
```
 
 
 
### Transmitting the data / connectivity
 
 
The data is transmitted from the sensor, to the GeekCreit and then through the bluetooth-module every 10000 milliseconds which corresponds to every 10 seconds. Bluetooth-module (HC-06) communicates through a Serial  Port Protocol, which means it sends the data direcly to a COM-port. Because of that it was very easy to set up and use, ones I got a hold of the use of different COM-ports. All I pretty much did was hooking up the module and choosing the right COM-port (no extra installation required).
 
- [X] How often is the data sent?
- [X] Which wireless protocols did you use (WiFi, LoRa, etc ...)?
- [X] Which transport protocols were used (MQTT, webhook, etc ...)

### Presenting the data

The dashboard was created using Node-RED. It requred some local installation and configurations but it was easy to find manuals how to do it on the internet. The data is saved at the same rate as the sensor is triggering, which is every 10 seconds. "msg" is there so I can see that correct data is transmitted from the device inside the "debug-menu" in Node-RED. "Fuktmätare" is the graph which shows the rising and falling value. "Nuvarande mätvärde" shows the current value measured. 

![](https://imgur.com/n3w6Cvi.jpg)

![](https://imgur.com/E9hpqVQ.jpg)
 
- [X] Provide visual examples on how the dashboard looks. Pictures needed.
- [X] How often is data saved in the database.

 
 
### Finalizing the design
 
 The project didn't get the complexity I wanted. I had to delete alot of code for the ultrasonic sensor. It took awhile for me to program so it took the average reading of a 100 readings but I was not happy in the end with the +-0,5CM difference between the readings. 
 
 I am a little disappointed that I couldn't get the WIFI to work (broken module) so I had to buy the bluetooth-module in the last minute. If I had the time to order a new one I would have tried to implement WIFI into my device. 

All and all I am happy that I manage to learn so much from knowing almost nothing about this since before. I have ordered some more sensors so I can expand my knowledge in the future. Next project will propably be a automated watering system for a plant. 
 
 ![](https://imgur.com/VlGlHbA.jpg)
 
 
- [x] Show final results of the project
- [x] Pictures
