In the realm of IoT projects, finding a reliable and efficient host hardware solution is important. The Adafruit Feather RP2040 is an excellent solution for that. It comes equipped with a comprehensive ecosystem, including an IDE and libraries tailored for your new projects. With this setup, you get to keep the main USB port for uploading, debugging, and data communication, while at the same time sending and receiving data to just-about-any USB device, like the BleuIO.
https://learn.adafruit.com/adafruit-feather-rp2040-with-usb-type-a-host
In this first blog with the Adafruit Feather board, we are going to show how you can setup the USB stack and communicate with BleuIO using the Adafruit Feather RP2040 board. Later in next project we will show how to read a Temperature and Humidity sensor and display the data help of the Bluetooth Low Energy (BLE) interface.
Requirements- Adafruit Feather RP2040 Board
- BleuIO – Bluetooth Low Energy USB Dongle
- Arduino IDE
- Adafruit TinyUSB Library
- Pico PIO USB Library
Arduino IDE Download
This section covers getting your Arduino IDE set up to include your board.
- Download and install it to your computer.
- Once installed, open the Arduino IDE. In the Arduino IDE, and navigate to the Preferences window.
- Copy the following URL and Add the URL to the the Additional Boards Manager URLs field
- https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
Add Board Support Package
- In the Arduino IDE, click on Tools > Board > Boards Manager. If you have previously selected a board, the Board menu item may have a board name after it.
- In the Boards Manager, search for RP2040. Scroll down to the Raspberry Pi Pico/RP2040 by Earle F Philhower, III entry. Click Install to install it.
Choose Your Board
- In the Tools > Boards menu, you should now see Raspberry Pi RP2040 Boards (possibly followed by a version number).
- Navigate to the Raspberry Pi RP2040 Boards menu and choose Adafruit Feather RP2040 USB Host.
Now you’re ready to begin using Arduino with your RP2040 board! The main use case for this Feather is to act as a USB host.
Library InstallationInstall Adafruit_TinyUSB Library
To use your Feather as a USB host, you’ll need to install the Adafruit TinyUSB library. It can be installed using the Library Manager in the Arduino IDE.
Click the Manage Libraries > menu item, search for Adafruit TinyUSB, and select the Adafruit TinyUSBLibrary
Install Pico PIO USB Library
Additionally, you’ll need to install the Pico PIO USB library.
Click the Manage Libraries > menu item again, search for PIO USB, and select the Pico PIO USB library.
Board Upload Settings
- In the Tools menu, select Adafruit Feather RP2040 USB Host under Board.
- For CPU Speed, you’ll need to select 120 MHz or240 MHz.
- Finally, under USB Stack, select Adafruit TinyUSB.
Serial Host Bridge Example
- Load the example code onto your Feather after following the library installation instructions on the Arduino Library Install page.
- Navigate to the Adafruit TinyUSB Library Examples and select DualRole – CDC – serial_host_bridge
Now you can control the BleuIO USB Dongle via the Adafruit Feather board.
With these steps completed, you’re now ready to start integrating BleuIO with your Adafruit Feather RP2040 board. This setup lays the foundation for exciting IoT projects, and we’ll explore more functionalities in future tutorials where we will show how to make the BleuIO USB Dongle advertise data from a Temperature and Humidity sensor.
Stay tuned for further guides on applying BleuIO and Adafruit Feather RP2040 for your projects!
Applying BleuIO and Adafruit Feather RP2040Now we are going to show you how to connect real sensors to the Feather, read the values and have it command the BleuIO to advertise them.
Basically you could say that you are going to create a 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- A Gas sensor BME680
- A OPT3002 Light-to-Digital Sensor
- Our example project [Download from GitHub]
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
- 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 and a SDA data wire.
- 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 aswell 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 advertings message
(in seconds)
#define READ_UPDATE_FREQUENCY 5
- Click the Upload button.
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.
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
Comments
Please log in or sign up to comment.