Introduction: JAWS: Just Another Weather Station

About: Started electronics as a hobby in the seventies, studied it in late seventies, begin 80's, bought my first arduino last november. Love Instructables!

What is the purpose?

Since my junior years, I'm very interested in weather. The very first data I collected was from an old, mercury-filled thermometer that hung outside. Every day, for months on a row, I wrote the temperature, date and hour in a small book.

But as it goes, I guess, after a few months I started to neglect it... Every now and then I forgot to take notes...

At school (junior high?) we had some lessons about weather. There was an old weather hut in the garden, with thermometers, hydrometers and barometers.

Since then, I crazed about weather and climate...

Thanks to Arduino, things got way easier :-)

Step 1: JAWS: What We Use

What do we need for our JAWS?

First of all, an Arduino.I use a Mega2560, since it needs lots of programming and data...

We take data from a BMP180: pressure and temperature.

We need an outdoor temperature sensor, that also gives the humidity. I use DHT 22 for it, as it also goes below zero. I used a second one that measures the same indoors.

Then we need a clock. By mistake I took a DS1307... Why by mistake? Because it is not that accurate. I'll replace it by a DS3231, which has a temperature-controlled crystal.

We want to save all our readings, so I use an SD-card reader and an SD card.

For reading our data, initially I used a 2004LCD and a 12864LCD. After more than two years I changed those with a 3.5" TFT LCD (like the one in the pictures).


To avoid having a breadboard lying around, I bought some expansion boards and some extra male and female headers.

Other things we need: a wind speed-meter, a way to see the wind direction and something to measure the amount of rain falling.

Those I have too, but getting data from them will be a work of the future...

Step 2: JAWS: Getting Our Stuff Ready.

It is quite simple to make such a JAWS.

You get your sensors, you throw them together on boards, and you start to used the libraries that come with the sensors.

Lets start with the setup of the program.

Since I'm Dutch speaking (native speaker) all the data and much of the variables I use are in Dutch. So now you have the chance to learn another language...


What do we want from JAWS?

Easy: we want to watch a screen that show us the actual time, date, ephemerides (sun up, sun down, length of the day and the astronomical noon).

Next to that, it would be nice to see the inside and outside temperature, the relative humidity and dewpoint, and the air pressure.

To make things easier, I use centigrades for temperature and hPa (=mBar) for pressure. So no-one has to calculate back from Fahrenheit or pounds per square furlongs...

At this time, only these data are available...

In the future, I'll add Air speed, wind direction and precipitation.

The idea is that I'll have an outside weather hut and all the data will be sent over 2.4GHz to the indoor unit.

Step 3: JAWS: Software.

To get to our software, most can be found with existing libraries.

In JAWS I use the following ones:

  1. SPI.h: The original library from Arduino for 4 wire protocol. Her it's used for the TFT-shield
  2. Adafruit_GFX.h and MCUfriend_kbv.h: both used for the graphics and screen. These make it very easy to write text, draw lines and boxes on the TFT-screen.
  3. dht.h: for our DHT's: this library can be used for DHT11 (the blue one) and DHT22.
  4. Wire.h: the Arduino library to make serial communication easy. It"s used for the clock and the SD card.
  5. SD.h: Again an Arduino original, to write and read from the SD card.
  6. TimeLord.h: this one I use for keeping time, calculating sun set or sun rise from any geographical position. It also set the clock for DST (summer or wintertime).

Let's start with the clock.

When reading out a clock, you need the variables you get from the different registers inside the clock module. When we make them more than just numbers, we can use the following lines:

const int DS1307 = 0x68;
const char* days[] = {"Zo.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Za."};

const char* months[] = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};


With TimeLord, we get this as data, for my place: (Lokeren, Belgium)

TimeLord Lokeren; setting it up
Lokeren.Position (51.096, 3.99); longitude and latitude

Lokeren.TimeZone(+1*60); GMT +1 = +1 x 60minutes

Lokeren.DstRules(3,4,10,4,60); DST from 3rd month, 4th week to 10th month, 4th week, +60minutes

