Raspberry PI 2/3 Cloud Weather Station from Scratch

DIY, IoT Platform, , , , , , ,

With Raspberry PI device you can log temperature and humidity data outside, in room, greenhouse, lab, cooling room or any other places completely free. This example we will use to log temperature and humidity.

Device will be connected to internet via Wifi or Ethernet

You will be able to check latest readings on your mobile phone, desktop or any other device with browser

1. You need hardware parts to make logging device

Monitor with HDMI, HDMI cable, USB mouse and keyboard are also required for this tutorial but usualy you already have this

You can purchase needed devices here (minimal required):

Also nice to have:

I purchased this on Banggood.com

This also tested/works with industrial AM2305 sensor:

2. Add your device to LoggingPlatform

Here you can add your device to get api keys needed later: https://loggingforest.com/index.php/page/pricing

3. Hardware connection

Connect DHT22 Out to RaspberryPi in/out PIN GPIO 4

Connect DHT22 + to RaspberryPi 3V PIN 1

Connect DHT22 – to RaspberryPi Ground PIN 6

Diagram example:

 

Example Raspberry Pins:

 

4. Upload software needed to Micro SD card (Windows Guide)

Connect MicroSD to MicroSD input on your Windows PC, if you don’t have it then purchase usb version like:

USB Micro SD reader

Download Win32DiskImager here

Download Latest Raspbian OS for Raspberry PI here (Official Raspberry PI link)

Extract downloaded Raspbian OS archive with your archiver or 7zip:

Now you need to write Raspbian OS with Win32DiskImager to your MicroSD card:

So insert MicroSD into your reader and run Win32DiskImager:

Select your downloaded and extracted Raspbian OS image file, your MicroSD and click on Write:

NOTICE ON ISSUE: If you have troubles or strangely formatted MicroSD, or running this again, then before this you need to remove all volumes from drive and create only one. This can be done with Disk Management tool in Windows:

Now to show you how to easy configure Wifi conenction on MicroSD boot volume drive just create file (this is very helpfully for IoT devices)

wpa_supplicant.conf

and into file insert your credentials to connect like:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="YOUR_SSID_HERE"
    psk="YOUR_SECRET_PASSPHRASE_HERE"
}

Insert MicroSD into your Raspberry, connect it to monitor, mouse and keyboard and run it 😉

5. RaspbianOS, loading Python program to Raspberry and Configuration needed

When Raspberry boot up, you just need to configure it wit hnice wizard, example:

After that install some libraries for DHT22 so in terminal run:

sudo apt-get update
sudo apt-get install build-essential python-dev python-openssl git
git clone https://github.com/adafruit/Adafruit_Python_DHT.git && cd Adafruit_Python_DHT
sudo python setup.py install

Create file now with command:

Paste basic LoggingForest code from this page in file

and change parameters received on loggingforest.com website:

CTRL+X

Y

enter

For test now you can run this script:

With CTRL+Z you can stop this program

After that your device will start sending data to loggingforest and you can see it there

In loggingforest device edit just define parameters name and values:

Click on preview:

And you will see nice data:

Of course, you probably want to run this python script automatically when Raspberry will be started or connected to power source.

open terminal and run:

sudo nano /etc/rc.local

and before exit 0 add code to run your script:

sudo bash -c 'python /home/pi/dht22-api.py > /home/pi/dht22-api.log 2>&1' &



Save file with CTRL+X , Y, Enter

Try to restart your raspberry PI, and now it’s ready!

Feel free to comment and share your logger

You can also find other code versions in github rep:

https://github.com/sandiwinter/loggingforest/tree/master/RaspberryPi_Python

Facebook Comments