Are you new to using CircuitPython? No worries, there is a full getting-started guide here.
Plug the device into your computer with a known good USB cable (not a charge-only cable). The device will appear to your computer in File Explorer or Finder (depending on your operating system) as a flash drive named CIRCUITPY. If the drive does not appear, you can install CircuitPython on your device and then return here.
Download the project files with the Download Project Bundle button below. Unzip the file and copy/paste the code.py and other project files to your CIRCUITPY drive using File Explorer or Finder (depending on your operating system).
Connect to WiFi
In order to communicate with the Wiz light your CircuitPython device needs to be connected to WiFi on the same network as the light. The easiest way to do this is to include your WiFi network credentials in a settings.toml file. If that file doesn't exist, then create it. Add these entries to the file and fill in the details for your own WiFi network.
CIRCUITPY_WIFI_SSID="network_name" CIRCUITPY_WIFI_PASSWORD="network_password"
Once that file is saved reboot your device and it will automatically connect to WiFi.
Setup Wiz Light
Install the Wiz smartphone app, available on both the Google Play and Apple app stores. Follow the prompts in the Wiz smartphone app to setup your light. You'll be prompted to enter a room name, and a name for the light, as well as your WiFi network credentials for the light to use to connect to the network. During "easy connect pairing", you'll need to ensure the light is powered off for at least 5 seconds, then turn it on and press the start button in the app to scan for nearby lights.
Once the light is found, it can be saved into your room, and it will ask you for initial settings like default color temperature and fade times. Once completed, the light will be listed under the chosen room inside of the app.
Find The Light IP Address
Once your light has been paired with the app, you need to find its IP address. Launch the Wiz app on your smartphone and follow these steps. Note that your room and light names will differ from the ones in the screenshots.
- Click the room that the light is in.
- Long-press on the light.
- Click settings in the menu that pops up.
- Click the dropdown chevron near the light's name at the top.
- Click "Device Info"
- Find the IP address listed along with other information about the light.
Once you've got your light's IP you'll need to fill it in to the line of code where the WizConnectLight
is initialized.
Drive Structure
After copying the files, your drive should look like the listing below. It can contain other files as well, but must contain these at a minimum.
Code
The code.py for the Wiz library simpletest is shown below. This code will cycle through setting a few of the properties to demonstrate the capabilities of the library and validate connectivity.
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim Cocks for Adafruit Industries # # SPDX-License-Identifier: MIT import time import wifi from adafruit_wiz import SCENE_IDS, WizConnectedLight udp_host = "192.168.1.143" # IP of UDP Wiz connected light udp_port = 38899 # Default port is 38899, change if your light is configured differently my_lamp = WizConnectedLight(udp_host, udp_port, wifi.radio) print(f"Current Status: {my_lamp.status}") print("Setting RGB Color") my_lamp.rgb_color = (255, 0, 255) time.sleep(2) print("Turning off") my_lamp.state = False time.sleep(2) print("Turning on") my_lamp.state = True print("Setting Light Color Temperature") my_lamp.temperature = 2200 time.sleep(2) print("Lowering the Brightness") my_lamp.brightness = 10 time.sleep(2) print("Raising the Brightness") my_lamp.brightness = 100 print("Available Scenes:") print(SCENE_IDS.keys()) print("Setting Scene") my_lamp.scene = "Party"
Text editor powered by tinymce.