This post describes how I setup a basic ADS-B receiver on a Raspberry PI Zero W using a USB RTL2832U based Software Defined Radio so that you can see any ADS-B equipped aircraft in your local area and present it on your own website.
Lets Encrypt is a new Certificate Authority (CA), run for the public’s benefit by the Internet Security Research Group (ISRG). At the time of writing it’s currently in Beta and is due to go public in December 2015.
Update: Lets Encrypt went into public -beta on December 3 2015. I have updated this article with the minor change needed to work with the live servers.
Now in the default mode, the standard Lets Encrypt client (it’s not the only one) can manage this automatically – however it’s not ideal if you have more than one server.
What I describe here is how to centralize managing certificate registration (& later renewal) on a central machine. When a certificate is then registered or renewed we can then copy the certs to the remote servers.
Some time ago I created a weather station using a Raspberry PI and an off the shelf weather station, connecting the two via USB.
However, for some time not I’ve been meaning to create a weather station from scratch – i.e. one or more Raspberry PI’s which connect to the network (via Ethernet or WiFi) and directly monitor the sensors directly.
Now the problem here is that some sensors are analog – for example the leaf, soil and UV sensors I have generate an analog signal so we need an ADC (Analogue to Digital Converter) which the Raspberry PI doesn’t have.
So we have two possible solutions:
- Add a Raspberry PI compatible ADC
- Use an Arduino
With the parts I have available, the Arduino won, not just on available ADC channels but also with the additional digital ports available.
Now how to connect it to the PI? Well the easiest way is to use USB, however the PI only has two USB ports (one for the Model A) and as I’m intending to use Model A’s for the final station I need that for WiFi (there won’t be room or power for hubs) so USB is out.
There’s RS232 which both support, however the PI runs on 3v3 whilst the Arduino (UNO) is 5v so I need to add a level converter between the two. It also limits me to just one arduino and I might need to use more than one so another solution is needed.
Weather webcams are always popular and it is easy and free to set one up yourself. This article will show how to setup a simple USB webcam to produce still images and serve them on a local apache webserver.
I had this problem of debugging some xml but when reading the output of some log4j it was almost impossible to read so I needed some way of prettifying the xml quickly.
For this example I have the following xml:
<?xml version="1.0"?><xml><iq xmlns="jabber:component:accept" from="email@example.com/client" id="iq_257" to="service.retep.org" type="get"><query xmlns="some:namespace"/></iq></xml>
So how do we pretify this in emacs?
Well the first thing to do is to write an extension function & place it into your ~/.emacs file. Placing it here means that when you open emacs the extension is available:
(defun xml-format () (interactive) (save-excursion (shell-command-on-region (mark) (point) "xmllint --format -" (buffer-name) t) ) )
Now this works by passing the buffer to the xmllint utility and replaces it with the output – in this case nicely formatted xml.
Now we need to install xmllint:
pi@lindesfarne: ~$ sudo apt-get install libxml2-utils
Ok so now open emacs and open the xml. To format first select the xml you want to format then Press Escape then x followed by xml-format & press return. You should then get the xml nicely formatted:
<?xml version="1.0"?> <xml> <iq xmlns="jabber:component:accept" from="firstname.lastname@example.org/client" id="iq_257" to="service.retep.org" type="get"> <query xmlns="some:namespace"/> </iq> </xml>
In the first article I covered how to install a weather station on a Raspberry PI. In the second part I’ll cover how to get it to upload data on an hourly basis to a website using FTP.
Getting the station to run hourly
First we need to get the station to run hourly. To do this I created a script called weatherupload which I placed under /usr/local/bin
pi@kell: ~$ sudo vi /usr/local/bin/weatherupload
Enter the following:
#!/bin/bash cd /usr/local/weather python Hourly.py -vvv data
Once saved make it executable and then edit the main crontab:
pi@kell: ~$ sudo chmod +x /usr/local/bin/weatherupload pi@kell: ~$ sudo vi /etc/crontab
At the end of the file you need to add the following:
0 * * * * root /usr/local/bin/weatherupload
Save it and now every hour it will now run.
Note: I’ve placed it there and not under /etc/cron.hourly because
- cron.hourly runs once an hour, but not necessarily at the top of the hour. I a later article when I add twitter you want the tweet to be close to 0m rather than at a random time.
- I’ve found in the past that using crontab -e doesn’t always work, even for root but in the core crontab it just works
Uploading to a website
First to generate the graphs pywws uses gnuplot so we need to install it:
pi@kell: ~/sudo apt-get install gnuplot
Next we need to add some details to the stations weather.ini file. At the top theres a section called paths. Make sure those point to the relevant templates and graph_templates directories in your pywws install.
Next under the hourly section you should see a pair of lines:
plot =  text = 
You need to add the plots and pages that need to be generated:
plot = ['7days.png.xml', '24hrs.png.xml', 'rose_24hrs.png.xml', 'rose_7days_nights.png.xml'] text = ['current.html', '24hrs.html', '6hrs.html', '7days.html', 'feed_hourly.xml', 'allmonths.html']
Finally theres the ftp section which needs configuring with the remote ftp server (your web host will give you these):
[ftp] secure = False site = ftp.example.com local site = False user = email@example.com directory = /weather/ password = mypassword
That’s about it. Now when you run the hourly script it will generate some simple pages & images to your website.
You can see an example of this over at maidstoneweather.com – although the uploaded templates only form part of that site.
One of the reasons for having multiple PI’s was to have one take over duties from an aging ITX based Linux box of reading from a USB Weather station and uploading the data to both it’s website and WeatherUnderground.
Unfortunately this project got pushed forward when, last Thursday morning, the ITX box decided to die on me. I think it’s power supply finally gave out after 9 years of service.
So this is the first part of a series on setting up a USB weather station onto a Raspberry PI.
Continue reading “Installing a USB Weather Station on a Raspberry PI Part 1”