The project as is works great - it has a nice date and time display with a touch screen switch. However, when combined with Adafruit IO, it can control a connected light or appliance through the internet or voice command. This is done using an Adafruit IO feed. This feed is then used  to create a virtual switch. This web based button allows you to turn on and off your smart switch remotely. Later this will be extended to voice commands using Alexa or a Google Assistant. But first is to get the switch working in

Read the Welcome to Adafruit IO learning guide to get learn about the features of Adafruit IO.

Integrating Adafruit IO with CircuitPython

Earlier you created an account and entered your credentials aio_username and aio_key into the file. Now to create a virtual switch using This requires creating a feed at . The feed name is hard-coded into as pyportal-switch. You can change this if needed, particularly if you creating more than one switch when you will need different names.

Creating a New Feed

To create a new feed, navigate to the feed list using "Feeds | View All". Create a new feed from the "Actions" menu and name it "PyPortal Switch". Verify the feed key is pyportal-switch since this is the name the PyPortal uses, not the name.

Once the feed is created, next is to create a virtual switch using an dashboard. This is not necessary for use with Alexa or Google Assistant, but it is a easy method to test the feed using a web browser.

Creating a New Dashboard

Navigate to "Dashboards | View All", create a new dashboard. You can name it whatever you would like. For our guide we named it "PyPortal Smart Switch".

Now to create the switch by clicking the blue plus sign icon on the right side of the dashboard. Create a toggle block from the list of block types. Then, select the "PyPortal Switch" feed from the "Choose Feed" dialog and proceed to the next step by clicking the "next step" button. Finally, give this block a descriptive name and keep the default button text values. Click the "create block" button to save the button.

To verify the switch and the underlying feed is working correctly, you can click on the "ON" or "OFF" button that appears on the dashboard. If your PyPortal is correctly running the file and the proper credentials were entered, You should see your PyPortal's switch icon change as the value is changed on If you have a light or appliance plugged in to the relay switch, it should also turn on or off when the virtual button is pressed.

You now have a web controlled smart switch. You can turn your appliance on or off from a web browser on your PC or smartphone. Continue to the next section to configure you smart switch for voice commands using either Amazon Alexa or Google Assistant.

This guide was first published on Dec 11, 2019. It was last updated on Dec 11, 2019.

This page (Adafruit IO Configuration) was last updated on Jan 25, 2021.