Skip to content

Installation

Phuc Doan edited this page Feb 24, 2025 · 4 revisions

Guide to install all components of the project

Prerequisites

PlatformIO-based components (Sensor, Hub)

Installation

  • Install PlatformIO extension for VSCode: Install
  • Clone the project into to a local repo: Tutorial
  • Make sure you have the PlatformIO extension in the sidebar. Click on it.

image

  • Choose Projects & Configuration -> Add existing

image

  • Locate and choose the directory you have just cloned.
  • Close the PIO Home GUI tab and reopen it. You should now see your newly created project. Click on Open and libraries should be automatically installed.
  • Compiling and Uploading firmware can be done through PlatformIO's sidebar extension, VSC's button in the top-right corner, hotkeys or CLI.
  • Optionally, install the official Serial monitor to help with debugging: Install

Configuration

In your local repo, open config/common.ini. Here contains commonly adjusted variables.

Sensor Node

  • Node ID's naming scheme: S-X, with X being an int starting from 0.
  • Change pin according to your board setup.
  • timer is in seconds.
  • air_value and water_value are to be adjusted after calibration.

ESP-NOW to UART Hub

  • Hub ID's naming scheme: H-X, with X being an int starting from 0.
  • rx_hub_io and 'tx_hub_io' are to communicate with the other part of the gateway. They must not be GPIO pins associated with the USB port / UART0.

UART to MQTT Hub

  • Hub ID here must match that of the other hub component.
  • You may only change topic's name here, not adding/deleting. It must be consistent with the one subscribed by the Python's client.
  • rx_hub and tx_hub are similar to the mentioned rx_hub_io and tx_hub_io respectively.
  • Also create a credentials.ini with content copied from credentials.ini.dist. Modify the variables within accordingly. Should you enter mqtt_username and mqtt_password, you will have to configure them while installing mosquitto broker.

Python client

  • Clone the project
  • Optionally, create and activate a virtual environment: Guide
  • Run the following command to install dependencies:
pip install -r requirements.txt
  • Run the client (only after other components have been installed and initialized)
python3 main.py

Configuration

  • In your local repo, open config.yaml. It is similar to common.ini. Only name changes allowed here.
  • Client ID's naming scheme: C-X, with X being an int starting from 0.
  • To store important credentials, create a .env file with the following structure:
HOST_IP=<your-mqtt-broker-ip-address>
MQTT_USERNAME=<mqtt-broker-approved-usrname>
MQTT_PASSWORD=<mqtt-broker-approved-password>

MQTT Broker (This will only cover Windows so far)

Installation

  • Install mosquitto MQTT broker: Install

Configuration

  • Navigate to mosquitto installation directory. It is by default on Windows at: C:\Program Files\mosquitto.
  • Create your MQTT Credentials with mosquitto_passwd utility. This should be what you configured for all clients (Hub and Python client): Docs and Guide.
  • Still in the installation directory, open mosquitto.conf as Admin. Paste this in, and adjust the password file and save it:
listener 1883 # Insecure channel without TLS/SSL
protocol mqtt
# Password setup. Use mosquitto_passwd.exe 
allow_anonymous false
password_file C:/Program Files/mosquitto/passwd # Change the password file name according to what you just created
  • To run the broker, open the terminal as Admin and run:
mosquitto -v -c "C:\Program Files\mosquitto\mosquitto.conf"

WiFi configuration

  • Your WiFi connection must be at 2.4 GHz, not the common 5 GHz.
  • Broadcast channel should be Auto.
  • Use Mobile Hotspot to expedite these setting changes.

Clone this wiki locally