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.

Advertisements

TEA5767 FM Radio with IR control and OLED Display

TEA5767 with IR and OLED

The sketch for this project can be found on my GitHub page here.

My last blog used the little FM radio, TEA5767, with a two line LCD and keypad display. I felt that it was a little clumsy and so decided to use an Infra Red controller and display the radio data on an OLED Display. I have gone for a number of preset stations and not to use the scan function. As it stands the sketch has six preset stations and the infra red remote is used to switch between them. There is also a favourite station button, press this and the radio tunes straight to your favourite. Two other buttons on the IR controller allow fine tuning up or down, this increases or decreases the frequency by 0.1 mHz.

The display:

TEA5767 OLED 1.

The radio wil automatically switch from Stereo to Mono if the signal strength drops to a level that affects sound quality. The display shows the audio mode, in this case it has switched to mono. The radio reports the signal strength and this is shown as a figure from 1 to 10. The third row shows the frequency the radio is tuned to, this is the value reported by the radio, for example a value of 102.0 mHz had been sent to the radio, but the radio had tuned to 101.99 mHz. The next row down is the station name and the last row is the tuning scale from 80 mHz to 110 mHz, a cursor shows the frequency.

Connections:

The TEA5767 and the OLED Display are I2C, connect Vcc and Gnd to the Arduino 5volts and Gnd. Connect SDA to Arduino pin A4 and SCL to Arduino pin A5. The infra red receiver has three connections, Vcc, Gnd and signal. Connect the signal, or data out, to Arduino data pin 3 and Vcc and Gnd to Arduino 5 volts and Gnd. Connect a flying lead to Arduino digital pin 3, this will be used to switch the display to the IR decode display. Almost any IR controller can be used and the sketch allows a setup mode to be entered, and this displays the decimal value of the key press. Decide which keys you are going to use for Preset Up, PresetDown, Favourite, fineTuneUp, finetuneDown and Radio On/Off. Put the sketch into setup mode by connecting the flying lead from pin 3 to Gnd, point the controller at the IR receiver and press a key (the onboard LED will light) and its value will be displayed as shown below. Press the key a few times to confirm the value and once you have all the key values needed put them into the sketch.

TEA5767 OLED 2

Adding the station names and frequencies:

Make a list of up to six stations you want to listen to (this can be increased or decreased by changing the values of stationMHZ[n]  and stations[n] where n is the number of preset stations + 1. Station names and frequencies are stored in these arrays, for example:

stationsMHZ[1] = 88.58;
stations[1] = “BBC Radio 2”;
stationsMHZ[2] = 96.10;
stations[2] = “Radio Solent”;

the maximum number of preset stations and the favourite are set as follows:

maxPresets = 6; // number of stations in list, change this as required
favourite = 6; // select your own favourite

The favourite station will play when power is first applied.

TEA5767 libraries:

I found a number of libraries on the internet, but settled on this one by Marcos R. Oliveira and this is the library I have used here. I have included a copy of this library on my GitHub page as shown at the top of this blog.

 

Arduino Tape Measure with OLED Display

The Sketch can be downloaded from my GitHub page here.

Ultrasonic1

This project uses an HC-SR04 Ultrasonic Transmitter/Receiver to measure a distance up to about 100 cm or 3 feet. The result is displayed on a small OLED Display.

The sketch includes a fairly common routine to measure distance in centimeters which is then displayed on a 128 x 64 OLED display. The distance to the object is printed on the Serial Monitor in both Centimeters and inches. A Bar graphic at the bottom of the screen displays the distance, and this is divided by 10cm tick marks.

Ultrasonic2

To even the readings out, five readings are taken and the average calculated and this helps keep the display reasonably steady. I use the U8Glib and this can be downloaded from Google Code here. The connections for the OLED display and the HC_SR04 Ultrasonic unit are shown in the sketch. The SSD1306_128X64 OLED is an I2C device and it is important to connect the power supply correctly as the display will not survive  a polarity reverse.

/***********************************************************
*
* Arduino Tape Measure with OLED Display
*
* By Chris Rouse Nov 2015
*
* HC-SRO4 Connections:
* VCC connection of the sensor attached to +5V
* GND connection of the sensor attached to ground
* TRIG connection of the sensor attached to digital pin 2
* ECHO connection of the sensor attached to digital pin 3
*
* OLED Connections:
* VCC +5v
* GND GND
* SDA Analog pin 4
* SCL Analog pin 5
*
*
********************************************************/

#include "U8glib.h"
#include <SPI.h>
#include <Wire.h>
// setup u8g object
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE); // I2C
//
const int trigPin = 2;
const int echoPin = 3;
long duration, inches, cm, avgCm;
String longString="";
int tapeLength = 0;

