Soil Moisture Data Retrieval Application Using Tuya Link Sdk

About the project

Soil Moisture Data Retrieval system using Tuya Link SDK, Tuya Smart Android App, ESP32, Moisture Sensor, Python and Arduino IDE in.csv format

Project info

Difficulty: Moderate

Platforms: ArduinoSparkFunPythonEspressifTuya

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

SparkFun Soil Moisture Sensor (with Screw Terminals) SparkFun Soil Moisture Sensor (with Screw Terminals) https://www.sparkfun.com/products/13322 x 1
Espressif ESP32 Espressif ESP32 https://www.digikey.com/en/products/detail/espressif-systems/ESP32-DEVKITC-32D/9356990 x 1
Micro-USB cable and connecting wires Micro-USB cable and connecting wires A micro-USB cable, and connecting wires x 1

Software apps and online services

Arduino IDE Arduino IDE https://www.arduino.cc/en/software
Python 3.x Python 3.x https://www.python.org/downloads/
Tuya Smart Application (Android) Tuya Smart Application (Android) https://play.google.com/store/apps/details?id=com.tuya.smart&hl=en_IN&gl=US
Tuya IoT Platform (Web) Tuya IoT Platform (Web) https://auth.tuya.com/?from=https%3A%2F%2Fiot.tuya.com%2F%3F_source%3D6eb8bc95075fdfc53d0ea6636c9a4b35

Story

In this article, we will develop a Soil Moisture Data Retrieval system using Tuya Link SDK, Tuya Smart Android App, Python and Arduino IDE. A Moisture sensor is connected to the ESP32 board to implement this application.

The moisture data will be logged in a.csv file and also displayed on the Tuya Smart App. This can prove very useful for home plantations, floriculture, horticulture, agriculture etc. where optimum soil moisture needs to be maintained for proper growth of plants.

GitHub Link:https://github.com/JayeshRajam/Tuya-sensorapp

Hardware Connections for Tuya Link SDK

Connections are pretty simple. The Pin 32 of the ESP32 board receives the Analog Signal from the moisture sensor. Connect the Vcc and GND of the ESP32 board and the Moisture Sensor.

If you have a moisture sensor like this, connections are the same but some extra jumper cables might be needed.

Tuya Link SDK Application Setup

First of all, create an account on Tuya Platform.

Install tuyaos-link-sdk in Python.

git clone https://github.com/tuya/tuyaos-link-sdk-python.gitpython -m pip install ./tuyaos-link-sdk-python

Tuya IoT Platform(Web)

Once logged in, create a new product (follow this simple tutorial as a getting started guide on Tuya) to get the following screen.

Now add the following functions by clicking the ‘Add’ button with the following attributes.

Next, complete the UI Studio Design. The UI Design should look like this. Test and Release it to resolve any errors.

Note: To refresh the Tuya server, the switch button is provided and every toggle of the button will register the current moisture reading in the MS.csv file.

Open the sensorapp.py file from the GitHub repo in the editor. Edit and change the productid, uuid, authkey (obtained by license generation for Link SDK) and the COM port of your connected ESP32 device in the file. Save this edited file, for the output section of this article.

Tuya Smart Application (Android)

After installing and setting up the Tuya Smart App, just click the scanner button to scan the QR code generated by the sensorapp.py file.

Now the MoistureApp will be added to the All Devices section of the Tuya Smart App.

Arduino IDE for Configuring Tuya Link SDK

The Arduino IDE Program in the GitHub repo sends the moisture reading received from the moisture sensor by the ESP32 board to the python program via the serial port. Simply add your ESP32 board in Arduino IDE, compile and flash the sensorapp.ino program.

Adjust the percentage value in the code to suit the sensor configuration.

Board Manager URL: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json

Output

Run the ledapp.py file using the command

python ./ledapp.py

MS.csv file content (Timestamp, Soil Moisture Reading)

Code

Tuya-sensorapp

https://github.com/JayeshRajam/Tuya-sensorapp

Credits

Leave your feedback...