Glowing Christmas Snowman Using ESP-WROOM-02 & Weather API



There are many applications to using ESP-WROOM-02 and its wifi communication function via Arduino program. Today, we’re going to get even more creative and make another Christmas decoration that glows according to weather information we obtain from a weather API!

Today’s Electronic Recipe

Estimated time to complete: 90 minutes

Parts needed:


First, I’d like to try out a sample program to enable wifi communication on the Arduino program of ESP-WROOM-02. Choose File → Sketch Example → ESP 8266 WiFi → WiFi Web Server. This sample program is used for basic processing for wifi communication with Arduino.

Figure 1. Load sketch sample

This sample program makes ESP-WROOM-02 a server. When the program is started, it waits until there is a request from another terminal and as soon as a request arrives with a specified argument, it processes the argument. In our case, we’ll light up the LED using this program.

I’d like to test using the circuit from last time. Change where “2” pin is specified in the sample program to “13” pin.


Figure 2. LED control circuit

When you start the program, try connecting to the router. If it’s connected it’ll display IP address, etc. on the serial monitor. So try accessing that IP address from the browser. When connected to /gpio/1, the LED lights up, and when connected to /gpio/0, the LED lights off.

Figure 3. Wifi access successful


Figure 4. Connection from smartphone


Control the servo motor by via the program

Next, for a practical example, let’s try to control the servo motor via wifi. The servo motor control should be the same as the LED control, basically. I will add a little bit of modification to the LED program and also add a bit of HTML when accessing from the browser.

In this program, angles 0 to 150 are displayed in the browser and when you click on each value, the servo motor moves to a specified angle.


Figure 5. Servo motor control via wifi


Let’s make our weather snowman!

Since Christmas is just around the corner, I decided to make a Christmas decoration. Luxurious lighting that adds a lot of LEDs is good, but something that feels like Christmas right on your desk is even better. So, I modeled a snowman using 123d design. It is a tool that can model while combining different shapes, so even beginners can easily create 3D models.

Snowman model


Figure 6. Modeling a snowman

Please feel free to change the shape or the size according to your preference. When modeling is done, I tried outputting with a 3D printer. The arm didn’t come off nicely…unfortunately.


Figure 7. 3D printed snowman

Now we’ll need a full-color LED. Let’s combine the full color LED and wifi communication into a desktop device that will change the color of the LED according to the weather data from a specific location.


Configuration of device

As usual, let’s think about the configuration of the device before creating a program or a circuit. The overall structure is as follows.


Figure 8. Overall device configuration

You can also connect directly to the API from the Arduino program to process and retrieve the data, but since the capacity of the Arduino program is small, we can consider external expansion, Arduino installs an external server “SERVER PROGRAM” and makes a request. The external server program connects to the API, acquires data in JSON format, and returns only necessary data to Arduino.


Get weather data from API

The API we’ll be using this time is OpenWeatherMap. It’s a free API available to you if you register. With this API, weather information of a place can be acquired by inputting the position information and a city name.


Figure 9.

Programs of external servers connected to the API are created in PHP. Using the program below, we can obtain weather information by using country, city, appid-API key as an argument. We will install this program in the environment where PHP runs and confirm the operation.

External server program (PHP): Get data from weather API

It’s complete if the weather information of the designated city is displayed when accessing the program from the browser.


Figure 10. Confirm in the browser


Full-color LED lighting

Next, let’s look at how to use the full color LED on the output side. Although it is said to be a full-color LED, basically it’s RGB (i.e. red, green and blue) LEDs on one board.

As shown in Figure 11, since the LED of each color glows with + and – combination, solder it so that it can be connected to the breadboard.


Figure 11. Full color LED


Figure 12. Solder the full-color LED

If you emit 3 full-color LEDs, the color becomes white. Since the voltage and current amount required for each color LED are different, it’s necessary to add different resistance values to each circuit.

  • 91 Ω: red
  • 180 Ω: green
  • 220 Ω: blue


Colors are displayed based on the following weather information when data is acquired from the API.

  • Clear – sunny to red
  • Clouds – cloudy → green
  • Rain – Rain → Green
  • Snow – snow → aqua

Figure 13. Full Color LED Control Circuit Diagram

ESP-WROOM-02: Light changing according to the weather

In this program, data is acquired every time to confirm the operation. Please change the settings according to your preference. When you start the program, the device glows based on that data after weather data is acquired.


Figure 14. Snowman glows based on the weather data acquired

After some final touches to the to the snowman, we’re done.


Figure 15. Complete snowman decoration

This time, we created a cute Christmas decoration using the weather API. By incorporating other APIs, programs and linking to a smartphone, I think you can create an even more interesting device. Please share your thoughts and ideas in the comment section below!