Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Arduino Based Weather Station


Gina

Recommended Posts

Looking back at the "direction table" for the wind direction sketch, I see they are using three voltage levels in the analogue inputs of the DS2450. This arises from using 8 reed switches and magnets and allowing for the overlap of the magnetic fields to obtain 16 directions from 8 switches.  I'm using a totally different system with the full 16 directions coded in binary form so this table will need changing (not a problem :D ).

On 13/02/2016 at 12:40, Gina said:

const float directionTable[16][4] = {

{ 4.5, 4.5, 2.5, 4.5 }, // N

{ 4.5, 2.5, 2.5, 4.5 }, // NNE

{ 4.5, 2.5, 4.5, 4.5 }, // NE

{ 2.5, 2.5, 4.5, 4.5 }, // ENE

{ 2.5, 4.5, 4.5, 4.5 }, // E

{ 2.5, 4.5, 4.5, 0.0 }, // ESE

{ 4.5, 4.5, 4.5, 0.0 }, // SE

{ 4.5, 4.5, 0.0, 0.0 }, // SSE

{ 4.5, 4.5, 0.0, 4.5 }, // S

{ 4.5, 0.0, 0.0, 4.5 }, // SSW

{ 4.5, 0.0, 4.5, 4.5 }, // SW

{ 0.0, 0.0, 4.5, 4.5 }, // WSW

{ 0.0, 4.5, 4.5, 4.5 }, // W

{ 0.0, 4.5, 4.5, 2.5 }, // WNW

{ 4.5, 4.5, 4.5, 2.5 }, // NW

{ 4.5, 4.5, 2.5, 2.5 } // NNW };

The optical sensors do not provide logic levels as such but will vary from the black level to the white level in a ramp as the vane turns from fully in the black to fully in the white and similarly from white to black.  Also the black and white voltage levels vary due to changes in reflectivity of the printed code disc and hub.

56c076bab1d26_OpticalSensorWaveform01.th

I could just apply a threshold of around 2.5v and convert directly to digital but better would be to apply two thresholds representing low, changing, high and if in the inbetween state (changing) hold the previous direction.  This has the effect of applying a Schmitt trigger action. Whether the extra complication is warranted by this application is questionable.

Edited by Gina
Link to comment
Share on other sites

Yes.  I'm not using Java and it looks like his book was written in the BA epoch (Before Arduino) :D  For the data mashing and web page dials and gauges I've used Python - which I shall have to bone up on when I get to that stage again.  I just want a simple indoor display for now. 

I have just had another browse through the book and was interested in his approach to a 1-wire humidity sensor but it seems so inaccurate (and awkward) that I think I'll stick with DHT22 directly connected to Arduino.  In fact I shall have several Arduinos in the observatory to measure various environmental conditions and control various things so that isn't much of a problem.  I can communicate with all of these by 1-wire bus now that I have the DS2408 sussed.  I have some code to write to communicate with the DS2408 library but don't think that will be a problem.  Might even write an Arduino library to cover the low level bit manipulation - or add to the DS2408 library.

Link to comment
Share on other sites

2 minutes ago, Gina said:

Yes.  I'm not using Java and it looks like his book was written in the BA epoch (Before Arduino) :D  For the data mashing and web page dials and gauges I've used Python - which I shall have to bone up on when I get to that stage again.  I just want a simple indoor display for now. 

I have just had another browse through the book and was interested in his approach to a 1-wire humidity sensor but it seems so inaccurate (and awkward) that I think I'll stick with DHT22 directly connected to Arduino.  In fact I shall have several Arduinos in the observatory to measure various environmental conditions and control various things so that isn't much of a problem.  I can communicate with all of these by 1-wire bus now that I have the DS2408 sussed.  I have some code to write to communicate with the DS2408 library but don't think that will be a problem.  Might even write an Arduino library to cover the low level bit manipulation - or add to the DS2408 library.

I've used these http://www.homechip.com/1-wire-controllers/sensors/ms-th-temperature-and-humidity-sensor.html

from Homechip for temp & humidity both outside and in our greenhouse. Nice but at £40.52 a bit pricey. They have an RJ45 at each end for easy daisy-chaining.

Link to comment
Share on other sites

2 hours ago, tekkydave said:

I have Tim's book aswell. From memory his code is all Java using the Maxim libraries. You can certainly re-use the algorithms though.

Yes.  I'm not using Java and it looks like his book was written in the BA epoch (Before Arduino) :D  For the data mashing and web page dials and gauges I've used Python - which I shall have to bone up on when I get to that stage again.  I just want a simple indoor display for now. 

I have just had another browse through the book and was interested in his approach to a 1-wire humidity sensor but it seems so inaccurate (and awkward) that I think I'll stick with DHT22 directly connected to Arduino.  In fact I shall have several Arduinos in the observatory to measure various environmental conditions and control various things so that isn't much of a problem.  I can communicate with all of these by 1-wire bus now that I have the DS2408 sussed.  I have some code to write to communicate with the DS2408 library but don't think that will be a problem.  Might even write an Arduino library to cover the low level bit manipulation - or add to the DS2408 library.

Link to comment
Share on other sites

2 minutes ago, tekkydave said:

I've used these http://www.homechip.com/1-wire-controllers/sensors/ms-th-temperature-and-humidity-sensor.html

from Homechip for temp & humidity both outside and in our greenhouse. Nice but at £40.52 a bit pricey. They have an RJ45 at each end for easy daisy-chaining.

Ah - the quote has worked this time :D

That's too expensive for me - Arduino Nano + DHT22 + DS2408 + hardware doesn't cost as much :)  And can do other things as well.

