Objectif: The main goal of this IoT Lab is to interface a Soil moisture sensor with IBM Quick Start using Nucleo and Wifi sheild. This sensor measures the volumetric content of water in soil and gives us the moisture level.
Students Levels : IIA, IMI and RT
Step 1: Required Hardware :
1. NucleoF401RE board with X-Nucleo-IDW01M1V2 wifi Sheild.
2. Moisture sensor :
The Moisture Senor can be used for detecting the moisture of soil or judge if there is water around the sensor, The moisture sensor uses the two probes to pass current through the soil, and then it reads that resistance to get the moisture level. More water makes the soil conduct electricity more easily (less resistance), while dry soil conducts electricity poorly (more resistance).
The specifications of the used soil moisture sensor are as follows:
- Input Voltage: 3.3 – 5V
- Output Voltage: 0 – 4.2V
- Input Current: 35mA
- Output Signal: Both Analog and Digital
The soil moisture sensor has four pins:
- VCC: Power
- A0: Analog Output
- D0: Digital Output
- GND: Ground
Step 2: Developing with Ecosystem
You should connect o the Arm® Mbed™ IoT Device Platform, the applications for this lab can be developed using the mbed online IDE, a free online code editor and compiler. sign in to the compiler :
Create new project , configure it with your hardware : NucleoF401RE board .
You must include the required libraries such as :
Create new file (main.cpp) into the project. you can use ST online project as template, the project allows to Connect through Wifi to IBM MQTT cloudhttps://quickstart.internetofthings.ibmcloud.com
ST code :
IDW01M1_Cloud_IBM - a mercurial repository | Mbed
Otherwise, you find attached a project to complete.
Use pin D13 as sensor digital output.
compile your project , upload it to the nucleo. You need to get the wifi sheild MAC adress, as it is used as Object identifier with IBM quick-start platform. Install and run a serial terminal interface (e.g.Teraterm) to visualize log messages and to get parameters such as Wi-Fi MAC adress.
When connection to access point is established, you can take note of the MAC address of your Wi-Fi expansion board :
Step 3: Visualize data on IBM Quickstart web-page
The application will read and transmit Quickstart raw data from the moisture sensor. The Quickstart web page showing the level state change when when there is water or moisture, as the output is binary (0, 5V):