The SenseCAP Indicator is a compact, versatile device designed for environmental monitoring and data display. It's part of the SenseCAP product line, developed by Seeed Studio, which includes various sensors and devices aimed at IoT applications.
Features include:
- Dual MCUs: ESP32S3 and RP2040
- 4-inch touch screen
- two Grove interfaces, which supports ADC and I2C transmission protocols
- Real-time air quality monitoring using built-in tVOC and CO2 sensors, and an external Grove AHT20 TH sensor for more precise temperature and humidity readings.
- Bluetooth low energy (BLE)
- LoRa
- WiFi
- Buzzer
The ESP32S3 is used to control the touch screen and is also interfaced with the LoRa module. It has built-in WiFi and BLE. The RP2040 is connected to the built-in environmental sensors, Grove interface, microSD module and buzzer.
This tutorial is the first part of a guide to programming the SenseCAP Indicator using XOD. In this first tutorial we will focus on the RP2040.
SetupIf you haven't used XOD before, I recommend taking a look at the following resources:
Add RP2040 to XOD IDE
You won't find the RP2040 on the list of board models in the XOD IDE, but it can easily be added. In your user directory you will find a directory named xod
, which contains a subdirectory called __packages__
. Here you will find a file named extra.txt
.
Add the following line to the extra.txt
file:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
This line is the URL of a JSON file which provides a description of all available RP2040 boards and provides a URL for downloading the appropriate toolchain. Every variant of RP2040 board should now appear in the XOD IDE; if not, click the Update button. Select Seeed INDICATOR RP2040
from the list of board models:
We will now install the toolchain for the RP2040. If you don't have a blank patch open, create a new one by selecting File→New Patch...
Next, click the Upload button. We aren't actually going to upload anything to the board, but we will prompt the IDE to check if it has the necessary toolchain installed. We will receive the following warning message:
Click Download & Install.
On successful installation of the toolchain the XOD IDE will display the following message:
Edit pin definition file
Each board model has a pin definition file. The pin definition file for the Seeed Indicator RP2040 can be found here:
xod/__packages__/packages/rp2040/hardware/rp2040/3.9.3/variants/seeed_indicator_rp2040/pins_arduino.h
We need to add the following line to the pin definition file for the Seeed Indicator RP2040:
#define SERIAL_PORT_HARDWARE Serial
This statement enables XOD to use the universal asynchronous receiver / transmitter (UART) interface.
Install RP2040 library
We are now ready to install the rp2040 library. In XOD IDE, hit File → Add Library and enter the full library name:
wayland/rp2040
See Using libraries for more information.
Following installation in the IDE workspace, the library will be visible in the project browser. To find out the function of a node, select the node and hit H to invoke help:
The library contains five example patches that demonstrate the use of the RP2040 and its associated hardware.
How to upload a patch to the RP2040Put RP2040 into bootloader mode
Connect USB cable to PC, but not to the Sense CAP Indicator.
Use a pin to depress the internal button:
Next, connect the USB cable to the Sense CAP Indicator while continuing to depress the internal button. Once the device is connected to the USB cable the internal button can be released. At this point your PC should detect the RP2040 as a storage device:
Upload a XODpatch
Go to the XOD IDE and choose a patch for upload. Hit Deploy → Upload to Arduino...
Make sure that the Seeed INDICATOR RP2040 is selected as the board model. It doesn't matter which serial port is selected, since it will not be used. Click the Upload button.
If you are prompted to install missing dependencies, click Download & Install.
After installing missing dependencies you will need to click the Upload button again. A firmware file (NEW.UF2) will be generated and flashed to the RP2040. The RP2040 will exit bootloader mode and will no longer appear as a storage device on your PC.
A note on debuggingAs far as I'm aware, it is not currently possible to use XOD's debugging features (watch nodes, tweak nodes, etc) with the RP2040. However, if your patch sends output over UART, this can be read using a serial monitor, such as the one available in the Arduino IDE (see next section).
UART is used for communication between the RP2040 and the ESP32S3, so gaining experience with the protocol here will provide a foundation for future work.
Built-in environmental sensorsSense CAP Indicator models D1S and D1Pro have two built-in environmental sensors:
- Sensirion SGP40 - air quality sensor (datasheet)
- Sensirion SCD41 - CO2, relative humidity and temperature sensor (datasheet)
These sensors are on the RP2040's first I²C bus. The first example patch in the rp2040 library (01-example-internal-sensors) demonstrates reading these sensors and sending the measurement data to UART. The patch can be divided into three sections:
- Initialize sensors.
- Read measurement data from sensors (data from the SCD41 are used by the SGP40 for relative humidity and temperature compensation).
- Send data over UART.
N.B. The sensors must be powered on using the power-internal-sensors node before they can be initialized and used.
Measurement data can be viewed in the Arduino IDE serial monitor. Take care to select the correct serial device and BAUD rate (115200). On my ubuntu laptop, the RP2040 serial port appears as:
/dev/ttyACM0 (Seeed INDICATOR RP2040)
N.B. Sense CAP Indicator models D1 and D1L do not have built-in environmental sensors.
Grove I²C interfaceThe first I²C interface on the RP2040 has a grove interface on the rear of the Sense CAP Indicator case:
I²C hubs are available (e.g. https://wiki.seeedstudio.com/Grove-I2C-Hub-6Port/) if you would like to connect more than one I²C device.
The D1S and D1Pro models of the Sense CAP Indicator are supplied with an AHT20 temperature and relative humidity sensor (datasheet) on a grove breakout board. The 2nd example patch (02-example-grove-i2c) demonstrates the use of this sensor:
The microSD card should be formatted as FAT16. Tools for formatting the microSD card can be found here:
Once formatted, the microSD card can be inserted into the microSD slot.
The XOD IDE has a built-in node for writing data to micro SD cards: sd-log. The current implementation of sd-log will only control SD modules on the first serial peripheral interface bus (SPI0), however, the SD module in the Sense CAP Indicator is on the 2nd SPI bus (SPI1). For this reason, the rp2040 library provides a node specifically for the SD module in the Sense CAP Indicator: sd-log-sense-cap-indicator.
The example data logging patch (03-example-log-sd) looks like this:
It is essentially the patch from example 1, with the following three nodes added: count, concat and sd-log-sense-cap-indicator.
Data from each of the sensors are written to file as a comma-separated string. The log file (log.csv) can be opened in a text editor or spreadsheet application:
The rp2040 library contains a node (buzzer-play-tone) for controlling the tone of the buzzer. In the fourth example patch (04-example-play-melody) this node is used to play a melody:
The final example patch (05-example-co2-alarm) combines the SCD41 and buzzer to sound an alarm when the concentration of CO2 in the air exceeds a user-defined threshold:
In the next tutorial (in preparation) we will see how to send data from the RP2040 to the ESP32S3 for display on the touchscreen.
Comments
Please log in or sign up to comment.