Solar Powered Mini-Weather Station
-
@floris, Thank you for your kind words. The luxmeter faces down, so the light is indirectly collected through the diffuser. If I were to build V2.0, I would look into adding a light pipe to provide more direct lighting on the sensor.

@Salmoides
Hi, where i can find light pipe lie this? -
I have one of these lights and got it with the plan of dissembling it for this very project but it was too good lol so think I'll buy another to dissect. The only disappointing thing is how the light is always on at a dim level so drains the battery. I'd much rather have it only activate on motion detection with the PIR.
-
Dear...
Great project...[ when i got my stuff i am going to build to...Only how do you use the motionsensor of this light...[ new one or do you use the build in one ]
In the sketch is can not see this motionsensor?
Only in our Vera controller is see arm and bypass?
Can you set the level of the lights, in vera?
Two times temperature?
And how is your battery action in the winter-period? -
Hi,
Here is the fritzing shema ; could you please tell me if it is correct before I begin the building of the weather station ?
Thanks for your support !

-
Hi,
The left resistor is a 1Mohm 2W(I'll confirm the power value once I'll received it), the right one is 4,7kohm, 1/4W.
For the Hardware, I read the beginning of the post, but unfortunately I'm also a newby, and need to have a validation of this diagram, because I'm not sure if it is correct, and I don't want to burn my house if I'll do cabling mistakes ;-)
I am not able to put the file created under fritzing, but if someone wants it, tell me how to do it please.Thanks for your feedback!
Regards. -
Hi all,
the lamp used as a basis for this desing is now frequently offered at Aliexpress. Price is around $10,-. DOn't know about quality, but looks very simular.
Ralph
-
Hello All,
Long time reader, first time poster.
I've been building my-sensors in combo with Domoticz for a while now , and this project is one of my favorites.
I can confirm that the fritzing schema is correct, i checked it against the one i build. (whish i had the schema earlier, it would have been so much easier ;-))
I used the followin library from Rob Tillaart for the DHT22 (http://playground.arduino.cc/Main/DHTLib / https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib) because the standard was not working...
Change line 37 to dht DHT;
comment out line 51
From line 78 i changed the code to this :delay(2000); int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN); temp = DHT.temperature; //Serial.print("Temperature DHT :"); //Serial.println(temp); if (isnan(temp)) { lastTemp = -1; } else if (temp != lastTemp) { lastTemp = temp; if (!metric) { temp = temp * 1.8 + 32.0; } gw.send(msgTemp.set(temp, 1)); } hum = DHT.humidity; if (isnan(hum)) { lastHum = -1; } else if (hum != lastHum) { lastHum = hum; gw.send(msgHum.set(hum, 1)); }And it is working like a charm.
Now i ordered one of these : Wind Sensor
I want to trie to get it working with this build.
And indeed the lamp is stil available Solar LampHope this helps,
With Regard's
Peer -
Hi,
Thanks for your help! I'm waiting for the LiPo charger, because I purchased a wrong one to pursue my implementation...- Could you tell me how I can comment our line 51 please? Just like this?
'dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); - Also, do you have already implement the Wind Speed Module, or it's under shipment? Do you use Domoticz as domotic software? It's to know how to implement this kind of child on it?
- Is the solar panel providing enough power to have the weather station always working? (I'm living in France on Paris latitude, and I would like to know if the quantity of sun is enough, or I need a second solar panel)
- And it appears my Barometric Pressure sensor gave me also the humidity and temperature; Why do we have 1DHT22 and 1BMP180 ?
- And finally, how do you deal with the battery level, as I didn't see at the beginning of this post how it is implemented inside Vera? Because I would like to implement it in Domoticz
Many thanks for your feedback!
- Could you tell me how I can comment our line 51 please? Just like this?
-
Hello All,
Long time reader, first time poster.
I've been building my-sensors in combo with Domoticz for a while now , and this project is one of my favorites.
I can confirm that the fritzing schema is correct, i checked it against the one i build. (whish i had the schema earlier, it would have been so much easier ;-))
I used the followin library from Rob Tillaart for the DHT22 (http://playground.arduino.cc/Main/DHTLib / https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib) because the standard was not working...
Change line 37 to dht DHT;
comment out line 51
From line 78 i changed the code to this :delay(2000); int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN); temp = DHT.temperature; //Serial.print("Temperature DHT :"); //Serial.println(temp); if (isnan(temp)) { lastTemp = -1; } else if (temp != lastTemp) { lastTemp = temp; if (!metric) { temp = temp * 1.8 + 32.0; } gw.send(msgTemp.set(temp, 1)); } hum = DHT.humidity; if (isnan(hum)) { lastHum = -1; } else if (hum != lastHum) { lastHum = hum; gw.send(msgHum.set(hum, 1)); }And it is working like a charm.
Now i ordered one of these : Wind Sensor
I want to trie to get it working with this build.
And indeed the lamp is stil available Solar LampHope this helps,
With Regard's
PeerHi,
Commenting is done with //
so//dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
The wind sensor is stil in shipment, so can't tell you anything about it, and i use Domoticz as controler software.
I presume you have your gateway setup and connected, so the node should show up in domoticz with all the childs.
I tested the the weather station only a few day's past monyh, because it is still under construction, but those day's it held out (I live near Eindhoven the Netherlands, so weather conditions are almost the same as yours ;-)).
The battery reports through the potentiometer to A0, if the battery level = 100% the readout of A0 should be 1023 (adjustable with the portentio meter.
Here is my sketch in total, althoug verry crude it works, it yust needs a lot of cleanup when i am done, but i need the sensor first to work.#include <SPI.h> #include <MySensor.h> #include <dht.h> #include <BH1750.h> #include <Wire.h> #include <Adafruit_BMP085.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 #define CHILD_ID_BARO 3 #define CHILD_ID_BTEMP 4 #define CHILD_ID_WINDSPEED 5 #define CHILD_ID_RAIN 6 #define CHILD_ID_RAINRATE 7 #define MESSAGEWAIT 500 #define nRainIn A2 #define DIGITAL_INPUT_RAIN_SENSOR 3 #define HUMIDITY_SENSOR_DIGITAL_PIN 5 #define ENCODER_PIN 2 #define INTERRUPT DIGITAL_INPUT_RAIN_SENSOR-2 //int encoder_pin = 7; // pulse output from the module unsigned int rpm; // rpm reading volatile byte pulses; // number of pulses unsigned long timeold; // number of pulses per revolution // based on your encoder disc unsigned int pulsesperturn = 1; boolean metric = false; int altitude = 16; // meters above sealevel float lastBmpTemp = -1; float lastPressure = -1; float lastHum = -1; float lastTemp = -1; double temp; double hum; int BATTERY_SENSE_PIN = A0; int lastRainValue = -1; int nRainVal; boolean bIsRaining = false; String strRaining = "NO"; int lastBatteryPcnt = 0; int updateAll = 60; int updateCount = 0; uint16_t lastLux; // unsigned long SLEEP_TIME = 60000; unsigned long SLEEP_TIME = 600; int batteryBasement = 800; float batteryConstant = 100.0 / (1023 - batteryBasement); Adafruit_BMP085 bmp = Adafruit_BMP085(); BH1750 lightSensor; dht DHT; MySensor gw; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL); MyMessage msgBtemp(CHILD_ID_BTEMP, V_TEMP); MyMessage msgPressure(CHILD_ID_BARO, V_PRESSURE); MyMessage msgWindSpeed(CHILD_ID_WINDSPEED, V_WIND); MyMessage msgRain(CHILD_ID_RAIN, V_TRIPPED); MyMessage msgRainRate(CHILD_ID_RAINRATE, V_RAIN); void counter() { //Update count pulses++; } void setup() { analogReference(INTERNAL); gw.begin(incomingMessage, 3, true); //dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); bmp.begin(); gw.sendSketchInfo("Weather Sensor", "1.0"); gw.present(CHILD_ID_HUM, S_HUM, "WS Humidity"); gw.present(CHILD_ID_TEMP, S_TEMP, "WS Temperature"); gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "WS Lux"); gw.present(CHILD_ID_BARO, S_BARO, "WS Pressure"); gw.present(CHILD_ID_BTEMP, S_TEMP, "WS P Temperature"); gw.present(CHILD_ID_WINDSPEED, S_WIND, "WS Windspeed"); gw.present(CHILD_ID_RAIN, S_MOTION, "WS Rain"); gw.present(CHILD_ID_RAINRATE, S_RAIN, "WS RainRate"); pinMode(DIGITAL_INPUT_RAIN_SENSOR, INPUT); lightSensor.begin(); metric = gw.getConfig().isMetric; pinMode(ENCODER_PIN, INPUT); //Interrupt 0 is digital pin 2 //Triggers on Falling Edge (change from HIGH to LOW) attachInterrupt(0, counter, FALLING); // Initialize pulses = 0; rpm = 0; timeold = 0; } void loop() { updateCount += 1; if (updateCount == updateAll) { lastTemp = -1; lastHum = -1; lastLux = -1; lastBmpTemp = -1; lastPressure = -1; lastRainValue = -1; lastBatteryPcnt = -1; updateCount = 0; } delay(2000); int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN); temp = DHT.temperature; //Serial.print("Temperature DHT :"); //Serial.println(temp); if (isnan(temp)) { lastTemp = -1; } else if (temp != lastTemp) { lastTemp = temp; if (!metric) { temp = temp * 1.8 + 32.0; } gw.send(msgTemp.set(temp, 1)); } hum = DHT.humidity; if (isnan(hum)) { lastHum = -1; } else if (hum != lastHum) { lastHum = hum; gw.send(msgHum.set(hum, 1)); } uint16_t lux = lightSensor.readLightLevel(); if (lux != lastLux) { gw.send(msgLux.set(lux)); lastLux = lux; } float pressure = bmp.readSealevelPressure(altitude) * 0.01; float bmptemp = bmp.readTemperature(); if (!metric) { bmptemp = bmptemp * 1.8 + 32.0; } if (bmptemp != lastBmpTemp) { gw.send(msgBtemp.set(bmptemp,1)); lastBmpTemp = bmptemp; } if (pressure != lastPressure) { gw.send(msgPressure.set(pressure, 0)); lastPressure = pressure; } nRainVal = analogRead(nRainIn); Serial.print("RainVal :"); Serial.println(nRainVal); bIsRaining = !(digitalRead(DIGITAL_INPUT_RAIN_SENSOR)); Serial.print("Is Raining :"); Serial.println(bIsRaining); if(bIsRaining){ strRaining = "YES"; } else{ strRaining = "NO"; } //Serial.print("Raining?: "); //Serial.print(strRaining); //Serial.print("\t Moisture Level: "); //Serial.println(nRainVal); //http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-rain-sensor-module-guide-and-tutorial/ gw.send(msgRain.set(bIsRaining)); nRainVal = nRainVal * -1; gw.send(msgRainRate.set(nRainVal)); int sensorValue = analogRead(BATTERY_SENSE_PIN); int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant; if (lastBatteryPcnt != batteryPcnt) { gw.sendBatteryLevel(batteryPcnt); lastBatteryPcnt = batteryPcnt; } if (millis() - timeold >= 1000) { //Don't process interrupts during calculations detachInterrupt(0); rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses; timeold = millis(); Serial.print("RPM = "); Serial.println(rpm,DEC); Serial.println(pulses); pulses = 0; rpm = rpm,DEC; if (rpm == 0) { rpm = 1; } gw.send(msgWindSpeed.set(rpm, 1)); //Restart the interrupt processing attachInterrupt(0, counter, FALLING); } gw.sleep(SLEEP_TIME); } void incomingMessage(const MyMessage & message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } }``` And there is the puls counter which i abandoned for the wind speed meter (wanted to build my own with a optocoupler, but changed my mind). Hope this is helpfull. Regard's Peer -
@Elfnoir,
Could you please send me the fritzing schema, or attach it here ?
I want to add the windmeter i bought.
I got it today, and with a little help from google i got it working.Greetz Peer
-
@Elfnoir,
Could you please send me the fritzing schema, or attach it here ?
I want to add the windmeter i bought.
I got it today, and with a little help from google i got it working.Greetz Peer
@peerkersezuuker 0_1459719366114_Weather Station.fzz
And thanks for your feedback and support!
-
So here it is :
And the code (still very rude but it works)
#include <SPI.h> #include <MySensor.h> #include <dht.h> #include <BH1750.h> #include <Wire.h> #include <Adafruit_BMP085.h> #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_LIGHT 2 #define CHILD_ID_BARO 3 #define CHILD_ID_BTEMP 4 #define CHILD_ID_WINDSPEED 5 #define CHILD_ID_RAIN 6 #define CHILD_ID_RAINRATE 7 #define MESSAGEWAIT 500 #define nRainIn A2 #define DIGITAL_INPUT_RAIN_SENSOR 3 #define HUMIDITY_SENSOR_DIGITAL_PIN 5 #define ENCODER_PIN 2 #define INTERRUPT DIGITAL_INPUT_RAIN_SENSOR-2 const int windSpeedPin = 2; // contact on pin 2 digital int windSpeedPinCounter = 0; // impuls counter int windSpeedPinStatus = 0; // actual impuls int windSpeedPinStatusAlt = 0; // oude Impuls-Status unsigned long windmeterStart; unsigned long windmeterStartAlt = 0; int windSpeed; // Variable voor Wind Speed int beaufort = 0; // Variable Wind in Beaufort const int windmeterTime = 10000; //float knoten = 0.0; //float wind = 0.0; int knoten = 0.0; int wind = 0.0; boolean metric = false; int altitude = 16; // meters above sealevel float lastBmpTemp = -1; float lastPressure = -1; float lastHum = -1; float lastTemp = -1; double temp; double hum; int BATTERY_SENSE_PIN = A0; int lastRainValue = -1; int nRainVal; boolean bIsRaining = false; String strRaining = "NO"; int lastBatteryPcnt = 0; int updateAll = 60; int updateCount = 0; uint16_t lastLux; // unsigned long SLEEP_TIME = 60000; unsigned long SLEEP_TIME = 600; int batteryBasement = 800; float batteryConstant = 100.0 / (1023 - batteryBasement); Adafruit_BMP085 bmp = Adafruit_BMP085(); BH1750 lightSensor; dht DHT; MySensor gw; MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL); MyMessage msgBtemp(CHILD_ID_BTEMP, V_TEMP); MyMessage msgPressure(CHILD_ID_BARO, V_PRESSURE); MyMessage msgWindSpeed(CHILD_ID_WINDSPEED, V_WIND); MyMessage msgRain(CHILD_ID_RAIN, V_TRIPPED); MyMessage msgRainRate(CHILD_ID_RAINRATE, V_RAIN); void setup() { analogReference(INTERNAL); gw.begin(incomingMessage, 3, true); //dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); bmp.begin(); gw.sendSketchInfo("Weather Sensor", "1.0"); gw.present(CHILD_ID_HUM, S_HUM, "WS Humidity"); gw.present(CHILD_ID_TEMP, S_TEMP, "WS Temperature"); gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "WS Lux"); gw.present(CHILD_ID_BARO, S_BARO, "WS Pressure"); gw.present(CHILD_ID_BTEMP, S_TEMP, "WS P Temperature"); gw.present(CHILD_ID_WINDSPEED, S_WIND, "WS Windspeed"); gw.present(CHILD_ID_RAIN, S_MOTION, "WS Rain"); gw.present(CHILD_ID_RAINRATE, S_RAIN, "WS RainRate"); pinMode(DIGITAL_INPUT_RAIN_SENSOR, INPUT); lightSensor.begin(); metric = gw.getConfig().isMetric; } // Wind Meter https://github.com/chiemseesurfer/arduinoWeatherstation/blob/master/weatherstation/weatherstation.ino float windmeter() { windmeterStart = millis(); // Actual start time measuringMessung windmeterStartAlt = windmeterStart; // Save start time windSpeedPinCounter = 0; // Set pulse counter to 0 windSpeedPinStatusAlt = HIGH; // Set puls status High while ((windmeterStart - windmeterStartAlt) <= windmeterTime) // until 10000 ms (10 Seconds) .. { windSpeedPinStatus = digitalRead(windSpeedPin); // Read input pin 2 if (windSpeedPinStatus != windSpeedPinStatusAlt) // When the pin status changed { if (windSpeedPinStatus == HIGH) // When status - HIGH { windSpeedPinCounter++; // Counter + 1 } } windSpeedPinStatusAlt = windSpeedPinStatus; // Save status for next loop windmeterStart = millis(); // Actual time } windSpeed = ((windSpeedPinCounter * 24) / 10) + 0.5; // WindSpeed - one Pulse ~ 2,4 km/h, windSpeed = (windSpeed / (windmeterTime / 1000)); // Devided in measure time in seconds Serial.print("wind Speed :"); Serial.println(windSpeed); knoten = windSpeed / 1.852; //knot's return knoten; } void loop() { updateCount += 1; if (updateCount == updateAll) { lastTemp = -1; lastHum = -1; lastLux = -1; lastBmpTemp = -1; lastPressure = -1; lastRainValue = -1; lastBatteryPcnt = -1; updateCount = 0; } delay(2000); int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN); temp = DHT.temperature; //Serial.print("Temperature DHT :"); //Serial.println(temp); if (isnan(temp)) { lastTemp = -1; } else if (temp != lastTemp) { lastTemp = temp; if (!metric) { temp = temp * 1.8 + 32.0; } gw.send(msgTemp.set(temp, 1)); } hum = DHT.humidity; if (isnan(hum)) { lastHum = -1; } else if (hum != lastHum) { lastHum = hum; gw.send(msgHum.set(hum, 1)); } uint16_t lux = lightSensor.readLightLevel(); if (lux != lastLux) { gw.send(msgLux.set(lux)); lastLux = lux; } float pressure = bmp.readSealevelPressure(altitude) * 0.01; float bmptemp = bmp.readTemperature(); if (!metric) { bmptemp = bmptemp * 1.8 + 32.0; } if (bmptemp != lastBmpTemp) { gw.send(msgBtemp.set(bmptemp,1)); lastBmpTemp = bmptemp; } if (pressure != lastPressure) { gw.send(msgPressure.set(pressure, 0)); lastPressure = pressure; } nRainVal = analogRead(nRainIn); Serial.print("RainVal :"); Serial.println(nRainVal); bIsRaining = !(digitalRead(DIGITAL_INPUT_RAIN_SENSOR)); Serial.print("Is Raining :"); Serial.println(bIsRaining); if(bIsRaining){ strRaining = "YES"; } else{ strRaining = "NO"; } //Serial.print("Raining?: "); //Serial.print(strRaining); //Serial.print("\t Moisture Level: "); //Serial.println(nRainVal); //http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-rain-sensor-module-guide-and-tutorial/ gw.send(msgRain.set(bIsRaining)); nRainVal = nRainVal * -1; gw.send(msgRainRate.set(nRainVal)); wind = windmeter(); Serial.print("Wind :"); Serial.println(wind); gw.send(msgWindSpeed.set(wind)); int sensorValue = analogRead(BATTERY_SENSE_PIN); int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant; if (lastBatteryPcnt != batteryPcnt) { gw.sendBatteryLevel(batteryPcnt); lastBatteryPcnt = batteryPcnt; } gw.sleep(SLEEP_TIME); } void incomingMessage(const MyMessage & message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } }``` Still need some cleaning and calibrating (rain and wind sensor) [0_1459792799776_Weather-station.fzz](/uploads/files/1459792799984-weather-station.fzz) Regard's Peer -
Oh yeah, a little source mentioning :
Weather Station
Weather Station CodeGreetz Peer
-
This is my project!!!!

// Example sketch för a "light switch" where you can control light or something // else from both vera and a local physical button (connected between digital // pin 3 and GND). // This node also works as a repeader for other nodes #include <MySensor.h> #include <SPI.h> #include <DHT.h> unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds) //pin sensori #define PIR_PIN 2 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!) #define HUMIDITY_TEMPERATURE_PIN 3 // sensore temperatura umidita #define RELAY_PIN 4 // relay pin int BATTERY_SENSE_PIN = A1; // Pin carica batteria o pannello solare int FOTORESIST_SENSE_PIN = A2; // Pin fotoresistenza //interupt per sleep arduino #define INTERRUPT PIR_PIN-2 // Usually the interrupt = pin -2 (on uno/nano anyway) //id per vera #define CHILD_ID_RELE 1 // Id relay #define CHILD_ID_HUM 2 // id temperatura #define CHILD_ID_TEMP 3 // id umidita #define CHILD_ID_PIR 4 // Id pir #define CHILD_ID_LIGHT 5 // Id luminosita (fotoresistenza) //definizione per nodo vera #define NODE_ID 10 #define SN "meteo station" #define SV "1.4" //variabili bool state_relay; //stato relay float batt_valore; //dichiaro la variabile valore che memorizzerà il valore della batteria dal pin analogico float batt_volt; //volt batteria float batt_charged_percent; //percentuale carica batteria float last_batt_charged_percent; //percentuale carica batteria precedente float batt_min_voltage = 0.5; //tensione minima batteria float batt_max_voltage = 5; //tensione massima batteria float fotoresistenza_valore; //dichiaro la variabile valore che memorizzerà il valore della fotoresistenza dal pin analogico float last_fotoresistenza_valore; //dichiaro la variabile valore precedente int lux_vera; //valore luminosita da inviare a vera MySensor gw; // sensore temperatura umidita DHT dht_int; float lastTemp_int = -1; float lastHum_int = -1; boolean metric = true; MyMessage msgRelay(CHILD_ID_RELE,V_LIGHT); MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgPir(CHILD_ID_PIR, V_TRIPPED); MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL); void setup() { gw.begin(incomingMessage, NODE_ID, false); gw.sendSketchInfo(SN, SV); //Sensore umidita temperatura dht_int.setup(HUMIDITY_TEMPERATURE_PIN); gw.present(CHILD_ID_RELE, S_LIGHT); //light vera gw.present(CHILD_ID_HUM, S_HUM); //umidity vera gw.present(CHILD_ID_TEMP, S_TEMP); // temp vera gw.present(CHILD_ID_PIR, S_MOTION); // motion vera gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL); //light level (fotoresistenza) metric = gw.getConfig().isMetric; // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); //PIR pinMode(PIR_PIN, INPUT); state_relay = 0; //GestisciRelay(); digitalWrite(RELAY_PIN, LOW); gw.send(msgRelay.set(state_relay)); } void loop() { gw.process(); //sensore temperatura umidita delay(dht_int.getMinimumSamplingPeriod()); float temperature_int = dht_int.getTemperature(); if (isnan(temperature_int)) { lastTemp_int = -1; Serial.println("Failed reading temperature from DHT"); } else if (temperature_int != lastTemp_int) { lastTemp_int = temperature_int; if (!metric) { temperature_int = dht_int.toFahrenheit(temperature_int); } gw.send(msgTemp.set(temperature_int, 1)); Serial.print("T int: "); Serial.println(temperature_int); } float humidity_int = dht_int.getHumidity(); if (isnan(humidity_int)) { lastHum_int = -1; Serial.println("Failed reading humidity from DHT"); } else if (humidity_int != lastHum_int) { lastHum_int = humidity_int; gw.send(msgHum.set(humidity_int, 1)); Serial.print("H int: "); Serial.println(humidity_int); } //sensore temperatura umidita //fotoresistenza for(int i=0;i<150;i++) { fotoresistenza_valore += analogRead(FOTORESIST_SENSE_PIN); //read the input voltage from battery or solar panel delay(2); } fotoresistenza_valore = fotoresistenza_valore / 150; Serial.print ("fotoresistenza: "); Serial.println(fotoresistenza_valore); if (fotoresistenza_valore != last_fotoresistenza_valore) { lux_vera = (int) fotoresistenza_valore; gw.send(msgLux.set(lux_vera)); last_fotoresistenza_valore = fotoresistenza_valore; } //fotoresistenza //pir relay // Read digital motion value boolean tripped = digitalRead(PIR_PIN) == HIGH; Serial.println("pir:"); Serial.println(tripped); gw.send(msgPir.set(tripped?"1":"0")); // Send tripped value to gw //accende la luce con il buio if (fotoresistenza_valore < 200) //poca luce { if (tripped == 1) { state_relay = 1; } else { state_relay = 0; } } //accende la luce con il buio GestisciRelay(); //pir relay //battery for(int i=0;i<150;i++) { batt_valore += analogRead(BATTERY_SENSE_PIN); //read the input voltage from battery or solar panel delay(2); } batt_valore = batt_valore / 150; Serial.print ("batt_valore: "); Serial.println(batt_valore); batt_volt = (batt_valore / 1024) * batt_max_voltage; Serial.print ("batt_volt: "); Serial.println(batt_volt); //////////////////////////////////////////////// //The map() function uses integer math so will not generate fractions // so I multiply battery voltage with 10 to convert float into a intiger value // when battery voltage is 6.0volt it is totally discharged ( 6*10 =60) // when battery voltage is 7.2volt it is fully charged (7.2*10=72) // 6.0v =0% and 7.2v =100% //batt_charged_percent = batt_volt*10; //batt_charged_percent = map(batt_volt*10, 60 , 72, 0, 100); batt_charged_percent = batt_volt * 10; batt_charged_percent = map(batt_volt * 10, batt_min_voltage * 10 , batt_max_voltage * 10, 0, 100); //batt_charged_percent = (batt_volt / batt_max_voltage) * 100; Serial.print ("batt_charged_percent: "); Serial.println(batt_charged_percent); if (last_batt_charged_percent != batt_charged_percent) { gw.sendBatteryLevel(batt_charged_percent); last_batt_charged_percent = batt_charged_percent; } //battery delay(50); // Sleep until interrupt comes in on motion sensor. Send update every two minute. gw.sleep(INTERRUPT, CHANGE, SLEEP_TIME); } void incomingMessage(const MyMessage &message) { // We only expect one type of message from controller. But we better check anyway. if (message.isAck()) { Serial.println("This is an ack from gateway"); } if (message.type == V_LIGHT) { // Change relay state_relay state_relay = message.getBool(); GestisciRelay(); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } void GestisciRelay() { //Serial.print(" GestisciRelay state_relay:"); //Serial.println(state_relay); if (state_relay == 0) { digitalWrite(RELAY_PIN, LOW); gw.send(msgRelay.set(state_relay)); //Serial.println("SPENTO RELAY"); } else { digitalWrite(RELAY_PIN, HIGH); gw.send(msgRelay.set(state_relay)); //Serial.println("ACCESO RELAY"); } }On vera

On board

-
I purchased a solar kit
Solar Panel
battery 12v
landstar solar charge controllerI want to insert into Arduino in output of charge controller (I have 12 volts)
to lower the voltage can I use a mobile charger Car 1 Ah
do you heat so much?
Thank
@Salmoides Good Project!!!!!