Digital RPi LED Thermometer

by AndersSeverinsen in Circuits > Raspberry Pi

9617 Views, 92 Favorites, 0 Comments

Digital RPi LED Thermometer

thermo_still.jpeg
thermo_se.jpeg
thermo_change.jpeg
thermo_com2.jpeg

Raspbian OSLearn how i made this Digital LED Thermometer, with a Raspberry Pi Zero W, LED strip, an OLED Display, and a custom PCB.

It automatically cycles thought a list of cities, and displays the temperature on the OLED display, and the LED's. But you can also manually select a city to display, with the buttons on the side. On top of that, it will shut off the LED's and the OLED, if it's been inactive for a few minutes, and will turn back on, if it detects a significant light change (Controlled by an LDR).

Supplies

- A Raspberry Pi Zero W and SD-card with Raspbian OS

- A 1.5 Inch OLED Module by Waveshare

- A 5V 2.4A Power Supply for Raspberry Pi

- A 5m WS2812B LED Strip, 30 LEDs/m

- Screws, washers, bolts and standoffs.

- A Custom PCB, with buttons, a switch, an ldr, pin-headers, and more

- Soldering iron and solder

- Hot glue

- Wood glue

- 4mm and 6mm plywood

- 3mm white acrylic

Weather Data

weather_api-key.jpg

Credit to StuffWithKirby for his code on reading JSON weather data in python.

I collect the weather data free from OpenWeatherMap.org, where they supply weather data from a lot of the bigger cities, in a lot of countries.

1. Start by making a FREE account on OpenWeatherMap.org.

2. Then copy your api-key to use later.

3. Now download, unzip and open the city.list.json.gz file, and search for the cities you want displayed, and copy the city-id's for later.

Downloads

Setting Up the RPi and Writing the Code

thermo-code.jpg
thermo_background2.JPEG

First I connected the OLED to the Pi, and installed the necessary libraries for the OLED, as described by the manufacturer, here.

Make sure the RPi is connected to the internet

1. Enable the I2C and SPI function in raspi-config under Interfacing Options. Exit and reboot.

2. Run this to update:

sudo apt-get update

3. Run the following commands to install the necessary libraries:

sudo apt-get install python-dev
sudo apt-get install python-smbus
sudo apt-get install python-serial
sudo apt-get install python-imaging

4. Run the following command to open the configuration file:

sudo nano /etc/modules

Make sure the following two lines, are in the configuration file, then exit and reboot:

i2c-bcm2708
i2c-dev

5. Now run this to clone my GitHub repo:

git clone https:/ /github.com/Anders644PI/1.5inch-OLED-with-RPi .git

6. Go into the new folder, and unzip RPi_GPIO-0_6_5.zip:

unzip RPi_GPIO-0_6_5.zip

Run this to install the library:

cd RPi_GPIO-0_6_5
sudo python setup.py install

7. Go back to the main folder, by typing by typing:

cd /home/pi/1.5inch-OLED-with-RPi/

Or

cd ..

Then do the some with spidev-3_2.zip.

8. Then unzip wiringPi.zip:

unzip wiringPi
cd wiringPi

And run these commands:

chmod 777 build
./build

Check the installation with:

gpio –v

9. Go back to the main folder, and unzip bcm2835-1_45.zip

unzip bcm2835-1_45.zip
cd bcm2835-1_45

10. Then run this, to install the library:

./configure 
make 
sudo make check
sudo make install

11. Again go back to /home/pi/1.5inch-OLED-with-RPi/, and run this, to test the OLED:

cd /Demo_Code/Python/
sudo python main.py

Then i also had to install the libraries for the WS2812B LED-strip, following this guide.

After that it was just a matter of writing the code, which took about a couple of months from start to finish, working on it on and off. My code can be found on my GitHub here.

Configuring the Weather API

thermo_code_api.png

1. Cd into LED_Thermometer_Code_and_OLED_driver:

cd LED_Thermometer_Code_and_OLED_driver

2. Then open Official_Digital_LED_Thermometer_v1-0.py:

nano Official_Digital_LED_Thermometer_v1-0.py

And then scroll down and edit the api-key, to your api key, from openweathermap.org, as shown in the image above. Also change the city-ids and city names, to your desired locations.

The Custom PCB

thermo_pcb_make.gif
thermo_pcb.JPEG
thermo_pcb2.JPEG

After having figured out all of the electronics, I designed my own PCB, to have everything connected neatly together, and got it fabricated and shipped from China.

The Laser Cut Enclosure

thermo_laser_parts2.jpeg
thermo_laser_parts.jpeg
thermo_design_gif.gif
thermo_laser.gif

Then I modeled an enclosure, and laser cut it out of 4mm and 6mm plywood. I also modeled in LED diffusers, which I cut out of 3mm white acrylic.

After that I attached the electronics and the LED-strip to the laser cut plywood. And then assembled the enclosure, partly with glue and friction, so I can take it apart if i want to.

As an added detail, i also 3D-printed button and switch extensions, so they are easier to press.

All the files, can be found and downloaded from my GitHub. You may have to scale the SVG files down to 75%.

The Result

thermo_s_short.jpeg
thermo_closeup.jpeg
thermo_sw.jpeg
thermo_se_2.jpeg
thermo_nswe_2.jpeg

So I hope you like my build. I personally think it was a fun projekt to work on.

If you are interested in buying the pcb with components, feel free to DM me, and we can arrange something. Note that i only have a limited supply.

Follow my work on Instagram and Twitter.