void setup() {
Serial.begin(9600);
Wire.begin();
}

void loop() {
avgCm = 0;
for(int f = 0; f <5; f++){ // average out 5 readings
ultrasonic();
avgCm = avgCm + cm;
}
cm = avgCm/5;
//draw loop
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
delay(50);
}

void ultrasonic()
{
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
}
long microsecondsToInches(long microseconds)
{
return microseconds / 74 / 2;
}
long microsecondsToCentimeters(long microseconds)
{
return microseconds / 29 / 2;
}
void draw(void){
u8g.setFont(u8g_font_profont12);
u8g.drawStr(5,8, "Arduino Tape Measure");
if(cm > 110){
longString = "---";
tapeLength = 0;
}
else{
longString=String(cm)+ "cm";
tapeLength = cm;
}
const char* newData = (const char*) longString.c_str();
u8g.setFont(u8g_font_profont29);
u8g.drawStr(30,40, newData);
// now draw tape
for(int f = 10;f <120; f = f+10){
u8g.drawLine(f,48,f,61);
}
for(int f = 2; f< tapeLength+3; f++){
u8g.drawBox(f,50,1,10);
}
}

Remote Bluetooth Thermometer with OLED Display.

Part 2 describing the Receiver is here.

The code for this project can be downloaded from my GitHub page here.

This is a version of an earlier post I made, using HC05 and HC06 Bluetooth modules to make a wireless thermometer. This project uses an OLED Display on the receiver.

This post details the construction and setting up of the transmitter. I have used an Arduino Uno, but a Mega or even Nano could be used. The HC05 can be powered from 3 to 5 volts, but the Tx and Rx lines are 3 volts only. A logic level converter, like this one from Hobbytronics, which has a 250ma 3volt regulator that can be used to power the HC05.

Parts List:
Arduino Uno
HC05 Master/Slave Bluetooth
Bidirectional Logic Level Shifter
TMP36 thermometer

bluetooth transmitter

The connection diagram is shown above, connect a flying lead to the KEY pin unless your breakout board has a small push button fitted. This will be used to switch the HC05 into command mode.
Once the circuit has been built upload the hc05_command_mode.ino sketch. Connect the KEY pin to 3.3 volts (or press the small push button if one is fitted) and apply power, Once the sketch is running remove the connection to the KEY pin (or release the small push button if one is fitted). The HC05 should now be in command mode, running at 38400 baud, check this by opening the Serial Monitor, (set to 9600 and NL/CR) and type in AT and click SEND, OK should be shown.

To set the HC05 up to act as a Master Unit, with it in the command mode enter the following commands into the Serial Monitor, pressing SEND each time.

AT+ORGL this resets the HC05 to factory settings
AT+ROLE =1  this sets the unit to Master
AT+INQM=1,9,48. this allows up to 9 Bluetooth units to be able to connect
AT+CMODE =1  this sets the connection mode to allow any unit to connect
AT+UART=9600,0,0 this sets the baud rate to 9600

Once these commands have been entered remove the power. Now build the receiver.

 

DHT22 Humidity Sensor with OLED Display for Arduino

DHT22

See The blog using an Si7021 here.
See the blog using a DHT11 here.

The sketch for this project on my GitHub page here.

This is the third in a series of Humidity/Temperature sensors for the Arduino and using an OLED Display. The DHT22 is more accurate than the DHT11, has a wider humidity range and can measure negative temperatures.

There is an in depth discussion of humidity sensors sensors here and the relative accuracy of different sensors as well as methods used to test them is shown. There are a number of libraries available for using this sensor with an Arduino, but I found the one used in the Arduino Playground and available on GitHub here to work well and is the one I have used.

The OLED Display shows temperature in both Centigrade and Fahenheit as well as Humidity in percent and Dew Point in centigrade. I have used the U8Glib library for the OLED Display and the code uses much of the code used for the Si7021 project.

