Hi guys,
As part of my project, I am on the need of designing a weather station using arduino uno. I will use it on the forest in order to measure rain fall, temperature and humidity.
I am using a rain gauge, 2 waterproof termometres DS18B20 (one for above ground and another for below ground) and one DHT-22 for temperature and humidity in situ. I will attach also an Adafruit shield with a RTC and SD card to keep all the data recorded. and a nokia 5110 LCD. I am thinking to use 4AA batteries as power supplier.
I have already got the different sketches. They are working correctly when I see them independently at the serial monitor but my concern is coming when I have to combine all of them in one.
I have been reading and studying tutorials, videos and so on because I am just a forester engineer so that it is being very difficult to me start combining sketches and make them work in one.
I would be more than pleased if you could indicate me how to combine these first two sketches:
Sketch for measuring temperature using DS18B20:
<#include <OneWire.h>
OneWire ds(2); // on pin 2 (a 4.7K resistor is necessary)/ check with 120 ohms for reading multiple temp sensors.
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
byte i;
byte present = 0;
byte type_s;
byte data[12];
byte addr[8];
float celsius, fahrenheit;
if ( !ds.search(addr)) {
Serial.println("No more addresses.");
Serial.println();
ds.reset_search();
delay(2000);
return;
}
Serial.print("ROM =");
for( i = 0; i < 8; i++) {
Serial.write(' ');
Serial.print(addr*, HEX);*
-
}*
-
if (OneWire::crc8(addr, 7) != addr[7]) {*
-
Serial.println("CRC is not valid!");*
-
return;*
-
}*
-
Serial.println();*
-
// the first ROM byte indicates which chip*
-
switch (addr[0]) {*
-
case 0x10:*
-
Serial.println(" Chip = DS18S20"); // or old DS1820*
-
type_s = 1;*
-
break;*
-
case 0x28:*
-
Serial.println(" Chip = DS18B20");*
-
type_s = 0;*
-
break;*
-
case 0x22:*
-
Serial.println(" Chip = DS1822");*
-
type_s = 0;*
-
break;*
-
default:*
-
Serial.println("Device is not a DS18x20 family device.");*
-
return;*
-
}*
-
ds.reset();*
-
ds.select(addr);*
-
ds.write(0x44, 1); // start conversion, with parasite power on at the end*
-
delay(1000); // maybe 750ms is enough, maybe not*
-
// we might do a ds.depower() here, but the reset will take care of it.*
-
present = ds.reset();*
-
ds.select(addr); *
-
ds.write(0xBE); // Read Scratchpad*
-
Serial.print(" Data = ");*
-
Serial.print(present, HEX);*
-
Serial.print(" ");*
-
for ( i = 0; i < 9; i++) { // we need 9 bytes*
_ data = ds.read();_
_ Serial.print(data*, HEX);
Serial.print(" ");
}
Serial.print(" CRC=");
Serial.print(OneWire::crc8(data, 8), HEX);
Serial.println();
// Convert the data to actual temperature*
* // because the result is a 16 bit signed integer, it should*
* // be stored to an "int16_t" type, which is always 16 bits*
* // even when compiled on a 32 bit processor._
int16_t raw = (data[1] << 8) | data[0];
if (type_s) {
_ raw = raw << 3; // 9 bit resolution default*
* if (data[7] == 0x10) {
// "count remain" gives full 12 bit resolution*
* raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
// at lower res, the low bits are undefined, so let's zero them*
* if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms*
* else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms*
* else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms*
* //// default is 12 bit resolution, 750 ms conversion time*
* }
celsius = (float)raw / 16.0;
fahrenheit = celsius * 1.8 + 32.0;
Serial.print(" Temperature = ");
Serial.print(celsius);
Serial.print(" Celsius, ");
Serial.print(fahrenheit);
Serial.println(" Fahrenheit");
}>
Sketch for measuring rain fall (rain gauge):
<int REED = 9; //The reed switch outputs to digital pin 9*
int val = 0; //Current value of reed switch
int old_val = 0; //Old value of reed switch
int REEDCOUNT = 0; //The intial count is zero
void setup(){
Serial.begin(9600);
pinMode (REED, INPUT_PULLUP); //This activates the internal pull up resistor
}
void loop(){
val = digitalRead(REED); //Read the status of the Reed swtich
if ((val == LOW) && (old_val == HIGH)){ //Check to see if the status has changed
* Serial.print ("Precipitation = ");
REEDCOUNT = REEDCOUNT + 9.5; //Add 9.5 to the count of bucket tips*
* old_val = val; //Make the old value equal to the current value*
* Serial.print(REEDCOUNT); //Output the count to the serial monitor*
* Serial.println (" ml of rain");
}
else {_
old_val = val; //If the status hasn't changed then do nothing*
}
>
Please edit your first post and put the code in code tags ("</>") button.
If you can give me an idea about where in the world this system will be installed, I will help you with a Solar/Battery system to run it.
Kiwi_Bloke:
If you can give me an idea about where in the world this system will be installed, I will help you with a Solar/Battery system to run it.
Hi Kiwi,
The project will be installed at three different locations based in Wicklow Mountains, Ireland. There is no much sun over this Island but solar panel are working good.
I would be more than pleased with any info related to.
Regards
Sorry for the slow response work has kept me busy.
Wasn't there a reply here detailing likely power usage? I have looked at solar radiation figures for Wicklow and the numbers are quite low for December & January, what I need now is some thoughts on how "Mission Critical" this system is?
Normally I would look at three days autonomy to cover sunless days, which is the industry standard for N.Z.. However what happens if you do run the battery flat and lose a few days data?
Other things you will need to consider are:
Budget - It seems likely you will need about 30 - 40 watts of P.V. Panel(s) to get you through the low months and possibly a 12 or 18AH battery plus a PWM controller (if you are going to do this correctly for a long term installation)
Location - The panel will need to face South with a clear view of the sun, i have not calculated mounting angle but it will probably be the same as your degrees latitude.
Required Autonomy - As mentioned earlier, this will determine the battery size required, which in turn determines P.V. array sizing.
I will run a calculation based on 100ma * 24 hours as a starting point so you can get some idea of whats likely to be required.
Thank you very much Stewart! I will apply your useful tips for the power supplier on my project as soon as I finish with the assembling of the remaining components. I will let you know how I am getting on!!
Antonio.
The LiPo rider needs a 6V solar panel; you have a 12V panel. That combination would create a smoke generator and not a trickle charger.
Give it a little effort and I'm sure you can find a panel and battery that has JST plugs that will fit right into the jacks on boards like the LiPo rider. Before you start buying those items you should work on getting a good estimate of the current consumption of your circuit; you'll certainly want to look into how to put everything to sleep to save power.
Example battery with JST plug
Chagrin:
The LiPo rider needs a 6V solar panel; you have a 12V panel. That combination would create a smoke generator and not a trickle charger.
Give it a little effort and I'm sure you can find a panel and battery that has JST plugs that will fit right into the jacks on boards like the LiPo rider. Before you start buying those items you should work on getting a good estimate of the current consumption of your circuit; you'll certainly want to look into how to put everything to sleep to save power.
Example battery with JST plug
Hi Chagrin,
Thanks for your answer.
I cannot put the installation to sleep because the rain gauge will collect precipitation at anytime, that is why I was thinking in using the 12V solar panel. Also, the project will be installed at Wicklow mountaings (Ireland) so I need this size of solar panel.
The installation is running with a rain gauge which sends pulses through a reed switch and it also has 4 water proof temperature sensor (DS18B20) attached in bus with a 300 ohms resistance.
Which battery do you suggest me with that solar panel!? or should I discard it and get a 6V instead?
Thanks, Antonio.
Sorry but no, the Solar panel is far too small for a start, as you can see from the figures below, December and January get less than one hours usable solar pressure per day:
Solar Radiation - Dublin
Month Solar Radiation (kWh/m^2/day)
January 0.90
February 1.63
March 2.61
April 3.70
May 4.79
June 5.07
July 4.72
August 4.15
September 2.94
October 2.06
November 1.12
December 0.73
Average 2.87
Based on 100mA per hour 24 hours per day your usage will be 24 X 100 = 2400mAH (2.4AH),
If you take 2.4amps per day from your battery you need to put at least 2.64 amps back into the battery.
In December you get less than 45 minutes of usable Solar so 2.64/.73 = 3.61amps for 44 minutes as a minimum charge current, at the appropriate charge voltage for your battery.
As an example, if you were to use a 6VDC Lead Acid Battery and run your system at 5 volts from this, with appropriate "buck" conversion, you would need 3.61 amps X 6.9 volts = 24.9 watts just to maintain the battery in the low months, the panel you have suggested is good for 2.4 watts at 12 volts.
It is crucial to determine total load current and voltage to enable an accurate power solution.