# Adafruit IO IOT Hub with the Adafruit FunHouse

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/102/297/medium800/projects_IMG_2035.jpg?1621530832)

This project uses the Adafruit FunHouse with the new [Adafruit CircuitPython Dash Display](https://github.com/adafruit/Adafruit_CircuitPython_Dash_Display) library to create a customizable Adafruit IO dashboard on your FunHouse. This guide, as well as the Dash Display library, is currently only for the FunHouse, but expect support to be added for other boards like the PyPortal and Feather boards with a screen and WiFi connectivity.

There are a few examples of peripheral devices that will work directly with this, but in theory, just about any device should work as long as it publishes to or is controllable via an Adafruit IO feed. The devices I've written examples for are:

- Relay control with [Power Relay Featherwing](https://www.adafruit.com/product/3191)
- Relay control with [4-Outlet Power Relay](https://www.adafruit.com/product/2935)
- NeoPixel control
- NeoPixel remote
- [LiPo battery charger](https://www.adafruit.com/product/4712)
- [Door sensor](https://www.adafruit.com/product/375)
- [Temperature and humidity sensor](https://www.adafruit.com/product/4885) (can be easily modified to work with just about any sensor)

I'll go over 3 of the examples in this guide, but if you want to see the rest, you can find them all [here](https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/FunHouse_IOT_Hub).

I've also tried to use [STEMMA QT](https://learn.adafruit.com/introducing-adafruit-stemma-qt/what-is-stemma-qt) whenever possible so the peripheral devices for this project should be very easy to assemble and should look pretty clean and organized.

This project mostly uses MQTT with the exception of the PyPortals which are currently having some issues with MQTT.

## Parts
### Adafruit FunHouse - WiFi Home Automation Development Board

[Adafruit FunHouse - WiFi Home Automation Development Board](https://www.adafruit.com/product/4985)
Home is where the heart is...it's also where we keep all our electronic bits. So why not wire it up with sensors and actuators to turn our house into an electronic wonderland. Whether it's tracking the environmental temperature and humidity in your laundry room, or notifying you when...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4985)
[Related Guides to the Product](https://learn.adafruit.com/products/4985/guides)
![Top-down video of Adafruit Funhouse PCB. The TFT display shows a data readout, and the NeoPixel LEDs glow rainbow colors.](https://cdn-shop.adafruit.com/product-videos/640x480/4985-00.jpg)

### Mini Magnet Feet for RGB LED Matrices (Pack of 4)

[Mini Magnet Feet for RGB LED Matrices (Pack of 4)](https://www.adafruit.com/product/4631)
Got a glorious&nbsp;RGB Matrix project you want to mount and display in your workspace or home? If you have one of the matrix panels listed below, you'll need a pack of these **Mini-Magnet Feet.** &nbsp;We got these specifically&nbsp;for our RGB LED Matrices, which no longer...

In Stock
[Buy Now](https://www.adafruit.com/product/4631)
[Related Guides to the Product](https://learn.adafruit.com/products/4631/guides)
![Angled shot of four magnet feet.](https://cdn-shop.adafruit.com/640x480/4631-00.jpg)

### USB Type A to Type C Cable - approx 1 meter / 3 ft long

[USB Type A to Type C Cable - approx 1 meter / 3 ft long](https://www.adafruit.com/product/4474)
As technology changes and adapts, so does Adafruit. This&nbsp;&nbsp; **USB Type A to Type C** cable will help you with the transition to USB C, even if you're still totin' around a USB Type A hub, computer or laptop.

USB C is the latest industry-standard connector for...

In Stock
[Buy Now](https://www.adafruit.com/product/4474)
[Related Guides to the Product](https://learn.adafruit.com/products/4474/guides)
![Angled shot of a coiled black, USB-C to USB-A cable.](https://cdn-shop.adafruit.com/640x480/4474-02.jpg)

### 5V 1A (1000mA) USB port power supply - UL Listed

[5V 1A (1000mA) USB port power supply - UL Listed](https://www.adafruit.com/product/501)
Need a USB jack for charging or powering a project, but don't want to lug around a computer? This switching supply gives a clean regulated output at up to 1000mA! 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but...

In Stock
[Buy Now](https://www.adafruit.com/product/501)
[Related Guides to the Product](https://learn.adafruit.com/products/501/guides)
![Wall wart power supply with 2 US prong power](https://cdn-shop.adafruit.com/640x480/501-05.jpg)

# Adafruit IO IOT Hub with the Adafruit FunHouse

## CircuitPython Setup

[CircuitPython](https://github.com/adafruit/circuitpython)&nbsp;is a derivative of&nbsp;[MicroPython](https://micropython.org/)&nbsp;designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the&nbsp; **CIRCUITPY** &nbsp;drive to iterate.

## Set Up CircuitPython

Follow the steps to get CircuitPython installed on your FunHouse.

[Download the latest CircuitPython for your board from circuitpython.org](https://circuitpython.org/board/adafruit_funhouse/)
 **Click the link above and download the latest .BIN and .UF2 file**

(depending on how you program the ESP32S2 board you may need one or the other, might as well get both)

Download and save it to your desktop (or wherever is handy).

![sensors_Download_Firmware.png](https://cdn-learn.adafruit.com/assets/assets/000/101/512/medium640/sensors_Download_Firmware.png?1618531628)

Plug your FunHouse into your computer using a known-good USB cable.

**A lot of people end up using charge-only USB cables and it is very frustrating! So make sure you have a USB cable you know is good for data sync.**

![sensors_4985-06.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/513/medium640/sensors_4985-06.jpg?1618531771)

## Option 1 - Load with UF2 Bootloader

This is by far the easiest way to load CircuitPython.&nbsp;**However it requires your board has the UF2 bootloader installed. Some early boards do not (we hadn't written UF2 yet!) - in which case you can load using the built in ROM bootloader.**

Still, try this first!

### Try Launching UF2 Bootloader

Loading CircuitPython by drag-n-drop UF2 bootloader is the easier way and we recommend it.

![sensors_Boot_Mode.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/514/medium640/sensors_Boot_Mode.jpg?1618534416)

Launch UF2 by&nbsp; **double-clicking** &nbsp;the Reset button (the one next to the USB C port). You may have to try a few times to get the timing right.

**About a half second pause between clicks while the DotStars are purple seems to work well.**

![sensors_Press_Reset.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/519/medium640/sensors_Press_Reset.jpg?1618586167)

If the UF2 bootloader is installed, you will see a new disk drive appear called&nbsp; **HOUSEBOOT**

![sensors_Windows_Drives.png](https://cdn-learn.adafruit.com/assets/assets/000/101/521/medium640/sensors_Windows_Drives.png?1618588909)

Copy the&nbsp; **UF2** &nbsp;file you downloaded at the first step of this tutorial onto the&nbsp; **HOUSEBOOT** &nbsp;drive

![sensors_Windows_Drag_Firmware.png](https://cdn-learn.adafruit.com/assets/assets/000/101/522/medium640/sensors_Windows_Drag_Firmware.png?1618589080)

If you're using Windows and you get an error at the end of the file copy that says&nbsp; **Error from the file copy, Error 0x800701B1: A device which does not exist was specified.&nbsp;** You can ignore this error, the bootloader sometimes disconnects without telling Windows, the install completed just fine and you can continue. [If its really annoying, you can also upgrade the bootloader (the latest version of the UF2 bootloader fixes this warning)](https://learn.adafruit.com/adafruit-funhouse/install-uf2-bootloader)

Your board should auto-reset into CircuitPython, or you may need to press reset. A&nbsp; **CIRCUITPY** &nbsp;drive will appear. You're done! Go to the next pages.

![sensors_Windows_CircuitPy.png](https://cdn-learn.adafruit.com/assets/assets/000/101/523/medium640/sensors_Windows_CircuitPy.png?1618589269)

## Option 2 - Use Chrome Browser To Upload BIN file
Warning: 

The next best option is to try using the Chrome-browser version of esptool we have written. This is handy if you don't have Python on your computer, or something is really weird with your setup that makes esptool not run (which happens sometimes and isn't worth debugging!) You can follow along on the&nbsp;[Install UF2 Bootloader](https://learn.adafruit.com/adafruit-funhouse/install-uf2-bootloader)&nbsp;page and either load the UF2 bootloader and then come back to Option 1 on this page, or you can download the CircuitPython BIN file directly using the tool in the same manner as the bootloader.

## Option 3 - Use esptool to load BIN file

For more advanced users, you can upload with&nbsp; **esptool** &nbsp;to the ROM (hardware) bootloader instead!

Follow the initial steps found in the&nbsp;[Run esptool and check connection section of the Install UF2 Bootloader page](https://learn.adafruit.com/adafruit-funhouse/install-uf2-bootloader)&nbsp;to verify your environment is set up, your board is successfully connected, and which port it's using.

**In the final command to write a binary file to the board, replace the port with your port, and replace "firmware.bin" with the the file you downloaded above.**

The output should look something like the output in the image.

![sensors_adafruit_products_Metro_ESP32_S2_binary_install.png](https://cdn-learn.adafruit.com/assets/assets/000/101/524/medium640/sensors_adafruit_products_Metro_ESP32_S2_binary_install.png?1618589586)

Press reset to exit the bootloader.

Your&nbsp; **CIRCUITPY** &nbsp;drive should appear!

You're all set! Go to the next pages.

![sensors_adafruit_products_Metro_ESP32_S2_CIRCUITPY.png](https://cdn-learn.adafruit.com/assets/assets/000/101/525/medium640/sensors_adafruit_products_Metro_ESP32_S2_CIRCUITPY.png?1618589627)

# Adafruit IO IOT Hub with the Adafruit FunHouse

## CircuitPython Internet Test

One of the great things about most Espressif microcontrollers are their built-in WiFi capabilities. This page covers the basics of getting connected using CircuitPython.

The first thing you need to do is update your **code.py** to the following (it will error until WiFi details are added). Click the **Download Project Bundle** button to download the necessary libraries and the&nbsp; **code.py** file in a zip file. Extract the contents of the zip file, and copy the **entire**  **lib**  **folder** and the **code.py** file to your **CIRCUITPY** drive.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/ESP32_S2_WiFi_Tests/CPy_Native_WiFi_Test/code.py

Your **CIRCUITPY** drive should resemble the following.

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/ESP32_S2_WiFi_Tests_CPy_Native_WiFi_Test.png )

To get connected, the next thing you need to do is update the **settings.toml** file.

## The settings.toml File

We expect people to share tons of projects as they build CircuitPython WiFi widgets. What we want to avoid is people accidentally sharing their passwords or secret tokens and API keys. So, we designed all our examples to use a **settings.toml** file, that is on your&nbsp; **CIRCUITPY** &nbsp;drive, to hold secret/private/custom data. That way you can share your main project without worrying about accidentally sharing private stuff.

If you have a fresh install of CircuitPython on your board, the initial **settings.toml** file on your **CIRCUITPY** drive is empty.

To get started, you can update the **settings.toml** on your **CIRCUITPY** drive to contain the following code.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/ESP32_S2_WiFi_Tests/CPy_Native_WiFi_Test/settings.toml

This file should contain a series of Python variables, each assigned to a string. Each variable should describe what it represents (say&nbsp;`wifi_ssid`), followed by an **=&nbsp;** (equals sign), followed by the data in the form of a Python string (such as `"my-wifi-password"` including the quote marks).

**At a minimum you'll need to add/update your WiFi SSID and WiFi password, so do that now!**

As you make projects you may need more tokens and keys, just add them one line at a time. See for example other tokens such as one for accessing GitHub or the Hackaday API. Other non-secret data like your timezone can also go here.

For the correct time zone string, look at&nbsp;[http://worldtimeapi.org/timezones](http://worldtimeapi.org/timezones)&nbsp;and remember that if your city is not listed, look for a city in the same time zone, for example Boston, New York, Philadelphia, Washington DC, and Miami are all on the same time as New York.

Of course, don't share your **settings.toml** - keep that out of GitHub, Discord or other project-sharing sites.

Warning: 

If you connect to the serial console, you should see something like the following:

![](https://cdn-learn.adafruit.com/assets/assets/000/097/014/medium800/adafruit_products_1__screen__Users_brentrubell__screen_.png?1605218222)

In order, the example code...

Checks the ESP32's MAC address.

```python
print(f"My MAC address: {[hex(i) for i in wifi.radio.mac_address]}")
```

Performs a scan of all access points and prints out the access point's name (SSID), signal strength (RSSI), and channel.

```python
print("Available WiFi networks:")
for network in wifi.radio.start_scanning_networks():
    print("\t%s\t\tRSSI: %d\tChannel: %d" % (str(network.ssid, "utf-8"),
                                             network.rssi, network.channel))
wifi.radio.stop_scanning_networks()
```

Connects to the access point you defined in the **settings.toml** file, and prints out its local IP address.

```python
print(f"Connecting to {os.getenv('WIFI_SSID')}")
wifi.radio.connect(os.getenv("WIFI_SSID"), os.getenv("WIFI_PASSWORD"))
print(f"Connected to {os.getenv('WIFI_SSID')}")
print(f"My IP address: {wifi.radio.ipv4_address}")
```

Attempts to ping a Google DNS server to test connectivity. If a ping fails, it returns `None`. Initial pings can sometimes fail for various reasons. So, if the initial ping is successful (`is not None`), it will print the echo speed in ms. If the initial ping fails, it will try one more time to ping, and then print the returned value. If the second ping fails, it will result in `"Ping google.com: None ms"` being printed to the serial console. Failure to ping does not always indicate a lack of connectivity, so the code will continue to run.

```python
ping_ip = ipaddress.IPv4Address("8.8.8.8")
ping = wifi.radio.ping(ip=ping_ip) * 1000
if ping is not None:
    print(f"Ping google.com: {ping} ms")
else:
    ping = wifi.radio.ping(ip=ping_ip)
    print(f"Ping google.com: {ping} ms")
```

The code creates a socketpool using the wifi radio's available sockets. This is performed so we don't need to re-use sockets. Then, it initializes a a new instance of the [requests](http://docs.python-requests.org/en/master/) interface - which makes getting data from the internet _really really easy._

```python
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
```

To read in plain-text from a web URL, call `requests.get` - you may pass in either a http, or a http **s** url for SSL connectivity.&nbsp;

```python
print(f"Fetching text from {TEXT_URL}")
response = requests.get(TEXT_URL)
print("-" * 40)
print(response.text)
print("-" * 40)
```

Requests can also display a JSON-formatted response from a web URL using a call to `requests.get`.&nbsp;

```python
print(f"Fetching json from {JSON_QUOTES_URL}")
response = requests.get(JSON_QUOTES_URL)
print("-" * 40)
print(response.json())
print("-" * 40)
```

Finally, you can fetch and parse a JSON URL using `requests.get`. This code snippet obtains the `stargazers_count` field from a call to the GitHub API.

```python
print(f"Fetching and parsing json from {JSON_STARS_URL}")
response = requests.get(JSON_STARS_URL)
print("-" * 40)
print(f"CircuitPython GitHub Stars: {response.json()['stargazers_count']}")
print("-" * 40)
```

OK you now have your ESP32 board set up with a proper **settings.toml** file and can connect over the Internet. If not, check that your **settings.toml** file has the right SSID and password and retrace your steps until you get the Internet connectivity working!

## IPv6 Networking

Starting in CircuitPython 9.2, IPv6 networking is available on most Espressif wifi boards. Socket-using libraries like **adafruit\_requests** and **adafruit\_ntp** will need to be updated to use the new APIs and for now can only connect to services on IPv4.

### IPv6 connectivity & privacy

IPv6 addresses are divided into many special kinds, and many of those kinds (like those starting with&nbsp; **FC** , **FD** , **FE** ) are private or local; Addresses starting with other prefixes like&nbsp; **2002:** and **2001:** are globally routable. In 2024, far from all ISPs and home networks support IPv6 internet connectivity. For more info consult resources like [Wikipedia](https://en.wikipedia.org/wiki/IPv6_address#Local_addresses). If you're interested in global IPv6 connectivity you can use services like [Hurricane Electric](https://www.he.net/) to create an "IPv6 tunnel" (free as of 2024, but requires expertise and a compatible router or host computer to set up)

It's also important to be aware that, as currently implemented by Espressif, there are privacy concerns especially when these devices operate on the global IPv6 network: The device's unique identifier (its EUI-64 or MAC address) is used by default as part of its IPv6 address. This means that the device identity can be tracked across multiple networks by any service it connects to.

### Enable IPv6 networking

Due to the privacy consideration, IPv6 networking is not automatically enabled. Instead, it must be explicitly enabled by a call to `start_dhcp_client` with the `ipv6=True` argument specified:

```python
wifi.start_dhcp_client(ipv6=True)
```

### Check IP addresses

The read-only&nbsp;`addresses` property of the `wifi.radio` object holds all addresses, including IPv4 and IPv6 addresses:

```python
&gt;&gt;&gt; wifi.radio.addresses
('FE80::7EDF:A1FF:FE00:518C', 'FD5F:3F5C:FE50:0:7EDF:A1FF:FE00:518C', '10.0.3.96')
```

The `wifi.radio.dns` servers can be IPv4 or IPv6:

```python
&gt;&gt;&gt; wifi.radio.dns
('FD5F:3F5C:FE50::1',)
&gt;&gt;&gt; wifi.radio.dns = ("1.1.1.1",)
&gt;&gt;&gt; wifi.radio.dns
('1.1.1.1',)
```

### Ping v6 networks

`wifi.radio.ping` accepts v6 addresses and names:

```python
&gt;&gt;&gt; wifi.radio.ping("google.com")
0.043
&gt;&gt;&gt; wifi.radio.ping("ipv6.google.com")
0.048
```

### Create & use IPv6 sockets

Use the address family `socket.AF_INET6`. After the socket is created, use methods like `connect`, `send`, `recfrom_into`, etc just like for IPv4 sockets. This code snippet shows communicating with a private-network NTP server; this IPv6 address will not work on your network:

```python
&gt;&gt;&gt; ntp_addr = ("fd5f:3f5c:fe50::20e", 123)
&gt;&gt;&gt; PACKET_SIZE = 48
&gt;&gt;&gt; 
&gt;&gt;&gt; buf = bytearray(PACKET_SIZE)
&gt;&gt;&gt; with socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) as s:
...     s.settimeout(1)
...     buf[0] = 0b0010_0011
...     s.sendto(buf, ntp_addr)
...     print(s.recvfrom_into(buf))
...     print(buf)
... 
48
(48, ('fd5f:3f5c:fe50::20e', 123))
bytearray(b'$\x01\x03\xeb\x00\x00\x00\x00\x00\x00\x00GGPS\x00\xeaA0h\x07s;\xc0\x00\x00\x00\x00\x00\x00\x00\x00\xeaA0n\xeb4\x82-\xeaA0n\xebAU\xb1')
```

# Adafruit IO IOT Hub with the Adafruit FunHouse

## Getting The Date & Time

A very common need for projects is to know the current date and time. Especially when you want to deep sleep until an event, or you want to change your display based on what day, time, date, etc. it is

**Determining the correct local time is really really hard. There are various time zones, Daylight Savings dates, leap seconds, etc.** Trying to get NTP time and then back-calculating what the local time is, is extraordinarily hard on a microcontroller just isn't worth the effort and it will get out of sync as laws change anyways.

For that reason, we have the free adafruit.io time service. **Free for anyone with a free adafruit.io account.** You _do need an account_ because we have to keep accidentally mis-programmed-board from overwhelming adafruit.io and lock them out temporarily. Again, it's free!

Info: 

## Step 1) Make an Adafruit account

It's free! Visit [https://accounts.adafruit.com/](https://accounts.adafruit.com/) to register and make an account if you do not already have one

## Step 2) Sign into Adafruit IO

Head over to [io.adafruit.com](https://io.adafruit.com/) and click **Sign In** to log into IO using your Adafruit account. It's free and fast to join.

## Step 3) Get your Adafruit IO Key

Click on **My Key** in the top bar

![](https://cdn-learn.adafruit.com/assets/assets/000/097/449/medium800/adafruit_products_image.png?1607208628 "My Key" has been replaced with a key-shaped icon!)

You will get a popup with your **Username** and **Key** (In this screenshot, we've covered it with red blocks)

![](https://cdn-learn.adafruit.com/assets/assets/000/097/450/medium800/adafruit_products_image.png?1607208767)

Go to the **settings.toml** file on your **CIRCUITPY** drive (or create one with the text editor with your operating system) and add three lines for&nbsp;`AIO_USERNAME`, `ADAFRUIT_AIO_KEY` and `TIMEZONE` so you get something like the following:

```python
# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it

CIRCUITPY_WIFI_SSID = "your-wifi-ssid"
CIRCUITPY_WIFI_PASSWORD = "your-wifi-password"
ADAFRUIT_AIO_USERNAME = "your-adafruit-io-username"
ADAFRUIT_AIO_KEY = "your-adafruit-io-key"
# Timezone names from http://worldtimeapi.org/timezones
TIMEZONE="America/New_York"
```

The timezone is optional, if you don't have that entry, adafruit.io will guess your timezone based on geographic IP address lookup. You can visit [http://worldtimeapi.org/timezones](http://worldtimeapi.org/timezones) to see all the time zones available (even though we do not use Worldtime for time-keeping, we do use the same time zone table).

## Step 4) Upload Test Python Code

This code is like the Internet Test code from before, but this time it will connect to adafruit.io and get the local time

```python
import ipaddress
import os
import ssl
import wifi
import socketpool
import adafruit_requests


# Get our username, key and desired timezone
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
aio_username = os.getenv("ADAFRUIT_AIO_USERNAME")
aio_key = os.getenv("ADAFRUIT_AIO_KEY")
timezone = os.getenv("TIMEZONE")
TIME_URL = f"https://io.adafruit.com/api/v2/{aio_username}/integrations/time/strftime?x-aio-key={aio_key}&amp;tz={timezone}"
TIME_URL += "&amp;fmt=%25Y-%25m-%25d+%25H%3A%25M%3A%25S.%25L+%25j+%25u+%25z+%25Z"

print("ESP32-S2 Adafruit IO Time test")

print("My MAC addr:", [hex(i) for i in wifi.radio.mac_address])

print("Available WiFi networks:")
for network in wifi.radio.start_scanning_networks():
    print("\t%s\t\tRSSI: %d\tChannel: %d" % (str(network.ssid, "utf-8"),
            network.rssi, network.channel))
wifi.radio.stop_scanning_networks()

print("Connecting to", ssid)
wifi.radio.connect(ssid, password)
print(f"Connected to {ssid}!")
print("My IP address is", wifi.radio.ipv4_address)

ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com:", wifi.radio.ping(ipv4), "ms")

pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())

print("Fetching text from", TIME_URL)
response = requests.get(TIME_URL)
print("-" * 40)
print(response.text)
print("-" * 40)
```

After running this, you will see something like the below text. We have blocked out the part with the secret username and key data!

![](https://cdn-learn.adafruit.com/assets/assets/000/097/451/medium800/adafruit_products_image.png?1607212430)

Note at the end you will get the date, time, and your timezone! If so, you have correctly configured your **settings.toml** and can continue to the next steps!

# Adafruit IO IOT Hub with the Adafruit FunHouse

## FunHouse-Specific CircuitPython Libraries

To use all the amazing features of your FunHouse with CircuitPython, you must first install a number of libraries. This page covers that process.

## Get Latest Adafruit CircuitPython Bundle

Download the Adafruit CircuitPython Library Bundle. You can find the latest release here:

[Download the latest Library Bundle from circuitpython.org](https://circuitpython.org/libraries)
Download the **adafruit-circuitpython-bundle-version-mpy-\*.zip** bundle zip file, and unzip a folder of the same name. Inside you'll find a **lib** folder. The entire collection of libraries is too large to fit on the **CIRCUITPY** drive. Therefore, you'll need to copy the necessary libraries to your board individually.

At a minimum, the following libraries are required. Copy the following folders or .mpy files to the **lib** folder on your **CIRCUITPY** drive. **If the library is a folder, copy the entire folder** to the **lib** folder on your board.

At a minimum we recommend the following libraries, in fact we more than recommend. They're basically required. So grab them and install them into&nbsp; **CIRCUITPY/lib** &nbsp;now!

Library folders (copy the whole folder over to lib):

- **adafruit\_funhouse&nbsp;** - This is a helper library designed for using all of the features of the FunHouse, including networking, buttons, DotStars, etc.
- **adafruit\_portalbase** &nbsp;- This library is the base library that adafruit\_funhouse is built on top of.
- **adafruit\_bitmap\_font&nbsp;** - There is fancy font support, and it's easy to make new fonts. This library reads and parses font files.
- **adafruit\_display\_text&nbsp;** - This library displays text on the screen.
- **adafruit\_io&nbsp;** - This library helps connect the FunHouse to our free data logging and viewing service
- **adafruit\_minimqtt** - MQTT library required for communicating with the MQTT Server
- **adafruit\_dps310** - This is used for the Barometric Pressure Sensor

Library files:

- **adafruit\_requests.mpy&nbsp;** - This library allows us to perform HTTP requests and get responses back from servers. GET/POST/PUT/PATCH - they're all in here!
- **adafruit\_fakerequests.mpy&nbsp;** &nbsp;- This library allows you to create fake HTTP requests by using local files.
- **adafruit\_miniqr.mpy&nbsp;** &nbsp;- QR creation library lets us add easy-to-scan 2D barcodes to the E-Ink display
- **adafruit\_dotstar.mpy&nbsp;** - This library is used to control the onboard DotStars.
- **simpleio.mpy&nbsp;** - This library is used for tone generation.
- **adafruit\_ahtx0.mpy** - This is used for the Humidity and Temperature Sensor

## Settings

Even if you aren't planning to go online with your FunHouse, you'll need to have a **settings.toml** &nbsp;file in the root directory (top level) of your **CIRCUITPY** drive. If you do not intend to connect to wireless, it does not need to have valid data in it. [Here's more info on the settings.toml file](https://learn.adafruit.com/adafruit-magtag/internet-connect#the-settings-dot-toml-file-3077419).

# Adafruit IO IOT Hub with the Adafruit FunHouse

## Adafruit IO Setup

In this section, I'll guide you through replicating my Adafruit IO dashboard. You don't have to have all the feeds I do, but you will have to slightly update the project code for that.

First, go to the [Adafruit IO feeds tab](https://io.adafruit.com/feeds). Then, click the 'New Feed' button and create these 7 feeds:

- battery
- door
- heatindex
- humidity
- lamp
- neopixel
- temperature

After you've created them, your Feeds page should look something like this, except the last values section should be blank for all of them.

![](https://cdn-learn.adafruit.com/assets/assets/000/102/172/medium800/projects_Screenshot_from_2021-05-17_09-45-42.png?1621259159)

Then, go to [the Dashboards tab](https://io.adafruit.com/dashboards) and click the 'New Dashboard' button. Name the dashboard whatever you want. I called mine 'IOT Hub'. Then, click on it and it should take you to a blank dashboard.

![](https://cdn-learn.adafruit.com/assets/assets/000/102/173/medium800/projects_Screenshot_from_2021-05-17_09-50-13.png?1621259431)

Next, click the gear icon and press the button labeled 'Create New Block'. You'll do this for every block you create.

![projects_Screenshot_from_2021-05-17_09-52-52.png](https://cdn-learn.adafruit.com/assets/assets/000/102/174/medium640/projects_Screenshot_from_2021-05-17_09-52-52.png?1621260151)

The first block we'll be creating will be a Toggle block. You can find it in the upper left-hand corner.

The first block we'll be creating will be a Toggle block. You can find it in the upper left-hand corner.

We'll use this block to control a relay. In my setup, I have it hooked up to a lamp, so we'll use the lamp feed.

On the next step, set the on text to 'True' and the off text to 'False' (it is case sensitive). Set the title to whatever you want, in this case I'll use 'Lamp'.

Then, click 'Create Block' and it should show up on your dashboard.

&nbsp;

![projects_Screenshot_from_2021-05-17_09-55-55.png](https://cdn-learn.adafruit.com/assets/assets/000/102/175/medium640/projects_Screenshot_from_2021-05-17_09-55-55.png?1621259867)

![projects_Screenshot_from_2021-05-17_09-58-15.png](https://cdn-learn.adafruit.com/assets/assets/000/102/176/medium640/projects_Screenshot_from_2021-05-17_09-58-15.png?1621259922)

![projects_Screenshot_from_2021-05-17_10-00-27.png](https://cdn-learn.adafruit.com/assets/assets/000/102/177/medium640/projects_Screenshot_from_2021-05-17_10-00-27.png?1621260103)

![projects_Screenshot_from_2021-05-17_10-07-09.png](https://cdn-learn.adafruit.com/assets/assets/000/102/178/medium640/projects_Screenshot_from_2021-05-17_10-07-09.png?1621260439)

Now, we'll make a block to display data from a temperature sensor. This one will be a Text block which is in the first column of the second row.

Set the feed to 'temperature'.

On the final screen, set the text size to medium, set the decimal places to 1, check 'show icon' and set the icon to 'thermometer'.

This block should appear right under the last block we made.

![projects_Screenshot_from_2021-05-17_10-11-45.png](https://cdn-learn.adafruit.com/assets/assets/000/102/179/medium640/projects_Screenshot_from_2021-05-17_10-11-45.png?1621260934)

![projects_Screenshot_from_2021-05-17_10-12-03.png](https://cdn-learn.adafruit.com/assets/assets/000/102/180/medium640/projects_Screenshot_from_2021-05-17_10-12-03.png?1621260954)

![projects_Screenshot_from_2021-05-17_10-12-48.png](https://cdn-learn.adafruit.com/assets/assets/000/102/181/medium640/projects_Screenshot_from_2021-05-17_10-12-48.png?1621260978)

![projects_Screenshot_from_2021-05-17_10-13-10.png](https://cdn-learn.adafruit.com/assets/assets/000/102/182/medium640/projects_Screenshot_from_2021-05-17_10-13-10.png?1621261071)

Now, we'll make the humidity block. This one is also a text block.&nbsp;

Using the humidity feed, we'll set the text size to medium, decimal places to one, enable 'show icon' and set the icon to 'w:humidity' and click 'create block'.

Now, click the gear icon, then 'edit layout' and click and drag it so it's next to the temperature block.

![projects_Screenshot_from_2021-05-17_10-11-45.png](https://cdn-learn.adafruit.com/assets/assets/000/102/188/medium640/projects_Screenshot_from_2021-05-17_10-11-45.png?1621261984)

![projects_Screenshot_from_2021-05-17_10-27-33.png](https://cdn-learn.adafruit.com/assets/assets/000/102/189/medium640/projects_Screenshot_from_2021-05-17_10-27-33.png?1621262004)

![projects_Screenshot_from_2021-05-17_10-28-29.png](https://cdn-learn.adafruit.com/assets/assets/000/102/190/medium640/projects_Screenshot_from_2021-05-17_10-28-29.png?1621262034)

![projects_Screenshot_from_2021-05-17_10-28-46.png](https://cdn-learn.adafruit.com/assets/assets/000/102/191/medium640/projects_Screenshot_from_2021-05-17_10-28-46.png?1621262039)

![projects_Screenshot_from_2021-05-17_10-29-33.png](https://cdn-learn.adafruit.com/assets/assets/000/102/192/medium640/projects_Screenshot_from_2021-05-17_10-29-33.png?1621262044)

After that, we'll make our fourth block, which displays the heat index. The heat index is what the temperature and humidity feels like. We'll also use a text block for this one.&nbsp;

Set feed to 'heatindex', the text size to medium, decimal places to 1, and the icon to 'w:thermometer-exterior'.

Once you've created the block, click 'edit layout' and resize it so it's the same width as the lamp block.

![projects_Screenshot_from_2021-05-17_10-47-42.png](https://cdn-learn.adafruit.com/assets/assets/000/102/193/medium640/projects_Screenshot_from_2021-05-17_10-47-42.png?1621262921)

![projects_Screenshot_from_2021-05-17_10-49-37.png](https://cdn-learn.adafruit.com/assets/assets/000/102/194/medium640/projects_Screenshot_from_2021-05-17_10-49-37.png?1621262993)

Next, make a color picker block. This will be used so we can set the color of a neopixel strip remotely. Use the neopixel feed for this one. You don't need to do any more configuration for this block.

![projects_Screenshot_from_2021-05-17_11-29-38.png](https://cdn-learn.adafruit.com/assets/assets/000/102/195/medium640/projects_Screenshot_from_2021-05-17_11-29-38.png?1621265540)

![projects_Screenshot_from_2021-05-17_11-33-13.png](https://cdn-learn.adafruit.com/assets/assets/000/102/196/medium640/projects_Screenshot_from_2021-05-17_11-33-13.png?1621265604)

For our penultimate block, we'll make a LiPo charger indicator. This will use the gauge block and the battery feed.

Set the title to Battery, the gauge label to Percent, the low warning value to 20, the decimal places to zero, and set the icon to battery.

![projects_Screenshot_from_2021-05-17_11-33-54.png](https://cdn-learn.adafruit.com/assets/assets/000/102/197/medium640/projects_Screenshot_from_2021-05-17_11-33-54.png?1621265903)

![projects_Screenshot_from_2021-05-17_11-37-57.png](https://cdn-learn.adafruit.com/assets/assets/000/102/198/medium640/projects_Screenshot_from_2021-05-17_11-37-57.png?1621265935)

![projects_Screenshot_from_2021-05-17_11-39-13.png](https://cdn-learn.adafruit.com/assets/assets/000/102/199/medium640/projects_Screenshot_from_2021-05-17_11-39-13.png?1621265964)

The last block will use the indicator block and the door feed.&nbsp;

Set the block title to Door and set conditions to equals 1.

If you decided to add all the blocks, your dashboard should look something like the third picture.

![projects_Screenshot_from_2021-05-17_11-40-39.png](https://cdn-learn.adafruit.com/assets/assets/000/102/200/medium640/projects_Screenshot_from_2021-05-17_11-40-39.png?1621266128)

![projects_Screenshot_from_2021-05-17_11-41-16.png](https://cdn-learn.adafruit.com/assets/assets/000/102/201/medium640/projects_Screenshot_from_2021-05-17_11-41-16.png?1621266147)

![projects_Screenshot_from_2021-05-17_11-42-36.png](https://cdn-learn.adafruit.com/assets/assets/000/102/202/medium640/projects_Screenshot_from_2021-05-17_11-42-36.png?1621266193)

# Adafruit IO IOT Hub with the Adafruit FunHouse

## Laser-cut Wall Mount

If you'd like to laser cut a mount to easily put your FunHouse on the wall, the file below should work great. Also, if you want to 3d print it, you should be able to import it into your CAD software and extrude it.

[Laser cut mount file](https://cdn-learn.adafruit.com/assets/assets/000/102/185/original/FunHouse-wall-mount.svg?1621261837)
# Adafruit IO IOT Hub with the Adafruit FunHouse

## Code the FunHouse IOT Hub

Ensure your **settings.toml** file should at the very least have values for the fields `CIRCUITPY_WIFI_SSID`, `CIRCUITPY_WIFI_PASSWORD`, `timezone`, `ADAFRUIT_AIO_USERNAME`, and `ADAFRUIT_AIO_KEY`. Make sure to copy it over to&nbsp; **CIRCUITPY** as well.

## Installing Project Code

To use with CircuitPython, you need to first install a few libraries, into the lib folder on your **CIRCUITPY** drive. Then you need to update **code.py** with the example script.

Thankfully, we can do this in one go. In the example below, click the **Download Project Bundle** button below to download the necessary libraries and the **code.py** file in a zip file. Extract the contents of the zip file, open the directory **FunHouse\_IOT\_Hub/iot\_hub/** &nbsp;and then click on the directory that matches the version of CircuitPython you're using and copy the contents of that directory to your **CIRCUITPY** drive.

Your **CIRCUITPY** drive should now look similar to the following image:

![CIRCUITPY](https://adafruit.github.io/Adafruit_Learning_System_Guides/FunHouse_IOT_Hub_iot_hub.png )

Info: Be sure you have the settings.toml file complete and loaded onto the CIRCUITPY drive also or the code will not run properly.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/FunHouse_IOT_Hub/iot_hub/code.py

## Customizing the Devices

Lines 204-236 in&nbsp; **code.py&nbsp;** are where I add all the devices. It's good to note that while I do call them devices, they're just Adafruit IO feeds with a few functions that make it easier to handle the data how we want to.

If you'd like to add your own device, it's good to know what the parameters are:

- **feed\_key** - The key of the Adafruit IO feed you want to use. This can't be left blank.
- **default\_text&nbsp;** - The text to set to the display before a value has been gotten. You can leave this blank and it should be fine.
- **formatted\_text** - The text in a way that can be formatted using curly braces (ex. "Lamp: {}". If you want a specific number of decimal points to be displayed put :.1f in the curly braces, replacing 1 with the precision you want. If you leave this blank it won't display any text unless you have a custom callback function that returns the formatted text you want.
- **color\_callback** - The function you want to be called whenever the device gets a new value to set the color of the text for that device. You can see two examples of this on line 150 and 154 of&nbsp; **code.py**. You can leave this blank.
- **callback&nbsp;** - The callback you want to run after the device gets a new message. This can do a number of things like turn on the FunHouse's built in dotstars or play a sound. There's a function on line 161 that shows how you could use a callback to set the text in a slightly more complicated way. If left blank, this defaults to a built-in callback that just uses&nbsp; **formatted\_text** to set the text.
- **pub\_method** - The function you want to call when the select button is pressed. Only 2 devices in&nbsp; **code.py** have one of these. If you look at line 168 you can see an example of a simple one that just toggles the lamp, but if you look at line 102 you can see a much more complicated one that displays a whole new screen and ui.

## Code Behavior

The code should show 6 lines with the various feeds. To navigate use the three buttons left of the display. The upper button moves the cursor up, the middle button will let you publish a new value to the feed if that is enabled (in my example it's only enabled for the lamp and neopixel feed).

If you wanted to turn the lamp on, you'd press the middle button and it will turn on pretty quickly.

If you want to change the color of the NeoPixels, navigate down to it with the third button then select it with the middle button. From there it will take you to a screen where you can edit the hex values for the red, green, and blue components of the NeoPixels. Use the up and down button to increase or decrease them and use the select button to switch between the colors. When you're done, you can submit it with the Capacitive Touch 8 button on the upper right of the screen. If you decide that you don't want to submit it, press the Capacitive Touch 7 button on the upper left of the screen and it will take you back to the home screen without submitting the value you set.

# Adafruit IO IOT Hub with the Adafruit FunHouse

## Code Run-Through

First, the code makes all of the required imports, this may seem like a lot, but most of them are just for making the connection to Adafruit IO.

```python
import time
import ssl
import displayio
import board
from digitalio import DigitalInOut, Direction, Pull
from adafruit_display_text.label import Label
import terminalio
import touchio
import socketpool
import wifi
import adafruit_minimqtt.adafruit_minimqtt as MQTT
from adafruit_io.adafruit_io import IO_MQTT
from adafruit_dash_display import Hub
```

First the code looks up your WIFI credentials and AIO username and token&nbsp; from the **settings.toml** file using `os.getenv()`. If any of those values are missing the code raises an exception because they are all required.

```auto
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
ssid = getenv("CIRCUITPY_WIFI_SSID")
password = getenv("CIRCUITPY_WIFI_PASSWORD")
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")

if None in [ssid, password, aio_username, aio_key]:
    raise RuntimeError(
        "WiFi and Adafruit IO settings are kept in settings.toml, "
        "please add them there. The settings file must contain "
        "'CIRCUITPY_WIFI_SSID', 'CIRCUITPY_WIFI_PASSWORD', "
        "'ADAFRUIT_AIO_USERNAME' and 'ADAFRUIT_AIO_KEY' at a minimum."
    )
```

Next, the navigation buttons are defined so they can be passed to the Dash Display library later.

```python
up = DigitalInOut(board.BUTTON_UP)
up.direction = Direction.INPUT
up.pull = Pull.DOWN

select = DigitalInOut(board.BUTTON_SELECT)
select.direction = Direction.INPUT
select.pull = Pull.DOWN

down = DigitalInOut(board.BUTTON_DOWN)
down.direction = Direction.INPUT
down.pull = Pull.DOWN

back = touchio.TouchIn(board.CAP7)
submit = touchio.TouchIn(board.CAP8)
```

Now, the DisplayIO group that the NeoPixel setter will use is defined. It consists of 6 labels, 3 that are static and 3 that are changed by user input.

```python
rgb_group = displayio.Group()
R_label = Label(
    terminalio.FONT,
    text="   +\nR:\n   -",
    color=0xFFFFFF,
    anchor_point=((0, 0.5)),
    anchored_position=((5, 120)),
    scale=2,
)
G_label = Label(
    terminalio.FONT,
    text="   +\nG:\n   -",
    color=0xFFFFFF,
    anchor_point=((0, 0.5)),
    anchored_position=((90, 120)),
    scale=2,
)
B_label = Label(
    terminalio.FONT,
    text="   +\nB:\n   -",
    color=0xFFFFFF,
    anchor_point=((0, 0.5)),
    anchored_position=((175, 120)),
    scale=2,
)
rgb_group.append(R_label)
rgb_group.append(G_label)
rgb_group.append(B_label)
R = Label(
    terminalio.FONT,
    text="00",
    color=0xFFFFFF,
    anchor_point=((0, 0.5)),
    anchored_position=((35, 120)),
    scale=2,
)
G = Label(
    terminalio.FONT,
    text="00",
    color=0xFFFFFF,
    anchor_point=((0, 0.5)),
    anchored_position=((120, 120)),
    scale=2,
)
B = Label(
    terminalio.FONT,
    text="00",
    color=0xFFFFFF,
    anchor_point=((0, 0.5)),
    anchored_position=((205, 120)),
    scale=2,
)
rgb_group.append(R)
rgb_group.append(G)
rgb_group.append(B)
```

Continuing what the code just did, the function that will use the DisplayIO group is defined. This function lets you input a hex value using the navigation buttons and then sends it to Adafruit IO.

```python
# pylint: disable=unused-argument
def rgb(last):
    """ Function for when the rgb screen is active """
    display.root_group = displayio.CIRCUITPYTHON_TERMINAL
    rgb_group[3].text = "00"
    rgb_group[4].text = "00"
    rgb_group[5].text = "00"
    display.root_group = rgb_group
    time.sleep(0.2)
    index = 0
    colors = [00, 00, 00]

    while True:
        if select.value:
            index += 1
            if index == 3:
                index = 0
            time.sleep(0.3)
            continue

        if up.value:
            colors[index] += 1
            if colors[index] == 256:
                colors[index] = 0
            rgb_group[index + 3].text = hex(colors[index])[2:]
            time.sleep(0.01)
            continue

        if down.value:
            colors[index] -= 1
            if colors[index] == -1:
                colors[index] = 255
            rgb_group[index + 3].text = hex(colors[index])[2:]
            time.sleep(0.01)
            continue

        if submit.value:
            color = ["{:02x}".format(colors[i]) for i in range(len(colors))]
            color = "#" + "".join(color)
            iot.publish("neopixel", color)
            break

        if back.value:
            break
        time.sleep(0.1)

    display.root_group = displayio.CIRCUITPYTHON_TERMINAL
    time.sleep(0.1)
```

The next two color callbacks are defined here. The first one just sets the text color to the value of the NeoPixel feed, which should always be an RGB hex string.

The second color callback sets the text color to red if the door is open and green if it is closed.

```python
def rgb_set_color(message):
    """ Sets the color of the rgb label based on the value of the feed """
    return int(message[1:], 16)

def door_color(message):
    """ Sets the color of the door label based on the value of the feed """
    door = bool(int(message))
    if door:
        return int(0x00FF00)
    return int(0xFF0000)
```

Then, a callback for the door feed is defined. This callback sets the text to "Door: Open" if the value of the door feed is 'False' and thus open and "Door: Closed" if it is 'True' and thus closed.

```python
def on_door(client, feed_id, message):
    """ Sets the door text based on the value of the feed """
    door = bool(int(message))
    if door:
        return "Door: Closed"
    return "Door: Open"
```

Next, the publish method for the lamp is defined. Basically it just publishes the opposite of whatever value was last sent from the lamp feed.

```python
def pub_lamp(lamp):
    if isinstance(lamp, str):
        lamp = eval(lamp)  # pylint: disable=eval-used
    iot.publish("lamp", str(not lamp))
    # funhouse.set_text(f"Lamp: {not lamp}", 0)
    time.sleep(0.3)
```

After that, the code does all the Adafruit IO setup.

```python
display = board.DISPLAY

print(f"Connecting to {ssid}")
wifi.radio.connect(ssid, password)
print(f"Connected to {ssid}!")

# Create a socket pool
pool = socketpool.SocketPool(wifi.radio)

# Initialize a new MQTT Client object
mqtt_client = MQTT.MQTT(
    broker="io.adafruit.com",
    username=aio_username,
    password=aio_key,
    socket_pool=pool,
    ssl_context=ssl.create_default_context(),
)
# Initialize an Adafruit IO MQTT Client
io = IO_MQTT(mqtt_client)
```

The code now defines the Dash Display `Hub` object and passes it the display, the Adafruit IO object, and the navigation buttons.

```python
iot = Hub(display=display, io=io, nav=(up, select, down, back, submit))
```

The code then adds all the devices to the `Hub` object so they will be displayed.

```python
iot.add_device(
    feed_key="lamp",
    default_text="Lamp: ",
    formatted_text="Lamp: {}",
    pub_method=pub_lamp,
)
iot.add_device(
    feed_key="temperature",
    default_text="Temperature: ",
    formatted_text="Temperature: {:.1f} C",
)
iot.add_device(
    feed_key="humidity", default_text="Humidity: ", formatted_text="Humidity: {:.2f}%"
)
iot.add_device(
    feed_key="neopixel",
    default_text="LED: ",
    formatted_text="LED: {}",
    color_callback=rgb_set_color,
    pub_method=rgb,
)
iot.add_device(
    feed_key="battery",
    default_text="Battery: ",
    formatted_text="Battery: {}%",
)
iot.add_device(
    feed_key="door",
    default_text="Door: ",
    formatted_text="Door: {}",
    color_callback=door_color,
    callback=on_door,
    )

iot.get()
```

Finally, the code calls the&nbsp;`Hub` object's loop function which checks all the nav buttons and does things accordingly.

```python
while True:
    iot.loop()
    time.sleep(0.01)
```

# Adafruit IO IOT Hub with the Adafruit FunHouse

## NeoPixel Remote Example

Warning: 

This example uses a PyPortal Titano as a remote control for NeoPixels. It uses HTTP which is pretty slow, but MQTT on PyPortals is a bit unreliable at the moment.

For this project, you need:

### Adafruit PyPortal Titano

[Adafruit PyPortal Titano](https://www.adafruit.com/product/4444)
The **PyPortal Titano** is the big sister to our [popular PyPortal](https://www.adafruit.com/product/4116) now with _twice as many pixels!_ The PyPortal is our easy-to-use IoT device that allows you to create all the things for the “Internet of...

In Stock
[Buy Now](https://www.adafruit.com/product/4444)
[Related Guides to the Product](https://learn.adafruit.com/products/4444/guides)
![Hand holding PyPortal Titano development board with SAMD51, ESP32 Wifi, and 3.5" touchscreen TFT display.](https://cdn-shop.adafruit.com/640x480/4444-10.jpg)

### Adafruit Feather M4 Express - Featuring ATSAMD51

[Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857)
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -&nbsp; with...

In Stock
[Buy Now](https://www.adafruit.com/product/3857)
[Related Guides to the Product](https://learn.adafruit.com/products/3857/guides)
![Angled shot of a Adafruit Feather M4 Express. ](https://cdn-shop.adafruit.com/640x480/3857-10.jpg)

### Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor

[Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor](https://www.adafruit.com/product/4264)
Give your Feather project a _lift_ with the Adafruit AirLift FeatherWing - a FeatherWing that lets you use the powerful ESP32 as a WiFi co-processor. You probably have your favorite Feather ([like the Feather M4](https://www.adafruit.com/product/3857)) that comes with its own...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4264)
[Related Guides to the Product](https://learn.adafruit.com/products/4264/guides)
![Angled shot of Adafruit AirLift FeatherWing.](https://cdn-shop.adafruit.com/640x480/4264-07.jpg)

### FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers

[FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers](https://www.adafruit.com/product/3417)
This is the **FeatherWing Tripler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are three! The magic of the Tripler comes when you want to connect your Feather to...

In Stock
[Buy Now](https://www.adafruit.com/product/3417)
[Related Guides to the Product](https://learn.adafruit.com/products/3417/guides)
![Triple prototyping feather wing PCB with socket headers installed](https://cdn-shop.adafruit.com/640x480/3417-05.jpg)

If the FeatherWing tripler is out of stock, you can also use a [FeatherWing Doubler](https://www.adafruit.com/product/2890) and put [Stacking Headers](https://www.adafruit.com/product/2830) on either the Feather M4 or the AirLift FeatherWing.

### Adafruit NeoPixel LED Strip Starter Pack - 30 LED meter - Black

[Adafruit NeoPixel LED Strip Starter Pack - 30 LED meter - Black](https://www.adafruit.com/product/2562)
You can't bake a cake without flour, sugar, and baking soda? Cream cheese? Muscadet?&nbsp;Ok - to be honest we don't do much cake baking. &nbsp;But we do light up a TON of NeoPixel LED strips! They're&nbsp;everywhere - from our <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/2562)
[Related Guides to the Product](https://learn.adafruit.com/products/2562/guides)
![Adafruit NeoPixel Digital RGB LED Strip wired to a microcontroller, with all the LEDs in a rainbow](https://cdn-shop.adafruit.com/640x480/2562-02.jpg)

## PyPortal Setup
First click&nbsp; **Download Project Bundle** below. This zip file will contain everything you need for this example. However, the files are also in the zip file you downloaded for the FunHouse, so you can get them from either one, just make sure you take the files from the&nbsp; **neopixel\_remote** directory.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/FunHouse_IOT_Hub/neopixel_remote/code.py

First, you'll need to copy over the following libraries to your PyPortal Titano:

- **adafruit\_display\_shapes/**
- **adafruit\_bus\_device/**
- **adafruit\_imageload/**
- **adafruit\_minimqtt/**
- **adafruit\_connection\_manager.mpy**
- **adafruit\_io/**
- **adafruit\_esp32spi/**
- **adafruit\_requests.mpy**
- **adafruit\_touchscreen.mpy**
- **adafruit\_ticks.mpy**
- **adafruit\_pixelbuf.mpy**
- **neopixel.mpy**

After you've done that, rename **neopixel\_remote.py** to **code.py** and put it on the PyPortal.

Next, make a new folder on your PyPortal named **bmps** and put **pyportal\_setter.bmp** inside it.

Finally, copy over your **settings.toml** file.

After you've done all that, this is what your **CIRCUITPY** drive should look like:

![CIRCUITPY](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/folder-images/FunHouse_IOT_Hub_neopixel_remote.png?raw=true )

When you've done all this, your PyPortal should look like this and you should be able to tap a square and have the top of the display turn that color as well as see the Adafruit IO color indicator turn that color.

![](https://cdn-learn.adafruit.com/assets/assets/000/102/282/medium800/projects_IMG_2024.jpg?1621455313)

## Feather Setup
https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/FunHouse_IOT_Hub/neopixel_remote/feather_code/code.py

First, copy over the required libraries:

- **adafruit\_esp32spi/**
- **adafruit\_io/**
- **adafruit\_minimqtt/**
- **adafruit\_requests.mpy**
- **neopixel.mpy**

The code above should already be downloaded. Rename it to **code.py** and copy it over to your Feather.

After you've copied all that over, copy your **settings.toml** over and you should be set as far as the files are concerned.

## Assembly

Solder the headers that came with each device. Then put the Feather and the AirLift FeatherWing in the FeatherWing Tripler and attach the data wire from the NeoPixel strip (often green. I used [one of these](https://www.adafruit.com/product/3786) to make it a bit easier) to pin D5 (third pin from the end furthest from the USB port of the header with less pins) on the Tripler and then connect the ground wire (usually white or black) to a GND pin on the Tripler.

Afer you've done all this it should look something like this:

![](https://cdn-learn.adafruit.com/assets/assets/000/102/332/medium800/projects_IMG_2041.jpg?1621965191)

Now, connect the NeoPixel strip to a power source. If you have a lot of pixels, use a power supply but if you only have a few, you can get away with connecting it to the **USB&nbsp;** pin (note: this only works if you're powering the board through USB. If you're powering it with a LiPo this won't work).

## Usage

To use the remote, just press one of the colored squares and it will send that to Adafruit IO. Then, the Feather will update the NeoPixels accordingly.

# Adafruit IO IOT Hub with the Adafruit FunHouse

## Battery Charger Example

Warning: 

This example uses a Feather RP2040 (although any Feather board with stemma works) and an LC709203 to track the charging of a LiPo battery with Adafruit IO.

For this project, you will need:

### Adafruit Feather RP2040

[Adafruit Feather RP2040](https://www.adafruit.com/product/4884)
A new chip means a new Feather, and the Raspberry Pi RP2040 is no exception. When we saw this chip we thought "this chip is going to be awesome when we give it the Feather Treatment" and so we did! This Feather features the&nbsp; **RP2040** , and all niceties you know and...

In Stock
[Buy Now](https://www.adafruit.com/product/4884)
[Related Guides to the Product](https://learn.adafruit.com/products/4884/guides)
![Angled shot of black rectangular microcontroller "Feather RP2040"](https://cdn-shop.adafruit.com/640x480/4884-04.jpg)

### Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor

[Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor](https://www.adafruit.com/product/4264)
Give your Feather project a _lift_ with the Adafruit AirLift FeatherWing - a FeatherWing that lets you use the powerful ESP32 as a WiFi co-processor. You probably have your favorite Feather ([like the Feather M4](https://www.adafruit.com/product/3857)) that comes with its own...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4264)
[Related Guides to the Product](https://learn.adafruit.com/products/4264/guides)
![Angled shot of Adafruit AirLift FeatherWing.](https://cdn-shop.adafruit.com/640x480/4264-07.jpg)

### Adafruit FeatherWing OLED - 128x32 OLED Add-on For Feather

[Adafruit FeatherWing OLED - 128x32 OLED Add-on For Feather](https://www.adafruit.com/product/2900)
A Feather board without ambition is a Feather board without FeatherWings! This is the **FeatherWing OLED** : it adds a 128x32 monochrome OLED plus 3 user buttons to _any_ Feather main board. Using our [Feather Stacking...](https://www.adafruit.com/products/2830)

In Stock
[Buy Now](https://www.adafruit.com/product/2900)
[Related Guides to the Product](https://learn.adafruit.com/products/2900/guides)
![Angled shot of a Adafruit FeatherWing OLED - 128x32 OLED Add-on For Feather connected to a white breadboard and a lithium battery. ](https://cdn-shop.adafruit.com/640x480/2900-10.jpg)

### Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor

[Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor](https://www.adafruit.com/product/4712)
Low cost Lithium Polymer batteries have revolutionized electronics - they're thin, they're light, they can be regulated down to 3.3V and they're easy to charge. On your phone, there's a little image of a battery cell that tells you the percentage of charge - so you know when...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4712)
[Related Guides to the Product](https://learn.adafruit.com/products/4712/guides)
![Top view of Adafruit LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor powered by a Lipoly battery and an OLED display.](https://cdn-shop.adafruit.com/640x480/4712-07.jpg)

### Stacking Headers for Feather - 12-pin and 16-pin female headers

[Stacking Headers for Feather - 12-pin and 16-pin female headers](https://www.adafruit.com/product/2830)
These two **Female Stacking Headers** alone are, well, lonely. But pair them with any of our [Feather](https://www.adafruit.com/categories/777) boards and you're in business!

What do they do? They stack. Put the headers through your Feather and then you can...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2830)
[Related Guides to the Product](https://learn.adafruit.com/products/2830/guides)
![Angled shot of a Stacking Headers for Feather - 12-pin and 16-pin female headers. ](https://cdn-shop.adafruit.com/640x480/2830-08.jpg)

### FeatherWing Doubler - Prototyping Add-on For All Feather Boards

[FeatherWing Doubler - Prototyping Add-on For All Feather Boards](https://www.adafruit.com/product/2890)
This is the **FeatherWing Doubler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are two! The magic of the Doubler comes when stacking a Feather and another...

Out of Stock
[Buy Now](https://www.adafruit.com/product/2890)
[Related Guides to the Product](https://learn.adafruit.com/products/2890/guides)
![Double prototyping feather wing PCB with socket headers installed](https://cdn-shop.adafruit.com/640x480/2890-01.jpg)

### STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long

[STEMMA QT / Qwiic JST SH 4-Pin Cable - 50mm Long](https://www.adafruit.com/product/4399)
This 4-wire cable is&nbsp;50mm / 1.9" long and fitted with JST SH female 4-pin connectors on both ends. Compared with the chunkier JST PH these are 1mm pitch instead of 2mm, but still have a nice latching feel, while being easy to insert and remove.

<a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/4399)
[Related Guides to the Product](https://learn.adafruit.com/products/4399/guides)
![Angled of of JST SH 4-Pin Cable.](https://cdn-shop.adafruit.com/640x480/4399-00.jpg)

### Lithium Ion Battery - 3.7V 2000mAh

[Lithium Ion Battery - 3.7V 2000mAh](https://www.adafruit.com/product/2011)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 2000mAh. If you need a larger (or smaller!) battery,&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/2011)
[Related Guides to the Product](https://learn.adafruit.com/products/2011/guides)
![Lithium Ion Polymer Battery 3.7v 2000mAh with JST 2-PH connector](https://cdn-shop.adafruit.com/640x480/2011-05.jpg)

If the cable or battery is out of stock, you can buy any other size, although for the STEMMA QT cable, shorter is better.

## Feather Setup

First, click **Download Project Bundle** below. This zip file will contain everything you need for this example. However, the files are also in the zip file you downloaded for the FunHouse, so you can get them from either one, just make sure you take the files from the **battery\_peripheral** &nbsp;directory.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/FunHouse_IOT_Hub/battery_peripheral/code.py

The first thing you'll need to do is copy all the required libraries over. The libraries needed are:

- **adafruit\_esp32spi/**
- **adafruit\_bitmap\_font/**
- **adafruit\_bus\_device/**
- **adafruit\_register.mpy**
- **adafruit\_minimqtt/**
- **adafruit\_io/**
- **adafruit\_display\_text/**
- **adafruit\_lc709203f.mpy**
- **adafruit\_requests.mpy**
- **neopixel.mpy**
- **adafruit\_ticks.mpy**
- **adafruit\_displayio\_ssd1306.mpy**

After you've copied over those libraries, copy&nbsp; **code.py** over to the **CIRCUITPY** drive.

Finally, copy **settings.toml** to the **CIRCUITPY** drive.

After you've done all that, this is what your **CIRCUITPY** drive should look like:

![CIRCUITPY](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/folder-images/FunHouse_IOT_Hub_battery_peripheral.png?raw=true )

## Assembly

Solder the stacking headers to either the RP2040 or the AirLift Featherwing, solder the normal headers to whichever one you didn't solder the stacking headers to and the OLED. Then, solder the headers that came with the FeatherWing Doubler to it (it's a bit easier to do if you put 2 Feather boards in to hold them in place before you get 2 pins on each header soldered).

Then, put the Feather RP2040 and AirLift FeatherWing on the doubler and put the OLED on top of the Feather.

Hook up the LiPo charger to the STEMMA QT connector on the Feather using either of the STEMMA QT connectors on the charger. Then, use the JST 2-PH cable that came with it to connect the charger to the Feather. You can use either jack on the charger.

Now that you've set everything up, plug a battery in and press the **RESET** button and it should look something like this:

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/102/292/medium800/projects_IMG_2027.jpg?1621527695)

# Adafruit IO IOT Hub with the Adafruit FunHouse

## Relay Control Example

Warning: 

This project uses a Feather and either the Relay FeatherWing or the 4 Outlet Power Relay to control devices that turn on and off through Adafruit IO.

For this project, you will need:

### Adafruit Feather M4 Express - Featuring ATSAMD51

[Adafruit Feather M4 Express - Featuring ATSAMD51](https://www.adafruit.com/product/3857)
It's what you've been waiting for, the Feather M4 Express featuring ATSAMD51. This Feather is fast like a swift, smart like an owl, strong like a ox-bird (it's half ox, half bird, OK?) This feather is powered by our new favorite chip, the **ATSAMD51J19** -&nbsp; with...

In Stock
[Buy Now](https://www.adafruit.com/product/3857)
[Related Guides to the Product](https://learn.adafruit.com/products/3857/guides)
![Angled shot of a Adafruit Feather M4 Express. ](https://cdn-shop.adafruit.com/640x480/3857-10.jpg)

### Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor

[Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor](https://www.adafruit.com/product/4264)
Give your Feather project a _lift_ with the Adafruit AirLift FeatherWing - a FeatherWing that lets you use the powerful ESP32 as a WiFi co-processor. You probably have your favorite Feather ([like the Feather M4](https://www.adafruit.com/product/3857)) that comes with its own...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4264)
[Related Guides to the Product](https://learn.adafruit.com/products/4264/guides)
![Angled shot of Adafruit AirLift FeatherWing.](https://cdn-shop.adafruit.com/640x480/4264-07.jpg)

### FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers

[FeatherWing Tripler Mini Kit - Prototyping Add-on For Feathers](https://www.adafruit.com/product/3417)
This is the **FeatherWing Tripler** - a prototyping add-on and more for all Feather boards. This is similar to our [FeatherWing Proto](https://www.adafruit.com/products/2884) except there are three! The magic of the Tripler comes when you want to connect your Feather to...

In Stock
[Buy Now](https://www.adafruit.com/product/3417)
[Related Guides to the Product](https://learn.adafruit.com/products/3417/guides)
![Triple prototyping feather wing PCB with socket headers installed](https://cdn-shop.adafruit.com/640x480/3417-05.jpg)

### Adafruit Power Relay FeatherWing

[Adafruit Power Relay FeatherWing](https://www.adafruit.com/product/3191)
A Feather board without ambition is a Feather board without FeatherWings! This is the **Power Relay FeatherWing**. It gives you power to control, and control over power. Put simply, you can now turn on and off lamps, fans, solenoids, and other small appliances that run on up to...

In Stock
[Buy Now](https://www.adafruit.com/product/3191)
[Related Guides to the Product](https://learn.adafruit.com/products/3191/guides)
![Angled shot of a Adafruit Power Relay FeatherWing. ](https://cdn-shop.adafruit.com/640x480/3191-04.jpg)

OR

### Controllable Four Outlet Power Relay Module version 2

[Controllable Four Outlet Power Relay Module version 2](https://www.adafruit.com/product/2935)
Say goodbye to hazardous high voltage wiring and create the [Internet of Things](https://www.adafruit.com/categories/342) with safe, reliable power control. The **IoT Power Relay** &nbsp;from&nbsp;[Digital...](http://www.digital-loggers.com/iot.html)

In Stock
[Buy Now](https://www.adafruit.com/product/2935)
[Related Guides to the Product](https://learn.adafruit.com/products/2935/guides)
![Controllable Four Outlet Power Relay Module](https://cdn-shop.adafruit.com/640x480/2935-13.jpg)

## Feather Setup

First, click **Download Project Bundle** below. This zip file will contain everything you need for this example. However, the files are also in the zip file you downloaded for the FunHouse, so you can get them from either one, just make sure you take the files from the **relay\_peripheral** &nbsp;directory.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/FunHouse_IOT_Hub/relay_peripheral/code.py

The first thing you'll need to do is copy all the required libraries over. The required libraries are:

- **adafruit\_esp32spi/**
- **adafruit\_bus\_device/**
- **adafruit\_connection\_manager.mpy**
- **adafruit\_pixelbuf.mpy**
- **adafruit\_ticks.mpy**
- **adafruit\_minimqtt/**
- **adafruit\_io/**
- **neopixel.mpy**
- **adafruit\_requests.mpy**

After you've copied all that over, rename&nbsp; **relay\_daughter.py** to&nbsp; **code.py** and copy it over to the&nbsp; **CIRCUITPY&nbsp;** drive.

Finally, copy **settings.toml** to the&nbsp; **CIRCUITPY** drive.

After you've done all that, this is what your&nbsp; **CIRCUITPY&nbsp;** drive should look like:

![CIRCUITPY](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/folder-images/FunHouse_IOT_Hub_relay_peripheral.png?raw=true )

## Assembly

Solder all the headers to the devices they came with. Then, put everything on the FeatherWing Tripler.

If you're using the Four Outlet Power Relay, then plug a breadboard wire into pin D10 on the FeatherWing Tripler and another wire into the GND pin. Then pull out the green part that the pins go into in the Relay itself and plug the wire from D10 into the receptacle marked with a + (the one on the left) and the wire from GND into the receptacle with a - (the one on the right). Then, screw in the two screws that hold the wires in place and plug the green part back into the Power Relay.

Now that you've set everything up, this is what yours should look like if you're using the Relay FeatherWing:

![](https://cdn-learn.adafruit.com/assets/assets/000/102/295/medium800/projects_IMG_2031.jpg?1621529771)

And, if you're using the 4-Outlet Power Relay, this is what it should look like:

![](https://cdn-learn.adafruit.com/assets/assets/000/102/296/medium800/projects_IMG_2033.jpg?1621529806)


## Featured Products

### Adafruit FunHouse - WiFi Home Automation Development Board

[Adafruit FunHouse - WiFi Home Automation Development Board](https://www.adafruit.com/product/4985)
Home is where the heart is...it's also where we keep all our electronic bits. So why not wire it up with sensors and actuators to turn our house into an electronic wonderland. Whether it's tracking the environmental temperature and humidity in your laundry room, or notifying you when...

Out of Stock
[Buy Now](https://www.adafruit.com/product/4985)
[Related Guides to the Product](https://learn.adafruit.com/products/4985/guides)
### Mini Magnet Feet for RGB LED Matrices (Pack of 4)

[Mini Magnet Feet for RGB LED Matrices (Pack of 4)](https://www.adafruit.com/product/4631)
Got a glorious&nbsp;RGB Matrix project you want to mount and display in your workspace or home? If you have one of the matrix panels listed below, you'll need a pack of these **Mini-Magnet Feet.** &nbsp;We got these specifically&nbsp;for our RGB LED Matrices, which no longer...

In Stock
[Buy Now](https://www.adafruit.com/product/4631)
[Related Guides to the Product](https://learn.adafruit.com/products/4631/guides)
### USB Type A to Type C Cable - approx 1 meter / 3 ft long

[USB Type A to Type C Cable - approx 1 meter / 3 ft long](https://www.adafruit.com/product/4474)
As technology changes and adapts, so does Adafruit. This&nbsp;&nbsp; **USB Type A to Type C** cable will help you with the transition to USB C, even if you're still totin' around a USB Type A hub, computer or laptop.

USB C is the latest industry-standard connector for...

In Stock
[Buy Now](https://www.adafruit.com/product/4474)
[Related Guides to the Product](https://learn.adafruit.com/products/4474/guides)
### 5V 1A (1000mA) USB port power supply - UL Listed

[5V 1A (1000mA) USB port power supply - UL Listed](https://www.adafruit.com/product/501)
Need a USB jack for charging or powering a project, but don't want to lug around a computer? This switching supply gives a clean regulated output at up to 1000mA! 110 or 240 input, so it works in any country. The plugs are "US 2-prong" style so you may need a plug adapter, but...

In Stock
[Buy Now](https://www.adafruit.com/product/501)
[Related Guides to the Product](https://learn.adafruit.com/products/501/guides)

## Related Guides

- [Adafruit FunHouse](https://learn.adafruit.com/adafruit-funhouse.md)
- [Funhouse Door Alert with Email Notification](https://learn.adafruit.com/funhouse-door-alert-email-notification.md)
- [FunHouse Motion Detecting Lights with LIFX Bulbs](https://learn.adafruit.com/funhouse-motion-detecting-lighting-for-lifx-bulbs.md)
- [No-Code Room Occupancy Status ](https://learn.adafruit.com/no-code-room-occupancy-status.md)
- [Hang out your washing reminder - Adafruit IO + Vibration switch](https://learn.adafruit.com/hang-out-your-washing-reminder-adafruit-io-vibration-switch.md)
- [Using the Adafruit FunHouse with Home Assistant](https://learn.adafruit.com/using-the-adafruit-funhouse-with-home-assistant.md)
- [No-Code WipperSnapper Water Detection](https://learn.adafruit.com/water-detection-with-wippersnapper.md)
- [No-Code WipperSnapper IoT Power Switch Outlet](https://learn.adafruit.com/no-code-wippersnapper-iot-power-switch-outlet.md)
- [Creating FunHouse Projects with CircuitPython](https://learn.adafruit.com/creating-funhouse-projects-with-circuitpython.md)
- [CircuitPython Web Workflow Code Editor Quick Start](https://learn.adafruit.com/getting-started-with-web-workflow-using-the-code-editor.md)
- [Track a Turtle with WipperSnapper](https://learn.adafruit.com/track-a-turtle-with-wippersnapper.md)
- [Motion Activated Outlet with the Adafruit FunHouse](https://learn.adafruit.com/motion-activated-outlet-with-the-adafruit-funhouse.md)
- [Pet Bowl Water Level Sensing](https://learn.adafruit.com/pet-bowl-water-level-sensing-with-the-funhouse-and-home-assistant.md)
- [FunHouse Mail Slot Detector](https://learn.adafruit.com/funhouse-mail-slot-detector.md)
- [FunHouse Parking Assistant](https://learn.adafruit.com/funhouse-parking-assistant.md)
