Course: Introduction to Applied Internet of Things (1DT305)
Student: Sara Enander (se223hv)
The aim of this project is to connect a soil moisture sensor to Ubidots using a lopy4 and pycom expansion board, and to notify user when moisture is below 30% of maximum moisture value. Depending on skill level and previous experience this project might take a few hours up to a couple of days to finalise
I chose to do this project because I love having lots of plants in my apartment, but I find it hard to keep track of when I have watered the plants and if I have watered enough - or maybe too much! That is why I chose to connect a sensor to measure the soil moisture and send the information to a platform and alert user when the soil is dry. This will also give insight to how often the plants need to be watered in order to stay on a relative constant moisture level.
The material used for this project is listed below:
| Material | Short specification |
| โโโโ | โโโโ | โโโโ |
|Pycom lopy4 with headers | Processing data recieved from sensor and sending to platform
| Pycom expansion board | To mount the lopy4 on and organise outlets and inputs |
|Soil moisture sensor | Consists of two parts: an electronic board and a probe. Probe is put in soil to collect data by measuring the resistance between the two legs on the probe. |
|Breadboard | Makes it easy to connect the sensor in a neat way |
| Jumper wires | Connecting the sensor to the expansion board |
All of the material was purchased from electrokit.com and cost in total about 1000 SEK.
To handle the data from the device it was connected to the Integrated Development Environment Atom. This IDE was chosen because it seemed easy learn and to use, and well suited for this project. First a new device was set up on the Pybytes webside, and then the pybytes package was installed in Atom. The device was then connected using an activation string from the Pybytes website. The code was then uploaded to the device, and the data from the sensor was sent to Ubidots for display. No extra installations had to be done.
The sensor was connected to the hardware as shown in Figure 1:
Figure 1: Circuit diagram
Picture sources: https://docs.pycom.io/gettingstarted/connection/lopy4/
https://www.electrokit.com/uploads/productfile/41015/41015738_-_Soil_Moisture_Sensor.pdf
How the setup looks in real life, with the breadboard, is shown in Figure 2:
Figure 2: The setup
The platform used to present and visualise the data was Ubidots. The free version was used. Ubidots was chosen because it had a user-friendly interface and many ways to present the data in a clear and simple way. It also contained the function to notfiy the user when the moisture level was too low. In the first tests the platform pybytes was used, and it was also easy to use, and to present data in a neat way. Ubdots were chosen over Pybytes because Ubidots contains more functions that suited the project.
The code in the main program is presented below:
The inital code was copied from the following guide: https://help.ubidots.com/en/articles/961994-connect-any-pycom-board-to-ubidots-using-wi-fi-over-http. The code was then altered to read data from the sensor connected and to suit the needs for this project.
The data was transmitted from the device over wi-fi, once every hour. The transport protocol MQTT was used. All this was implemented using the guide linked to above.
The Ubidots dashboard contains of two widgets, showed in Figure 3:
Figure 3: The Ubidots dashboard
The line chart is showing the last 100 measurements of the moisture level, which is equivalent to about 4 days back in time. The other widget is showing the current moisture level. The user is notified by e-mail when the moisture level is below 30%, an example is shown in Figure 4. This is easily added under the tag "Data" and then "Events". The trigger moisture level can easily be adjusted depending on the plant's water needs.
Figure 4: The email received by user when moisture level is too low
The final setup can be seen in Figure below:
Figure: The final setup
To make this project more usable and neater a box for the Pycom unit and breadboard could be used. A waterproof box would also be needed if the soil moisture of outdoor plants would be measured. Multiple sensors could also be connected to measure the moisture in different pot plants.