<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://air.imag.fr/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Moreaua</id>
	<title>air - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://air.imag.fr/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Moreaua"/>
	<link rel="alternate" type="text/html" href="https://air.imag.fr/index.php/Special:Contributions/Moreaua"/>
	<updated>2026-06-10T02:15:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://air.imag.fr/index.php?title=SEN-08942&amp;diff=4262</id>
		<title>SEN-08942</title>
		<link rel="alternate" type="text/html" href="https://air.imag.fr/index.php?title=SEN-08942&amp;diff=4262"/>
		<updated>2012-01-17T16:35:11Z</updated>

		<summary type="html">&lt;p&gt;Moreaua: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:SEN-08942.jpg|300px|thumb|[[SEN-08942]] Weather station sensors]]&lt;br /&gt;
[[Image:SEN-08942-mounted.jpg|300px|thumb|[[SEN-08942]] Weather station sensors]]&lt;br /&gt;
[[Image:Solarpanel2.jpg|300px|thumb|right|Module XBee sur Arduino Fio]]&lt;br /&gt;
[[Image:MontageWeather.JPG|300px|thumb|right|Montage arduino UNO, station météo, capteur température Dallas, photorésistance]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Le [http://www.sparkfun.com/products/8942  SEN-08942] est un ensemble anémomètre, girouette et pluviomètre (anemometer, wind vane, and rain gauge) permettant de prototyper une station météo amateur.&lt;br /&gt;
&lt;br /&gt;
* Spec http://www.sparkfun.com/datasheets/Sensors/Weather/Weather%20Sensor%20Assembly..pdf&lt;br /&gt;
* http://www.sparkfun.com/products/8942&lt;br /&gt;
* http://www.lextronic.fr/P4452-capteurs-pour-station-meteo.html&lt;br /&gt;
* http://home.comcast.net/~saustin98/misc/WeatherStationADC.txt&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// From http://home.comcast.net/~saustin98/misc/WeatherStationADC.txt&lt;br /&gt;
&lt;br /&gt;
/* Arduino sketch for Weather device from Sparkfun.&lt;br /&gt;
Uses only the wind direction vane and the anemometer (not the rain gauge).&lt;br /&gt;
&lt;br /&gt;
Although the inclination for a weather logger is to run it for&lt;br /&gt;
a long time, due to the way Wiring.c implements the millis() function,&lt;br /&gt;
this should be restarted, oh, monthly. The millis() functions overflows&lt;br /&gt;
after about 49 days. We could allow for that here, and handle the&lt;br /&gt;
wraparound, but you&#039;ve got bigger problems anyway with the delay()&lt;br /&gt;
function at an overflow, so it&#039;s best to &amp;quot;reboot&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=========================================================&lt;br /&gt;
ANEMOMETER&lt;br /&gt;
=========================================================&lt;br /&gt;
This is connected to Arduino ground on one side, and pin 2 (for the&lt;br /&gt;
attachInterrupt(0, ...) on the other.&lt;br /&gt;
Pin 2 is pulled up, and the reed switch on the anemometer will send&lt;br /&gt;
that to ground once per revolution, which will trigger the interrupt.&lt;br /&gt;
We count the number of revolutions in 5 seconds, and divide by 5.&lt;br /&gt;
One Hz (rev/sec) = 1.492 mph.&lt;br /&gt;
&lt;br /&gt;
=========================================================&lt;br /&gt;
WIND DIRECTION VANE&lt;br /&gt;
=========================================================&lt;br /&gt;
We use a classic voltage divider to measure the resistance in&lt;br /&gt;
the weather vane, which varies by direction.&lt;br /&gt;
Using a 10K resistor, our ADC reading will be:&lt;br /&gt;
   1023 * (R/(10000+R))&lt;br /&gt;
where R is the unknown resistance from the vane. We&#039;ll scale&lt;br /&gt;
the 1023 down to a 255 range, to match the datasheet docs.&lt;br /&gt;
&lt;br /&gt;
                  +5V&lt;br /&gt;
                   |&lt;br /&gt;
                   &amp;lt;&lt;br /&gt;
                   &amp;gt;     10K&lt;br /&gt;
                   &amp;lt;   Resistor&lt;br /&gt;
                   &amp;lt;&lt;br /&gt;
                   &amp;gt;&lt;br /&gt;
                   |&lt;br /&gt;
 Analog Pin 5------|&lt;br /&gt;
                   |&lt;br /&gt;
                   -----------| To weather vane&lt;br /&gt;
                              | (mystery resistance)&lt;br /&gt;
                   -----------|&lt;br /&gt;
                   |&lt;br /&gt;
                   |&lt;br /&gt;
                 -----&lt;br /&gt;
                  ---&lt;br /&gt;
                   -&lt;br /&gt;
The ADC values we get for each direction (based on a 255 max)&lt;br /&gt;
follow, assuming that pointing away from the assembly center&lt;br /&gt;
is sector zero. The sector number is just which 45-degree sector&lt;br /&gt;
it is, clockwise from the &amp;quot;away&amp;quot; direction. The direction&lt;br /&gt;
shown is assuming that &amp;quot;away&amp;quot; is West. Depending how&lt;br /&gt;
you orient the system, you&#039;ll have to adjust the directions.&lt;br /&gt;
&lt;br /&gt;
Sector   Reading  Direction&lt;br /&gt;
  0        18        W&lt;br /&gt;
  1        33        NW&lt;br /&gt;
  2        57        N&lt;br /&gt;
  7        97        SW&lt;br /&gt;
  3       139        NE&lt;br /&gt;
  6       183        S&lt;br /&gt;
  5       208        SE&lt;br /&gt;
  4       232        E&lt;br /&gt;
The values in the ADC table below list the midpoints between&lt;br /&gt;
these, so our reading can vary a bit. We&#039;ll pick the first value&lt;br /&gt;
that&#039;s &amp;gt;= our reading.&lt;br /&gt;
=========================================================&lt;br /&gt;
RAIN GAUGE&lt;br /&gt;
=========================================================&lt;br /&gt;
Implemented here.&lt;br /&gt;
It is done the same way as the anemometer, and use&lt;br /&gt;
attachInterrupt(1, ...) on pin 3. Each interrupt represents&lt;br /&gt;
.011 inches of rain (0.2794 mm), according to the docs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*********************************************************************/&lt;br /&gt;
&lt;br /&gt;
#define uint  unsigned int&lt;br /&gt;
#define ulong unsigned long&lt;br /&gt;
&lt;br /&gt;
#define PIN_ANEMOMETER  2     // Digital 2&lt;br /&gt;
#define PIN_RAINGAUGE  3     // Digital 3&lt;br /&gt;
#define PIN_VANE        5     // Analog 5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// How often we want to calculate wind speed or direction&lt;br /&gt;
#define MSECS_CALC_WIND_SPEED 5000&lt;br /&gt;
#define MSECS_CALC_WIND_DIR   5000&lt;br /&gt;
#define MSECS_CALC_RAIN_FALL  30000&lt;br /&gt;
&lt;br /&gt;
volatile int numRevsAnemometer = 0; // Incremented in the interrupt&lt;br /&gt;
volatile int numDropsRainGauge = 0; // Incremented in the interrupt&lt;br /&gt;
ulong nextCalcSpeed;                // When we next calc the wind speed&lt;br /&gt;
ulong nextCalcDir;                  // When we next calc the direction&lt;br /&gt;
ulong nextCalcRain;                  // When we next calc the rain drop&lt;br /&gt;
ulong time;                         // Millis() at each start of loop().&lt;br /&gt;
&lt;br /&gt;
// ADC readings:&lt;br /&gt;
#define NUMDIRS 8&lt;br /&gt;
ulong   adc[NUMDIRS] = {26, 45, 77, 118, 161, 196, 220, 256};&lt;br /&gt;
&lt;br /&gt;
// These directions match 1-for-1 with the values in adc, but&lt;br /&gt;
// will have to be adjusted as noted above. Modify &#039;dirOffset&#039;&lt;br /&gt;
// to which direction is &#039;away&#039; (it&#039;s West here).&lt;br /&gt;
char *strVals[NUMDIRS] = {&amp;quot;W&amp;quot;,&amp;quot;NW&amp;quot;,&amp;quot;N&amp;quot;,&amp;quot;SW&amp;quot;,&amp;quot;NE&amp;quot;,&amp;quot;S&amp;quot;,&amp;quot;SE&amp;quot;,&amp;quot;E&amp;quot;};&lt;br /&gt;
byte dirOffset=0;&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Initialize&lt;br /&gt;
//=======================================================&lt;br /&gt;
void setup() {&lt;br /&gt;
   Serial.begin(9600);&lt;br /&gt;
   pinMode(PIN_ANEMOMETER, INPUT);&lt;br /&gt;
   digitalWrite(PIN_ANEMOMETER, HIGH);&lt;br /&gt;
   digitalWrite(PIN_RAINGAUGE, HIGH);&lt;br /&gt;
   attachInterrupt(0, countAnemometer, FALLING);&lt;br /&gt;
   attachInterrupt(1, countRainGauge, FALLING);&lt;br /&gt;
   nextCalcRain = millis() + MSECS_CALC_RAIN_FALL;&lt;br /&gt;
   nextCalcSpeed = millis() + MSECS_CALC_WIND_SPEED;&lt;br /&gt;
   nextCalcDir   = millis() + MSECS_CALC_WIND_DIR;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Main loop.&lt;br /&gt;
//=======================================================&lt;br /&gt;
void loop() {&lt;br /&gt;
   time = millis();&lt;br /&gt;
&lt;br /&gt;
   if (time &amp;gt;= nextCalcSpeed) {&lt;br /&gt;
      calcWindSpeed();&lt;br /&gt;
      nextCalcSpeed = time + MSECS_CALC_WIND_SPEED;&lt;br /&gt;
   }&lt;br /&gt;
   if (time &amp;gt;= nextCalcDir) {&lt;br /&gt;
      calcWindDir();&lt;br /&gt;
      nextCalcDir = time + MSECS_CALC_WIND_DIR;&lt;br /&gt;
   }&lt;br /&gt;
   if (time &amp;gt;= nextCalcRain) {&lt;br /&gt;
      calcRainFall();&lt;br /&gt;
      nextCalcRain = time + MSECS_CALC_RAIN_FALL;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Interrupt handler for anemometer. Called each time the reed&lt;br /&gt;
// switch triggers (one revolution).&lt;br /&gt;
//=======================================================&lt;br /&gt;
void countAnemometer() {&lt;br /&gt;
   numRevsAnemometer++;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Interrupt handler for rain gauge. Called each time the reed&lt;br /&gt;
// switch triggers (one drop).&lt;br /&gt;
//=======================================================&lt;br /&gt;
void countRainGauge() {&lt;br /&gt;
   numDropsRainGauge++;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Find vane direction.&lt;br /&gt;
//=======================================================&lt;br /&gt;
void calcWindDir() {&lt;br /&gt;
   int val;&lt;br /&gt;
   byte x, reading;&lt;br /&gt;
&lt;br /&gt;
   val = analogRead(PIN_VANE);&lt;br /&gt;
   val &amp;gt;&amp;gt;=2;                        // Shift to 255 range&lt;br /&gt;
   reading = val;&lt;br /&gt;
&lt;br /&gt;
   // Look the reading up in directions table. Find the first value&lt;br /&gt;
   // that&#039;s &amp;gt;= to what we got.&lt;br /&gt;
   for (x=0; x&amp;lt;NUMDIRS; x++) {&lt;br /&gt;
      if (adc[x] &amp;gt;= reading)&lt;br /&gt;
         break;&lt;br /&gt;
   }&lt;br /&gt;
   //Serial.println(reading, DEC);&lt;br /&gt;
   x = (x + dirOffset) % 8;   // Adjust for orientation&lt;br /&gt;
   Serial.print(&amp;quot;  Dir: &amp;quot;);&lt;br /&gt;
   Serial.println(strVals[x]);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Calculate the wind speed, and display it (or log it, whatever).&lt;br /&gt;
// 1 rev/sec = 1.492 mph = 2.40114125 kph&lt;br /&gt;
//=======================================================&lt;br /&gt;
void calcWindSpeed() {&lt;br /&gt;
   int x, iSpeed;&lt;br /&gt;
   // This will produce kph * 10&lt;br /&gt;
   // (didn&#039;t calc right when done as one statement)&lt;br /&gt;
   long speed = 24011;&lt;br /&gt;
   speed *= numRevsAnemometer;&lt;br /&gt;
   speed /= MSECS_CALC_WIND_SPEED;&lt;br /&gt;
   iSpeed = speed;         // Need this for formatting below&lt;br /&gt;
&lt;br /&gt;
   Serial.print(&amp;quot;Wind speed: &amp;quot;);&lt;br /&gt;
   x = iSpeed / 10;&lt;br /&gt;
   Serial.print(x);&lt;br /&gt;
   Serial.print(&#039;.&#039;);&lt;br /&gt;
   x = iSpeed % 10;&lt;br /&gt;
   Serial.print(x);&lt;br /&gt;
&lt;br /&gt;
   numRevsAnemometer = 0;        // Reset counter&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//=======================================================&lt;br /&gt;
// Calculate the rain , and display it (or log it, whatever).&lt;br /&gt;
// 1 bucket = 0.2794 mm&lt;br /&gt;
//=======================================================&lt;br /&gt;
void calcRainFall() {&lt;br /&gt;
   int x, iVol;&lt;br /&gt;
   // This will produce mm * 10000&lt;br /&gt;
   // (didn&#039;t calc right when done as one statement)&lt;br /&gt;
   long vol = 2794; // 0.2794 mm&lt;br /&gt;
   vol *= numDropsRainGauge;&lt;br /&gt;
   vol /= MSECS_CALC_RAIN_FALL;&lt;br /&gt;
   iVol = vol;         // Need this for formatting below&lt;br /&gt;
&lt;br /&gt;
   Serial.print(&amp;quot;Rain fall: &amp;quot;);&lt;br /&gt;
   x = iVol / 10000;&lt;br /&gt;
   Serial.print(x);&lt;br /&gt;
   Serial.print(&#039;.&#039;);&lt;br /&gt;
   x = iVol % 10000;&lt;br /&gt;
   Serial.print(x);&lt;br /&gt;
   Serial.println();&lt;br /&gt;
   &lt;br /&gt;
   numDropsRainGauge = 0;        // Reset counter&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La trace&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Wind speed: 0.0  Dir: W&lt;br /&gt;
Wind speed: 0.0  Dir: W&lt;br /&gt;
Wind speed: 0.0  Dir: SW&lt;br /&gt;
Wind speed: 1.1  Dir: NE&lt;br /&gt;
Wind speed: 7.1  Dir: E&lt;br /&gt;
Rain fall: 0.0&lt;br /&gt;
Wind speed: 3.8  Dir: N&lt;br /&gt;
Wind speed: 3.8  Dir: E&lt;br /&gt;
Wind speed: 4.1  Dir: E&lt;br /&gt;
Wind speed: 2.9  Dir: E&lt;br /&gt;
Wind speed: 1.1  Dir: E&lt;br /&gt;
Rain fall: 0.2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Moreaua</name></author>
	</entry>
	<entry>
		<id>https://air.imag.fr/index.php?title=File:MontageWeather.JPG&amp;diff=4261</id>
		<title>File:MontageWeather.JPG</title>
		<link rel="alternate" type="text/html" href="https://air.imag.fr/index.php?title=File:MontageWeather.JPG&amp;diff=4261"/>
		<updated>2012-01-17T16:31:43Z</updated>

		<summary type="html">&lt;p&gt;Moreaua: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Moreaua</name></author>
	</entry>
</feed>