Joystick Weather Clock, 15 months on

joystick-weather-clock

The original post for this project can be found here  A link to all the files on GitHub can be found here.

Following a suggestion from Alan Powell I decided to add a Humidity Sensor. The DHT11 is cheap and suited to this project. A lack of variable space meant that I was unable to save the data to the SD Card but as a bonus, the Humidity screen displays the Dew Point. See the end of this blog for more details.

Back in September 2015, I built this Joystick Weather Clock and it has sat on my desk recording pressure and temperature on an SD Card for fifteen months, without missing one hourly record. The data was stored as a CSV file so that it would load into EXCEL or similar spreadsheet program. I decided to see how it was faring after running all that time uninterrupted.

The fact that it was still saving data meant that there had been no stack overflow caused by unused variables filling up available free memory. The DS1307 Real time clock had not done too well, it was now 45 minutes fast, gaining around 38 seconds per week. The OLED display seemed to have lost a number of pixels and in places the display looked a little ragged, the LEDs used to light up under the display were still going strong. The pressure sensor was working perfectly.

So much for the hardware, what about the software? The calendar was perfect, having come through a leap year and the moon phase display was spot on. Data had been recorded exactly as designed and the whole file on the SD Card took up less than 4mb. Over 11,000 hourly temperature and pressure readings had been recorded and I believe this unit could run unattended for several years.

The pressure information was the most interesting, it was possible to follow the remains of a hurricane that hit the UK at the start of January 2016.

pressure-graph

The pressure had remained fairly stable at around 102000 pascals until New Year’s Eve, dropping to below 98000 pascals over four days. The result was high winds and flooding.

I am really pleased with the software side, but I feel that a better Real Time Clock module is needed. To protect the OLED I think some kind of simple Screen Saver is needed and I will add this in the new year sometime. The subroutines to calculate the calendar and moon phase have worked flawlessly and, although the data saved on the SD Card is OK, I think that a VBA routine for EXCEL to extract the Pressure and/or the Temperature data and to place it all in a single column is needed. This will allow a graph to quickly be drawn. Please note that the hourly data builds up throughout the 24 hours and only the data saved at  2300 hours contains all the days’ data.

One final addition would be to use a 5-volt power bank as a backup battery, it can be left plugged into the Arduino and would only be used if the mains power was lost. The software saves the last 48 hours in a temporary file on the SD card, if the power is lost then once power is restored this temporary data is loaded, but if the power is lost for more than one hour the data for the time during power down would be lost.

Adding another Sensor:

The Sketch uses 74% of the available space for variables and at 78% usage the Arduino  IDE starts to complain, so I have tried to keep below this figure. I decided to try to fit a Humidity sensor, following a suggestion from Alan Powell. The DHT11 although slow is quite cheap and as long as you don’t request data too often it should work well. I started by installing the library and the routine to read the Humidity data. That consumed very little precious variable space. I then added a new screen to display the data. Now I had a working Humidity screen that also displayed the Dew Point.

The DHT11 is a slow device that should not be addressed more than once every few seconds. I decided to save the Humidity value and only update it once an hour when data is saved to the SD card. When you display the Humidity screen the value could be up to an hour out of date, but simply press the joystick and the value is updated immediately.

I fitted a ChronoDot board with a DS3231 RTC chip, this is just a simply plug in replacement, I just needed to swap the SDA and SCL lines. No change to Library or Sketch is needed.

Heres to the next 18 months when I can see how well the new RTC performs.

humidity

The new Humidity screen, accessed by moving the Joystick one place left from the Analog Clock Screen. The age of the reading is shown and although this is updated once an hour it can be updated manually at any time by pressing the joystick switch in this screen.

The DHT11 has three pins 5v, OUT and GND. Connect 5v and Gnd to the Arduino and OUT to digital pin 12. While I was fitting the DHT11 I took the opportunity to swap the DS1307 RTC for a (hopefully) more accurate DS3231.

The picture at the top of this post shows the new ChronoDot RTC and DHT11 fitted to the clock.

weather-clock-wiring-diagram

Use this connection diagram in conjunction with the wiring instructions in the sketch. Check the pinouts on your devices before wiring as they may not match those shown above. The OLED will die instantly if not connected correctly.

BMP180 and the Raspberry Pi Version 2

  

Looking at this board it looks like the power can be between 3 and 5 volts, but I suspect that the SDA and SCL are 3.3 volts. That makes it ideal for the Raspberry Pi, as long as you remember to power it from the 3.3 volt pin. I connected the +pin to pin 1 on the Pi, the Gnd to pin 9, the SDA pin to pin 3 and the SCL pin to pin 5. I followed the Adafruit page here and although this is for the BMP085 it works just as well with the BMP180. Once I had installed the library I ran the python example simpletest.py using this

cd /home/pi/Adafruit_Python_BMP/examples

sudo python simpletest.py

However, I noticed that I never got the same reading for height and that was not what I needed with my weather balloon project. I started looking around the Internet and found a number of sites that would give you the height above sea level if you provide the pressure and temperature at sea level, you can visit that site here. Unfortunately you need to provide pressure at sea level, but again the Internet helps. I found a local meteorological site that had an iPad app, this app showed the area around where I live (on the South Coast of England) and four weather stations all within a few miles of me. These stations updated their sea level pressure and sea level temperature every 10 minutes or so. However, you should be able to find local pressure on the Internet.

If I entered the sea level pressure from the website (and not that reported by the Adafruit library), I got my correct height. It must be that the library uses the standard sea level pressure of 101325pa. A little bit more detective work and I found that if you call

sensor.read_altitude()

It will use the standard sea level pressure, but if you add the correct sea level pressure between the brackets like so

sensor.read_altitude(103554)

it gave the correct answer. I will send the actual sea level pressure to the sub routine that handles the BMP180 and completely ignore the sea level value provided by the library.

BMP180 and Raspberry Pi

Update: I found this gave incorrect readings, see this post for the method I used to correct problems with height measurements.

The I2C pins on my Raspberry Pi for the Weather Ballon project were tied up with a Real Time Clock. However, this stopped working after a week and so I decided to add the BMP 180 atmospheric pressure sensor. This would not only give the pressure but would provide an air temperature reading that the onboard thermometer in the radio could be compared against. There does not seem to be too much information on the Internet about using this sensor on the Pi and using Python, so I went over to the Adafruit site and followed their instructions.

I added the the library but as soon as I tried to run the script in IDLE it showed an error. When I tried the Adafruit example it worked perfectly as long as I ran the script directly. If I loaded into IDLE and tried to run it would not work. So, I made the alterations to my weather balloon script and saved the file. I shut down VNC and opened up connection via SSH. I use Serverauditor on my iPad, and once it was running I used the following commands:

Cd /home/pi/Weather_Balloon

Sudo Python remote_camera.py

Once the programme was running I could monitor the output from the slave on my iPad.

I made some alterations to the main control panel software running on my laptop and now the local pressure, sea level pressure and height (measured on the balloon) are shown. I am hoping to be able to show how pressure decreases with height above sea level.