Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

Arduino Based Weather Station


Gina

Recommended Posts

Sorting out the RTC reading (and setting) and the data logging code.

The data logging shield uses the Dallas DS1307 RTC chip which uses I2C and Analog pins 4 & 5 to talk to the Arduino. Info on this and more is on the appropriate web page :- http://www.ladyada.n...shield/rtc.html

This provides links to the required library and how to install it plus code to set the clock and read the time.

Setting the time is simply :-


RTC.adjust(DateTime(__DATE__, __TIME__));

which takes the time from the computer on compilation and writes it to the RTC when it's run.

Reading the clock is just as simple :-


DateTime now = RTC.now();

Serial.print(now.year(), DEC);
Serial.print('-');
Serial.print(now.month(), DEC);
Serial.print('-');
Serial.print(now.day(), DEC);
Serial.print('T');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);

Serial.println();

This shows displaying the RTC time on the computer but the logging to SD file works similarly. I have converted the code to use the ISO standard (up to the seconds).

Link to comment
Share on other sites

Code for logging date/time to SD card file :-


// fetch the time
now = RTC.now();
// log time
logfile.print(now.year(), DEC);
logfile.print("-");
logfile.print(now.month(), DEC);
logfile.print("-");
logfile.print(now.day(), DEC);
logfile.print("T");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
Link to comment
Share on other sites

Now I'm looking at the sensors - how many and which pins they require. Everything 1-wire goes on one single digital pin, which takes care of wind speed & direction, light level and rain gauge. Temperature/humidity can use DHT22 and one pin but for both indoor and outdoor, that's two. Then we come to the barometric pressure for which I'm thinking of the BMP085 breakout board :- http://www.ebay.co.u...=item4ab97f69cc

This uses I2C and and Analog pins 4 & 5. Now the data logger shield also uses I2C and pins A4 & A5. Is it possible to run more than one I2C device off the one bus?

Edited by Gina
Link to comment
Share on other sites

It's alright - got the answer. It's a bus like 1-wire with device IDs but using 2 wires instead of 1. It's also much more limited for range - just a metre they say whereas the 1-wire bus will go hundreds of metres.

So I can run both the RTC and pressure devices off the A4 & A5 pins. The I2C can be used for communication between 2 Arduinos - that could be useful.

Looks like I should have sufficient I/O on the Arduino Uno.

Edited by Gina
Link to comment
Share on other sites

Sensor & data I/O list :-

  1. Wind Speed - 1-wire - pin 4
  2. Wind Direction - 1-wire - pin 4
  3. Light Level - 1-wire - pin 4
  4. Rainfall - 1-wire - pin 4
  5. Barometric Pressure - I2C - pins A4 & A5
  6. Inside Temperature & Humidity - pin 5
  7. Outside Temperature & Humidity - pin 6
  8. RTC - I2C - pins A4 & A5
  9. SD card CS - pin10
  10. SD card MOSI - pin 11
  11. SD card MISO - pin 12
  12. SD card CLK - pin 13
  13. Red LED - pin 2
  14. Green LED - pin 3

That leaves Digital pins 5 to 9 and Analog A0 to A3 free ATM. This is using the data logger sield but not the Ethernet ATM - I'll look into that later.

Link to comment
Share on other sites

Change of plan... This makes more sense to me :D Sensor & data I/O list :-

  1. Wind Speed - 1-wire - pin 2
  2. Wind Direction - 1-wire - pin 2
  3. Light Level - 1-wire - pin 2
  4. Rainfall - 1-wire - pin 2
  5. Barometric Pressure - I2C - pins A4 & A5
  6. Inside Temperature & Humidity - pin 3
  7. Outside Temperature & Humidity - pin 4
  8. RTC - I2C - pins A4 & A5
  9. SD card CS - pin10
  10. SD card MOSI - pin 11
  11. SD card MISO - pin 12
  12. SD card CLK - pin 13
  13. Red LED - pin 5
  14. Green LED - pin 6
Link to comment
Share on other sites

Wired up the data logger shield with a DHT22, connection for the 1-wire and components for the exterior DHT22 connection plus the two LEDs. There's still the barometer module to add - when it comes.

post-13131-0-25107600-1347893231_thumb.jpost-13131-0-61428700-1347893246_thumb.j

Edited by Gina
Link to comment
Share on other sites

Now have a test sketch which is logging date/time, temperature, humidity and dew point. Here is the data in a spread sheet (Open Office Calc) taken from the SD card.

post-13131-0-05548300-1347913915_thumb.p

Edited by Gina
Link to comment
Share on other sites

Fixed the time - wanted time to be UTC (alias GMT). Changing the clocks for British Summer Time (Daylight Saving Time in the US) in the weather data causes all sorts of problems so all my weather data is going to be in GMT/UTC. Having looked at doing it it code I thought of a much simpler idea :) Simply turned off "Daylight Saving Time" in Win 7 then ran clock setting sketch again. Then put Win 7 clock back to normal. I've added a "Z" to the date/time data to conform with the ISO standard for UTC but might find this isn't wanted.

