Introduction: PixelMeteo (UltraLow Power Forecast Monitor)
IOT is a cool thing because allow you to connect everything to internet and control it remotely but there is one thing that it’s cool too and are leds... But there is one more thing, most of the people don’t like wires, but they don’t like either change battery cells, so it would be awesome if it could run for years without changing the battery. With these ideas born this project.
Before start, if you like this Project, please consider to vote this project at the WIRELESS AND LED CONTEST I will appreciated.
This project is a weather monitor which show the weather forecast for the next hour with a retro pixel animation and could work up to 3 years (almost theoretical). This device runs with a ESP8266 and connects to Accuweather (Which is a weather forecast web) to obtain the weather in the place that you choose showing a pixel retro animation with the weather and the temperature. The left side number are the tens and the right side number are the units of the value of the temperature. After show the info it turns off himself to save energy.
So It's time to start!
Step 1: What Do You Need?
All the components are easy to find in eBay or some chinese web such as Aliexpress or Bangood. In the majority of the components name I attached a link to the product. Some components like resistors are sell in packs so if you don't want so many resistors is recommended to buy in a local store.
- 3D printer.
- FTDI USB to TTL programmer
WS2812 61Bit ring: 13€
2x 2N2222A : 0.04€ (Any similar NPN transitor would work)
BC547 or 2N3906: 0.25€ (Any similar PNP transistor would work and you could maybe find cheaper in a local store)
3X 220 Ohm resistor :It could be around 0.1€ the link is for a kit of resistor.
Drilled PCB 40x60mm: 1.10€ (You only need 40x30mm).
- 1 Capacitor 470uF/10V
3 AAA Cells
Step 2: The Electrical Circuit and How It Works.
To show how it works I attached two photos, the first one is the protoboard view in Fritzing (also I upload the file) and the second one it’s the schematic in Eagle with also a PCB design. Despite of have a few “analogical” components, is a quite simple circuit.
The operation of this circuit is: When you push the button, the circuit of the NPN and PNP transistors, feed the ESP8266 and the LEDS. This kind of circuit is call “Latching Button” you can see a nice explanation of this kind of circuithere or here. When everything is finished (Its’ve been shown the animation), the microcontroller gives a high state to base of the transistor and them turn off the circuit. That’s why it’s connects the base of the second NPN transitor to ground.
The reason to use this circuit is because we want to have the minimum consumption and with this configuration we could achieve around 0.75 µA when is off, which more or less… nothing. This current consumption is because the transistor has leakage current.
If you don't want a little bit of theory jump to the next line:
I don’t want to go so deeply with the theory, but I think it’s good to know how to calculate how much autonomy can have a device like this one. So, a little of theory.
In IOT devices achieved a huge battery life is the 50% of the device, so there is a way to achieve years of autonomy: Only turning on when it’s necessary and for a very little time and them a timer or a sensor decide when turn on again. I think it’s clear with an example.
Imaging a humidity sensor in a forest which capture the level of humidity in a zone of the forest and that zone it’s quite abrupt, so you need something which could be working for years without human interaction and it’s needed to be on 30 seconds (Which it’s the time that needs to measure and send the info) every 12 hours. So, the schematic would be: A timer which is off 12 hours and on 30 seconds with the output of the timer connects to the supply input of the microcontroller. This timer is always on, but it has a consume of nanoamperes.
End of the theory
Once we have seen this example, we could see that it’s quite similar of this project only with difference of we decided the time off. So to calculate the battery life time we must apply the formula attached in the picture and these are the values to use:
- Ion: The current that consume when it’s on (In this case depends of the weather because each animation has a consumption which can go from 20mA to 180mA and a)
- Ton: The time that it’s on. (In this case each time you start the device will be on for 15 seconds)
- Ioff: Current consumption when is off.
- Toff: Time off. (This is all day (in seconds) less 15 seconds if we turn on only one time).
- The capacity of the battery. (In this case 3 AAA cells in series with a capacity of 1500mAh).
The battery life time depends of the number of times that you turn on at the day and the weather, because when it sunny with cloud the current drain is around 180 mA but when it’s raining or snowing it’s only 50 mA.
Finally in this Project we can achieve 2.6 years appliying this values to the formula:
- Capacitiy of the battery: 1000mAh.
- Ion: 250mA (The worst case-> Sunny cloud)
- Ioff: 0.75uA
- Ton: 15 seg(Only turn on once per day)
- Toff: 24 hours less 15 sec.
The last photo is the finished PCB but you can also easily do in a drilled PCB which is better if you don't know how to do a cooper PCB.
Step 3: How It Works the Code?
This project runs with ESP8266-01 and Arduino IDE.
I attached a video with every animation and use of case. The video quality is not the best, due to it was a little difficult to record to a light moving. When you see with your eyes it's looks way better.
The code if fully documented so you can see all the details but I'm going to explain how it works in a "schematic" way and what it's necessary to work properly.
The workflow of this software is:
- Connects to your Wi-Fi network. Meanwhile is connecting it show an animation in the LEDs.
- Create a http Client and connects to Accuweather Web.
- Send a JSON Get request to Accuweather. This is basically asking to the web the forecast for the next hour in a place. Extra data: This is very interesting for lots of projects because with this thing you get data from your local bus, underground, train... or stock values. And with those data you can do whatever you want for example turn on a buzzer when your bus is arriving or some stock value go down.
- Once we receive the info from the web, it's needed to "Split" the info and save in the variable.The variables used at this point are: temperature and the icon use in the web to show the forecast.
- Once we have the temperature it's necessary to transform into number of the led that should be turn on and which color it's necessary to use. If the temperature if higher of 0º Celsius, the color is orange and in the other case it is blue.
- Them depending the value of ICON variable, we choose which animation fits.
- Finally 5 seconds later the device will turn off himself.
Once we know how it works it's needed to write some data in the code, but it's quite easy. In the photo attached you can see which data you should change and in which line are.
First step: It's necessary to get an Api Key of Acuweather go to this web and register-> API Acuweather
Second step: Once you're logging in go to this site and follow this steps. You need to get a free license and create a whatever APP, you only want the API key.
Third step: To get the location it's only necessary to look for the city that you want in Accuweather and them see the URL and copy the number which is in bold in the example:
https://www.accuweather.com/es/es/Estepona/301893/weather-forecast/301893 (This number is specific for each city)
Final step: Introduce your Wi-Fi data and upload the code to the Microcontroller.
Step 4: Printing the Enclosure.
To print the parts I used this settings in Cura:
Top and bottom pieces:
-0.1mm per layer.
-60 mm/s .
-0.2mm per layer
All the parts must be orientated as in the photo attached.
Step 5: Joining Everything.
Because sometimes it's difficult to see how to assembly a device only with images, I decided to create an animation which shows how to assembly it when you have all the parts and you can see in the GIF or in this video(The video and the Gif are the same animation but in the video you can see larger).
There is one thing that I missed in the animation and in the renderized imagen and is that I forgot to add the push button, but you can see where it's necessary to add in the real photos.
It's important to know that the cells are solder in series and have a total voltage of 4.5V. In the fourth photo you can see a how I've soldered it and it fits nicely in the body of the device. I recommend to use electric tape to avoid any accidental contact when it's inside.
In the rest of the photo you can see how to put the components and the cables to fit properly inside the body of the device.
The nuts should fit with high pressure but I recommend to use some kind of Super Glue (Loctite glue or whatever), because when you close the device, the nut could "jump" outside the device due to the pressure.
Step 6: That's All!
Well, it's done!
I hope you've found interesting the project and I aim you to build it, because you can do in a weekend if you have everything and you will learn a lot.
I've tried to give an educational vision to this project, because I think it's interesting to know some basically aspects of IOT and a practical use of the Internet protocols.
So that's it!
Thank you for your time and if you have any question ask me!
First Prize in the
We have a be nice policy.
Please be positive and constructive.