int jaar= year +2000;

byte sunRise[]= {0,0,12,monthday,month,year}; start calculating every day from 00 hours

byte sunSet[]={0,0,12,monthday,month, year}; same as above

byte maan[]={0,0,12,monthday,month,year}; same as above

float phase;

From here, the calculations are made.

phase = Lokeren.MoonPhase(maan);

Lokeren.SunRise(sunRise);

Lokeren.SunSet(sunSet);

Lokeren.DST(sunRise);

Lokeren.DST(sunSet);

int ZonOpUur=sunRise[tl_hour];

int ZonOpMin = sunRise[tl_minute];

int ZonOnUur = sunSet[tl_hour];

int ZonOnMin = sunSet[tl_minute];

This is the example of how things are calculated in TimeLord. With this library, you get (pretty) accurate times of sunset and sunrise.


At the end, I'll put the entire program with this Instructable. It's pretty straight-forward.

Step 4: More Software...

More about the software...

We have three big parts in the software.

1) We get some raw data from our different sensors: from our clock, DHTs and BMP180. That's our input.

2) We need to translate the data to (1 and 0) to something that makes sense. For this, we use our libraries and variables.

3) We want to read and store our data. That's our output.For immediate use, we have our LCD-TFT, for later use, we have our saved data on our SD card.

In our loop(), we get a lot of "GOTO's": we jump to the different libraries. We get our data from one of the sensors, get the data and store them in (mostly) a floating data variable. We choose our variable-names wisely, not with x or y but with names like "tempOutside" or "pressure" or things like that. To make them more readable. OK, this makes it a bit heavier on variables-use and more memory-consuming.

Here comes the trick: when making our variables visible on the screen, it is just placing them on the right position.

The two libraries used here, Adafruit_GFX.h and MCUfriend_kbv.h have a nice work set to use colours, fonts and the ability to draw lines. In a first instance, I used a 12864- screen with these libraries, later I changed that in the tft-screen. All I had to do, is placing boxes, rectangles and lines, and make sure that the data came out in the right place. For that, you can use setCursor and tft.Write as command. Easy does it. Colours can be set as variables also, there are many examples in those libraries how to choose them.


For writing on the SD-card, we also need some simple tricks.

For example, we read our data from the clock as separate hours, minutes and seconds. Temperatures are DHT.temperature and DHTT.temperature, to differentiate between indoor or outdoor.

When we want to put them on the SD card, we use a string: we start every loop as an empty string:

variablestring=""; Then we can fill it up with all our data:

variablestring = variablestring + hours+":" + minutes +" :" + seconds. This gives the string like 12:00:00.

Since we write it as a TXT-file (see the SD.h on Arduino.cc), for the next variables we add a tab, so it is easier to import it in Excel.

So we come to: variablestring = variablestring +" \t " + DHT.temperature + " \t" + DHTT.Temperature.

And so on.

Step 5: Some Screenshots...

To be sure we don't "overload" our datasets, I wrote data only once every 10 minutes. Giving us 144 entries per day.Not bad, I think.

And of course, you can continue to process that data: you can make averages, you can look for maxima and minima, you can compare with past years...

Met offices usually make averages of day and night, for temperatures: daytime starts at 8 AM, and runs to 8PM.

For wind, pressure and precipitation, the averages are taken from midnight to midnight.

Step 6: Finished?

Not really... As I told I'd like to finally get the wind-speed and wind-direction sensor working with the rest of the JAWS.

The little construction I made stands about 4m high. Meteorologist get wind-speed from 10m high. A bit too high for me...

I hope you enjoyed reading this!

Adafruit-GFX is explained here: https://learn.adafruit.com/adafruit-gfx-graphics-...

MCUFRIEND_kbv.h is to be found here: https://github.com/prenticedavid/MCUFRIEND_kbv

More about BMP 120 (same as BMP085): https://learn.sparkfun.com/tutorials/bmp180-barometric-pressure-sensor-hookup-/all

About DHT22: https://playground.arduino.cc/Main/DHTLib/

Sensors Contest

Participated in the
Sensors Contest