This is a Reference Design for a Soil Moisture Monitor that monitors environmental factors like light intensity, temperature, humidity, and pressure and uses a relay to actuate grow lights and ventilation.
Do not clone this repo using git. Zephyr's west
meta tool should be used to set up your local workspace.
cd ~
mkdir golioth-reference-design-soil-moisture
python -m venv golioth-reference-design-soil-moisture/.venv
source golioth-reference-design-soil-moisture/.venv/bin/activate
pip install wheel west
cd ~/golioth-reference-design-soil-moisture
west init -m git@github.com:golioth/reference-design-soil-moisture.git .
west update
west zephyr-export
pip install -r deps/zephyr/scripts/requirements.txt
Build Zephyr sample application for Sparkfun Thing Plus nRF9160 from the top level of your project. After a successful build you will see a new build directory. Note that any changes (and git commmits) to the project itself will be inside the app folder. The build and deps directories being one level higher prevents the repo from cataloging all of the changes to the dependencies and the build (so no .gitignor is needed)
During building Replace <your.semantic.version> to utilize the DFU functionality on this Reference Design.
$ (.venv) west build -b aludel_mini_v1_sparkfun9160_ns app -- -DCONFIG_MCUBOOT_IMAGE_VERSION=\"<your.semantic.version>\"
$ (.venv) west flash
Configure PSK-ID and PSK using the device shell based on your Golioth credentials and reboot:
uart:~$ settings set golioth/psk-id <my-psk-id@my-project>
uart:~$ settings set golioth/psk <my-psk>
uart:~$ kernel reboot cold
This app currently implements Over-the-Air (OTA) firmware updates, Settings Service, Logging, RPC, and both LightDB State and LightDB Stream data.
The following settings should be set in the Device Settings menu of the Golioth Console.
LOOP_DELAY_S
Adjusts the delay between sensor readings. Set to an integer value (seconds).
Default value is
60
seconds.MOISTURE_LEVEL_X
Determines threshhold values for the moisture sensor. Set to an integer value corresponding to 'counts'.
MOISTURE_LEVEL_0
:3400
(default value)MOISTURE_LEVEL_20
:3200
(default value)MOISTURE_LEVEL_40
:3000
(default value)MOISTURE_LEVEL_60
:2800
(default value)MOISTURE_LEVEL_80
:2600
(default value)
The following RPCs can be initiated in the Remote Procedure Call menu of the Golioth Console.
get_network_info
Query and return network information.
reboot
Reboot the system.
set_log_level
Set the log level.
The method takes a single parameter which can be one of the following integer values:
0
:LOG_LEVEL_NONE
1
:LOG_LEVEL_ERR
2
:LOG_LEVEL_WRN
3
:LOG_LEVEL_INF
4
:LOG_LEVEL_DBG
Sensor data is periodically sent to the following sensor/*
endpoints of the LightDB Stream service:
sensor/imu/accel_x
: Acceleration X-axis (m/s²)sensor/imu/accel_y
: Acceleration Y-axis (m/s²)sensor/imu/accel_z
: Acceleration Z-axis (m/s²)sensor/ligth/b
: Blue Light Valuesensor/ligth/g
: Green Light Valuesensor/ligth/int
: Clear Light Intensity (LUX)sensor/ligth/r
: Red Light Valuesensor/moisture/level
: Mosture Levelsensor/moisture/raw
: Moisture Reading RAW valuesensor/weather/humidity
:Humidity (%RH)sensor/weather/pressure
: Pressure (kPa)sensor/weather/temp
: Temperature (°C)
Battery voltage and level readings are periodically sent to the following battery/*
endpoints:
battery/batt_v
: Battery Voltage (V)battery/batt_lvl
: Battery Level (%)
The concept of Digital Twin is demonstrated with the LightDB State example_int0
and example_int1
variables that are members of the desired
and state
endpoints.
desired
values may be changed from the cloud side. The device will recognize these, validate them for [0..65535] bounding, and then reset these endpoints to-1
state
values will be updated by the device whenever a valid value is received from thedesired
endpoints. The cloud may read thestate
endpoints to determine device status, but only the device should ever write to thestate
endpoints.
This reference design may be built for the Nordic nRF9160 DK, with the MikroE Arduino UNO click shield to interface the two click boards.
- Position the MikroE Weather Click board in Slot 1
- Position the MikroE Shuttle Click board in Slot 2
Connect the MikroE Hydro Probe Click, the MikroE IR Gesture Click and the LIS2DH Adapter Board to the MikroE Shuttle Click.
Use the following commands to build and program. (Use the same console commands from above to provision this board after programming the firmware.)
$ (.venv) west build -p -b nrf9160dk_nrf9160_ns app -- -DCONFIG_MCUBOOT_IMAGE_VERSION=\"<your.semantic.version>\"
$ (.venv) west flash
The following code libraries are installed by default. If you are not using the custom hardware to which they apply, you can safely remove these repositories from west.yml
and remove the includes/function calls from the C code.
- golioth-zephyr-boards includes the board definitions for the Golioth Aludel-Mini
- libostentus is a helper library for controlling the Ostentus ePaper faceplate
This reference design was forked from the Reference Design Template repo. We recommend the following workflow to pull in future changes:
- Setup
- Create a
template
remote based on the Reference Design Template repository
- Create a
- Merge in template changes
- Fetch template changes and tags
- Merge template release tag into your
main
(or other branch) - Resolve merge conflicts (if any) and commit to your repository
# Setup
git remote add template https://github.com/golioth/reference-design-template.git
git fetch template --tags
# Merge in template changes
git fetch template --tags
git checkout your_local_branch
git merge template_v1.0.0
# Resolve merge conflicts if necessary
git add resolved_files
git commit