Now that you've installed WipperSnapper on your board - let's learn how to use Adafruit IO to interact with your board!
There's a large number of components (physical parts like buttons, switches, sensors, actuators) supported by the WipperSnapper firmware, this page will get you started with the core concepts to build an IoT project with Adafruit IO.
Blink a LED
One of the first programs you typically write to get used to embedded programming is a sketch that repeatably blinks an LED. IoT projects are wireless so after completing this section, you'll be able to turn on (or off) the LED connected to your QT Py from anywhere in the world.
Wiring
While the QT Py has a built-in NeoPixel, WipperSnapper does not (yet) support NeoPixels (we'll update this guide when it does).
To work around this, you'll build an external LED circuit connected to your QT Py.
You will need to connect the following pins to the LED and resistor:
- QT PY GND to LED cathode (short leg)
- QT PY Pin A2 to one leg of the 220-ohm resistor
- LED anode (long leg) to the second leg of the 220-ohm resistor
Usage
Navigate to the device page, io.adafruit.com/wippersnapper. You should see the QT Py you just connected to Adafruit IO listed on this page.
Verify that your QT Py is online and ready to communicate with Adafruit IO by checking that the device tile says Online in green text.
-
If the QT Py appears offline on the website but was previously connected, press the Reset (RST) button to force the board to reboot.
Once verified that the device is online, click the device tile to navigate to the board page.
Add a new component to your QT Py by clicking the + button or the + New Component button.
The Component Picker lists all the available components, sensors, and parts, which can be used with the WipperSnapper firmware.
Click the LED component.
The QT Py contains GPIO pins that can be configured either as an input or an output. The "Create LED Component" screen tells Adafruit IO to configure a general-purpose output pin connected to the LED on your QT Py as a digital output so you can turn the LED on or off.
Select the A2 pin as the LED Pin and click Create Component
Adafruit IO will send a command to your board (running WipperSnapper) telling it to configure the GPIO pin as a digital output. Your QT Py's board page displays the new LED component.
On the board page, toggle the LED component by clicking the toggle switch. This should toggle the LED connected to your QT Py on or off.
Read a Push-Button
You can also configure a board running WipperSnapper to wirelessly read data from standard input buttons, switches, or digital sensors, and send the state to Adafruit IO.
Let's wire up a push button to a QT Py and configure it with WipperSnapper to publish a value to Adafruit IO when the button has been pressed or depressed.
Make the following connections between the QT-PY and the button:
- QT Py GND to one leg of the Push Button
- QT Py GPIO A2 to the other leg of the Push Button
Usage
On the board page, add a new component to your QT Py by clicking the + button or the + New Component button.
From the component picker, select the Push Button.
The next screen presents you with options for configuring the push button. Start by selecting the QT Py's digital pin you connected to the push button.
The Return Interval dictates how frequently the value of the push-button will be sent from the QT Py to Adafruit IO. For this example, the push-button's value should only be sent when it's pressed.
Select On Change
Finally, check the Specify Pin Pull Direction checkbox and select Pull Up to turn on the QT Py's internal pull-up resistor.
Make sure the form's settings look like the following screenshot. Then, click Create Component.
Adafruit IO should send a command to your board (running WipperSnapper), telling it to configure the GPIO pin you selected to behave as a digital input pin and to enable it to pull up the internal resistor.
Your QT Py's board page should also show the new push-button component.
Press the button to change the value of the push button component on Adafruit IO.
Read an I2C Sensor
Inter-Integrate Circuit, aka I2C, is a two-wire protocol for connecting sensors and "devices" to a microcontroller. A large number of sensors, including the ones sold by Adafruit, use I2C to communicate.
Typically, using I2C with a microcontroller involves programming. WipperSnapper lets you configure a microcontroller to read data from an I2C sensor and publish that data to the internet without writing code.
WipperSnapper supports a number of I2C sensors, viewable in list format here. If you do not see the I2C sensor you're attempting to use with WipperSnapper - we have a guide on adding a component to WipperSnapper here.
The process of adding an I2C component to your WipperSnapper board is similar between most sensors. For this section, we're using the Adafruit AHT20, an inexpensive sensor that can read ambient temperature and humidity.
Wiring
First, wire up an AHT20 sensor to your board exactly as follows. Here is an example of the AHT20 wired to a QT Py using I2C with a STEMMA QT cable (no soldering required).
Make the following connections between the QT-PY ESP32-S3 and the AHT20 Sensor
-
Board 3V to sensor VIN (red wire on STEMMA QT)
-
Board GND to sensor GND (black wire on STEMMA QT)
-
Board SCL to sensor SCL (yellow wire on STEMMA QT)
- Board SDA to sensor SDA (blue wire on STEMMA QT)
Scan I2C Bus
First, ensure that you've correctly wired the AHT20 sensor to your QT Py by performing an I2C scan to detect the I2C device on the bus.
On the upper right-hand corner of the board page, click Start I2C Scan.
- If you do not see this button, double-check that your QT Py shows as Online.
You should see a new pop-up showing a list of the I2C addresses detected by an I2C scan. If wired correctly, the AHT20's default I2C address of 0x38
appear in the I2C scan list.
First, double-check the connection and/or wiring between the sensor and the board.
Then, reset the board and let it re-connect to Adafruit IO WipperSnapper.
Create the Sensor Component
Now that you know the sensor can be detected by the QT Py, it's time to configure and create the sensor on WipperSnapper.
Start by clicking +New Component
The Component Picker lists all the available components, sensors, and parts that can be used with WipperSnapper.
Under the I2C Components header, click AHT20.
On the component configuration page, the AHT20's I2C sensor address should be listed along with the sensor's settings.
The AHT20 sensor can measure ambient temperature and relative humidity. This page has individual options for reading the ambient temperature, in either degree Celsius or degree Fahrenheit, and the relative humidity. You may select the readings which are appropriate to your application and region.
The Send Every option is specific to each sensor measurement. This option will tell the QT Py how often it should read from the AHT20 sensor and send the data to Adafruit IO. Measurements can range from every 30 seconds to every 24 hours.
For this example, set the Send Every interval for both seconds to Every 30 seconds and click Create Component.
The page should now show the AHT20 component you created.
After the interval you configured elapses, WipperSnapper automatically reads values from the sensor and sends them to Adafruit IO.
Going Further
Want to learn more about Adafruit IO WipperSnapper? We have more complex projects on the Adafruit Learning System.
Page last edited December 19, 2024
Text editor powered by tinymce.