Tuesday, October 7, 2014

Meteo Notifier Raspberry PI project building

Introduction


I was returning from my job on a friday afternoon and I was thinking about what I could do with my Raspberry PI to do a small IoT project over the weekend. I was in my car thinking about the Android wear meteo notifications and all the hardware I have at my place and had the idea of doing a simple wood device with two arms that will display a sun on one and a raining cloud on the other. So basically the device will fetch the local meteo from the internet and display the cloud if any precipitation is currently falling and the sun otherwise. For the CPU I choose to use my Raspberry PI (RPi) with the Raspbian Linux OS. I choose the Raspbian OS because it enabled me to code the program using Python using the stock image. Using the default Python libraries to do the PWM control of the servo motor is not the best option because it use a software implementation that made the servo giggle. But I really wanted to use Python for this project and it was not to big a problem for me. As I wanted to build the device rapidly with a minimum of external hardware, I only connected the servo to the 5V of the RPi, even though is not super good for it.


Hardwares


  • Raspberry PI B
  • 5V Servo motor Hitec HS-45HB
  • Small metal wire
  • Paper with sun and cloud image
  • Small wood board
  • Bolt and nut
  • Old phone power supply

Electronic


As the project is really simple the only electronic involved is the servo motor. I use the 5V output from the 2 pin of the RPi and the ground from the 6 pin. For the PWM signal I used the 7 pin as an output signal. The way to use a servo motor is by sending a PWM (Pulse-width modulation) to it. Normal servo will set the rotation angle of the arm depending on the width of the pulse. The signal need to be refreshed every 20 milliseconds. So in this case the Hitec servo require a refresh of 50 Hz and a width of 1 to 2 milliseconds  and the center position at 1.5 ms. For my project I used the sunny position to 40 degree and the rain position at 150 degree. For the power supply I used an old phone power supply that can offer up to 1.5 amps and I use it to power the RPi and the servo.

Mechanic


The mechanic involved in this projects is also not very complex, but as a software guy this is the part that take me the longer time. The project consist of a wooden base with a pivotal two arms display. I used the servo motor to move the arms so that it can display the current weather. I used a metal wire between the servo arms and the wooden arms. The most difficult part for me was to figure out how to make the display arms move correctly and I found that using the servo to do a linear displacement instead of a rotational move is easier to design. I also have some difficulties fixing the servo to the base using wood fixture and glue. This is not the final look I wanted for this device but with my limiting ressources and tools this is the best I can do so far. In the future I want to make the device more pretty and hide the arms of the display behind a wood panel and display the current weather by a windows. 


Software


I used Python with the Raspbian Linux OS to control the servo and fetch the current weather from the Yahoo server. The servo motor control is made by the Python default GPIO library that use a software implementation for the PWM signal generation. For the display, I make I request to fetch the current weather each 15 minutes but this can be easily changed to longer time because weather do not change that much here in Montreal. This is a very simple code and as it is my first Linux project, I took the opportunity to learn how to program bash scripts to install my software and to configure the auto start when the system boot. As I do not connect the HDMI display in normal operation I changed the code to set the position of the arms in the middle so that I can see it move to the current weather when the weather do not change between the last boot and know that the system is now running. The code is available on my GitHub account meteonotifier



No comments:

Post a Comment