# CircuitPython Connected Weather Cloud Lamp

## Overview

https://youtu.be/QHlU3wvb13I

This is a fun project that plays with how to visualize information using only light and sound. What better way to have some fun with this than to make an Internet connected cloud that connects to an open source weather API?

This CircuitPython based project will walk you through connecting to lights, sound, and a network cloud service. Next we add some code to make it all go, along with a few sound files. There is plenty of room for your artistic side as we turn our electronics into a super fluffy cloud. Hang it up and watch it go.

This cloud is set to display the following weather updates common to the [OpenWeather API](https://openweathermap.org/)

- Clear
- Clouds, Fog, Mist
- Drizzle, Rain
- Thunderstorm
- Snow

# CircuitPython Connected Weather Cloud Lamp

## Tools and Supplies

There is a little bit of soldering to add connectors for this project, but nothing super difficult. Mostly we will be doing a bit of crafting to make the cloud itself.

Featured
### Hakko Professional Quality 20-30 AWG Wire Strippers

[Hakko Professional Quality 20-30 AWG Wire Strippers](https://www.adafruit.com/product/527)
These are the finest wire strippers we have used, and if you have to do a lot of wiring, you will agree! They have soft rounded grips - very comfortable to use, and precision ground notches that do a perfect job every time. No more yanking or twisting to strip wires cleanly and quickly.<br...></br...>

In Stock
[Buy Now](https://www.adafruit.com/product/527)
[Related Guides to the Product](https://learn.adafruit.com/products/527/guides)
![Red and black multi-size wire stripplers, closed](https://cdn-shop.adafruit.com/640x480/527-02.jpg)

You are also going to want to use a hot glue gun as well.

### Part: High Temp Glue Gun
quantity: 1
This will help you glue things together.
[High Temp Glue Gun](https://www.michaels.com/artminds-high-temp-glue-gun/10301572.html)

## Supplies

There are quite a few things you will need to make the cloud itself. Feel free to get creative and add whatever you want to make it your own. You should be able to find equivalents in most craft stores, online or in person.

![](https://cdn-learn.adafruit.com/assets/assets/000/090/094/medium800/weather_Poly-Fil.jpg?1585859145)

### Part: Poly-Fill Polyester
quantity: 1
Fluffy polyester stuffing
[Poly-Fill Polyester](https://www.michaels.com/product/the-original-polyfil-premium-fiber-fill-bag-20oz-10509852)

You will need something to make the cloud frame from, and though I have used laser cut wood and acrylic, I have actually found that cardboard and foam board work just as well, even for larger clouds.

### Part: Foam Board, White
quantity: 1
White foam core board for the frame of the cloud.
[Foam Board, White](https://www.michaels.com/elmers-foam-board-white/10110205.html)

### Part: Hot Glue Sticks
quantity: 1
You will be doing a fair bit of gluing.
[Hot Glue Sticks](https://www.michaels.com/product/4-full-size-dual-temperature-glue-sticks-by-ashland-10228078)

### Part: Zip Tie Locking Ties
quantity: 1
White plastic zip ties for holding down electronics and LEDs.
[Zip Tie Locking Ties](https://www.michaels.com/product/bundle-buddies-natural-multi-purpose-cable-ties-10658177)

# CircuitPython Connected Weather Cloud Lamp

## Wiring

A bit of wiring is necessary to connect everything to the Metro M4 microcontroller. For this project,&nbsp; connect the NeoPixel strip and the speaker power directly to the 5V DC power supply so that they don't overload the Metro M4. Other than that, we will just be connecting a button and a few components for the audio output.

![](https://cdn-learn.adafruit.com/assets/assets/000/089/637/medium800/weather_Wiring.png?1584817645)

## Audio Wiring

We will be using the Analog 0 Pin as an Audio out pin, but we do need to add some components to trim the signal and make this sound good.

1. Solder the the **Black** wire to the **common pin** on the 3.5mm Stereo Headphone Jack.
2. Use some **Blue** wire to jump the **outer two pins** on the Headphone Jack together since we will be using a Mono signal.
3. Connect one of the **outer pins** from the Headphone Jack to the **negative** side, the one with the white stripe, of a **100uf Capacitor**.
4. Connect the other side of the **Capacitor** to one of the outer pins of a **10k Potentiometer.**
5. Finally connect a **Blue** wire to the **center**  **pin** , or common pin, on the **Potentiometer**.

The **Black** and **Blue** wires should now be set to connect with the **GND** and **A0** pins on the **Metro M4**.

![](https://cdn-learn.adafruit.com/assets/assets/000/090/095/medium800/weather_Wiring-audio.png?1585860151)

## NeoPixel Wiring

Because we will be using a fair amount of NeoPixels, we need to connect the power directly to the 5V DC so that we don't overload the Metro M4.

1. Make sure that each of the following wires are about 10 inches long.
2. Connect the **Red** wire to the **positive** side, the side without the white stripe, of a **4700uF Capacitor**.
3. Connect the **Black** wire to the **negative** side, the side with the white stripe, of the **Capacitor**.
4. Add an **Orange** wire to the **Din** pin, usually a **White** wire, at the beginning of the NeoPixel string.

The **Orange** wire should now be ready to connect to pin **2** on the **Metro M4**.

![](https://cdn-learn.adafruit.com/assets/assets/000/090/096/medium800/weather_Wiring-LEDs.png?1585861267)

## Power Connector Wiring

Along with the NeoPixels, we also need to power the speakers with our 5V DC connection. The speakers have a USB connector as it's power connection but this can be removed to expose a Red and Black wire.

1. Use wire cutters to cut the wire just behind the speakers USB connector.
2. Strip the outer wire casing off about 3 inches down to get to the **Red** and **Black** wires.
3. Strip about 0.25 inches off of the ends of the **Black** and **Red** wires for the Speaker and the NeoPixels.
4. Twist the two **Red** wire ends together and insert them into the **+** side of the Female DC Power adapter screw terminal.
5. Twist the two **Black** wire ends together and insert them into the **-** side of the Female DC Power adapter screw terminal.

This is now ready to be connected to the DC Barrel Jack Splitter later.

![](https://cdn-learn.adafruit.com/assets/assets/000/090/124/medium800/weather_Wiring-Power.png?1585877208)

# CircuitPython Connected Weather Cloud Lamp

## Loading CircuitPython

## Mu Editor

The Mu editor works really well with the Metro M4 Express AirLift and it is the recommended choice for editing CircuitPython code.

[Link to Installing Mu Editor](https://learn.adafruit.com/adafruit-metro-m4-express-airlift-wifi/installing-mu-editor)
## Updating Your Metro M4 Express AirLift

This project was set up and tested using CircuitPython version 5 or higher. You will want to update your Metro M4 Express AirLift and Libraries to match the version you are using.

[Link to Installing CircuitPython](https://learn.adafruit.com/adafruit-metro-m4-express-airlift-wifi/install-circuitpython)
## CircuitPython Library Installation

Next you'll need to install the necessary libraries to use the hardware carefully follow the steps to find and install these libraries from&nbsp;[Adafruit's CircuitPython library bundle](https://github.com/adafruit/Adafruit_CircuitPython_Bundle) matching your version of CircuitPython. This project uses CircuitPython version 5 or later.

[Download CircuitPython Libraries from CircuitPython.org](https://circuitpython.org/libraries)
### CircuitPython Library files used in this tutorial

Plug your Metro M4 Express AirLift&nbsp;into your computer via a known, good USB data + power cable (not the kind that comes with USB battery packs, those are power only). A new flash drive should show up in your computer's file explorer/finder named **CIRCUITPY**. If it's not there, check your cable and that you installed CircuitPython correctly earlier.

The following libraries are used here. Copy the corresponding file from the library bundle to your **CIRCUITPY** drive in a subdirectory named **lib**. Create this subdirectory, if necessary, then copy these files/directories:

- **adafruit\_bus\_device**
- **adafruit\_esp32spi**
- **adafruit\_fancyled**
- **adafruit\_requests.mpy**
- **neopixel.mpy**

Before continuing make sure your board's&nbsp; **lib** &nbsp;folder has the following files and folders **&nbsp;** copied over. Note that the non-library files will be retrieved in the page called "The Full Code".

![](https://cdn-learn.adafruit.com/assets/assets/000/089/980/medium800/weather_file_map.png?1585351195)

# CircuitPython Connected Weather Cloud Lamp

## OpenWeather API setup

## Open Weather Maps API Key

We'll be using OpenWeatherMaps.org to retrieve the weather info through its API. In order to do so, you'll need to register for an account and get your API key.

Go to this&nbsp;[link](https://home.openweathermap.org/users/sign_up) and register for a free account. Once registered, you'll get an email containing your API key, also known as the "openweather token".

Copy and paste this key into your **settings.toml** file that is on the root level of your **CIRCUITPY** drive, so it looks something like this:

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

# CircuitPython Connected Weather Cloud Lamp

## Sound Files

The Metro M4 can play **PCM 16-bit Mono Wave files at 22KHz&nbsp;**** sample rate**. Thankfully you can find some files that were made just for this project that will work.

You can download the following sounds and place them into a new folder called **sounds** in the **CIRCUITPY** drive.

[Clear.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/129/original/Clear.wav?1585882428)
[Clouds.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/130/original/Clouds.wav?1585882436)
[Rain.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/131/original/Rain.wav?1585882448)
[Snow.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/132/original/Snow.wav?1585882456)
[Thunderstorm0.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/133/original/Thunderstorm0.wav?1585882463)
[Thunderstorm1.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/134/original/Thunderstorm1.wav?1585882470)
[Thunderstorm2.wav](https://cdn-learn.adafruit.com/assets/assets/000/090/135/original/Thunderstorm2.wav?1585882477)
If you would like to make your own sounds, the following link will take you to a guide that can help you format the WAV files. Keep in mind that you will want to make your files small, as WAV files can fill up your storage space quickly.

[Convert files to WAV](https://learn.adafruit.com/adafruit-wave-shield-audio-shield-for-arduino/convert-files)
# CircuitPython Connected Weather Cloud Lamp

## CircuitPython Code

Here is the code that you will need for the **code.py** file in the **CIRCUITPY** drive.

Click **Download Zip** to get all the sounds as well

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

# CircuitPython Connected Weather Cloud Lamp

## Build the cloud

## Cut out the Shapes

The first few clouds I made a few years back, I tried to make the base frame look more like a cloud thinking that it would make the outside of the cloud look more fluffy. No matter the shape of the frame, cloud is going to do what cloud will do. So I switched to just making an oval with a slightly flatter bottom and it looks just like all the other more complex ones. So keep things simple.

1. Place the two speakers onto your foam core or cardboard so you can trace them out for later. Be sure to leave plenty of space for the outer shape of the cloud.
2. Continue this for other parts of the frame, remembering to add holes for the button and wires to be strung through them.
3. Use a cutting tool to cut out all of the layers for your cloud. Do not forget to cut holes for your wires and the speakers. Keep in mind that all of this will be covered with fluffy stuff to hide the crimes.

I did four layers for this cloud but you can make it as big or small as you like.

![weather_CutParts1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/891/medium640/weather_CutParts1.jpg?1585244559)

![weather_CutParts2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/892/medium640/weather_CutParts2.jpg?1585244587)

![weather_CutParts3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/893/medium640/weather_CutParts3.jpg?1585244662)

## The First Layer
1. You will want to install the button into the first layer so that it will end up on the bottom of the cloud for easy access.
2. Use some of the cut-out pieces from your foam core or cardboard to make two pieces that can be added to the button.
3. Glue these pieces to the button top so that it can extend further down through some of the cloud fluff to make it easy to press.
4. Place the first layer onto the speakers and glue them in place with the button facing out.

![weather_1stLayer1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/898/medium640/weather_1stLayer1.jpg?1585244825)

![weather_1stLayer2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/899/medium640/weather_1stLayer2.jpg?1585244848)

![weather_1stLayer3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/900/medium640/weather_1stLayer3.jpg?1585244875)

![weather_1stLayer4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/901/medium640/weather_1stLayer4.jpg?1585244900)

## The Second Layer
1. Place the second layer down over the backs of the two speakers and down to the back of the button. Glue this to the speakers as well.
2. Use double sided tape or a zip tie to hold the Metro M4 onto place between the speakers.
3. Connect one end of the DC power cable splitter to the 2.1mm DC jack on the Metro M4.
4. Connect the button wires to the following pins:
  1. Black wire to GND pin
  2. Yellow wire to A2 pin

![weather_2ndLayer1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/902/medium640/weather_2ndLayer1.jpg?1585244948)

![weather_2ndLayer2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/903/medium640/weather_2ndLayer2.jpg?1585244974)

![weather_2ndLayer3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/904/medium640/weather_2ndLayer3.jpg?1585245043)

![weather_2ndLayer4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/905/medium640/weather_2ndLayer4.jpg?1585245265)

## The Third Layer
1. Place part of the third layer about half way down over the Metro M4 power and USB connector.
2. You may want to also connect a USB cable to the Metro M4 so that your can program it later.
3. You can glue the stereo headphone jack down to make it easy to connect the audio cable later.
4. Connect the 3.5mm headphone jack assembly wires to the following pins:
  1. Black wire to GND pin
  2. Blue wire to A0 pin

5. Connect the Orange NeoPixel wire to the 2 Pin&nbsp;
6. Get all of the wires gathered towards the center and glue the other side of layer 3 to the speakers.
7. Connect the power connector for the speakers to the other end of the DC Barrel Jack Splitter.
8. Connect the speakers audio plug into the 3.5mm headphone jack.

![weather_3rdLayer1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/906/medium640/weather_3rdLayer1.jpg?1585245368)

![weather_3rdLayer2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/907/medium640/weather_3rdLayer2.jpg?1585245397)

![weather_3rdLayer3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/908/medium640/weather_3rdLayer3.jpg?1585245426)

![weather_3rdLayer4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/909/medium640/weather_3rdLayer4.jpg?1585245454)

![weather_3rdLayer5.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/910/medium640/weather_3rdLayer5.jpg?1585245491)

![weather_3rdLayer6.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/911/medium640/weather_3rdLayer6.jpg?1585245521)

## The Top Layer
1. To make it easy to change the volume of the cloud, I cut a slot to fit part of the volume control through the fourth layer and glued it into place.
2. Feed the end of the DC Barrel Jack Splitter through the hole in the fourth layer along with the NeoPixel strip and the USB cable if that you may have&nbsp;connected.
3. Glue the fourth layer to the top of the speakers to hold it in place.

![weather_4thLayer1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/912/medium640/weather_4thLayer1.jpg?1585245558)

![weather_4thLayer2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/913/medium640/weather_4thLayer2.jpg?1585245591)

![weather_4thLayer3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/914/medium640/weather_4thLayer3.jpg?1585245622)

![weather_4thLayer4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/915/medium640/weather_4thLayer4.jpg?1585245642)

## Adding LEDs

Now we will be wrapping the NeoPixel strip around the cloud. This cloud uses 150 NeoPixels but you could add more if you want it brighter or to make a larger cloud.

1. Start at one end of the cloud and as best you can, wrap the NeoPixel strip securing it with zip ties.
2. Continue wrapping the cloud with the LED strip trying to keep things as evenly spaced as you can securing with zip ties where needed.
3. When you get to the other end of the cloud, use another zip tie to hold the end of the LED strip in place.
4. You can use one final zip tie to make a loop that will let you hang the cloud up when finished.

![weather_LEDstring1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/933/medium640/weather_LEDstring1.jpg?1585254642)

![weather_LEDstring2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/934/medium640/weather_LEDstring2.jpg?1585254665)

![weather_LEDstring3.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/935/medium640/weather_LEDstring3.jpg?1585254703)

![weather_LEDstring4.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/936/medium640/weather_LEDstring4.jpg?1585254734)

![weather_LEDstring5.jpg](https://cdn-learn.adafruit.com/assets/assets/000/089/937/medium640/weather_LEDstring5.jpg?1585254761)

## Adding some fluffy stuff

Clouds are fluffy and so we will use some Poly-Fil polyester fiber and hot glue to make it happen. It is a good idea to go slow and use smaller pieces for this to ensure that everything holds together nicely.

The following video shows you how I put a bit of hot glue down on the cloud frame and apply a bit of the Poly-Fil over and over again.

https://youtu.be/OF907cZBXy4

I tend to leave a bit on the top without Poly-Fil just so I can access the volume control and the DC plug.

# CircuitPython Connected Weather Cloud Lamp

## Usage

https://youtu.be/Cz0Gf8zinv8

The cloud will automatically connect to the WiFi network that you set in the **secrets.py** file. Once connected the cloud will pull weather data from the OpenWeather API and display the animation for your locations current forecast.

## Changing the Weather

You can cycle through each of the weather animations by pressing the button at the bottom of your cloud. The animations start with sunny/clear, overcast, rain, thunderstorm, snow, and back to sunny.

## Turning your cloud off

If you want to turn your cloud off for awhile, just press and hold the button at the bottom of the cloud for 4 seconds. The cloud will turn off and be ready to show the weather later.

## Turn your cloud on again

Whenever you want to see the weather forecast, just press the button at the bottom of the cloud. This will look for the latest forecast and switch to that animation.

## Going farther

This is a fun and entertaining project but there is plenty of room to make it better.

- Make your own sounds for the weather.
- Add some lightning wrangling air ships to your cloud.
- See is you can change the number of lights that turn blue based on how much rain the forecast predicts.
- Try to add an alert for severe weather or some other weather based alert.
- Show that you know your stuff by connecting your cloud to Adafruit.io for full IoT control.


## Guide Products

### Digital Genuine Hakko FX888DX-010SV (936 upgrade)

[Digital Genuine Hakko FX888DX-010SV (936 upgrade)](https://www.adafruit.com/product/1204)
Known by engineers for making excellent quality tools & soldering irons! This is a genuine Hakko FX-888D with **digital temperature control**! We worked hard to get the best and a great price, these are **not** &nbsp;knock-offs. This iron is an upgrade to the...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/1204)
[Related Guides to the Product](https://learn.adafruit.com/products/1204/guides)
### Hakko Professional Quality 20-30 AWG Wire Strippers

[Hakko Professional Quality 20-30 AWG Wire Strippers](https://www.adafruit.com/product/527)
These are the finest wire strippers we have used, and if you have to do a lot of wiring, you will agree! They have soft rounded grips - very comfortable to use, and precision ground notches that do a perfect job every time. No more yanking or twisting to strip wires cleanly and quickly.<br...></br...>

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

## Related Guides

- [Adafruit Metro M4 Express AirLift (WiFi)](https://learn.adafruit.com/adafruit-metro-m4-express-airlift-wifi.md)
- [Boomy Pi Airplay Boombox](https://learn.adafruit.com/boomy-pi-airplay.md)
- [Arcade Stick Conversion](https://learn.adafruit.com/arcade-stick-conversion.md)
- [No-Solder Faux Neon Bike Lights](https://learn.adafruit.com/no-solder-faux-neon-bike-lights.md)
- [Control Electronics with your Brain using NextMind](https://learn.adafruit.com/control-electronics-with-your-brain-using-nextmind.md)
- [RGB Matrix Panels With Raspberry Pi 5](https://learn.adafruit.com/rgb-matrix-panels-with-raspberry-pi-5.md)
- [Introducing Adafruit Crickit #MakeRobotFriend](https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-construction-kit.md)
- [Guardian Robot – Zelda BOTW](https://learn.adafruit.com/guardian-robot-zelda-botw.md)
- [Halloween Skeleton Transformation Illusion Prop](https://learn.adafruit.com/halloween-skeleton-transformation-illusion-prop.md)
- [PB Gherkin 30% keyboard with KMK, CircuitPython, & KB2040](https://learn.adafruit.com/pb-gherkhin-30-keyboard-with-kmk-circuitpython-kb2040.md)
- [LED Trampoline](https://learn.adafruit.com/led-trampoline.md)
- [Make It Talk](https://learn.adafruit.com/make-it-talk.md)
- [Breakbeat Breadboard](https://learn.adafruit.com/breakbeat-breadboard.md)
- [LED Neon Selfie Spot](https://learn.adafruit.com/led-neon-selfie-spot.md)
- [Christmas Soundboard with NeoTrellis M4](https://learn.adafruit.com/xmas-sound-board.md)
- [PyPortal IoT Weather Station](https://learn.adafruit.com/pyportal-iot-weather-station.md)
