With the advancement of technologiesand the improvement of living conditions, the cultivation of ornamental flowers has become a part of people's life. But since the outbreak of covid 19, many people can not take care of their beloved plants when they self-isolate in other places. Therefore, we have designed an intelligent plant maintenance system, which uses the esp32wifi communication module as the core and a soil moisture sensor outside.DHT11 temperature and humidity sensor, carbon dioxide sensor and photosensitive resistance, these three sensors work together tomonitor the plant living environment in real time. The system also transmits data to the web front-end interface using mqtt protocol. We developed a front-end page to show monitoring data at any time and control the water pump. At the same time, some monitoring data can also be seen on the OLED display screen, When the water in the sink is insufficient, a buzzer will give an alarm for replenishment. It can help you take care of your plants in real time
1.1 IssueWith the improvement of living conditions, the succulent has become a part of people's life. People hope that their lives are full of green, and green plants have brought a great impact on people’s lives. It can change people's mood and release stress. Green plants have a very good air purification effect. They can absorb formaldehyde and benzene in the air, which are harmful to the human body, and release oxygen. People perform operations such as ventilation, shading, and watering by observing the air humidity, temperature, light intensity, and soil humidity in the green plant growth environment. Do not dry or pour, pour thoroughly is the principle of watering. However, it is difficult for people to judge the exact degree of soil dryness and wetness, and it is impossible to grasp the time and amount of watering. The amount of watering will seriously affect the growth of green plants. Moreover , there is a serious shortage of water resources in our country, and improper watering methods may lead to a great waste of water resources. Since the breakout of the covid-19,many people can't take care of their beloved plants when they isolate in other places.
1.2 SolutionWe designed an intelligent plant maintenance system. The system uses the esp32wifi communication module as the core, and is connected to the soil moisture sensor, DHT11 temperature and humidity sensor, carbon dioxide sensor, photosensitive resistor, OLED display and pump. Through the MQTT protocol to realize the interaction with the web interface, the system can automatically water according to the data collected by the sensors. The sensors send data to the Mobius server platform . The Mobius server accepts the uploaded data from authenticated IoT devices and stores the data into the MySQL DB . At the same time, users can also control watering on the web page. When the amount of water in the sink is insufficient, a buzzer will alarm and remind you on the web. Therefore, the project is more real-time, reliable and practical. It can accurately determine the automatic watering, so that people who are busy with work do not have to worry about the lack of water for their favorite green plants and affect their growth. It can make different watering plans for green plants with different living habits.
2.User Guide2.1 IntroductionOur Succulent care system provide users many data, you can get temperature,air humidity, soil humidity, light intensity and so on. We use many sensors to monitor the environment of your plant, and the sensors send data to the Mobius server platform . The Mobius server accepts the uploaded data from authenticated IoT devices and stores the data into the MySQL DB . The authenticated IoT applications can retrieve the data stored in Mobius server using Mobius open APIs for monitoring purpose, the authenticated IoT applications are able to control remotely IoT devices that have already registered with Mobius server by sending control commands included in resource. The Mobius server then executes control commands to the target devices. For our system, user can control the pump by clicking the button "water" on the web. And the pump can automatically work when the soil humidity is under 15%, and it will stop automatically too. By using our system, your succulent will won't die of drying.
To run this project, the following tools are requied:
- Mobius Server Platform
- Node JS v13 or higher
- MySQL DB
- MQTT Server
- vue cli v4.5.13
- Arduino IDE or Platform IO
2.2.1 Node JS v13 or higherNode.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool for almost any kind of project.Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. In contrast to multi-thread based servers, node.js operating on a single thread using non-blocking I/O calls allows it to support tens of thousands of concurrent connections. With node.js, users don’t need worry about the dead-locking of processes because almost no function in node.js directly performs I/O so there is no locks problem at all and therefore, scalable systems can be Window-A Window-B Figure 20 Mosquitto broker test window reasonably developed through node.js. Node.js was originally written by developer Ryan Dahl in 2009 and distributed as an open source and currently a diverse of modules developed from contributors are included covering file system I/O, networking, binary data (buffers), cryptography and data streams etc. Node JS can be download at below link:
[Download Node.js (nodejs.dev)](https://nodejs.dev/download)
After installation of Node.js, check the system environment variables table (here taking Windows system as an example) to ensure that the installation path of node.js (default is C:\Program File\nodejs) is already added automatically in PATH environment variable and if there is no node.js path, update the PATH with node.js path . To test whether Node.js is installed properly, open a Windows Command Prompt window and under the user directory, run node command to enable node.js mode. In the node.js, input console.log("hello node.js"); if receives response hello node.js then it indicates the Node.JS are installed and works properly.
Mobius Yellow Turtle server platform deploys MySQL DBMS as a database so MySQL is required to be installed as a basic and then MQTT server and Mobius server have to install one by one. Note that it is unnecessary to install MQTT server if MQTT protocol and MQTT related functions are not supported.Mobius server platform stores the data uploaded from devices into MySQL database. Different versions of MySQL are provided for download at below link:
[MySQL :: Download MySQL Community Server](https://dev.mysql.com/downloads/mysql/)
Step 1: Create a Mobiusdb Schema After the MySQL is connected properly, right click the mouse at the workbench GUI as depicted as Figure 17 and create a schema using popped tab. Name the new schema as ‘mobiusdb’ and apply the schema creation. Then you can see the new created ‘mobiusdb’ schema at the SCHEMA column at the left down side of GUI, select the mobiusdb schema and right click to select ‘Set as Default Schema’ to set the current schema as default.
Step 2: Import Mobiusdb database All we need regarding for configuring Mobius database are bundled into a sql script file (mobiusdb.sql). Users can download freely the .sql scipt file from OCEAN alliance website Mobius page. As depicted as Figure 18, import the downloaded .sql script file through ‘Data Import’ popped window. In ‘Import from Disk tab’, select option ‘Import from Self-Contained File’ and browse to the downloaded .sql script and select ‘the default schema to be imported to’ as created ‘mobiusdb’ schema. Finally click the ‘Start Import’ to apply the change. After the .sql file is imported, refresh the mobiusdb schema and you can see the mobiusdb schema is updated with empty tables are updated.
EMQ X (Erlang/Enterprise/Elastic MQTT Broker) is an open source IoT MQTT message broker based on the Erlang/OTP platform. Erlang/OTP is an excellent Soft-Realtime, Low-Latency and Distributed development platform. MQTT is a lightweight message exchange protocol using publish-subscribe pattern.
EMQ X is designed for massive clients access and realizes fast and low-latency message routing between massive physical network devices:
1. Stable to host large-scale MQTT client connections, and a single-server node supports millions of connections.
2. Distributed cluster, fast and low-latency message routing, and single-cluster supports tens of thousands of routes.
3. Extensible, support customized plugins, such as authentication and other functions.
Comprehensive IoT protocol support, including MQTT, MQTT-SN, CoAP, LwM2M, and other TCP/UDP based proprietary protocol.
Installation
wget https://repos.emqx.io/install_emqx.sh
chmod +x install_emqx.sh
sudo ./install_emqx.sh emqx-ee
For more information:[EMQ X docs](https://docs.emqx.io/en/enterprise/v4.3/)
2.2.4 Mobius Server PlatformMobius is a middleware server platform that connects diverse IoT devices through physical communication medias and creates virtual representations (oneM2M resources) for each IoT device to enable the interactions between each other as well as the communication between devices and IoT applications. In this way, Mobius provides an open environment and APIs for users to interconnect their own devices together and develop user specific IoT services to build an IoT ecosystem.
The Mobius server accepts the uploaded data from authenticated IoT devices and stores the data into the MySQL DB. The authenticated IoT applications can retrieve the data stored in Mobius server using Mobius open APIs for monitoring purpose.The authenticated IoT applications are able to control remotely IoT devices that have already registered with Mobius server by sending control commands included in resource. The Mobius server then executes control commands to the target devices.
Mobius server platform is distributed with binary and source package in OCEAN alliance website (http://www.iotocean.org) or the Mobius GitHub (https://github.com/IoTKETI/Mobius). User can download the Mobius server zipped package and configure the Mobius server in terms of communication port and CSE name etc. .
2.3 Download the projectThe software resources are located in the github from the master branch:
[view ](https://github.com/pilipalaBu/onem2mview)
[hardwar](https://github.com/pilipalaBu/onem2mhackathon)
[Mobius](https://github.com/IoTKETI/Mobius)
2.4 Hardware PrerequisitesThe intelligent plant maintenance system has rich functions and realizes many detection and control modules. The following part introduces the process of configuring these modules in detail.
ESP32Servo by Kevin Harrington
Adafruit BuslO by Adafruit
Adafruit GFX Library by Adafruit
Adafruit SGP30 Sensor by Adafruit
Adafruit SSD1306 by Adafruit
SimpleDHT by Winlin
DHT sensor library by Adafruit
Adafruit Unified Sensor by Adafruit
LiquidCrystal by F Malpartida
PubSubClient
2.4.2 Components:Esp32s for WiFi
Bread board
DHT11 ----------------------------------GPIO 16 (detect air temperature and humidity)
Water level sensor -----------------GPIO 34 (detecting residual water volume of water tank)
Soil moisture sensor---------------GPIO 36 (detecting soil moisture)
Buzzer---------------------------------- GPIO 14 (alarm when the water tank is insufficient)
Relay ----------------------------------- GPIO 17 (connecting water pump and power supply, controlling water pump watering)
Photoresistor ----------------------- GPIO 39 (sensing the intensity of light according to the resistance value)
Carbon dioxide sensor----------- GPIO 21 GPIO 22 (detect the concentration of carbon dioxide in the air)
OLED display------------------------- GPIO 21 GPIO 22(display some monitoring data)
resistance
2.4.3 DHT11Connect DHT11 to GPIO 16 pin, call simpledht function, collect the data collected by the sensor and store it in temt and hum variables
2.4.4 Water level sensorConnect the water level sensor to the GPIO 34 pin, store the data collected by the sensor in the values and values2 variables and map it to the appropriate range, and finally display the data in millimeters.
2.4.5 Soil moisture sensorConnect the soil moisture sensor to the GPIO 36 pin, collect the level analog signal collected by the sensor, and convert the level into a percentage value through the mapping function
2.4.6 BuzzerConnect GPIO 14, first define different tones, then list each frequency and beat according to the spectrum, and call tune function to play music
2.4.7 RelayConnect GPIO 17 , connect the water pump and power supply. When the soil humidity is lower than the specific value or receives the front-end watering command, set it to high level for watering. When the soil humidity is higher than the specific value or the water level drop is greater than the specific value, set it to low level and stop watering.
2.4.8 PhotoresistorConnect GPIO 39, sense the intensity of light through the value of photoresist resistance, and map the data to the value of bits 0-100 through the mapping function.
2.4.9 Carbon dioxide sensorCall the Adafruit SGP30 Sensor by Adafruit function library, connect the CO2 sensor to the GPIO21 and GPIO22 pins, collect the data collected by the sensor and store it in the sgp.eco2 variable
2.4.10 OLED displayCall Adafruit SSD1306 by Adafruit and Adafruit GFX Library by Adafruit library, connect the OLED display screen to I2C SCL and I2C SDA pins, and set pixels through functions to form data to be displayed
2.6 Run2.6.1 WebThe web shows data including temperatrue, soil humidity , light intensity ,water depth and so on. We provide simple chart for users who don't need to know the carbon dioxide or light intensity. Those sers can choose from menu to see the temperature chart or humidity chart only.When clicking the button "water", a request is sent to the Mobius server platform ,then the pump is controled to water.Also,when clicking the button "refresh", all the data will refresh again and show the latest data.
To connect IoT devices together and retrieve data from the Mobius platform,we use the code below:
getData () {
axios.get('http://onem2m.baluobo.top:7579/Mobius/ae_test/cnt_test02/la', {
// params: data,
headers: {
'X-M2M-Origin': 's',
'X-M2M-RI': '12345'
}
}).then((res) => {
this.dataData = res.data
console.log(res.data)
for (const item in this.dataData) {
this.jValue = this.dataData[item]
}
for (const i in this.jValue) {
if (i === 'con') {
this.jValue = this.jValue[i]
console.log(this.jValue)
}
}
for (const j in this.jValue) {
if (j === 'tem') {
this.tem = this.jValue[j]
console.log('tem:' + this.tem)
}
if (j === 'hum') {
this.tem = this.jValue[j]
console.log('hum:' + this.hum)
}
if (j === 'CO2') {
this.tem = this.jValue[j]
console.log('CO2:' + this.co2)
}
if (j === 'light') {
this.tem = this.jValue[j]
console.log('light:' + this.light)
}
if (j === 'soil') {
this.tem = this.jValue[j]
console.log('soil:' + this.soil)
}
if (j === 'water') {
this.tem = this.jValue[j]
console.log('water:' + this.water)
}
}
})
},
```java
createConnection () {
const { host, port, endpoint, ...options } = this.connection
const connectUrl = `ws://${host}:${port}${endpoint}`
try {
this.client = mqtt.connect(connectUrl, options)
} catch (error) {
console.log('mqtt.connect error', error)
}
this.client.on('connect', () => {
console.log('Connection succeeded!')
})
this.client.on('error', error => {
console.log('Connection failed', error)
})
this.client.on('message', (topic, message) => {
this.receiveNews = this.receiveNews.concat(message)
console.log(`Received message ${message} from topic ${topic}`)
})
},
```
To publish the message to the server,we use code below:
```
doPublish () {
const { topic, qos, payload } = this.publish
this.client.publish(topic, payload, qos, error => {
if (error) {
console.log('Publish error', error)
}
})
},
```
To send the "water" request, we write a function like this:
```
watering () {
this.createConnection()
this.doPublish()
}
```
Comments