WeatherDuino Forum

Full Version: Challenge: GPO feature - What have you developed for your station?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It has been just over a month and a half since version 2 of WeatherDuino Pro2 Software was released with some cool new features. One of these new features is called "GPO", General Purpose Output. It allows preset conditions to be programmed into the receiver's software and when met, provide an output to drive a relay or similar.

It is a great way to get creative and experience working with code.


So, what have you done?


For me, I wanted to monitor my transmitter battery voltage to ensure that everything continues to run smoothly especially as winter is fast approaching. So I have installed four 3mm LED's in between the LCD display and the front of the box. When the right conditions are met, these LED's will come on and illuminate the LCD screen in a bright red colour to draw my attention to it.

These LED's are powered directly from the RX board from the GPO output. I have ensured this load does not exceed more than 60 mA (the maximum recommendation for this output).

I developed this in two stages: First stage will flash the LED's on and off at a preset TX voltage once every minute and change the text on the LCD screen. When it drops below a second preset TX voltage, the LED's will stay on permanently until the TX voltage returns above the preset values.

Code:
GPO_state = 0;
//Check the TX battery voltage for set values. This value will leave LEDs on

if ((Unit[0].BatVolt / 100.0) <= 12.0 && (Unit[0].BatVolt / 100.0) != 0 )
{  
setPortHIGH(PORTD, 3); //Turn on the GPO pin
lcd.setCursor(0, 0); //Set cursor to top row (over write date/time)
lcd.print(F("BATTERY LOW!! ")); // Print battery warning text
lcd.print(Unit[0].BatVolt / 100.0, 2); // Print battery voltage
lcd.print(F("V"));
GPO_state = 1;
}

//Check the TX battery voltage for set values. This value will flash LEDs on and off (pre low warning)

else if ((Unit[0].BatVolt / 100.0) <= 12.05 && (Unit[0].BatVolt / 100.0) != 0 )
{  
setPortHIGH(PORTD, 3); //Turn on the GPO pin
lcd.setCursor(0, 0); //Set cursor to top row (over write date/time)
lcd.print(F("BATTERY LOW!! ")); // Print battery warning text
lcd.print(Unit[0].BatVolt / 100.0, 2); // Print battery voltage
lcd.print(F("V"));
setPortLOW(PORTD, 3); //Turn off the GPO pin (looks like a flash of light)      
GPO_state = 1;
}

else setPortLOW(PORTD, 3); //Keep LEDs off

If you wanted to do something similar without adding the 3mm LEDs, you could also try simply toggling the LCD screen on and off with something like:
BackLight_State = !BackLight_State; lcd.setBacklight(BackLight_State);

The photo does not really represent this the best, but I am sure it shows the idea/concept. The text where the date and time would normally be displayed has been replaced with the battery voltage. When I redesign my RX enclosure, I will attempt to recess the LED's better.



So the challenge: What have you done with your GPO feature in Version 2 of WeatherDuino Pro2 Software? Lets get creative!


More information about the GPO feature can be found on this forum here:
http://www.meteocercal.info/forum/Thread...ve-a-relay
Nice idea!
The GPO function can be used for so many things that will be interesting to see what will come out...

What I like more in the GPO function is that it can lead some users that never wrote a line of code, to start doing it.
I have developed the GPO function I run on my weather station a little more.

Now, not only will it warn me of a low battery, but it will also warn me of high wind gusts and extreme temperatures.

Using the same LED illumination as mentioned above, the GPO function will check for high wind gust values and pre-set temperature ranges. As the GPO function runs once a minute, the LED illumination and screen text will only display for minimum of 1 minute or while the condition is true. This is enough time to take note if you are in the room to see it.

As previously written, this is a two part process. The GPO function will illuminate LEDs through the relay output and also replace the date/time text with a written warning.

The conditions I am checking are:
BatVolt = Battery Voltage of TX unit
Output_WGust = High wind gusts
Output_T_Out = Outside Temperature

Code:
GPO_state = 0;
//Check the TX battery voltage for set values. This value will leave LEDs on

if ((Unit[0].BatVolt / 100.0) <= 12.10 && (Unit[0].BatVolt / 100.0) != 0 )
{  
setPortHIGH(PORTD, 3); //Turn on the GPO pin
lcd.setCursor(0, 0); //Set cursor to top row (over write date/time)
lcd.print(F("BATTERY LOW!! ")); // Print battery warning text
lcd.print(Unit[0].BatVolt / 100.0, 2); // Print battery voltage
lcd.print(F("V"));
GPO_state = 1;
}

//Check the TX battery voltage for set values. This value will flash LEDs on and off (pre low warning)

else if ((Unit[0].BatVolt / 100.0) <= 12.15 && (Unit[0].BatVolt / 100.0) != 0 )
{  
setPortHIGH(PORTD, 3); //Turn on the GPO pin
lcd.setCursor(0, 0); //Set cursor to top row (over write date/time)
lcd.print(F("BATTERY LOW!! ")); // Print battery warning text
lcd.print(Unit[0].BatVolt / 100.0, 2); // Print battery voltage
lcd.print(F("V"));
setPortLOW(PORTD, 3); //Turn off the GPO pin (looks like a flash of light)      
GPO_state = 1;
}

else if (Output_WGust >= 45) // Wind Warning
   {  
setPortHIGH(PORTD, 3);
lcd.setCursor(0, 0);
lcd.print(F("!HIGH WIND "));
lcd.print(Output_WGust, 1);
lcd.print(F("km/h!"));
GPO_state = 1;
   }

else if ((Output_T_Out / 10.0) >= 30) // Temperature warning above 30
   {  
setPortHIGH(PORTD, 3);
lcd.setCursor(0, 0);
lcd.print(F("!HIGH TEMP.  "));
lcd.print(Output_T_Out / 10.0, 2);
lcd.write(B11011111);   // Degree Symbol
lcd.print(F("C!"));
GPO_state = 1;
   }

else if ((Output_T_Out / 10.0) <= -0.01) // Temperature warning below zero
   {  
setPortHIGH(PORTD, 3);
lcd.setCursor(0, 0);
lcd.print(F("!LOW  TEMP.  "));
lcd.print(Output_T_Out / 10.0, 2);
lcd.write(B11011111);   // Degree Symbol
lcd.print(F("C!"));
GPO_state = 1;
   }
else setPortLOW(PORTD, 3);


Next step I will be looking at trying to add is a "high rain rate" alarm, but at this stage do not know how to check for this condition. Time will tell.
Nice work. Whatever you do, remember to always keep at least 350 bytes of free SRAM. It may work with less, but at some point (after one day, a week or a month) instability could happen.

The variable which have the rainfall rate in tips per hour is: loopData.rainRate
Multiply it by the value of each tip bucket (ex: 0.3) of your rain gauge, and you have the rainfall rate in mm/hr.
Thanks for your help.

I have now added the rain rate warning as well, leaving 470 bytes of space free when compiled. If I do have any troubles, I can always remove these warnings. It is just something to play around with for now.

Thanks Werk_AG