Rpi_status (The raspberry pi has got his hat on, Sort of)

tl;dr

As of writing this the raspberry pi zero is still hard to get hold of, Since I managed to snag one I thought I would put it some use. Also Hackaday/Adafruit gave me a kick up the arse with there Contest too.

I haven’t really done anything with raspberry pi GPIO before now. I had made a weather display with a atmega328, passing the data to it via serial from a python script running on a raspberry pi. I wanted to update this but using the raspberry pi GPIO instead of the atmega328. I went with a ssd1306 oled screen a few buttons and a WS2812 ring of LED’s and a BMP180 for temperature logging.

Hardware

Jpeg

  • 40 pin 90 degree headers
  • red 3mm LED
  • Push button x4
  • 220ohm resistor
  • WS2812 ring 8 LED’s
  • ssd1306 oled screen
  • BMP180

As I said above this is my first project to use the raspberry pi GPIO with python. I know that this project might be considered over kill by some and I could have just used a ESP8266. This wasn’t the point of the project, I just simply wanted to try developing on the raspberry pi. One of my bug bears with the raspberry pi is that Dropbox don’t make a client for the platform. I have found an alternatives which is open source and free, syncthing is slightly different then Dropbox because you host your own files. Lucky the software takes care of everything for you and the storage is practically unlimited.

I have incorporated my previous project the shutdown button into the project and added a reset button. The reset button shorts the run pin on your pi. The problem with the run pins is they are in different spots on the different pi’s, so I’m going to have a female header and connect the pins with jumper wires.

 

Software

Before we get started we need to install a few things. I followed the install instructions in the links

I’ve had to split the code into 2 camps. If you are using a raspberry pi zero you will know that you have to run raspbian jessie but if you’re using a raspberry pi original or 2 then there’s a good chance your still using raspbian wheezy. To check what version your running run this command


cat /etc/debian_version

If it returns 7.x then your on wheezy, If it returns 8.x then your on jessie

Rasbian jessie code

If you are running jessie on your raspberry pi then you will need to follow these steps

Since the release of jessie raspbian has moved over to systemd which changes the way you start code at startup.

Shutdown button code needs to run all the time because it needs to always check to see if the shutdown buttons been pressed. This script will be set up separate from the status screens script. The shutdown button code can be found on my github page.

  1. Place pishutdown.py in ‘/home/pi/shutdown’
  2. Make script executable with ‘sudo chmod +x script.py’
  3. Move pishutdown.service to /etc/systemd/system/
  4. Enable service ‘sudo systemctl enable pishutdown.service’
  5. Run service at boot ‘sudo systemctl start pishutdown.service’

Weather display code updates every 15 minutes and 1 minute after boot. The code can be found on my github page. You need to register as a developer on weatherunderground.com and add your api key to the code.

  1. Move ‘jessie_weather_screen.py’ to /home/pi/
  2. Make script executable with ‘sudo chmod +x script.py’
  3. Move both weather_screen.service and weather_screen.timer to /etc/systemd/system/
  4. Enable it with ‘sudo systemctl enable weather_screen.timer’
  5. Start at boot with ‘sudo systemctl start weather_screen.timer’
  6. Reboot when done

Temperature logging code also runs every 15 minutes and 1 minute after boot. The code can be found on my github page. You will need to sign up to be a developer on thingspeak.com and add your api key to the code for it to work.

  1. Move templogger.py to /home/pi
  2. Make script executable with ‘sudo chmod +x script.py’
  3. Move templogger.service templogger.timer to /etc/systemd/system/
  4. Enable service ‘sudo systemctl enable templogger.timer’
  5. Run service at boot ‘sudo systemctl start templogger.timer’

Rasbian wheezy code

If you are running wheezy on your raspberry pi then you will need to follow these steps

Shutdown button code needs to run all the time because it needs to always check to see if the shutdown buttons been pressed. This script will be set up separate from the status screens script. The shutdown button code can be found on my github page.

  1. Place pishutdown.py in ‘/home/pi/shutdown/’
  2. Make script executable with ‘sudo chmod +x script.py’
  3.  Edit ‘/etc/rc.local’ as root aka ‘sudo vi /etc/rc.local’
  4.  Add ‘sudo python /home/pi/shutdown/pishutdown.py’ before the ‘exit 0’ line
  5.  Save file and reboot pi

Weather display code runs every 15 minutes.The code can be found on my github page. You need to register as a developer on weatherunderground.com and add your api key to the code.

  1. Move ‘wheezy_weather_screen.py’ to /home/pi/
  2. Make script executable with ‘sudo chmod +x script.py’
  3. Edit crontab with ‘EDITOR=”vi” crontab -e’
  4. Add this line to end of file ‘0,15,30,45 * * * * sudo python /home/pi/wheezy_weather_screen_bmp.py’
  5. Reboot for good measure

Temperature logging code also runs every 15 minutes and 1 minute after boot. The code can be found on my github page. You will need to sign up to be a developer on thingspeak.com and add your api key to the code for it to work.

  1. Move templogger.py to /home/pi/
  2. Make script executable with ‘sudo chmod +x script.py’
  3. Edit crontab with ‘EDITOR=”vi” crontab -e’
  4. Add this line to end of file ‘0,15,30,45 * * * * sudo python /home/pi/templogger.py’
  5. Reboot for good measure

Videos

Hardware walk thought

Time lapse build video

Advertisements

3 responses to “Rpi_status (The raspberry pi has got his hat on, Sort of)

  1. Pingback: Pi Zero Weather HAT#piday #raspberrypi #pizero @Raspberry_Pi « Adafruit Industries – Makers, hackers, artists, designers and engineers!·

  2. Pingback: Pi Zero Weather HAT#piday #raspberrypi #pizero @Raspberry_Pi - Raspberry Pi News·

  3. Pingback: Rpi_status (The raspberry pi has got his hat on, Sort of) — Facelesstech – OSH Park·

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s