The monitoring system developed based on ART-PI and RT-Thread Studio IDE, approach to dht11,ds18b20, soil moisture, mpu6050 to monitor air temperature and humidity in breeding environments, soil temperature, and vibration density of the earthworm. External fans and pumps will control the above environmental variables. After connecting to the cloud OneNet, the environment variables can be observed and controlled remotely in the backend in real-time.

Development Environment

Hardware: ART-Pi STM32H750

Expansion Board: DS18B20 waterproof digital temperature sensor, DHT11 temperature and humidity sensor, 2pcs MPU6050 sensor, soil moisture sensor.

RT-Thread: V 4.0.3

IDE: RT-Thread Studio IDE 2.0.0(Free of charge)

RT-Thread RTOS Used in this Project

Scheduler: Create multiple threads to do different work.

Semaphore: Used to synchronize threads.

Mutex: Multiple related acquisition threads can access system resources at the same time and are not preempted by other threads

Message Queue: Used to synchronize acquisition threads, control threads, and Cloud OneNet upload threads.

Message Mailbox: onenet_mqtt synchronize with the control thread after accepting the control command

Components: I2c framework, Sensor framework

I2C Framework: Use the I2C Framework to drive the MPU6050

ADC device: Used to collect soil moisture

PWM device: Used to control fans, pumps.

Sensor Framework: The MPU6050, DHT11, DS18b20 are packs that based on sensor framework that provide a unified operating interface for the upper layer, improve the reusability of the upper layer code, and simplify the underlying drive development.

RT-Thread Software Packages Used

Webclient: Provide the basic functions of communication between the device and the HTTP Server.

pahomqtt: A set of MQTT client programs designed on the basis of Eclipse paho-mqtt source packages.

Onenet: An adaptation to connect RT-Thread with the OneNET Cloud platform so devices can be easily connected to the OneNet platform on RT-Thread to complete data transmission, reception, device registration and control, etc.

cJSON: The minimalist resolution of the JSON format package implemented in C language.

DHT11: GPIO simulates a single bus protocol, reads sensor temperature and humidity, and registers in the sensor framework.

Ds18b20: GPIO simulates a single bus protocol, reads the sensor temperature, and registers in the sensor framework.

MPU6050: A universal sensor drive package for InvenSense six-axis series of sensors, with the option of an I2C or SPI communication protocol. With the Sensor framework, developers can quickly drive this sensor.

Hardware Framework

Software Framework

Multiple acquisition threads read the temperature and humidity in the environment in real time and send it to the stream message queue; Onenet uploading thread receives the message and uploads it to the appropriate stream. When the Cloud issued commands, triggering Onenet_cmd_rsp_cb, in which to send the received control commands to the command cache mailbox, the control thread will query the mailbox, after finding the mail then start using rt_mq_urgent to send emergency control stream, and timely synchronize the status of cloud control devices.

Software Module Explanation

>span class="">Semaphore

mqttinit_sem is mainly used for WIFI connection and to synchronize onenet_mqtt_init.

sensor_msg_sem_empty primarily used to limit the number of message resources consumed by the acquisition thread.

5 Acquisition Threads

adc1_5_entry: Periodically read the value of the soil moisture sensor and send the value to the message queue sensor_msg_mq

read_dhtll_entry: Periodically read the value of the DHT11 temperature and humidity sensor and send the value to the message queue sensor_msg_mq

read_ds18b20_entry: Periodically read the value of the ds1b20 soil temperature sensor and send the value to the message queue sensor_msg_mq


Read more »