post-13131-0-25815100-1347961130_thumb.p

Link to comment
Share on other sites

Now have the barometer working and logging to SD file :) The module also reads temperature so I've included that too (called Temp2). However the temperature does not seem very accurate being a degree C or so high. The DHC22 is accurate to half a degree so I'll use that and ignore the BMP085 temperature.

Here are serial display and SD file contents.

post-13131-0-75767900-1347986979_thumb.ppost-13131-0-72769600-1347986982_thumb.p

Link to comment
Share on other sites

I'm now looking into accessing the 1-wire devices. The DS2423 (counter), DS2450 (4 line ADC) and DS2438 (battery sensor - voltage, current, temperature) are no problem - I've found and installed libraries for them but the DS2413 ( 2 channel switch) is a problem, I can't find any source of a library for this decice for the Arduino. I may have to change my circuitry unless anyone knows where I can fine the DS2413 Arduino library.

The DS2413 is used to enable the LEDs used when reading the wind vane direction.

Link to comment
Share on other sites

There's a library for the DS2408 which is an 8 channel switch whereas the DS2413 is a 2 channel switch. Should be similar but I'll have to look at the details in the data sheets.

Link to comment
Share on other sites

looking good Gina!

Whats the current drain for 1-wire on the pin. I have an Arduino controlling 8 relays to switch 12v observatory power and am thinking of adding some 1-wire weather data.

I wish I could steal some of your spare time to work on my Arduino......:D

Link to comment
Share on other sites

Obviously there is a current limit if supplying from the USB cable but I seem to remember there is a current limit on the I/O. You can only supply a max of 20ma per pin up to a max of 200ma?? So as, for example, my 8 relays would have drawn considerably more current than the Arduino I/O can handle I had to hook the relays up to an External power.

I can only drive up to 6 relays without external power connected to the relay board (I.e. using the Arduino power and I/O) this is the limit of what worked and not something that would work for very long.

My doubt is, the more I add devices to the Arduino the more uncertain I get that I have enough current or that I am not going above any current limits on the Arduino. I assume the 1-wire, being comms, doesn´t consume much power unless it´s supplying the devices...er ...is it supplying the sensors as well?

I am starting to put various things I have tried onto one Arduino hence I am starting to get confused as to whether I have enough current or if I have to add any transistors or other load switching device.

Link to comment
Share on other sites

Current considerations were why I decided to switch the LEDs on and off. So the sequence is :- LEDs on - measure PT output - LEDs off. The Leds only need to be on for a millisecond or less while the DS2450 reads the PTs. That meant I could use parasitic power to supply the LEDs in conjunction with a capacitor to supply the brief relatively high current (about 5mA) - just 50 microamps from the 1-wire bus. In fact using CAT5 cable with only one pair used for the 1-wire bus, there's no real reason why power should not be privided by other wires in the cable. Can't remember now why I didn't do that in the first place.

Link to comment
Share on other sites

  • 9 months later...

With the astro projects on hold due to the hot weather (too hot to work in shed except very early morning) I'm looking at my other projects including CCTV with remote control and this one. The CCTV is currently waiting for deliveries of components.

So I've just read through this thread to see what I was doing and where I'd got to. It looks like I already have a lot of it built or at least designed. The hardware seems to have survived storage without damage :) And most of the bits are in a dedicated project box waiting to go.

I would like to get a weather station going again - the Fine Offset (Maplin) one has completely died now except that the wind instruments are still working mechanically at the top of the mast. I simply don't feel like bothering with that any more :D With the hot weather it would be nice to be able to see how hot the observatory was getting.

The one remaining little problem would seem to be the DS2413 control in the sketch and I think I'll simple mod the hardware to control this separately via an extra wire from the Arduino rather than try to figure out the coding. With a mains powered Arduino there is no need to keep power consumption to a minimum. In fact there is now no requirement to switch the LEDs off at all AFAICS.

Link to comment
Share on other sites

  • 5 months later...

This project is back on with the recent storms having destroyed the anemometer (and the current pole is bent - the whole thing looks a pretty sorry site!).  I have some bigger aluminium tube for the mast and plan to attach it to the observatory on spacing blocks to allow the roll off roof clearance, probably at the dividing wall position on the north side.  The base unit with Arduino and indoor sensors, can be placed just inside the scope room to measure the scope room temperature and humidity as well as atmospheric pressure.  The outdoor sensors will go in my Stevenson screen which I shall also attach to the north obsy wall just outside the scope room next to the mast.  The screen needs a repaint first.

In view of the sort of weather we are getting these days I shall be looking closely at the mast head assembly and seeing if I can boost its storm resistance.

The LEDs for the wind direction encoder will be run continuously from separate wires in the CAT 5E cable that connects to the 1-wire devices on the mast (there are 6 spare :D)

Link to comment
Share on other sites

Hi Gina

Just thought it was funny that post #48 was talking about the weather being too hot, and post #49 was written in somewhat different circumstances!! I had quite forgotten that it was hot this summer!?

Good luck with the project anyway.

Cheers,

Stu

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.