Use Adafruit Feather RP2040 to create BLE air quality sensor
2024-06-26 | By Sheikh Shuhad
License: General Public License Bluetooth / BLE Adafruit Feather RP2040
Basically, we are going to create an autonomous BLE beacon that advertise the current temperature, humidity etc.
For this example, we are using a Gas sensor BME680 and a OPT3002 Light-to-Digital Sensor.
Requirements
- Adafruit Feather RP2040 Board
- BleuIO – Bluetooth Low Energy USB Dongle
- Arduino IDE
- A Gas sensor BME680
- A OPT3002 Light-to-Digital Sensor
- Our example project [Download from GitHub]
Arduino Libraries
The libraries can easily be installed through the Arduino IDE:
- Open Library Manager by clicking the Library Manager icon to the left or go through menu: Sketch>Include Libraries>Manage Libraries…
- Search for Adafruit_BME680, and install the Adafruit_BME680 Library
- Search for ClosedCube OPT3002, and install the ClosedCube OPT3002 library.
Connecting I2C sensors
- Connect four wires (at a minimum) for each I2C device.
- Power the device with 3.3V, then a ground wire.
- And a SCL clock wire, and an SDA data wire.
Running the example
- Make sure the BleuIO Dongle is connected to the Feather RP2040 Board.
- Connect the Feather RP2040 Board to your computer using the USB cable.
- Make sure the Feather RP2040 Board is selected as well as the correct COM port in the dropdown menu.
- (Optional) Change the frequency the sensors are read, and advertising data updated, in the code
// How often we read the sensors and update the advertisings message
(in seconds)
#define READ_UPDATE_FREQUENCY 5
- Done! The dongle should now be advertising the sensor values. (If you just plugged in the Feather, it may take about 10 seconds before advertising starts as the BleuIO bootloader opens and closes)
- (Optional) Open Serial Monitor. You can open the Serial Monitor from the menu: Tools>Serial Monitor
You should now see the output from the project.
Scanning the results
To see the results, you can use any BLE scanner app.
Here we use nRF Connect:
The data in the red box is our sensor values:
0x006203EB001700170041
When we parse the hex into decimal values we get:
Light: 0x0062 = 98 uW/cm2Pressure: 0x03EB = 1003 hPaTemperature: 0x0017 = 23 CelciusHumidity: 0x0017 = 23 %RhGas Resistance: 0x0041 = 65 KOhms
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum