Categories

Raspberry Pi; Thermometer.

= I created this page after the creation of the thermometer, during the process I lost some info, pictures and so on… will keep updating it till have a sort of summary of what and how =

= click on any picture to make it bigger =

malina_caramel

Thermometer = malina =

Just wanted to know the temperature in an easy way, as well as a short time rain forecast prediction, and also keep track of the changes in time.
So I created a thermometer with a couple of raspberry pi, few sensors and some easy scripts.
Data is extracted from the sensors connected to both raspberries. And from a couple of websites I check its reliability.
Then is sent to a graphite server running in one of the raspberries.
Results can be seen by the phone, running a small script, or from the graphite charts.

As mention, this is not for commercial use, but for personal use… as well as a way to learn/refresh a bit of electronics and informatics knowledge.

Some example outputs.

Screenshot_2014-07-28-08-26-46~2 graphite1  dht11_graph

First steps.

There are easy steps for the initial set up of the raspberry pi (download the image, extend to the total size of the card, network settings…).
I may explain it in another post, but there is plenty of information out there.

First sensor I tried to use a DHT11 and follow, more or less, the advise from this link.
Then I move into more sensors and use graphite as data base as well of  a way to represent the data gathered.

I will recommend not use the DHT11 but the DHT22 instead, very little price increase, but better temperature range and more realistic humidity values.
Also, if the sensor is outside, will be good to get a nice cover as rain may affect the reading values.

Checking the values from the website vs the sensors.

sensorvsweb.jpg.png    openvsbuien_b.jpg

  • Checking the temperature and humidity values gathered from the sensors vs the values gathered from the web (first screenshot above);

Green and pink are the humidity and temperature of buienradar.nl (gather each hour).
Blue and red are the equivalent series obtained from the sensor data (gather each five minutes).

  • Checking the pressure values, from two websites and from the sensor (second screenshot);

For Amsterdam; in green openweathermap, in red buienradar and in violet the bmp085 data (may be a bit high since my apartment is over sea level, therefore, has less air pressure).

How to install graphite.

I know I changed some of the things that I will mention bellow, but at this moment I am not quite sure of which ones… will take a deep look later on, but so far here are som of the instructions I follow to get graphite installed on the raspberry pi.

# update
sudo apt-get update
# switch to root user
sudo -i
# install python dependencies
apt-get install python-pip python-cairo python-django python-django-tagging python-twisted
# install apache
apt-get install apache2 libapache2-mod-wsgi libapache2-mod-python
# install graphite
pip install whisper
pip install carbon
pip install graphite-web

After that some configuration is needed...

# switch to graphite config directory and copy the example configs
cd /opt/graphite/conf
cp carbon.conf.example carbon.conf
cp aggregation-rules.conf.example aggregation-rules.conf
cp storage-aggregation.conf.example storage-aggregation.conf
cp relay-rules.conf.example relay-rules.conf
cp storage-schemas.conf.example storage-schemas.conf
cp dashboard.conf.example dashboard.conf
cp graphTemplates.conf.example graphTemplates.conf
cp graphite.wsgi.example graphite.wsgi
cd /opt/graphite/webapp/graphite
cp local_settings.py.example local_settings.py
# uncomment timezone setting (default is CST, but we're in PST)
sed -i 's/\#TIME_ZONE/TIME_ZONE/g' local_settings.py
nano -w local_settings.py
# find and uncomment DATABASES = … block
python manage.py syncdb
# answer prompts - yes, blank for default username (root), enter email address, enter password (e.g. raspberry)
chown -R www-data:www-data /opt/graphite/storage/
# configure Apache
wget https://raw.github.com/tmm1/graphite/master/examples/example-graphite-vhost.conf -O /etc/apache2/sites-available/graphite
# change default socket path from /etc/httpd/wsgi which doesn't exist to /var/run/apache2
sed -i 's/\/etc\/httpd\/wsgi\//\/var\/run\/apache2\//g' /etc/apache2/sites-available/graphite
# set django root path
sed -i 's/@DJANGO_ROOT@/\/usr\/lib\/python2.7\/dist-packages\/django/g' /etc/apache2/sites-available/graphite
# enable graphite website
a2ensite graphite
# restart apache to apply changes
service apache2 reload

Next figure shows roughly the structure that I used initially to store temporary the data...

graphite_data

TIP: all graphite directories are bellow the opt folder. I am not sure why (permissions, incorrect path… ) but, sometimes after boot the raspberry, it does not start fine. It does when the file /opt/graphite/carbon-cache-a.pid contains the pid number of the process id assigned to the carbon daemon. If is not the case, I stop (kill) carbon, remove that file, and start carbon manually. Some useful instructions (to apply depending of the situation);

 /opt/graphite/storage $ cat carbon-cache-a.pid
/opt/graphite/storage $ top | grep carbon
/opt/graphite/storage $ rm carbon-cache-a.pid
/opt/graphite/storage $ sudo kill 2185
/opt/graphite/storage $ sudo /opt/graphite/bin/carbon-cache.py start

Guess my _graphit does not have yet rights on the /opt/graphite/storage… since first case, of the ones bellow, does not work, and second does;

/opt/graphite/storage $ top | grep carbon
2191 _graphit  20   0 24860  10m 1888 S   1.3  2.3   0:00.42 carbon-cache
/opt/graphite/storagtop | grep carbon
2723 root      20   0 25616 9.8m 1548 S   0.3  2.2   0:00.05 carbon-cache.py

TIP: To set up the retention time for the data stored by graphite, you need to edit the file /opt/graphite/conf/storage-schemas.conf. More information in this link.
As an example;

[malina]
pattern = ^malina\.
retentions = 900s:7d,3600s:1095d

So keeping samples every 15 minutes for 7 days, and a sample every hour during 3 years. To see if that will be valid, we can check that the result of 3600/900 has no decimals. So, we will keep more than 17.500 data samples for each one of malina´s sensor.

If you change the retention, and you want to keep the old data, you need to resize the old data, as explained in here.
As example;

/opt/graphite/storage/whisper/malina/bmp085 $ sudo whisper-resize.py pressure.wsp 60s:30d 900s:1095d
Retrieving all data from the archives
Creating new whisper database: pressure.wsp.tmp
Created: pressure.wsp.tmp (1779880 bytes)
Migrating data without aggregation…
Renaming old database to: pressure.wsp.bak
Renaming new database to: pressure.wsp

Scripts.

The thermometer uses scripts written in python, C++ and Java.

When ruing it automatically, it uses few cron tasks. Next lines list the crontab for normal and sudo users. The APC was a more than 10 years device for measure temperature and humidity in a cabinet (where I store the rasbperries).

$ crontab –l
# Temp interna i lectures sensors
*/10 * * * * ./intemp.sh
#
# Temp APC (calaix transformadors i del menjador)
*/10 * * * * ./apc.sh
#
# Lectures web
(aqui depen si volem llegir dades de les webs automaticament)
 
& sudo crontab –l
*/10 * * * * sudo /home/pi/scripts/get22.sh
*/10 * * * * echo `date +\%Y\%m\%d\%H\%M\%S`,`/home/pi/wiringPi/dht11` >> /home/pi/temp.log
*/10 * * * * echo `/home/pi/wiringPi/dht11_humidity`>>/home/pi/dht11_humidity.log
*/10 * * * * echo `/home/pi/wiringPi/dht11_temp`>>/home/pi/dht11_temp.log
 
$ cat intemp.sh
PORT=2003
SERVER=graphite
echo “malina.rasp.temp `echo “scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000″ | bc` `date +%s`” | nc ${SERVER} ${PORT}
echo “malina.bmp085.temp `python /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085/BMP085_temp.py` `date +%s`” | nc ${SERVER} ${PORT}
echo “malina.bmp085.pressure `python /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085/BMP085_pressure.py` `date +%s`” | nc ${SERVER} ${PORT}
echo “malina.dht11.temp `tail /home/pi/dht11_temp.log -n 1` `date +%s`” | nc ${SERVER} ${PORT}
echo “malina.dht11.humidity `tail /home/pi/dht11_humidity.log -n 1` `date +%s`” | nc ${SERVER} ${PORT}

$ cat apc.sh
PORT=2003
SERVER=graphite
#echo “apc.ap9319.temp1 `snmpget -v1 -c public 192.168.1.19 1.3.6.1.4.1.318.1.1.10.3.13.1.
echo “apc.ap9319.envprobe1.temp `snmpget -v1 -c public 192.168.1.19 1.3.6.1.4.1.318.1.1.2.1.1.0 -Oqv` `date +%s`” | nc ${SERVER} ${PORT}
echo “apc.ap9319.envprobe1.humidity `snmpget -v1 -c public 192.168.1.19 1.3.6.1.4.1.318.1.1.2.1.2.0 -Oqv` `date +%s`” | nc ${SERVER} ${PORT}
echo “apc.ap9319.envprobe2.temp `snmpget -v1 -c public 192.168.1.19 1.3.6.1.4.1.318.1.1.2.1.3.0 -Oqv` `date +%s`” | nc ${SERVER} ${PORT}
echo “apc.ap9319.envprobe2.humidity `snmpget -v1 -c public 192.168.1.19 1.3.6.1.4.1.318.1.1.2.1.4.0 -Oqv` `date +%s`” | nc ${SERVER} ${PORT}

When running it manually, it uses next shell script…

dades.sh

echo =============================
echo = Termometre MALINA =
echo =============================
date
echo
echo Al menjador…
echo “temperatura_1: `python /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085/BMP085_temp.py`oC”
echo “temperatura_2: `sudo /home/pi/scripts/dht_temp 22 17`oC”
echo “pressio: `python /home/pi/Adafruit-Raspberry-Pi-Python-Code/Adafruit_BMP085/BMP085_pressure.py`hPa”
echo “humitat: `sudo /home/pi/scripts/dht_humi 22 17`%”
echo
ssh pi@192.168.1.5 sudo /home/pi/Documents/scripts/dades.sh
echo
echo Mirant la web…
gpio -g write 22 1
sudo java ServeiMeteo -b
sudo java RainFrcst -b
gpio -g write 22 0

It uses crontab to get the data automatically at the schedule intervals.

Added the ssh key from the external unit and the keyring of the internal, so it can connect without using the password.
For doing that I follow next steps at malina´s prompt.

ssh-keygen
ssh-copy-id -i pi@valdema
(It will once ask for the password of the host system)
test ssh with… ssh pi@valdema

ServeiMeteo and RainFrcst are two java scripts I created to get the information from internet sites.
The parameter -b is to show the values at the screen, but also send them to graphite.
The version for the scheduler only sends the values to graphite.

Creating a board for the sensors from the ‘internal’ raspberry pi.

setup

After a while, I thought that having the sensors hanging was not so nice arranged, so I bought a normal prototype board and weld the sensors there.
The way that I did it, allows modify the ports to wehere are connected, split ports into several connectors and so on.

Next diagram and pictures show a bit the distribution of the sensors at the external board, as well as the connections to the GPIO (I extended all ports from the raspberry to the board, and leave empty the ones not used at this moment).

malina_extension_ver2   board_label_final    back

I put out some LED´s although not clear yet for what I want them. So far I do that every time that the script connects to internet all turn on during that time.
I just added “gpio -g write 22 1” at the beguining of the sh that gets the data, and the same command with 0 at the end.
The GPIO 22 sends the signal to one of the 6 connectors and from there, to a cable to each one of the leds connections.
Signal goes through a resistor of 220 ohms, then to the cathode of the led, and I connected the anode to the ground.

Next diagram shows it with a bit more detail.

leds_ver2    20140716_203635

How to check the leds:

  • I started connecting the resistor+led to the Vcc of 3.3v and to the ground, to check that the led is ok and turns on.
  • Then you can do… where 22 is the port used…

sudo su
cd /sys/class/gpio
echo 22 > export
cd gpio22
echo out > direction
echo 1 > value

Last line will put the led on. To put it off, change the 1 for a 0.

  • Finally, as mention, I used the raspberry pi wire libraries, so with the gpio write/read I have enough for my sh script. For example the gpio -g write 22 1 will set the LEDs on. If that does not work after boot the raspberry, try to do the step above first.

You can see some easy py scripting at… http://www.raspberrypi.org/forums/viewtopic.php?f=32&t=77775
As some documentation mentions, the easier way of programming a game was… make a led blink randomly, ask the user to memorize it and ask then the numbers of blinks it had.

External unit = vadelma =

I did add another raspberry with some sensors, which are also sending the information to graphite.

IMG-20140420-WA0015 20140806_203850

Some of the instructions used…

After install the os, and expand it to the complete card, add the correct location…

Then modify the wireless settings…
sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf_original
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

… and the normal network settings…
sudo cp /etc/network/interfaces /etc/network/interfaces_original
sudo nano /etc/network/interfaces

.. get the updates…
sudo apt-get upgrade

… getting the adafruit code…
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
cd Adafruit-Raspberry-Pi-Python-Code/
cd Adafruit_DHT_Driver
gcc Adafruit_DHT.c -o dht
sudo ./Adafruit_DHT 22 4

… getting bcm2835 code…
mkdir bcm2835
cd bcm2835/
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.25.tar.gz
gunzip bcm2835-1.25.tar.gz
tar xvf bcm2835-1.25.tar
cd bcm2835-1.25
./configure
sudo make install
cd sensors/
cd Adafruit_DHT_Driver
make
sudo ./Adafruit_DHT 22 4

… some other instructions that I used…
tail filename.log -n 2
sudo chmod 777 filename.sh

The scripts for the external unit.

The last two are just modifications of the examples provided…

dades.sh

echo “Al balco…”
echo “temperatura: `/home/pi/Documents/scripts/dht_temp 22 4`oC”
echo “humitat: `/home/pi/Documents/scripts/dht_humi 22 4`%”
#echo “llum:”
sudo python /home/pi/Documents/scripts/light_both.py

light_both.py

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.IN)
GPIO.setup(15, GPIO.IN)
input_value_1 = GPIO.input(14)
input_value_2 = GPIO.input(15)

#per el script normal a linia de comandes
if input_value_1==0:
  print (‘canal 1 detecta llum’)
else: print (‘canal 1 no detecta llum’)

if input_value_2==0:
  print (‘canal 2 detecta llum’)
else: print (‘canal 2 no detecta llum’)

The scripts dht_temp and dht_humi are the same as before, only the part already compiled.

To run it automaticaly there is a task scheduled each 5 minutes, at sudo crontab, as follows…

*/5 * * * * sudo /home/pi/Documents/scripts/getData.sh

Where getData.sh contains…

#graphite server
PORT=2003
SERVER=192.168.1.2
#gathering, and sending, data from the internal raspberry
echo “vadelma.rasp.temp `echo “scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000″ | bc` `date +%s`” | nc ${SERVER} ${PORT}
#gathering, and sending, data from the dht22
echo “vadelma.dht22.temp `/home/pi/Documents/scripts/dht_temp 22 4` `date +%s`” | nc ${SERVER} ${PORT}
echo “vadelma.dht22.humidity `/home/pi/Documents/scripts/dht_humi 22 4` `date +%s`” | nc ${SERVER} ${PORT}
#gathering, and sending, data from the light sensor
echo “vadelma.light.ch1 `sudo python /home/pi/Documents/scripts/light_1.py` `date +%s`” | nc ${SERVER} ${PORT}
echo “vadelma.light.ch2 `sudo python /home/pi/Documents/scripts/light_2.py` `date +%s`” | nc ${SERVER} ${PORT}

And the pyton scripts light_1.py and light_2.py are very similar to light_both.py, but with only the data of one of the sensors…

As an example, light_1.py will be as follows…

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.IN)
GPIO.setup(15, GPIO.IN)
input_value_1 = GPIO.input(14)
input_value_2 = GPIO.input(15)

#per enviar el resultat del canal 1
if input_value_1==0:
  print (‘1’)
else: print (‘0’)

The light sensor BH1750FVI seems can measure it from 0 till 65535 lx .

Added sun rise and set times.

I had also curiosity about when the day starts and when  it finishes, based on the sun light.
For that I added a small script at malina which calculates those values; at which time the sun rises and at which time is the sun set.
Although the Java programs till now were home made… this time I have found some interesting code at the web as  “sun-moonriseset” and especially “SunMoonCalculator”.

I used that second one, adding only a few lines, as explained bellow.

To input the date/time automatically…

long ts = System.currentTimeMillis();
Date localTime = new Date(ts);
String format = “yyyy/MM/dd HH:mm:ss”;
SimpleDateFormat sdf = new SimpleDateFormat(format);

// entering the date…        
int year = Integer.parseInt(sdf.format(localTime).substring(0,4));
int month = Integer.parseInt(sdf.format(localTime).substring(5,7));
int day = Integer.parseInt(sdf.format(localTime).substring(8,10));
int h = Integer.parseInt(sdf.format(localTime).substring(11,13));
int m = Integer.parseInt(sdf.format(localTime).substring(14,16));
int s = Integer.parseInt(sdf.format(localTime).substring(17,19));

… to calculate the offset (UT difference plus the day light savings)…

int adj = TimeZone.getDefault().getOffset(ts)/3600000;

… and finally, to show it at the screen (the value adj is added to the hours at getDateAsString) …

System.out.print(“Sol (A’dam) “);
System.out.print(arrow_up+”:”+sunriseset.getDateAsString(smc.sunRise, adj));
System.out.println(” “+arrow_down+”:”+sunriseset.getDateAsString(smc.sunSet, adj));

This seems to work and, although the script can do much more things that I may use later on, so far it gives approximated enough values for the sun rise and the sun set.

If it is daylight, the set is for the same day and the rise for next day. So ading a “java sunriseset” instruction to the “dades.sh” we get now…

sol        google_sun      google_sun_barcelona

The last screens shows the google answer for “sun rise sun set amsterdam” and for “sun rise sun set barcelona”, in order to compare the results.

I used next values for the  longitude – latitude; 4.55 – 52.21 (for Amsterdam) and  2.1 – 41.23 (for Barcelona).

Moon age and cycle.

Well, since I had already the last script which tells the age, in days, of the moon… I rounded it to one decimal and and put some conditionals to check in which cycle is.

The age of the moon is the duration, in number of days (d), hours (h), and minutes (m), between one new moon and the following one. The average value is 29 days 12 hours 44 minutes and is called a synodic month. As found at the links bellow, each of the 4 lunar phases is roughly 7 days (~7.4 days) each, but varies slightly due to lunar apogee and perigee.

So next code was added to the script…

// moon age
double edatLluna = Math.round(smc.moonAge*10.0)/10.0;
System.out.println(“Edat de la lluna: ” + edatLluna+” dies.”);
// moon cycle
if (edatLluna < 7.4){System.out.println(“Fase de lluna nova.”);};
if ((7.5 < edatLluna)&&(edatLluna<14.8)) {System.out.println(“Fase quart creixent.”);};
if ((14.9 < edatLluna)&&(edatLluna<20.2)) {System.out.println(“Fase conte Lluna plena.”);};
if ((20.3 < edatLluna)&&(edatLluna<29.7)) {System.out.println(“Fase quart minvant.”);};

It shows now as follows…

LlunaPhase

Smoke detector.

Since malina is running all the time at the living room, I decided to add also silent smoke detector. If smoke is detected, it will add a line to the script dades.sh alerting of the smoke (so will know it when running the script remotely out of the house), and also will turn on a led. Found this nice tutorial that will follow.

Weather station.

Recently I bough, at the local store, a “model unit” of an old weather station (Alecto WS-5000) for around 30% of the total price. I did connect, the indoor unit, to the raspberry and sent also the data to the graphite server. Found this code; pywws, that was very useful. And here some more information about how to install it. Also Juanmi  helped me out with my Linux and Python questions and sent me lots of improvements that I should implement !!! (my code looks crappy, but this is a learning experience for me).

My weather station looks like that one…

First I did connect the internal unit to the raspberry with the usb cable (have not need extra power, and the raspberry uses a usb-wifi at the other USB port).

Did install the python-usb package…

pi@malina ~/pywws $ sudo apt-get install python-usb
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
python-usb
0 upgraded, 1 newly installed, 0 to remove and 93 not upgraded.
Need to get 17.7 kB of archives.
After this operation, 132 kB of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main python-usb armhf 0.4.3-1 [17.7 kB]
Fetched 17.7 kB in 0s (45.8 kB/s)
Selecting previously unselected package python-usb.
(Reading database … 91688 files and directories currently installed.)
Unpacking python-usb (from …/python-usb_0.4.3-1_armhf.deb) …
Setting up python-usb (0.4.3-1) …

Then the pywws software…

pi@malina ~/pywws $ sudo pip install pywws
Downloading/unpacking pywws
Downloading pywws-14.06.1.tar.gz (423Kb): 423Kb downloaded
Running setup.py egg_info for package pywws
warning: no files found matching ‘*.md’
no previously-included directories found matching ‘src/doc/api’
Installing collected packages: pywws
Running setup.py install for pywws
warning: no files found matching ‘*.md’
no previously-included directories found matching ‘src/doc/api’
Installing pywws-livelog script to /usr/local/bin
Installing pywws-hourly script to /usr/local/bin
Installing pywws-version script to /usr/local/bin
Installing pywws-testweatherstation script to /usr/local/bin
Installing pywws-setweatherstation script to /usr/local/bin
Installing pywws-reprocess script to /usr/local/bin
Installing pywws-livelog-daemon script to /usr/local/bin
Successfully installed pywws
Cleaning up…

Checking the connection to the weather station…

pi@malina ~/pywws $ sudo python -m pywws.TestWeatherStation
23:10:22:pywws.Logger:pywws version 14.06.1
0000 55 aa 00 00 00 00 14 08 24 11 12 14 08 28 13 34 1e 20 02 20 09 00 00 00 00 00 00 3c 03 00 9c 41
0020 bc 27 c0 27 00 00 00 00 00 00 00 14 09 09 23 10 41 23 c8 00 00 00 46 2d 2c 01 64 80 c8 00 00 00
0040 64 00 64 80 a0 28 80 25 a0 28 80 25 00 b4 00 00 68 01 00 0a 00 f4 01 12 00 b8 c5 2d 0a 01 0a 03
0060 01 55 47 2a 63 00 2e 01 cb 00 f4 00 00 00 f4 00 00 00 bc 00 00 00 f4 27 fe 26 14 28 1e 27 0e 00
0080 1f 00 1e 00 45 00 45 00 45 00 45 00 00 14 08 26 04 04 14 09 08 14 04 14 08 24 06 45 14 08 23 20
00a0 27 14 09 03 13 23 14 08 25 08 22 14 09 05 15 31 14 08 23 20 27 14 09 05 15 31 14 08 23 20 27 14
00c0 08 28 17 48 14 08 23 20 27 14 09 03 11 21 14 08 26 05 30 14 09 03 11 21 14 08 26 05 30 14 08 31
00e0 16 22 14 08 31 14 14 14 08 24 01 03 14 08 23 20 27 14 08 23 23 36 14 08 23 20 27 14 08 23 23 36
pi@malina ~/pywws $

Disconnecting and connecting the weather station we can see more info about the model…

pi@malina ~/pywws $ tail -f -n 0 /var/log/kern.log
Sep  9 23:13:30 malina kernel: [92928.844425] usb 1-1.3: new low-speed USB device number 6 using dwc_otg
Sep  9 23:13:30 malina kernel: [92928.958275] usb 1-1.3: New USB device found, idVendor=1941, idProduct=8021
Sep  9 23:13:30 malina kernel: [92928.958307] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Sep  9 23:13:30 malina kernel: [92928.982948] hid-generic 0003:1941:8021.0002: hiddev0,hidraw0: USB HID v1.00 Device [HID 1941:8021] on usb-bcm2708_usb-1.3/input0

Created the rules and booted the raspberry, as recommended at the documentation of pywws…

pi@malina ~/pywws $ sudo nano /etc/udev/rules.d/39-weather-station.rules

After install pywws, I created two small scripts: compare.sh and pywws_graphite.py.

A crontab entry will make run daily at 23:45 the compare.sh.

Next screen show the compare.sh … and the rough pywws_graphite.py (I removed all comments, and also is not very neat yet, sorry).

compare2_sh pywws_graphite_py

Next screen shots show the execution of ran manually the compare.sh script, and how things look at graphite…

executant_compare   pywws_graphite

Comparing the information gather from the Weatherstation versus the data gather from the cheap sensors connected to the raspberries…

tempWSvsSensors   pressureWSvsSensor

Next steps…

  • Crate all-in-one board for the external sensors.
  • Will try to create the remote unit using the all-in-one board above, and an arduino board connected via wifi to a local network, sending the data through internet to the graphite server. Using the CC3000 WiFi chip and may be the nano v3. Something similar as explained here , and here (but sending the data to graphite). Taking out the common costs of the power supply and the sensors used, for all options, we may reduce the cost, using the nano,  in a 30% (although the down sides are that a WIFI adapter alone cost the same as a Raspberry, and with the nano you cannot do as much as with the raspberry). Taking a quick look to the options for the external unit, using a raspberry the costs are around forty six euro (26 € Rasp + 10€ WIFI + 10€ SD card + sending costs) against the thirty two euro using the arduino nano (6€ NanoV3 + 26€WIFI). A third option will be not use the wifi for the nano, but this 433mhz transceiver at the nano, and the receiver at the raspberry (to send/receive the data). Cost for this last option will be of around nine euro in total (6€ NanoV3 + 3€ for the 433 MHz transciver). So using the wifi adaptor will be good when using internet to connect to an external unit (as in another country), while using the transceiver will be good for when the external unit is at the same home. Will need still to check out if the bmp085 (or the new bmp180), and the BH1750FVI can work with this fake nano. Also, if it is not need to use the wifi for the nano, it can be used this Ethernet adapter.
  • To get the wind direction, it can be used a 3d printed vane with inside a compass, a mini controller and the 433 rf to send the data to the raspberry.

Components

Some other links:

URLs with weather data
Amsterdam´s rain forecast (buienradar.nl)
Netherlands (Asmterdam) actual weather (buienradar.nl)
Amsterdam and Barcelona actual weather (openweathermap.org)

GPIO connectors
Raspberry Pi Rev2 P1 Connectors

Drawing electronic circuits
TinyCad

Resistors
Calculator three bands
Codes for four, five and six bands resitors

Graphite
Raspberry Pi, control of the fermentation

SSH connections with public keys
SSH Authentication

Taking data from a wireless weather station
Software (pywws)
Implementation to feed a mysql , more info in here.
Website templates

Lightning maps (an interesting project… not used in here)
blitzortung.org …is a lightning detection network for the location of electromagnetic discharges in the atmosphere (lightning discharges) based on the time of arrival (TOA) and time of group arrival (TOGA) method. It consists of several lightning receivers and one central processing server…

About the Moon
Lunar Phase
About Moon Phases
Current Moon Phase
Full moon cycle

Spanish AEMET weather data… is not free anymore (Spanish article at the news paper).

Weather links
MeteoCat
PortOlimpicBCN
BuienRadarADAM

An interesting set up from October 2014 in here.

Sergi – 2014

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.