Maker.io main logo

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

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

BLE air quality beacon with adafruit feature rp2040

  • Search for ClosedCube OPT3002, and install the ClosedCube OPT3002 library.

BLE air quality beacon with adafruit feature rp2040

Connecting I2C sensors

  • Connect four wires (at a minimum) for each I2C device.
  • Power the device with 3.3V, then a ground wire.

BLE air quality beacon with adafruit feature rp2040

  • And a SCL clock wire, and an SDA data wire.

BLE air quality beacon with adafruit feature rp2040

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.

BLE air quality beacon with adafruit feature rp2040

  • (Optional) Change the frequency the sensors are read, and advertising data updated, in the code
Copy Code
// How often we read the sensors and update the advertisings message
(in seconds)
#define READ_UPDATE_FREQUENCY 5

BLE air quality beacon with adafruit feature rp2040

  • 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.

BLE air quality beacon with adafruit feature rp2040

Scanning the results

To see the results, you can use any BLE scanner app.

Here we use nRF Connect:

BLE air quality beacon with adafruit feature rp2040

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
 

制造商零件编号 SSD005/4-V2B
BLUETOOTH 5 LOW ENERGY USB DONGL
Smart Sensor Devices
¥256.49
Details
制造商零件编号 SSD005/4-V2W
BLUETOOTH 5 LOW ENERGY USB DONGL
Smart Sensor Devices
¥256.49
Details
制造商零件编号 BME680
SENSOR GAS/HUM/PRES/TEMP I2C SPI
Bosch Sensortec
¥93.28
Details
制造商零件编号 OPT3002DNPR
SENSOR OPT 505NM AMBIENT 6 UDFN
Texas Instruments
¥16.34
Details
制造商零件编号 5723
ADAFRUIT FEATHER RP2040 WITH USB
Adafruit Industries LLC
¥142.45
Details
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum