Language Switcher

M5StickC+Yun Hatで作る簡単お天気ガジェット

A Simple Weather Gadget using M5StickC+Yun Hat

Make things

Sometimes, You wonder if you need to bring an umbrella before you leave home. Today, we would like to make a very convenient weather notification machine, sticking to the fridge or door with a magnet, using M5Stick C and a weather gadget Yun Hat.

Materials

You can install obniz OS on your M5StickC. → obnizOS installation

※It doesn’t matter with no power supply and no cable because M5StickC has its own battery. However, you should use the power supply if you want to run the program for a long time.

How to make

Hardware connection

Connect a Yun Hat to an M5StickC by referring to Yun Hat Library.

Software

The program gets weather information from Open Weather API, and changes display and LED color depending on its information.

You need to acquire API Key of Open Weather API.


Here, we will explain simply about “API.”

API is an abbreviation of “Application Programming Interface”. The interface seems like a difficult word, but it just means “a thing to connect something to something”. In other words, API is a thing to connect application(function) and program.

Open Weather API is the thing to acquire weather information. Anyone can use it for free. Today, we will use the weather information from Open Weather API as a URL and paste it into the code. We call the URL “Key“. Then, let’s get the key steps below.


First, go to Open Weather API’s website clicking the link below. Then, sign up to issue your own key. You cannot use it if you do not register your account.

・Open Weather API website (https://openweathermap.org/api)

There is “Sign UP” button on the top of the page so you can register your own account.

After signing up, you can sign in and see the screen as below. Then, click “API Keys” (Arrow-marked) and “Create Key” to make your own key.

After making API Key, you need to note this key.

Replace the API KEY HERE (code.js line2) with your API Key.

Sensing with Yun Hat

Today, no sensor on Yun Hat is used in this article because the program gets weather information from Open Weather.

You can use sensors on Yun Hat if you uncomment the comment outed part. (sponsored values such as temperature, humidity, brightness, and Barometric pressure will be displayed on the console like the image below.)

Also, you can see a simple description in the comment outed section.

Please read the link below to know how to use the functions about Yun Hat.

Yun Hat function docment →(https://github.com/obniz/obniz/tree/master/src/parts/M5Stack/M5StickC_Yun)

Program

How to use

Connect Yun Hat to M5StickC, and supply power to M5StickC with cable. If you use M5StickC only built-in battery, you don’t need power supply.

Save the program at obniz’s developer console and run it.

Then, try sticking this module to the door or refrigerator. You can easily put this module because Yun Hat has magnets on the backside.

M5StickC+Yunでお天気を知らせる

If you run the program…look! You have completed the module that change LED colors depending on current weather.