This document will guide you through the Wireless Soil Sensor project. You will be able to see, save and analyze moisture level and temperature in Node-RED and Grafana visualization tool.

Video tutorial

Block Concept

Requirements

Measured data will be saved and visualized in Grafana on Raspberry Pi. It is also possible to use your computer. Just follow Playground Setup document.

Connecting to Raspberry Pi

All the configuration, services and flashing firmware will be done on the Raspberry Pi. You use your computer only to connect to the Raspberry Pi SSH server and Grafana web page.

Please follow the Raspberry Pi Login document where you find how to discover Raspberry Pi IP address on your network and connect to the SSH server.

Firmware Upload

In this procedure we will use the BigClown Firmware Tool to upload firmware to the Core Module. You will connect and flash firmware with Raspberry Pi

Now it's time to write firmware to the Core Module.

  1. Connect the Micro USB cable to the Core Module and Raspberry Pi.

  2. Upload the firmware to the Core Module:

    Write this command to the Raspberry Pi SSH command line.

    bcf flash --device /dev/ttyUSB0 bigclownlabs/bcf-wireless-soil-sensor:latest
    
  3. Remove the Micro USB cable from the Core Module and Raspberry Pi.

Hardware Assembling

  1. Start with the Battery Module.

  2. Plug the Core Module on top of the Battery Module.

  3. Plug the Sensor Module on top of the Core Module.

  4. Plug the Soil Sensor connector to the Sensor Module.

Radio Pairing

In this section, we will create a radio link between the USB Dongle and the Wireless Climate Monitor.

Follow these steps in Node-RED:

  1. Click on the Start node pairing button.

  2. Insert the batteries into the Wireless Climate Monitor to send the pairing request (you should also see the red LED on the Core Module to be on for about 2 seconds).

    In the Node-RED debug tab, there is a message about name and firmware version of the new paired module.

  3. Click on the Stop node pairing button.

Communication Test

Follow these steps in Node-RED:

  1. Switch to debug tab on the right.

  2. Start breathing on the temperature sensor on the Soil Sensor to invoke a change of temperature and hence trigger a radio transmission.

    You should then see similar messages:

Enclosure

Optionally put the assembly into the appropriate enclosure, if you have one.

Integration Grafana

Now we have assembled our kit and let's start with some basic integration with Grafana.

  1. Install Grafana and InfluxDB database to your Raspberry Pi. This is explained in Grafana for Visualization document.

  2. Add these lines to the /etc/bigclown/mqtt2influxdb.yml configuration file which you had created in the Grafana for Visualization tutorial. This adds support for new topics that Soil Sensor sends.

    Open mqtt2influxdb configuration in nano text editor.

    sudo nano /etc/bigclown/mqtt2influxdb.yml
    

    And append these lines at the end of the existing file:

- measurement: moisture
    topic: node/+/soil-sensor/+/moisture
    fields:
        value: $.payload
    tags:
        id: $.topic[1]
        channel: $.topic[3]

- measurement: temperature
    topic: node/+/soil-sensor/+/temperature
    fields:
        value: $.payload
    tags:
        id: $.topic[1]
        channel: $.topic[3]
  1. Test that the configuration is valid. Otherwise there is some formating error in the YAML file.

    mqtt2influxdb -c /etc/bigclown/mqtt2influxdb.yml --test
    
  2. Restart MQTT2InfluxDB service, because we've changed the configuration

    pm2 restart mqtt2influxdb
    
  3. Open Grafana page which is running on Raspberry Pi on port 3000.

    http://hub.local:3000

  4. Now you can see temperature and battery voltage on the bottom. We need to add a moisture graph. Because we added - measurement: moisture to the config file, we need to duplicate existing graph and change its measurement data source to moisture.

    Now click on Edit in the duplicated graph.

    Now in Metrics tab change the FROM item from value temperature to moisture.

  5. Now click on the Save button in the Grafana so all your configuration stays the same next time you open the page.

Chapters in this document:
Edit this page