Basic Weather Station for Greenhouse
by alexevenko in Circuits > Microcontrollers
422 Views, 0 Favorites, 0 Comments
Basic Weather Station for Greenhouse
1. GY-b11 280 barometric pressure sensor (also measures temperature and RH but not included in code)
2. SHT3X temperature and Relative Humidity Sensor
3. ADS1115 module (increases resolution- 2^16 bits)
4. Solar Radiation Sensor- model RY EBN1, sensitivity 277.01µV to W/M^2
5. Wind three cup anemometer (not included in above picture because unable to calibrate. Included in code but set to a constant of 1m/s windspeed)
6. Voltage Buck converter (check specific model)
7. Breadboard
8. Male-male and male-female jumper wires
9. Esp32 microcontroller
10. Plus and minus cable (the larger black cable that carries 12V to the voltage buck converter-check specific name).
11. Electrical box
Connecting Barometric Pressure Sensor
From what I saw online and in action
attaching this sensor, the baud rate needs to be adjusted to 115200 in the void setup (shown below) and on the serial monitor if you want to see the readings (it did not work on 9600, but all the other sensors do work on 115200). And the “begin” should be set to 0x76. See https://www.xtronical.com/bmp280andesp32 for reference. Regarding the baud rate and the begin-this depends on your type of sensor and may or may not be true depending on its quality. Try both if one is not working.
· void setup() {
· Serial.begin(115200);
· while ( !Serial ) delay(100); // wait for native usb
· Serial.println(F("BMP280 test"));
· unsigned status;
· //status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
· status = bmp.begin(0x76);
· if (!status) {
· Above image above and more information taken from: https://www.xtronical.com/bmp280andesp32/
· Accessing the individual code for this sensor can be done on Arduino platform itself via examplesàAdafruit BMP280 Libraryà bmp280test
Relative Humidity and Temperature Sensor
The SHT3X Temperature and Relative humidity sensor code, along with WIFI and uploading to Thingspeak codes can be found on https://agrotech-lab.github.io/code/2022/04/05/intro-to-sensor-modules-and-thingspeak
· The wiring is similar to the BMP280 in that it is I2C and is thus wired with SCL to I2C Clock (pin 22) and SDA to I2C Data (pin 21)
Cup Anemometer
The cup anemometer code and wiring:
The wiring of the cup anemomter (shown above) is red to 5V, black to Ground, and blue to pin 32. Calibration necessary, but unsuccessful for us and so not included in final setup of meteorological station but it included in the code so that the user can switch from a set constant 1m/s windspeed to the calibrated value !
Code
//wind sped anonumeter SM5386:
const int RecordTime = 1; //Define Measuring Time (Seconds)
const int SensorPin = 32; //Define Interrupt Pin (2 or 3 @ Arduino Uno)
int InterruptCounter;
float WindSpeed;
void setup()
{
Serial.begin(115200);
//------------------------------------------------------------------
//------------------------------------------------------------------
//wind sped anonumeter SM5386:
pinMode(SensorPin, INPUT);
}
void loop() {
meassure();
Serial.print("Wind Speed: ");
Serial.print(WindSpeed); //Speed in km/h
Serial.print(" km/h - ");
Serial.print(WindSpeed / 0.004); //Speed in m/s
Serial.println(" m/s");
delay(1000);
}
void meassure() {
InterruptCounter = 0;
attachInterrupt(digitalPinToInterrupt(SensorPin), countup, RISING);
delay(1000 * RecordTime);
detachInterrupt(digitalPinToInterrupt(SensorPin));
WindSpeed = (float)InterruptCounter / (float)RecordTime * 0.004;
}
void countup() {
InterruptCounter++;
}
The Radiation Sensor
the code gives us options
sensor: works on 277uV to W/m2
So for GAIN_FOUR is within our desired range (+/- 1.024V) (i think we could have chosen others and just followed accordingly)
1 bit=0.03125mV
0.277mV =1w/m2
We use the ADS1115 because it is 16 bits
and can increase our resolution significantly and fits the 1.024V from GAIN_FOUR.
See in code calculation for voltageàW/m2àMJ/m2*day:
rN=((results*0.03125)/0.277)*86400/1000000
(where “results” is the output when the parameters above are used in the code)
Calculating VPD
Calculating VPD
shown in final code:
// VPD calc__
// the following is for VPD calculation
float e;
float m;
float SVP;
float VPD;
float f;
float whatsTheVpd (float h, float tempeture) {
e = 2.71828;
m = tempeture / (tempeture + 238.3) * 17.2694;
SVP = 610.78 * pow(e, m);
f = 1 - h / 100;
VPD = SVP * f;
return VPD / 1000;
Calculating Evapotranspiration According to the following equation circled in yellow. Notice that this simplified equation assumes what is highlighted in Green (regarding albedo, resistance, and crop height): Also in our code we set Kc (the crop coefficient to =1 but should be adjusted accooridng to specific crop and physiological age coefficient. The Units needed for each variable are shown in red highlight. So for instance the Solar radiation gives us readings in W/m2 (after calibration of mVs). We must convert this to MJ/ m2* day (*seconds in a day and /by 10^6 joules per megajoule).
Penman Monteith Evapotranspiration calculation ( https://link.springer.com/book/10.1007/978-3-319-... (chapters 5,9, 10)
Assume Kc, Rn, Windspeed all=1 for now.
**Windspeed here is assumed to be at 2 m height while we may do it above this height.
Or (https://www.fao.org/3/X0490E/x0490e06.htm):
Full Greenhouse Setup and Github Code
Check at our GitHub for the full code at
https://github.com/Alevegreen/Agtechcourse_finproject