AtticTemp - Temperature / Climate Logger

9,601

117

16

About: 3D printing and designing RaspberryPI projects for a few years now

High tolerance temperature gauge and climate logger for your attic or other outdoor structures

Step 1: Flashing RaspberriPi Hard Disk / Install Required Software (Using Ubuntu Linux)

Download "RASPBIAN JESSIE LITE" https://www.raspberrypi.org/downloads/raspbian/

Create your new hard disk for DashboardPI

Insert the microSD to your computer via USB adapter and create the disk image using the dd command

Locate your inserted microSD card via the df -h command, unmount it and create the disk image with the disk copy dd command

$ df -h /dev/sdb1 7.4G 32K 7.4G 1% /media/XXX/1234-5678

$ umount /dev/sdb1

Caution: be sure the command is completely accurate, you can damage other disks with this command

if=location of RASPBIAN JESSIE LITE image file of=location of your microSD card

$ sudo dd bs=4M if=/path/to/raspbian-jessie-lite.img of=/dev/sdb (note: in this case, it's /dev/sdb, /dev/sdb1 was an existing factory partition on the microSD)

Setting up your RaspberriPi

Insert your new microSD card to the raspberrypi and power it on with a monitor connected to the HDMI port

Login

user: pi pass: raspberry

Change your account password for security

sudo passwd pi

Enable RaspberriPi Advanced Options

sudo raspi-config

Choose: 1 Expand File System

9 Advanced Options

A2 Hostname change it to "AtticTemp"

A4 SSH Enable SSH Server

A7 I2C Enable i2c interface

Enable the English/US Keyboard

sudo nano /etc/default/keyboard

Change the following line: XKBLAYOUT="us"

Reboot PI for Keyboard layout changes / file system resizing to take effect

$ sudo shutdown -r now

Auto-Connect to your WiFi

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the following lines to have your raspberrypi automatically connect to your home WiFi (if your wireless network is named "linksys" for example, in the following example)

network={ ssid="linksys" psk="WIRELESS PASSWORD HERE" }

Reboot PI to connect to WiFi network

$ sudo shutdown -r now

Now that your PI is finally on the local network, you can login remotely to it via SSH. But first you need to get the IP address it currently has.

$ ifconfig Look for "inet addr: 192.168.XXX.XXX" in the following command's output for your PI's IP Address

Go to another machine and login to your raspberrypi via ssh

$ ssh pi@192.168.XXX.XXX

Start Installing required packages

$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get install vim git python-requests python-smbus i2c-tools python-imaging python-smbus build-essential python-dev rpi.gpio python3 python3-pip libi2c-dev

Update local timezone settings

$ sudo dpkg-reconfigure tzdata

select your timezone using the interface

Setup the simple directory l command [optional]

$ vi ~/.bashrc

add the following line:

$ alias l='ls -lh'

$ source ~/.bashrc

Fix VIM default syntax highlighting [optional]

$ sudo vi /etc/vim/vimrc

uncomment the following line:

syntax on

Step 2: Clone Project / Install Software Drivers

Clone Project repository

$ cd ~

$ git clone https://github.com/khinds10/AtticTemp.git

DHT22 Install

$ cd ~

$ git clone https://github.com/adafruit/Adafruit_Python_DHT.g...

$ cd Adafruit_Python_DHT/

$ sudo python setup.py install

$ sudo python ez_setup.py

$ cd examples/

$ vi simpletest.py

Change the following line:

sensor = Adafruit_DHT.DHT22

Comment the line out

pin = 'P8_11'

Uncomment the line and change the pin number to 16

pin = 18

Run the test

python simpletest.py

You should see a metric reading of Temp and Humidity displayed on the command line.

SSD1306 Install

Extract drivers/SSD1306.zip to the project folder

Install the Driver

$ cd ssd1306/
$ sudo python setup.py install

Confirm your device registers, usually it's \0x3c on the i2c bus

$ sudo i2cdetect -y 1

0 1 2 3 4 5 6 7 8 9 a b c d e f 00:
-- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Run the demo to confirm your display is in working order

$ cd examples/ $ python demo.py

Step 3: Supplies Needed

RaspberriPi Zero

DHT22 temperature-humidity sensor

0.96" I2C IIC SPI Serial 12864 OLED LCD LED White Display Module

2.4" 400x240 16:9 Serial:UART/I2C/SPI TFT Touchscreen Display

Step 4: Wire the Device

SSD1306 Display

GND -> GND

DATA -> SDA

CLK -> SCL

VCC -> 3V

Digole Display

GND -> GND

DATA -> SDA

CLK -> SCL

VCC -> 3V

DHT22 Humidistat

VCC -> 5V

GND -> GND

DATA -> GPIO 18 / PIN 12

Step 5: Build the Device

Cut Plexiglass to fit the front of the device under the 3D printed frame

Mount the glass with screws through the 3D printed frame

Step 6: Build the Device (cont...)

Hot Glue Components against the front panel

Wire Unit inside

Mount the back and it should be ready to go

Step 7: Configure Application to Run Correctly in Settings.py Config File

Find the file settings.py and adjust to your current settings

# forecast.io API key for local weather information

weatherAPIURL = 'https://api.forecast.io/forecast/'

weatherAPIKey = 'YOUR API KEY FOR FORECAST.IO'

# optional for running the remote temp/humidity logger

deviceLoggerAPI = 'mydevicelogger.com'

# search google to get the Latitude/Longitude for your home location

latitude = 41.4552578

longitude = -72.1665444

Step 8: Setup Scheduled Scripts

$ crontab -e

Add the following lines:
*/7 * * * * python /home/pi/AtticTemp/displays.py

OPTIONAL: Temp Logger to API script each 10 minutes

$ crontab -e

Add the following lines:
*/10 * * * * python /home/pi/EnvironmentClock/temp-check.py

Step 9: OPTIONAL: Creating Your Own Weather Images to Render on the Display

Upload your own 128x128 file to the following URL:

http://www.digole.com/tools/PicturetoC_Hex_converter.php

Choose your image file to upload, add what size you want it to be on the screen (Width/Height)

Select "256 Color for Color OLED/LCD(1 byte/pixel)" in the "Used for" dropdown

Obtain the hex output.

Add the hex output to a display/build/ header (.h) file, use the other ones as guides for syntax.

Include the new file in the digole.c file #include "myimage.h

Include a new command line hook to your image file in the. Note: the command below is saying draw your image at position 10 pixels over 10 pixels down. You can change it to different X,Y coordinates, you can also change the values 128,128 to whatever size your new image actually is.

} else if (strcmp(digoleCommand, "myimage") == 0) { drawBitmap256(10, 10, 128, 128, &myimageVariableHere,0); // myimageVariableHere is defined in your (.h) file }

Now rebuild (ignore the errors) below to have your new image render with the following command.

$ ./digole myimage

Re-Building [Included] Digole Display Driver for your optional changes

$ cd display/build

$ gcc digole.c

$ mv a.out ../../digole

$ chmod +x ../../digole

Step 10: Finished!

Share

    Recommendations

    • Sensors Contest

      Sensors Contest
    • Beauty Tips Contest

      Beauty Tips Contest
    • Pets Challenge

      Pets Challenge

    16 Discussions

    0
    None
    ionei

    Question 3 months ago

    Probably a mistake on my part, but I see nothing for Step 1. See attached screen shot.

    Capture.JPG
    3 answers
    0
    None
    khinds10ionei

    Answer 3 months ago

    oh wow, that step builder tool is crazy. step 2 is step 1, ha!

    0
    None
    ioneikhinds10

    Reply 3 months ago

    wow, one of us seems to be a time traveller. I hadn't realized how long instructables has been around. Check out the time stamp on this exchange.

    Capture2.JPG
    0
    None
    ioneikhinds10

    Reply 3 months ago

    thanks! It seemed that way but I wasn't quite sure...

    2
    None
    LarryS55

    4 months ago

    A small environmental station with a touchscreen display is a neat project, but it seems like overkill for the purpose. I built a remote temperature/humidity sensor with just an ESP01 and a DHT22. The ESP only costs a couple dollars compared to $60+ for the pi and displays. It uploads the data to adafruit.io where I can see history or create triggers based on temp/humidity (my plan is to control a smart plug powering a humidifier). I can monitor my sensor(s) from my phone with a MQTT dashboard.

    6 replies
    0
    None
    rchLarryS55

    Reply 4 months ago

    In this particular case, this project is using a Raspberry Pi Zero, which costs about $5-$10. Even the Raspberry Pi Zero W that has bluetooth and WiFi is only about $10 also.

    0
    None
    ioneirch

    Reply 3 months ago

    Where do you find Pi Zero W for that price? (Lowest price I find is twice that and probably a cheap chinese counterfeit.)

    0
    None
    rchionei

    Reply 3 months ago

    I have bought more than 1 Raspberry Pi Zero W for $10 on eBay, and the Pi Zero without wireless on eBay is generally 5 to 7 dollars.
    Since the Raspberry Pi operates using open source, some people think of it in the same light as the Arduino, which has open sourced not only the software, but also the board itself. Raspberry Pi does not allow their board into the open source arena, but they do publish their schematics for their boards.
    While this could lead to counterfeits, I have not heard of this being a problem. There are, however, many Single Board Computers out there that look and function very closely to the Raspberry Pi, but they are not clones, per se.

    0
    None
    ioneirch

    Reply 3 months ago

    thanks! I will search 'harder' in the future and try to catch these good deals. And I can hope that any 'replicas' work pretty much the same. I am a newbie regarding the programming and any incompatibilities would probably stump me.
    Thanks again!

    0
    None
    LarryS55LarryS55

    Reply 3 months ago

    OK on second thought... a $5 Pi Zero W (if you can get it) vs. a $3 ESP8266... now that's a tiny price jump for a lot more capability. Maybe it's the display I really don't see the need for.

    0
    None
    charlessenf-gm

    Question 4 months ago

    "Why have a screen on the device when it is in the attic?"
    I have to ask this as well.
    Why have anything in the hot cold dusty dirty difficult to access attic save the sensor and the circuitry requisite to transmitting the data down into some 'conditioned' space. Perhaps to a home office computer or to the home wifi and onto the Internet?

    0
    None
    LesB

    Question 4 months ago

    What does this do?
    Presumably "logger" implies that cumulative data is recorded. Is the data recorded in the hard disk or memory chip? Can it be downloaded into a PC?

    0
    None
    pgs070947

    4 months ago

    Comprehensive project.
    Attics/loft/roof-spaces are the forgotten areas in a house and I log temperatures there as well.
    Unventilated roof-spaces can turn into tropical forests if left neglected. A combination of humidity from the living areas, cold felt, can soon lead to trouble.
    In summer, I've recorded temperatures under the tiles of 60-degrees Celsius and even in winter, the tiles can get to 25-degrees on sunny days, providing a useful heat source.
    Of course it's useful to have a display.

    0
    None
    carltonwb

    Question 4 months ago on Step 10

    Followed the instruction and worked first time out.
    I have a silly question though. Why have a screen on the device when it is in the attic.
    In my area it can get to 150F+ during the summer and a screen seems out of place.

    I am going to try one that will integrate into my hass.io setup.
    Thanks for the great work.

    1 answer
    0
    None
    khinds10carltonwb

    Answer 4 months ago

    Hey that's great! Already somebody trying it. You had the same parts to assemble and 3D print? the plastic plexi- glass really isn't needed, just trying something new. The DHT22 can read up to 176*F.