RUI3 example code for WisBlock I2C sensor modules, focused on Environment and Light sensors and a 2.13" E-ink display.
This example code is NOT using the loop at all. Instead it is complete event driven. The WisDuo/WisBlock module is sleeping unless an event occurs. An event can be a timer callback or an external interrupt, or if using LoRaWAN Class C, it can be a packet received from the LoRaWAN server.
This code does setup a timer that wakes up the device in the desired send interval, send a packet and then the system goes back to sleep automatically.
It can be extended to use external interrupts, see my other examples codes.
The code compiles on all RUI3 modules. But when used with a RAK3172, due to the limited memory available, only one LoRaWAN region can be enabled.
This examples includes three custom AT commands:
ATC+SENDINT
to set the send interval time or heart beat time. If the device is not in motion it will send a payload with this interval. The time is set in seconds, e.g.AT+SENDINT=600
sets the send interval to 600 seconds or 10 minutes.ATC+STATUS
to get some status information from the device.
Once the device has connected to a LoRaWAN server, it will update the display with the latest measurements and send a data packet to the server.
Module | Function | Supported |
---|---|---|
RAK4631-R |
WisBlock Core module with RUI3 | ✔ |
RAK3372 |
WisDuo RAK3172 Evaluation Board with RUI3 | ✔ |
RAK19007 |
WisBlock Base board | ✔ |
RAK19001 |
WisBlock Fullsize Base board | ✔ |
RAK1906 |
WisBlock Environment Sensor | ✔ |
RAK1903 |
WisBlock Light sensor OPT3000 | ✔ |
RAK12010 |
WisBlock Light sensor VEML7700 | ✔ |
- ArduinoIDE
⤴️ - RAK-STM32-RUI
⤴️ - RAK-nRF52-RUI
⤴️ - RAK-Apollo3-RUI
⤴️
- CayenneLPP
⤴️ - ArduinoJson
⤴️
- RAK1906 Environment (manual installation)
⤴️ - RAK1903 Light (manual installation)
⤴️ - RAK12010 Light
⤴️ - RAK14000 EPD
⤴️
The packet data is made compatible with the extended Cayenne LPP encoding from ElectronicCats/CayenneLPP
The content of the packet depends on the modules installed on the WisBlock Base Board:
Data | Channel # | Channel ID | Length | Comment | Required Module | Decoded Field Name |
---|---|---|---|---|---|---|
Battery value | 1 | 116 | 2 bytes | 0.01 V Unsigned MSB | RAK4631 | voltage_1 |
Humidity | 2 | 104 | 1 bytes | in %RH | RAK1901 | humidity_2 |
Temperature | 3 | 103 | 2 bytes | in °C | RAK1901 | temperature_3 |
Barometric Pressure | 4 | 115 | 2 bytes | in hPa (mBar) | RAK1902 | barometer_4 |
Illuminance | 5 | 101 | 2 bytes | 1 lux unsigned | RAK1903 | illuminance_5 |
Humidity 2 | 6 | 104 | 1 bytes | in %RH | RAK1906 | humidity_6 |
Temperature 2 | 7 | 103 | 2 bytes | in °C | RAK1906 | temperature_7 |
Barometric Pressure 2 | 8 | 115 | 2 bytes | in hPa (mBar) | RAK1906 | barometer_8 |
Gas Resistance 2 | 9 | 2 | 2 bytes | 0.01 signed (kOhm) | RAK1906 | analog_9 |
GNSS stand. resolution | 10 | 136 | 9 bytes | 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01 meter | RAK1910, RAK12500 | gps_10 |
GNSS enhanced resolution | 10 | 137 | 11 bytes | 4 byte lon/lat 0.000001 °, 3 bytes alt 0.01 meter | RAK1910, RAK12500 | gps_10 |
Soil Temperature | 11 | 103 | 2 bytes | in °C | RAK12023/RAK12035 | temperature_11 |
Soil Humidity | 12 | 104 | 1 bytes | in %RH | RAK12023/RAK12035 | humidity_12 |
Soil Humidity Raw | 13 | 2 | 2 bytes | 0.01 signed | RAK12023/RAK12035 | analog_in_13 |
Soil Data Valid | 14 | 102 | 1 bytes | bool | RAK12023/RAK12035 | presence_14 |
Illuminance 2 | 15 | 101 | 2 bytes | 1 lux unsigned | RAK12010 | illuminance_15 |
VOC | 16 | 138 | 2 bytes | VOC index | RAK12047 | voc_16 |
MQ2 Gas | 17 | 2 | 2 bytes | 0.01 signed | RAK12004 | analog_in_17 |
MQ2 Gas Percentage | 18 | 120 | 1 bytes | 1-100% unsigned | RAK12004 | percentage_18 |
MG812 Gas | 19 | 2 | 2 bytes | 0.01 signed | RAK12008 | analog_in_19 |
MG812 Gas Percentage | 20 | 120 | 1 bytes | 1-100% unsigned | RAK12008 | percentage_20 |
MQ3 Alcohol Gas | 21 | 2 | 2 bytes | 0.01 signed | RAK12009 | analog_in_21 |
MQ3 Alcohol Gas Perc. | 22 | 120 | 1 bytes | 1-100% unsigned | RAK12009 | percentage_22 |
ToF distance | 23 | 2 | 2 bytes | 0.01 signed | RAK12014 | analog_in_23 |
ToF Data Valid | 24 | 102 | 1 bytes | bool | RAK12014 | presence_24 |
Gyro triggered | 25 | 134 | 6 bytes | 2 bytes per axis, 0.01 °/s | RAK12025 | gyrometer_25 |
Gesture detected | 26 | 0 | 1 byte | 1 byte with id of gesture | RAK14008 | digital_in_26 |
LTR390 UVI value | 27 | 2 | 2 byte | 0.01 signed | RAK12019 | analog_in_27 |
LTR390 UVS value | 28 | 101 | 2 bytes | 1 lux unsigned | RAK12019 | illuminance_28 |
INA219 Current | 29 | 2 | 2 byte | 0.01 signed | RAK16000 | analog_29 |
INA219 Voltage | 30 | 2 | 2 byte | 0.01 signed | RAK16000 | analog_30 |
INA219 Power | 31 | 2 | 2 byte | 0.01 signed | RAK16000 | analog_31 |
Touchpad left | 32 | 102 | 1 bytes | bool | RAK14002 | presence_32 |
Touchpad middle | 33 | 102 | 1 bytes | bool | RAK14002 | presence_33 |
Touchpad right | 34 | 102 | 1 bytes | bool | RAK14002 | presence_34 |
SCD30 CO2 concentration | 35 | 125 | 2 bytes | 1 ppm unsigned | RAK12037 | |
SCD30 temperature | 36 | 103 | 2 bytes | in °C | RAK12037 | |
SCD30 humidity | 37 | 104 | 1 bytes | in %RH | RAK12037 | |
MLX90632 sensor temp | 38 | 103 | 2 bytes | in °C | RAK12003 | |
MLX90632 object temp | 39 | 103 | 2 bytes | in °C | RAK12003 |
Channel ID's in cursive are extended format and not supported by standard Cayenne LPP data decoders.
A matching decoder can be found in the RAKwireless_Standardized_Payload Github repo