How Too Peripherals Python Tutorials

Small Meteo station

Post Reply
raspberrypi / howtoo     Views: 33314Prev .. Next
Small Meteo stationPosted: Thursday, February 16, 2017 [16:42:31] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
This is a small station that measures temperature, atmospheric pressure and air humidity.

Post 87281351 Image 1

Ventilated Sun protector made out of drain cap and down coupler from Home Depot along with 2 inch PVC pipe.

Post 87281351 Image 2

All data brought inside and Raspberry Pi sitting under the counter in the kitchen. Only USB power comes to it VIA BackUPS.

Post 87281351 Image 3

sorry for the picture quality.. it's too dark under the counter.

I'll add sensor's hook-up info later-on.There's no place like ~
Small Meteo station - HardwarePosted: Thursday, February 16, 2017 [18:35:03] - 2
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Sensors used:
AM2302 Humidity and atmospheric pressure sensor
BMP180 Barometric Pressure/Temperature/Altitude Sensor

Post 87288103 Image 1
AM2302 pins connection:
Pin 1 (red) to Pin 1 (+3.3V) on RPi
Pin 2 (white) to Pin 7 (GPIO 4) on RPi
Pin 4 (black) to Pin 9 (Ground) on RPi
* No resistor was used as stated on many reviews

Post 87288103 Image 2
BMP180 pins connection:
VIN (red) to Pin 17 (+3.3V) on RPi
GND (black) to Pin 9 (Ground) on RPi
SCL (green) to Pin 5 (SCL1/I2C) on RPi
SDA (orange) to Pin 3 (SDA1/I2C) on RPi

Post 87288103 Image 3

just as simple as that
Hot glue is used to keep jumper wires.There's no place like ~
Small Meteo station - AM2302 and BMP180 setupPosted: Thursday, February 16, 2017 [19:10:37] - 3
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Setup I2C interface for BMP180:
https://learn.adafruit.com/using-the-bmp085-with-raspberry-pi/configuring-the-pi-for-i2c
install software from GitHub and test it.

Setup AM2302:
learn.adafruit.com

When everything works and checked both sensors are read in one sweep by Perl and reported to the server for storing in database.
View Code#!/usr/bin/perl
use strict;
our %sendfl;our $f;
our $hum = `/usr/bin/python /home/pi/Desktop/meteo/humid.py 2302 4`;
$hum =~ s/\n|\r|\*//g;
$hum =~ s#(\-\d{1,3}\.\d{1,2}|\d{1,3}\.\d{1,2})(\s)(\d{1,3}\.\d{1,2})#$&#;
our $temp = $1;
our $humidity = $3;
if($temp) {
$sendfl{'temp.outside.txt'}=$temp;
} else {
if($temp < 1 && $temp > -1) {
$sendfl{'temp.outside.txt'}=$temp;
}
}
if($humidity) {$sendfl{'humidity.txt'}=$humidity;}
our %dread;
$hum = `/usr/bin/python /home/pi/Desktop/meteo/pressure.py`;
while($hum =~ /(.*?)( = )(.*?)(\n)/gs) {$dread{$1} = $3;}
my %fnames = (
'Altitude','altitude',
'Pressure','pressure',
'Sealevel Pressure','sealevel.pressure',
'Temp','temperature.kitchen'
);
my %dconv = (
'Pressure','pressure',
'Sealevel Pressure',
'sealevel.pressure'
);

my $sh;
foreach $f (sort keys(%dread)) {
($dread{$f},$sh) = split(/ /,$dread{$f});
if($dconv{$f}) {
$dread{$f} *= .00750061561303;
$dread{$f} = sprintf("%0.0f",$dread{$f});
} ## END IF CONVERT REQUIRED

unless($f =~ m/sealevel|altitude/i) {
$sendfl{"$fnames{$f}.txt"}=$dread{$f};
}
}
## Check connection to the server
my $dcheck = `/bin/ping -c 1 -r -t 5 192.168.1.12`;
sleep(6);
unless($dcheck =~ m/1 packets transmitted\, 1 received/) {
exit(0); ## Exit if there is a network problem
}

our $urlsendd;our $report;
foreach $f (sort keys(%sendfl)) {
$urlsendd = "http://user:password\@192.168.1.12/report.cgi";
$report .= `/usr/bin/curl --connect-timeout 30 -F f=$sendfl{$f} -F fn=$f $urlsendd`;
$report .= " \: $sendfl{$f}\n";
} ## FOREACH FILE END
if($report) {
chomp $report;
open(RPRT,">/home/pi/Desktop/meteo/curl.report.txt");
print RPRT "$localtime\n$report\n";
close(RPRT);
}
exit(0);


Then Perl script added to the cron jobs for every 15 minutes run as root.
As Perl runs as root, no sudo required to run Python from within Perl script to get data from GPIO pins.

Output of Python scripts was a bit modified to get formatted data in Perl.There's no place like ~
Small Meteo station RPi framePosted: Thursday, February 16, 2017 [19:31:14] - 4
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
This is a 3D view of the frame for Raspberry Pi 3:

Post 87291474 Image 1

Download STL file for your 3D printer:
https://www.codemacs.com/downloads/frame.stlThere's no place like ~
Small Meteo station - Spacers 3DPosted: Friday, February 17, 2017 [16:43:59] - 5
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
This is a 3D view of spacers used to assembly the Sun protector made of drain couplings.

Post 87367839 Image 1

and STL file download for 3D printer:
https://www.codemacs.com/downloads/spacers.stl

This is a Home Depot parts used in this project:

View Code611942112562 1INX2FT PVC $2.16
1"X2' PVC PIPE
052063344072 4X3 COUPLING

4"X3" SEWER/DRAIN COUPLING D3034 PVC
[email protected] $5.60

0000-225-866 4IN CAP $2.10
4" SEWER/DRAIN CAP D3034 PVC

611942038190 PVC BUSHING
1-1/4"X1" PVC BUSHING SPGXS
[email protected] $2.64

SUBTOTAL $12.50
SALES TAX $0.76
TOTAL $13.26


enjoyThere's no place like ~
RE: Small Meteo stationPosted: Friday, December 27, 2019 [13:29:16] - 6
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
This is a part of a Weather station:
www.codemacs.com/coding/p..There's no place like ~
raspberrypi / howtooPrev .. Next
 
Post Reply
Home - Raspberrypi: How Too Peripherals Python Tutorials
Our Telegram Group