Connect the OLED AS follows, taking care to connect the power supply to the display correctly, Vcc to 5 volts and Gnd to Gnd, as reversing the power will destroy the display. Connect SDA to Arduino pin A4 and SCL to Arduino pin A5. Connect Vcc on the DHT22 to Arduino 5volts, the Gnd to Arduino Gnd. Connect the Data Out on the DHT22 to Arduino pin 2.

Upload the sketch and the display should be as shown in the picture at the top of this page. The reading is updated every 2 seconds as this is the fastest recommended for this sensor.

Comparison with the Si7021

The first obvious difference is size, the Si7021 is a fraction of the size of the DHT22. The DHT22 can only be read once in 2 seconds, but the Si7021 seems to have no such restrictions. Although the Si7021 is about three times more expensive than the DHT22 on eBay, it is about the same cost as the DHT22. Without a doubt the Si7021 wins hands down and the extra accuracy provided makes it the sensor of choice, even though it is more expensive.

DHT 11 Humidity Sensor with OLED Display

 

See the blog using the Si7021 here.
See the blog using the DHT22 here.

The sketch for this project on my GitHub page here.

I wanted to see how the DHT11 compared with the Si7021 Humidity Sensor. As I already had the circuit set up for the Si7021 it did not take long to modify it for use with the DHT11.

There is an in depth discussion of humidity sensors here and the relative accuracy of different sensors as well as methods used to test them is shown. There are a number of libraries available for using this sensor with an Arduino, but I found the one used in the Arduino Playground and available on GitHub here to work well and is the one I have used.

The author of the library included a method to calculate Dew Point, using Humidity and Temperature, and I have included this in my sketch.

The OLED Display shows temperature in both Centigrade and Fahenheit as well as Humidity in percent and Dew Point in centigrade. I have used the U8Glib library for the OLED Display and the code uses much of the code used for the Si7021 project.

Connect the OLED AS follows, taking care to connect the power supply to the display correctly,  Vcc to 5 volts and Gnd to Gnd, as reversing the power will destroy the display. Connect SDA to Arduino pin A4 and SCL to Arduino pin A5. Connect Vcc on the DHT11 to Arduino 5volts, the Gnd to Arduino Gnd. Connect the Data Out on the DHT11 to Arduino pin 2.

Upload the sketch and the display should be as shown in the picture at the top of this page, the output is also sent to the Serial Monitor to help with debugging. The reading is updated every 2 seconds as this is the fastest recommended for this sensor.

Comparison with the Si7021

The first obvious difference is size, the Si7021 is a fraction of the size of the DHT11. The DHT11 can only be read once in 2 seconds, but the Si7021 seems to have no such restrictions. Although the Si7021 is about three times more expensive than the DHT11 on eBay, it is about the same cost as the DHT22. Without a doubt the Si7021 wins hands down and the extra accuracy provided makes it the sensor of choice, even though it is more expensive.

MAX6675 Thermocouple with OLED Display

image

The code for this project can be downloaded from my GitHub page here.

In an earlier Blog I here used a MAX6675 Thermocouple board and used the Serial Monitor to display the results. I have now connected the board to an OLED display.

The output from the MAX6675 is very erratic (at least in my case) and to get a reasonably stable reading I read the output from the thermometer twenty five times to give an average reading. This slows down the screen update, but does not interfere with the thermocouple response. So, for example, put the probe into a hot cup of coffee and the display will jump in a number of steps to the final reading. This has not proved to be a problem in practice.

The OLED display is connected to 5 volts, Ground and SDA is connected Arduino pin A4 (on a UNO) with SCL connected to Arduino pin A5 (on a UNO). I have used the library from Adafruit for the MAX6675 and if pin2 and 3 are set as OUTPUTS they can be used to supply power to the MAX6675 and the board can be simply be plugged into header pins 2 to 6. Check that the connections on your board match the pins in the Sketch.

In particular check the OLED connections, I have had a number of these with various pin connections making it impossible to swap displays without changing the wiring. I have destroyed three displays this week by not paying enough attention. Reversing the power supplies kills the display immediately.

The MAX6675 library can be downloaded from the Adafruit GitHub here.

This thermometer can display in either Centigrade or Fahrenheit, a variable at the head of the code centigrade, if set to true will display temperature values in Centigrade. If set to false, values in Fahrenheit will be displayed. The line of code to change is


boolean centigrade = true; // set to false for readings in Fahrenheit

The maximum temperature reached is shown on the top left and the minimum temperature is shown on the top right.