In the cacophony of the modern world, exploring the secrets of noise seems like an endless journey. However, with the aid of innovative technology, we now have the opportunity to glimpse into the enigmatic world of sounds in the universe.
This article will take you on a deep dive into creating your very own noise detector using Arduino IDE, an LM358-based sound sensor, the Seeed Studio XIAO RP2040 processor embedded in the SenseCAP S2110 Sensor Builder, and the SenseCAP S2100 Data Logger that can upload data to the LoRaWAN network. Embark on an exciting adventure to detect and unravel the mysteries of sounds in both urban and natural environments.
- Sound Sensor -- It detects the sound intensity of the environment and outputs an analog signal which is easily sampled and tested by a Seeeduino.
- SenseCAP S2110 Sensor Builder -- It has Seeed Studio XIAO RP2040 as the dual-core ARM Cortex M0+ processor, and has one Grove and one RS485 connector. It also enables developers to build a custom industrial-grade LoRaWAN sensor connecting to SenseCAP Cloud with SenseCAP Data Logger.
- SenseCAP S2100 Data Logger -- It supports MODBUS-RTU RS485/Analog/GPIO input and transmit the data from sensors to the LoRaWAN network.
Step 1: Unscrew the four screws on the SensorBuilder lid to open the lid and unscrew the cable gland (with a coin).
Step 2: Choose a Sound Sensor Grove and Install it on SensorBuilder.
Connect Using Universal 4 Pin Unbuckled Cable.
Step 3: Download and Install Arduino IDE, Download RP2040 Board Support Package.
- Reference document link:https://wiki.seeedstudio.com/XIAO-RP2040-with-Arduino/
Note:If installing the Developer repository in the latest version of the Arduino IDE fails, download Arduino 1.8.18.
Navigate to File > Preferences, and fill Additional Boards Manager URLs with the url below:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.jsonStep 4: Software Set Up
- Install the S2110 Converter Source Code:
https://github.com/Seeed-Studio/Seeed_Arduino_S2110
- Install the necessary sensor support library :
Grove_BMP280
Grove_Sunlight_Sensor
Seeed_Arduino_MultiGas
Seeed_Arduino_BME68x
Seeed_Arduino_UltrasonicRanger
Seeed_Arduino_MultiGas
arduino-i2c-scd4x
ArduinoRS485
ArduinoModbus
- Add pin defines:
Add the following lines at the end of the /Users/[your own floder]/Library/Arduino15/packages/rp2040/hardware/rp2040/3.3.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 1How to Add a New SensorStep 1: Add a New Sketch, click the top-right corner "..." to add a New tab, name and save it as sensorSound.hpp file.
Step 2: Define the sensor class and implement the init() and sample() functions.
Note:sensorSound.hpp file is provided below.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: Add a sensorSound.hpp file to the src\sensor folder for the Sound sensor.
Step 4: Include the sensorSound.hpp file and call it.
Add line #include "sensorSound.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 */
...
...
// add Sound sensor to sensor list
Serial.println("SensorBuilder add Sound");
sensorSound *sound = new sensorSound();
SensorBuilder.addSensor(sound);
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.Step 5: Select the corresponding development board Seeed XIAO RP2040 and COM port, compile the code using Type-C, and then upload it.
Step 6: View and monitor data.
We can find that the register address for the Sound Sensor is 52.
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.Upload data to LoRaWAN
Step 1: Connect SenseCAP S2100 Data Logger.
- Reference document link:https://wiki.seeedstudio.com/Build-LoRaWAN-Sensors-SenseCAP-XIAO-Controller-Data-Logger/
Connect using the tool.
Step 2: Obtain AppKey, DevEui, and AppEui through the SenseCAP Mate app.
- Reference document link: https://files.seeedstudio.com/products/SenseCAP/S2100/SenseCAP
Step 1: Click on Get started - The Things Network and enter the TTN login page. From there, you can create or sign in to your TTN account.
Step 2: Create application
1. Fill in the relevant information
2. Click on "Create application"
Note:The "Application name" and "Description" fields are optional. If the application name is not provided, the Application ID will be used as the default name.
Step 3: After creating the application, go to the application page and click on "+Register end device" to create a new device.
Step 4: configure the device
Go to the device registration page and select "Enter the device manually".
Fill in the corresponding information:
For the Frequency Plan, select EU868/US915 FSB_2
For the LoRaWAN version, select LoRa Specification 1.0.2
For the Regional Parameters version, select Regional Parameters 1.0.2 revision B
Note: The frequency plan needs to be consistent with the gateway frequency plan
Step 5: On the TTN platform device registration page, enter the corresponding "Join EUI" (i.e. AppEUI) and "DevEUI". Click "Generate" in the AppKey field to generate Appkey for writing to the device. Copy the Key.
Step 6: The device has been successfully added to the TTN network!
Decoder: https://github.com/Seeed-Solution/TTN-Payload-Decoder/blob/master/SenseCAP_LoRaWAN_V2_Decoder.j


Comments