Link to comment
Share on other sites

I now have the Anemometer connected to the wind instruments 1-wire circuit board and running the DS2423 sketch.  The Serial Monitor is showing an increasing count as I rotate the anemometer rotor :) 1 count per cup ie. 3 counts per revolution as should be :)

RESULT - 1-wire anemometer working :):hello2:

  • Like 1
Link to comment
Share on other sites

The DS2423 counters count up to 2^32 = 4,294,967,296.  This means they are capable of dealing with 100mph continuous wind for 42949672.96 hours = just under 4900 years.  I think that will do :D

Edited by Gina
Link to comment
Share on other sites

Working on the vane direction circuit now - much more complicated and proving awkward to fit in the space, avoiding the fixing holes for the lid and anemometer base.

Link to comment
Share on other sites

I have now wired up the wind direction encoder and it's mostly working :)  The DS2450 is working fine and I have loaded the voltage reading sketch so that I can see what voltages the optical sensors are producing.  There is one optical sensor not working - the DS2450 is showing a constant 4.6v which is the supply voltage feeding the pull-up resistors, so the phototransistor is not pulling the input down.  Could be several things. A short across the IR LED or open circuit connection to the phototransistor, for example.  I shall need to open the encoder casing again and check.  Oh well, nothing unusual.

The working sensors are giving a low level of a few hundred millivolts and a high level of around 3v or so.  A threshold level of 1.5v would therefore be suitable.

Here is the test sketch I'm using.

/*
 *   DS2450Voltages
 *
 *   This example demonstrates the use of the DS2450 library and the Arduino
 *   OneWire library to read voltages from a Dallas Semiconductor
 *   DS2450 quad a/d.
 *
 *   by Joe Bechter
 *
 *   (C) 2012, bechter.com
 *
 *   All files, software, schematics and designs are provided as-is with no warranty.
 *   All files, software, schematics and designs are for experimental/hobby use.
 *   Under no circumstances should any part be used for critical systems where safety,
 *   life or property depends upon it. You are responsible for all use.
 *   You are free to use, modify, derive or otherwise extend for your own non-commercial purposes provided
 *       1. No part of this software or design may be used to cause injury or death to humans or animals.
 *       2. Use is non-commercial.
 *       3. Credit is given to the author (i.e. portions © bechter.com), and provide a link to the original source.
 *
 */

#include <Arduino.h>
#include <OneWire.h>
#include <DS2450.h>

// define the Arduino digital I/O pin to be used for the 1-Wire network here
const uint8_t ONE_WIRE_PIN = 8;

// define the 1-Wire address of the DS2450 quad a/d here (lsb first)
uint8_t DS2450_address[] = { 0x20, 0xAD, 0x30, 0x12, 0x00, 0x00, 0x00, 0x42 };

OneWire ow(ONE_WIRE_PIN);
DS2450 ds2450(&ow, DS2450_address);

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

void loop() {
    ds2450.update();
    if (ds2450.isError()) {
        Serial.println("Error reading from DS2450 device");
    } else {
        for (int channel = 0; channel < 4; channel++) {
            Serial.print("Channel ");
            Serial.print(char('A' + channel));
            Serial.print(" = ");
            Serial.print(ds2450.getVoltage(channel), 1);
            if (channel < 3) {
                Serial.print("v, ");
            } else {
                Serial.println("v.");
            }
        }
    }
    delay(500);
}

 

Link to comment
Share on other sites

