Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Arduino Based Weather Station


Gina

Recommended Posts

Looking at the Mega pinout I don't see pins 3, 4, 5 as being SPI pins but I may be wrong. I did however just tested the chip again with the following pins and changed the sketch to match and worked fine.

Arduino D10 - SS

Arduino D11 - SCK

Arduino D12 -  MOSI

Link to comment
Share on other sites

PHEW!!  Sometimes I'm too blooming clever for my own good :D  Trouble is I like to understand what I'm doing!  Now to put everything back together...  Then to try it from the RPi.  I also have the wind speed counter routine to add to the sketch.

Edited by Gina
  • Like 1
Link to comment
Share on other sites

I'm just wondering how often I want to read the data.  Also, there are two ways of reading the wind speed - count the pulses or measure the time between pulses.  Maybe use both depending on the wind speed.  Interval for low speeds and count for higher speeds.  If I were just to use the count and sample once per second the speed would be directly in mph.  Maybe I don't need anything better and that would definitely be the easiest.  I think I would really like a faster update on the analogue wall indicators though.  Updating once a second would look very jittery - I guess I could smooth it.

Link to comment
Share on other sites

A very simple wind display would be two rings of lights (LED probably).  16 (or 32) for wind direction and 12 (13?) for wind speed on the Beaufort Scale.  I'd prefer pointers though :D  But a semi-log scale for wind speed.

beaufort-wind-scale.gif?t=1398725710

Edited by Gina
Link to comment
Share on other sites

I found that measuring the wind speed and direction more frequently than every 15s just produces a jittery output that moves too fast to follow. I measure every 15s and store in a database with an accurate timestamp. Then periodically retrieve all valid values for last 15 mins to do the concensus calculations for the web site.

You will need to experiment with what averaging works best for how you want to display it.

  • Like 1
Link to comment
Share on other sites

Wind vane data.  First number is the record count second the bearing in tenths of a degree.  Rotated wind vane in clockwise direction as seen from underneath.  This means anticlockwise for the wind direction.  This is with the magnet behind the chip rather than in front so direction is opposite to what I expected.  Does show that the magnet works fine underneath the chip though.  Since I have no information as to the pole alignment on the magnet I shall have to calibrate the North direction later in the code.  ATM zero is about 135° from vane in line with boom.  Correction in code is easy, just add an adjustment number and mod 360.  (Assuming degrees.)

5a37e3529a4ef_SensorData06.png.6bc025afdb67601bb4619394131fb3b7.png

Edited by Gina
Link to comment
Share on other sites

This is with the wins vane aligned with the boom.  If I arrange the boom facing south, this will indicate north.  Think I'll call it 249°.  Also think I'll calibrate the angle to data function with a protractor as 360-249 = 111 rather than the 135° that I estimated as the angle for data=0.  24° is rather a large error!

5a37e7c96b116_SensorData07.png.a6240eac140ec03aedce487f87905a1d.png

Link to comment
Share on other sites

Here are the data values (rounded to the nearest degree) for the 8 compass points.  45, 90, 135, 180, 225, 270, 315, 0

Quote

285
335
180
55
83
153
208
248

 

Edited by Gina
Link to comment
Share on other sites

Think I'll add code to give the angle in degrees from the reference position.  (248-x+360) mod 360.  ie. (608-x) mod 360.  Where x is the data value in degrees.

Edited by Gina
Link to comment
Share on other sites

Here is the code section :-

void loop() {
  if (mlxMetro.check() == 1) { 
  ii = mlx_1.readAngle(); 
  ii = ii / 10;
  ii = 608 - ii;
  ii = ii % 360;
  Serial.print(count);
  Serial.print("  ");
  Serial.println(ii);
  }
  delay(1000);
  count++;
}

Getting errors up to 12° degrees - worst at 180° I think but I'll have to do a proper calibration.

5a37fcbba06aa_SensorData11.thumb.png.8d5a9af74368539cd3c80e53017f3f37.png

Edited by Gina
Link to comment
Share on other sites

Highest should be 3599 and lowest 0.  Well within the 32767 range of the int variable.  In fact the data output is 14bits so couldn't exceed the 15bit int variable.

Edited by Gina
Link to comment
Share on other sites

The errors in the angle reading could be due to the magnet axis being offset from the sensor chip axis or the magnet may not be perfectly flat on the end of the axle or the chip may not be perfectly orthogonal to the axle axis.

I could take readings every 22.5° or even less and produce a calibration graph.  I could then read off values and produce an array (table) to correct the error.  I can't see the error changing with time or any other variable the station might encounter.  OTOH the errors may not be worth bothering about.  Normally wind direction accurate to the 16 point compass is considered accurate enough.  So far the error seems to be about half this.

 

Edited by Gina
Link to comment
Share on other sites

8 minutes ago, Gina said:

The errors in the angle reading could be due to the magnet axis being offset from the sensor chip axis or the magnet may not be perfectly flat on the end of the axle or the chip may not be perfectly orthogonal to the axle axis.

Most likely the magnetic field is far from symmetrical.

  • Like 1
Link to comment
Share on other sites

Here are the data values as I turned the vane from reference ACW as looked at from beneath, every 45°. 

5a380ce915c7c_SensorData12.png.2541ef947ac65cf9f029522a3181e975.png

I see the values as follows.  If I were to change the offset calibration by 5° the errors are reduced, giving an error of  ±7° which is near enough :)  It can also be seen that the error is roughly cyclical as would result from an off-axis condition.  If I wanted I could apply an empirical correction but no need really.

  • Angle Data   Error
  • 0            0      0     -5
  • 45        43     -2    -7
  • 90        93      3    -2
  • 135    145    10    5
  • 180    192    12    7
  • 225    235    10    5
  • 270    276     6     1
  • 315    317     2    -3
Edited by Gina
Link to comment
Share on other sites

33 minutes ago, JamesF said:

Or perhaps just make a small table of offsets and subtract the nearest one to the data value, to give better accuracy across the range?

James

Yes, a small table would be quite sufficient.  Just first order error correction would be more than adequate.

Link to comment
Share on other sites

This is a graph of the errors.  Very rough as the data is only to the nearest degree and the x axis is only graduated in steps of 45°.  Within those bounds it seems to approximate to a sine wave, indicating an offset of the rotation axis from the chip or magnet as we have deduced already.

5a3820b4926c8_SensorErrors01.png.af29d3fdab8989451441c1475ffb09d2.png

Edited by Gina
Link to comment
Share on other sites

I could take the above graph and produce a table from it but for now I'll just adjust the offset by -5° ie. subtract the angle from 603°.  Here's the result - again every 45°.  Errors are -3, -1, 2, 2, 1, -1, 0, 1, -4.  Looks like I've over compensated.  Think I try 604° and run the test again.  Actually, I doubt I can get the angle as accurate as 1° anyway; I'd need a dividing head.

5a3828cf28393_SensorErrors02.png.f0ebb1ed6204e5a8828db9d8bde64aee.png

Edited by Gina
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.