This project just collects moisture data of your soil to help you better take care of your plants.
Below shows how data gets transferred from the soil sensor to Influx Data. Influx data will serve both as part of the middleware layer that hosts all the data and also the application layer to help users interact with the data via its dashboard feature.
graph LR
A(Soil Sensor) --> |Data| C(Hive Public MQTT Broker)
C --> D(MQTT Forwarder)
E(InfluxDB)
subgraph Wio Terminal
A
end
subgraph The Cloud
C
E
end
subgraph Raspberry Pi Server
D
end
D --> E
🙋♂️ If you want to host your own MQTT broker on the Raspberry Pi, just refer to the appendix section below
-
Capture Soil Moisture % using a moisture sensor
-
Collects and Soil Moisture telemetry to Influx Data
-
Display Moisture % on Wio Terminal Display
- Laptop or Computer
Based off of instructions from Random Nerd Tutorials
-
Create a influx data cloud account: InfluxDB Cloud
-
Select where to save your data
-
Select the free plan
-
Create a Bucket.
On the left side panel, click Load Data then click Buckets
Then click the Create Bucket button on the right
You'll give your bucket a name then click on the Create button ?��
-
Collect the influx DB credentials
Go to Sources then scroll down and click Python
Copy your token from the Tokens section and other information listed below from the Initialize Client Section
-
Copy
template.h
file asconfig.h
in the same parent foldercd <path_to_repo>/is-my-soil-moist/soil_moisture_terminal/src/ cp template.h config.h
-
Replace the following values in your
config.h
file with the appropriate ones-
<YOUR_WIFI_ID>
-
<YOUR_WIFI_PASSWORD>
-
<YOUR_GUID>
-
-
Connect your Wio Terminal to your Computer with a USB-C Cable
-
Turn on your Wio Terminal
-
Hit the upload button on Platform IO
-
Clone the repo
git clone
-
Install the following libraries
pip3 install
-
Run the following code
python3
Refer the the appendix section for a great time
If you want to use your own MQTT Broker hosted on the Raspberry Pi instead of the public mosquitto
. broker.
-
First install
sudo apt get update sudo apt install mosquitto mosquitto-clients sudo reboot
-
Test your installation
sudo systemctl enable mosquitto
-
Edit the
mosquitto.conf
filesudo nano /etc/mosquitto/mosquitto.conf
Replace
include_dir /etc/mosquitto/conf.d
with
allow_anonymous true listener 1883
-
Restart mosquitto service.
sudo systemctl restart mosquitto
The configuration should be applied and the broker will listen on port 1883.
-
To test if you are able to publish/subscribe to your MQTT Broker. Use another computer connected to the same local network.
sudo apt install mosquitto-clients
Subscribe to a topic in one terminal window
mosquitto_sub -h <raspberry_pi_ip_address> -p 1883 -v -t test/message
Publish to the topic in another terminal window. Replace
<raspberry pi ip address>
with your rasp pi ip addressmosquitto_pub -h <raspberry_pi_ip_address> -t test/message -m 'Hello World!'
You should be able to see a response from the subscribe terminal window! This was my output
test/message Hello World!
If you're running into trouble with the test above. you may be experiencing some firewall issues. You can refer to this stack overflow post: Stack Overflow - mosquito server refuses connections .
-
Random Nerd Tutorials | esp32 InfluxDB - quick guide for how to use influxdb cloud
-
PubSub Client API Documentation - Documentation on the PubSub Client used in the PlatformIO Environment
-
IoT-For-Beginners/app.py at main · microsoft/IoT-For-Beginners · GitHub - A free Microsoft Course on IoT Basic Concepts. The lessons here also used the Wio Terminal and has helped me a lot with setting up the code.
-
HIVE MQTT Arduino PubsubClient - Resource in setting up a MQTT Client with Arduino
-
HIVE MQTT Python Client - Resource in setting up a MQTT Client with Python
-
IoT4 Beginners - Install MQTT Broker on Raspberry Pi - Helped me get started on installing and setting up my Raspberry Pi
-
HacksterIO - Running a MQTT Broker on Raspberry Pi - Also helped me get started on installing and setting up my Raspberry Pi
-
Stack Overflow - mosquito server refuses connections - Helped me figure out how to disable a firewall for port 1883 (the default mqtt broker port)
-
Stack Overflow - mosquitto client refused connection - this guide helped me figure what to add to my
mosquitto.conf
file when I kept getting aclient refused connection
error