Solar Powered Mini-Weather Station
-
If i'm not mistaken, the solor panel is directly connected to the power input of the solar charger. @Salmoides wired a mini/microUSB to the power cables to make it easy connect/disconnect. It's this one, from what I can see in the pictures. http://www.aliexpress.com/item/5PCS-Micro-USB-5V-1A-18650-Lithium-Battery-Charger-Board-With-Protection-Module/1852341893.html
From there, it's pretty straight forward. The battery is connected to the B+ and B- leads. The OUT+ and OUT- would be connected to the VIN/RAW and GND on your Nano, respectively.
-
The lamp is not shipped to NL and many other countries . Did anyone find it in Europe?
-
In The Netherlands they used to have it at Action .
But haven't been there lately
-
This One looks similar -> http://www.banggood.com/Solar-LED-Motion-Sensor-Waterproof-Wall-Light-For-Home-Garden-Outdoor-p-921885.html
Maybe banggood ships to NL?
-
There seems to be a similar one for sale right now at groupdeal.nl
but just for another 9 hours or so...
-
I really liked this project (@Salmoides ThankYou for sharing it)
Expecially the solar powered box.I've successully prototyped one, but would like to report something to pepople trying to also make this.
The solar panel included in the box, is outputting 6V, while the Charger board is sized to acced only 5V as input.
The consequence, is (at least on my prototype) that when there is enought sun, the charger board don't charge the battery (the blue led lights on, and the red seems to vibrate slighty : I guess this is a "protection mode" when VCCin is to high). If i remove the solar panel, and put a usb cable in the charger input, then the RED led lights on, and the barrety is being charged.I guess that slighly modifying the charger board, would allow it to accept 6V as input, but this is too far from my electronic skills (Anyone?)
As a workaround, I've ordered a StepDown module to reduce the 6V provided by the solar panel to 5V for the charger input. I guess It will do the job. I will report back as soon as I get the StepUp module from china.
HTH those interested in this excellent project.
BTW @Salmoides , How did you solved it? Does your Solar panel outputs 5V, instead of 6V? Does your charger works with 6V input (might be slighly diffrent board or mine has an issue)? Did you modified the charger or added extra component to reduce the input voltage ?
Cheeers to evereyone !
-
@soif said:
StepDown module to reduce the 6V provided by the solar panel to 5V for the charger input.
Put one or two silicon diodes in series with the solar panel. Each diode will lower the voltage by approx 0.7volts
-
@Yveaux thank you for the amazing fast and really helpful answer.
Droping the voltage by 0.7v would certainly change the charger beahaviour to behave properly, and not be in "protection mode", Definitively better than inserting a stepDown module.
I assume that I put the diode in serie from the VCC+ out of the Solar panel TO the VCC+ IN of the charger (right?), ie:
Solar VCC out ------ --->| ---- Charger VCC in.3 questions:
- Is there any diode reference recommendation, or any value do the job (1N400x) ?
- Will the diode "eat" some current, ot just drop the voltage -0,7v. ?
- BTW what is a "Silicon" diode?
thank you very much for your valuable support !
Berst regards,
-
@soif Your connection idea is correct. If you mount it in reverse, it simply won't work.
The actual voltage drop over the diode will depend on the amount of current flowing through it, so that's why you might require 2 in series.An 1N400x will do just fine. The higher the x, the more current it can handle.
The diode will consume some current, but that will be less then a step-down converter.
Most diodes nowadays use silicon as semiconductor. Years ago Germanium diodes were used, which have a lower voltage drop.As a reference: everything you need to know about diodes
-
@Yveaux Thank you very much for the diode explanation, as well as the very interesting diode tutorial.
Thanks to you, I've learned something more today.I'm gonna test it very soon, and will report back.
-
@bisschopsr @RiVoW @korttoma Accidentally ran into this one: http://www.aliexpress.com/store/product/1set-Garden-Security-Lamp-16-LED-Solar-Power-Motion-Sensor-Outdoor-Waterproof-Light/124364_32274407358.html
Looks identical, and free shipment to The Netherlands
-
This is similar to the one I have also bought at aliexpress
-
Hello, thank you for this beautiful project.
I have recreated it with a DHT22, a BMP180 and a BH1750FVI on a breadboard. From there everything is transferred to Domoticz via WiFi gateway. Everything is working properly. Only the light sensor makes problems ...
The reading of the sensor gives correct values in Lux. These are sent right to the gateway. The Gateway appears to be wrong to interpret these values. It transmits incorrect values via WiFi.
What can I do against it? Did anyone have an idea?
I'm using MySensors 1.5 on Arduino 1.6.7.
Thomas
-
@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 !
-
This is great.....[ and great for a dummy like me ]
Would you please tell me all the hardware you use?
Or the strength of the resistor etc etc
-
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?
-
Hi,
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
-
@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
-
Please can you ex-plane how i can remove 1 of the sensors in the sketch...
I will try to build more of this sensors...
Only 1 rain and 1 baro is good for me
-
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!!!!!
-
what are the resistors? Or what do you u use between the wires?
Look simple to me..
-
@Dombo71 look a fritzing schematic
-
-
@Didi 0_1459967939633_schema-pannello-solare-2.fzz
Fritzing File!!!!
-
New fritzing
I have two questions?
- voltage divider for more 5 v (battery voltage 12-13 volts)
- I use a auto phone charger for step down (12v --> 5 V) - warmers if I close in a box?
Thank
-
@gigi said:
New fritzing
I have two questions?
- voltage divider for more 5 v (battery voltage 12-13 volts)
- I use a auto phone charger for step down (12v --> 5 V) - warmers if I close in a box?
Thank
Is your fritzing correct?
On the green wire (light sensor?) you measure on ground where I guess you should measure between the resistor and the sensor.
-
@Petjepet said:
On the green wire (light sensor?) you measure on ground where I guess you should measure between the resistor and the sensor.
Is the same
voltage divider
-
@gigi I know but in your breadboard picture the now mentioned V output is connected directly to ground.
-
-
Back to the weather station.
I was having problems reporting wind speed to domoticz (in hardware my sensor was listed, but there was no device creation)
After a question on their forum, i learned tha i had to implement gust and direction to the sensor becaus Domoticz is aspectiong these to before it vreates a device.
I had to remove the rainrate because the sketch was getting to big.
Here is the latest sketch i am using :#include <SPI.h> #include <MySensor.h> #include <dht.h> #include <BH1750.h> #include <Wire.h> #include <Adafruit_BMP085.h> #include <MySigningAtsha204.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 MESSAGEWAIT 500 #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; unsigned int knoten; unsigned int wind; 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); MyTransportNRF24 radio; // NRFRF24L01 radio driver MyHwATMega328 hw; // Select AtMega328 hardware profile MySigningAtsha204 signer(true); // Select HW ATSHA signing backend Adafruit_BMP085 bmp = Adafruit_BMP085(); BH1750 lightSensor; dht DHT; MySensor gw(radio, hw, signer); 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 msgWGust(CHILD_ID_WINDSPEED, V_GUST); MyMessage msgWDirection(CHILD_ID_WINDSPEED, V_DIRECTION); MyMessage msgRain(CHILD_ID_RAIN, V_TRIPPED); 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"); 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 windSpeed; } 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; } bIsRaining = !(digitalRead(DIGITAL_INPUT_RAIN_SENSOR)); 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, 1)); wind = windmeter(); Serial.print("Wind : "); Serial.println(wind); int wdirection = 1; int wgust = 1; gw.send(msgWindSpeed.set(wind, 1)); gw.send(msgWGust.set(wgust, 1)); gw.send(msgWDirection.set(wdirection, 1)); 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"); } }
regards Peer
-
Hi,
It means that there is no possibility to implement wind speed on this weather station... ok.
I've just received the good Li-Ion charging component, I can continue with the construction!I'll post if I will be facing for some trouble, or when it will be finished.
-
@Salmoides - I must congratulate you on a very neat and professional build.
I'm not sure if you are still hanging around this forum but even if you aren't, others may find the following suggestion helpful.
@Salmoides said*:
With it [the rain detector] I get 0.98 mA [drain] during the gw.sleep command
There is a very easy, but often overlooked, method to disable sensors to reduce battery drain that requires no additional components. Because the sensor draws approximately 1ma, that is well within the 'drive' capacity of an Arduino output pin (which is about 20ma). So, all you need to do is wire the "+" power pin of the rain sensor to a spare output pin and "digitalWrite(pin,HIGH)" to turn it on and "digitalWrite(pin,LOW)" to turn it off.
IMPORTANT: You should check the specs of the processor you are using to make sure the I/O pin can 'drive' or 'source' more than the required current of the sensor you wish to switch. I'd suggest allowing a 50% safety margin.
Paul
-
Looks like a feasible idea, as my stn does consume all the battery on bad days, and yes I needed the diode between the solar and controller to get to the right voltage
cheers doug
-
Hello, it a nice job
I am french so I beg your pardon for my poor English
Can you , please show me how the lipo and the solar cell are connected and how the arduino is powered by the little shield (Charger Board ) at the right of picture over the DHT ?
Thanks
-
@gigi: Besides the already adressed error in the Fritzing I have anaother question. In the diagram there is a charge controller for 12V. The original design in this threat uses a 5V charging module. What module are you using or planning to use?
Thanks Ralph
-
@Renard : Bonjour! Je fais le raccordement cette semaine j'espère, je galère sur la déclaration dans Domoticz et l'étalonnage pour controler la charge de la batterie, mais je dirais:
- OUT+ et - sur RAW et GND de l'Arduino
- B+ B- à la batterie
- "+ et -" au panneau solaire, c'est ce qu'il me semble sur les photos.
@bisschopsr : Hi, There is no charge controler 5 or 12 volts. On my Fritzing to understand better the scheme (Post #70), I draw batteries and solar panel, but Fritzings following are with 12volts charger, I don't know why. If you purchased a solar lamp, it's to avoid 5 or 12volts charger and use the sun
-
Merci pour la réponse
C 'est donc l'arduino qui gère la décharge..
Je vais donc mettre "Arduino Compatible Solar Charger shield -LiPo rider" a la place ...Thanks for answer
It is the arduino wich control the discharge
I put "Arduino Compatible Solar Charger shield -LiPo rider" without control of lipo capacity
-
Thanks for the anwer @Elfnoir. I looked back at your schedule and there is some logic between the solar panel, the batteries and the other components (as the power consumers). That logic in the middle is what I refered to as charge controller. I would like to know what part this is.
Thanks again.
Ralph
-
@Renard c'est bien l'arduino qui gère la décharge et envoi l'info à Domoticz; c'est pour cela que tu dois étalonner le min/max avec le potentiomètre
it is the Arduino which manages the discharge and send the info to Domoticz ; that's why you have to calibrate the min / max with the potentiometer@bisschopsr If I well understand your question, the module which take the solar power to charge the battery with providing in the same time power to the arduino, and provide power of the battery to the arduino when there is no sun or at night: it's the Lipo Ride. There is no monitoring from the Arduino to the Lipo, but the Arduino read the level of voltage coming from the battery and send it to Domoticz.
Do I understand well your question please?
-
@Elfnoir You understood the question correct :). That was the answer I was looking for. So your battery is something like a 3.7V LiOn?
Thanks again
Ralph
-
@bisschopsr yes, the battery inside the “16 LED Solar Power Motion Sensor Security Lamp Outdoor Waterproof Light” (http://www.ebay.com/itm/271693521438) is 3.7v 800mAh.
-
@Elfnoir Thank you very much. I found a local LED lamp with 3.6V 600mAh NiMh battery. I'm going to try and make a simular solution from that one.
-
@Salmoides I built this weather station (exactly as decribed above in the initial message) and have some problems with the radio when going about 15 meters from the gateway.
I have several other nodes on similar distance working just fine.I guess the metal top of the case (where the solar panel is in) is causing the issue. Is there a way to change that? Maybe an additional antenna wire (how)?
-
@Petjepet The metal is definitely influencing the radio performance. It’s 2.4 GHz like the home wifi signal, so you might understand the impact if you compare these two. A solution to use a radio with an external antenna that can be placed outside the metal case. There is a radio with ext. antenna available, you might need an additional extension cable of say 15-30 cm. Does this help.
Regards,
Ralph
-
@bisschopsr That must be the same one I use for the gateway with the external antenna.
I also saw once a wire connected to the standard radio but can't recall where I saw that.
-
@Petjepet Yes, you are probably using this version for the GW (I know I am :-)). I have also see people hacking the original module by attaching a wire antenna instead of the on board printed antenna. The advantage of the other antenna based board is, you can actually bring the antenna to the outside. Something more difficult to do with a wire hack.
-
I have been adapting this mini-weather station code to he API 2.0 and add it the battery sensor. Here's my first attemp
// Enable debug prints to serial monitor #define MY_DEBUG // Enable and select radio type attached #define MY_RADIO_NRF24 //#define MY_RADIO_RFM69 #define MY_NODE_ID 2 #define MY_PARENT_NODE_ID 0 #define MY_PARENT_NODE_IS_STATIC #include <SPI.h> #include <MySensors.h> #include <DHT.h> #include <BH1750.h> #include <Wire.h> #include <Adafruit_BMP085.h> #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #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_BATTERY 6 #define MESSAGEWAIT 500 #define DHT_DATA_PIN 3 // Pin 3 digital = DHT11 or DHT12 #define windSpeedPin 4 // Pin 4 digital = Anenometer #define SENSOR_TEMP_OFFSET 0 #define STABILIZATION_TIME 500 // Let the sensor stabilize 0.5 seconds before reading static const uint8_t FORCE_UPDATE_N_READS = 10; static const uint64_t UPDATE_INTERVAL = 60000; #define BATTERY_FULL 7400 // 3,000 millivolts when battery is full (assuming 2xAA) #define BATTERY_ZERO 2800 // 1,700 millivolts when battery is empty (reqires blown brownout detection fuse, use 2,800 otherwise) const float ALTITUDE = 162; // <-- adapt this value to your own location's altitude. 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; unsigned int knoten; unsigned int wind; long oldvoltage = 0; bool metric = true; float lastBmpTemp; float lastPressure; float lastHum; float lastTemp; uint8_t nNoUpdatesTemp; uint8_t nNoUpdatesHum; int updateAll = 60; int updateCount = 0; uint16_t lastLux; unsigned long SLEEP_TIME = 60000; Adafruit_BMP085 bmp = Adafruit_BMP085(); BH1750 lightSensor; DHT dht; MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE); 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 msgWGust(CHILD_ID_WINDSPEED, V_GUST); MyMessage msgWDirection(CHILD_ID_WINDSPEED, V_DIRECTION); void setup() { analogReference(INTERNAL); dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) { Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!"); } // Sleep for the time of the minimum sampling period to give the sensor time to power up // (otherwise, timeout errors might occure for the first reading) sleep(dht.getMinimumSamplingPeriod()); if (!bmp.begin()) { Serial.println("Could not find a valid BMP085 sensor, check wiring!"); while (1) {} } metric = getConfig().isMetric; } void presentation() { lightSensor.begin(); sendSketchInfo("Weather Sensor", "4.1.C"); present(CHILD_ID_HUM, S_HUM, "WS Humidity"); // present(CHILD_ID_TEMP, S_TEMP, "WS Temperature"); present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "WS Lux"); present(CHILD_ID_BARO, S_BARO, "WS Pressure"); present(CHILD_ID_BTEMP, S_TEMP, "WS P Temperature"); present(CHILD_ID_WINDSPEED, S_WIND, "WS Windspeed"); present(CHILD_ID_BATTERY, S_CUSTOM, "WS Battery"); } // 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 windSpeed; } void loop() { updateCount += 1; if (updateCount == updateAll) { lastTemp = -1; lastHum = -1; lastLux = -1; lastBmpTemp = -1; lastPressure = -1; updateCount = 0; } long voltage = readVcc(); if (oldvoltage != voltage) { // Only send battery information if voltage has changed, to conserve battery. send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts and set wants volts and how many decimals (3 in our case) sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO))); oldvoltage = voltage; } delay(2000); // Force reading sensor, so it works also after sleep() dht.readSensor(true); // Get temperature from DHT library float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); } // Reset no updates counter nNoUpdatesTemp = 0; temperature += SENSOR_TEMP_OFFSET; send(msgTemp.set(temperature, 1)); #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif } else { // Increase no update counter if the temperature stayed the same nNoUpdatesTemp++; } // Get humidity from DHT library float humidity = dht.getHumidity(); if (isnan(humidity)) { Serial.println("Failed reading humidity from DHT"); } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) { // Only send humidity if it changed since the last measurement or if we didn't send an update for n times lastHum = humidity; // Reset no updates counter nNoUpdatesHum = 0; send(msgHum.set(humidity, 1)); #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif } else { // Increase no update counter if the humidity stayed the same nNoUpdatesHum++; } uint16_t lux = lightSensor.readLightLevel(); if (lux != lastLux) { 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) { send(msgBtemp.set(bmptemp,1)); lastBmpTemp = bmptemp; } if (pressure != lastPressure) { send(msgPressure.set(pressure, 0)); lastPressure = pressure; } wind = windmeter(); Serial.print("Wind : "); Serial.println(wind); int wdirection = 1; int wgust = 1; send(msgWindSpeed.set(wind, 1)); send(msgWGust.set(wgust, 1)); send(msgWDirection.set(wdirection, 1)); 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"); } } long readVcc() { // From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/ // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ADMUX = _BV(MUX5) | _BV(MUX0); #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) ADMUX = _BV(MUX3) | _BV(MUX2); #else ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #endif delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA, ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high << 8) | low; result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts }
It a little big but does what i need and the best thing it's that the anenometer works
-
My experience with using a "Micro USB 5V 1A 18650 Lithium Battery Charger Board With Protection Module" together with the "16 LED Solar Power Motion Sensor Security Lamp Outdoor Waterproof Light"s solar panel is that it's not charging the battery as well as the original built in PCB. Due to the varying voltage (up to 6V) of the solar panel it's not so well suited as a power source for "Micro USB 5V 1A 18650 Lithium Battery Charger Board With Protection Module". I experimented with diodes in serial (2 diodes gave best result) to lower the voltage. However using the original board allowed the battery to charge with a much higher current. I just cut of the motion sensor, and the power switch. It seems to work well. It's even charging a few mA now here when it's raining. My conclusion is that the "Micro USB 5V 1A 18650 Lithium Battery Charger Board With Protection Module" might be used but the original PCB makes a better job charging the battery.
Cheers!
Suggested Topics
-
Welcome
Announcements • • hek