Found it :)  DMM testing showed a short from the lowest IR LED positive to Gnd.  It was a minute sliver of remaining copper where the stripboard track should have be severed.  I missed it on earlier inspection :(

I'll put it all back together and test it again tomorrow.  Done enough for today :D  I've proved the DS2450 is still working and found the problem with the no.4 optical sensor - it should work now that I've removed the short.

Edited by Gina
Link to comment
Share on other sites

It's working :)  The test sketch showing the voltages, that is.  The pull down currents turned out to be higher than optimum but still alright.  I turned the supply voltage down from 13.8v to 12v and it was better.  Here are some screenshots of the voltages as displayed in the Serial Monitor.

56c1df33875bf_WindVaneEncoderVoltages01.56c1dff5d0320_WindVaneEncoderVoltages02.56c1e110ab9ed_WindVaneEncoderVoltages03.

There seem to be odd rogue values in there which will need processing out.  I wonder if these are due to inteference pickup and if capacitors across the A/D inputs would help.  To do it with processing, I could sample at a higher rate and use majority logic, taking several samples and discarding the rogue values.

Edited by Gina
Link to comment
Share on other sites

Slowly rotating the code disc, I'm seeing quite a large variation of voltages within each segment particularly the black parts - the white parts generally seem fairly consistant at 0.0v.  This tells me that the blacks are not black enough - or too close to the sensor perhaps.  Some bits of black velour would help the black areas if I can find some.  Should have a roll of it somewhere but not seen it for some time :(

I'm trying increasing the distance from code disc to sensors - this is not "carved in stone" yet but this is not really any better.  One thing I could do is redesign the hub and code disc to give deeper holes for the black parts.

Edited by Gina
Link to comment
Share on other sites

I haave now redesigned the hub and encoder disc to give the encoder just over 6mm instead of 3mm and the hub has been thinned down to match.  There is now "half a hole" in each part to take the 8mm ali tube for the vane.

56c22439990dd_WindVaneHubandEncoder01.th56c2243b2ca48_WindVaneHubandEncoder02.th

Link to comment
Share on other sites

This tells me I need to get my act together.

My long abandoned weather station uses a gray code disk made by laser printing on OHP film. Must look at getting it all working again and adding a few more sensors (I have a humidity sensor or two that have spent the last few years inside their plastic bags.

  • Like 1
Link to comment
Share on other sites

Printed the code disc but when I went to print the hub part (in black) the printer stopped working - print bed heating failed.  This is the little UP Plus 2 3D printer and this is a repeat of an earlier problem.  I am having to reassess the position.

Link to comment
Share on other sites

  • 2 weeks later...

I've repaired the UP printer but everything is so worn that producing accurate prints is no longer possible.  I'm working on my DIY Pilot printer ATM, rebuilding the X carriage so that is out of action.  The larger Titan (another home build) is partly working, particularly for smaller prints and I may try printing the hub part for the wind vane.

Link to comment
Share on other sites

  • 10 months later...

When going through some boxes in my store room I came across one containing some of the bits for my weather station, so had a look.  I don't think there's a lot needed to get this working.  Last time I looked at it I was stumped by not having a decent 3D printer working but having spent time on my Pilot printer recently it's now working well so I'm in a position to further this project a bit more.  It might prove to be "light relief" from some of the others :D

I've just tidied up the wind vane hub and encoder so I can now print that.  It would be nice to be able to display wind direction and speed indoors.  The model for these two parts is shown above - it will be printed in two parts and glued together.  I haven't got a two colour printer yet.

I'll be looking back through this thread to see where I had got to.  In view of my new knowledge of the Raspberry Pi 3 I might change some of the electronics.  For one thing I don't want long 1-wire cabling eaten by rodents as has happened in the past.  An RPi 3 with WiFi would only need power to the remote electronics which would be easier to rodent proof.  The other problem is that 1-wire seems to be dropped by Maxim - the only manufacturers of the devices.

Edited by Gina
Link to comment
Share on other sites

I'm using the standard tipping bucket with a reed switch and magnet on the bucket.  Quite a large funnel feeds it.  Or I should say was using....  Not using anything ATM :D  I'll see if I can find more details.

  • Like 1
Link to comment
Share on other sites

Tipping bucket

They aren't very accurate and calibration depends on rain rate.  The one I have is just the one from the Maplin kit which is a standard Chinese clone same as many others.  It's just a plastic bucket - very crude.  Replacement cost of whole rain gauge is just a few pounds :D  I would like something better but what?  I might have a think about this but with so many people failing to improve on the tipping bucket for an automatic weather station I guess I'll need tho think pretty hard :D

Link to comment
Share on other sites

One possibility might be to modify the manual arrangement with some method of emptying the water.  There are a number of ways to automate measuring the water height in a measuring cylinder such as ultrasonic - which I use to check the water in the sump under my observatory.  Maybe a combination of level sensing and tipping bucket...  OTOH do we actually need accurate rain measurement?

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.