Giter Site home page Giter Site logo

is-my-soil-moist's Introduction

Soil Moisture Sensor

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

Table of Contents

Features

  • Capture Soil Moisture % using a moisture sensor

  • Collects and Soil Moisture telemetry to Influx Data

  • Display Moisture % on Wio Terminal Display

Materials Needed

Tools

  • Laptop or Computer

Pre-requisites

  1. Visual Studio Code

  2. Platformio IDE Extension on Visual Studio Code

Steps

1 - Create a InfluxData Account

Based off of instructions from Random Nerd Tutorials

  1. Create a influx data cloud account: InfluxDB Cloud

    InfluxDB Account

  2. Select where to save your data

    InfluxDB select provider

  3. Select the free plan

    InfluxDB select plan

  4. 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 ?��

  5. 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

    • INFLUX_TOKEN

    • INFLUX_ORG

    • INFLUX_URL

    • INFLUX_BUCKET

2 - Setup Config file for WIO Terminal

  1. Copy template.h file as config.h in the same parent folder

    cd <path_to_repo>/is-my-soil-moist/soil_moisture_terminal/src/
    cp template.h config.h

  2. Replace the following values in your config.h file with the appropriate ones

    • <YOUR_WIFI_ID>

    • <YOUR_WIFI_PASSWORD>

    • <YOUR_GUID>

2 - Upload code to WIO Terminal

  1. Connect your Wio Terminal to your Computer with a USB-C Cable

  2. Turn on your Wio Terminal

  3. Hit the upload button on Platform IO

3 - Run Python MQTT Forwarder Code

  1. Clone the repo

    git clone 
  2. Install the following libraries

    pip3 install
  3. Run the following code

    python3

Refer the the appendix section for a great time

Appendix

Install a MQTT Broker on the Raspberry Pi

If you want to use your own MQTT Broker hosted on the Raspberry Pi instead of the public mosquitto

. broker.

  1. First install

    sudo apt get update
    sudo apt install mosquitto mosquitto-clients
    sudo reboot
  2. Test your installation

    sudo systemctl enable mosquitto
  3. Edit the mosquitto.conf file

    sudo nano /etc/mosquitto/mosquitto.conf

    Replace

    include_dir /etc/mosquitto/conf.d
    

    with

    allow_anonymous true
    listener 1883
    
  4. Restart mosquitto service.

    sudo systemctl restart mosquitto

    The configuration should be applied and the broker will listen on port 1883.

  5. 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 address

    mosquitto_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 .

References

is-my-soil-moist's People

Contributors

okyang avatar

Stargazers

 avatar

Watchers

 avatar

is-my-soil-moist's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.