Skip to content

Latest commit

 

History

History
240 lines (203 loc) · 7.02 KB

README.md

File metadata and controls

240 lines (203 loc) · 7.02 KB

ModHabitarNotes:

Queda pendiente agregar librería loudness y sunlight sensor, para habilitar todas las clases sensores (quedan estás dos sin habilitar)

Build Your Own LoRaWAN Sensor With SenseCAP S2110 XIAO LoRaWAN SensorBuilder

This is the source code for SenseCAP S2110 XIAO LoRaWAN SensorBuilder and it provides an open-source tool to build your own LoRaWAN sensors.

Hardware Set Up

  • Step 1: Unscrew the four screws on the SensorBuilder lid to open the lid and unscrew the PG connector (with a coin)
  • Step 2: If you have already made the connection between the XIAO SensorBuilder and the Data Logger with the 4 wires, it is recommended to remove the red wire which connects to the 5V pin of the XIAO SensorBuilder
  • Step 3: Connect one end of a USB Type-C cable to the XIAO SensorBuilder and the other to the PC

Now you can open Arduino IDE on the PC and start tinkering!

Software Set Up

refer to Seeed Studio XIAO RP2040 with Arduino | Seeed Studio Wiki

  • Step 3: Add pin defines.

Add the following lines at the end of the C:\Users\${UserName}\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.1.0\variants\seeed_xiao_rp2040\pins_arduino.h file.

// RS485
#define RS485_SERIAL_PORT Serial1
#define RS485_DEFAULT_DE_PIN D8
#define RS485_DEFAULT_RE_PIN D8
#define RS485_DEFAULT_TX_PIN 1

How to Add a New Sensor

  • Step 1: Add a sensorNew.hpp file to the src\sensor folder for the new sensor.

  • Step 2: Define the sensor class and implement the init() and sample() functions.

The sensor class should inherits from the sensorClass class, and implement the init() and sample() functions. The init() function is used to initialize the sensor, and than returns a register offset value for Modbus communication. The sample() function is used to read the sensor data, returns true when the data is valid, and returns false when the data is invalid.

  • Step 3: Include the sensorNEW.hpp file and call it.

Add line #include "sensorNew.hpp" to the src\sensor\sensorBuilder.hpp file. In the setup() function of the sensorBuilder.ino file, create the new sensor class object and call the SensorBuilder.addSensor() function with it as an argument.

Refer to the following code :

void setup()
{
  Serial.begin(9600);
  SensorBuilder.check_grove();
 
  /* sensor list */
  sensorUltrasonic *ultrasonic = new sensorUltrasonic();
  SensorBuilder.addSensor(ultrasonic);
  
  // add new sensor to sensor list
  sensorNew *newSensor = new sensorNew();
  SensorBuilder.addSensor(newSensor);

  SensorBuilder.begin();
}

NOTE: the Modbus register address for the new sensor will start from 0x0034, the register bit width for each measurement value is 32, so the register address offset between two adjacent measurement values is 2.

Modbus Register Table

Grove Sensor Name Register Name Register Address
(Hexadecimal)
Register Address
(Decimal)
Grove - CO2 & Temperature & Humidity Sensor (SCD41) Temperature 0x0004 04
Humidity 0x0006 06
CO2 0x0008 08
Grove - Light Sensor v1.2 Light 0x000A 10
Grove - Flame Sensor Flame 0x000C 12
Grove - Oxygen Sensor (MIX8410) Oxygen 0x000E 14
Grove - Sunlight sensor (SI1151) Light Intensity 0x0010 16
Visible Light 0x0012 18
UV 0x0014 20
Grove Temperature and Barometer Sensor (BMP280) Barometric Temperature 0x0016 22
Atmospheric Pressure 0x0018 24
Height 0x001A 26
Grove - Temperature Humidity Pressure Gas Sensor(BME680) Temperature 0x001C 28
Atmospheric Pressure 0x001E 30
Humidity 0x0020 32
Air Quality(VOC) 0x0022 34
Grove - Gas Sensor V2(Multichannel) N02 0x0024 36
C2H50H 0x0026 38
VOC 0x0028 40
CO 0x002A 42
Grove - UV Sensor UV Intensity 0x002C 44
Grove - Turbidity Sensor Meter V1.0 Turbidity 0x002E 46
Grove - TDS Sensor TDS 0x0030 48
Grove - Ultrasonic Ranger Distance 0x0032 50
> Modbus register addresses 0x0000 to 0x0003 are reserved for storing module system information, where 0x0000 is the modbus address with a default value of 1 and a maximum value of 247, 0x0001 is the serial port baud rate with a default value of 96 (corresponding to 9600), and 0x0002 to 0x0003 are for software version.