Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Solar Powered Mini-Weather Station

Solar Powered Mini-Weather Station

Scheduled Pinned Locked Moved My Project
111 Posts 39 Posters 119.7k Views 27 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • bisschopsrB bisschopsr

    The lamp is not shipped to NL and many other countries :unamused: . Did anyone find it in Europe?

    YveauxY Offline
    YveauxY Offline
    Yveaux
    Mod
    wrote on last edited by
    #64

    @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 :+1:

    http://yveaux.blogspot.nl

    1 Reply Last reply
    0
    • soifS Offline
      soifS Offline
      soif
      Plugin Developer
      wrote on last edited by
      #65

      This is similar to the one I have also bought at aliexpress ;-)

      1 Reply Last reply
      0
      • thmT Offline
        thmT Offline
        thm
        wrote on last edited by
        #66

        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

        0_1454423311883_wrong_Lux.JPG

        1 Reply Last reply
        0
        • SalmoidesS Salmoides

          @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.

          LightPipe.gif

          M Offline
          M Offline
          maciejka
          wrote on last edited by
          #67

          @Salmoides
          Hi, where i can find light pipe lie this?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chickey
            wrote on last edited by
            #68

            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.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              Dylano
              wrote on last edited by
              #69

              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?

              Domoticz, with a lot of working hardware, include mysensors :-)
              OpenPLI, RuneAudio, Solarmeter, etc......

              Not a great builder of software and hardware, more a user...
              Only i try to do my best :-(

              1 Reply Last reply
              0
              • E Offline
                E Offline
                Elfnoir
                wrote on last edited by Elfnoir
                #70

                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 !

                0_1457780151323_Untitled Sketch_bb.jpg

                D 1 Reply Last reply
                0
                • E Elfnoir

                  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 !

                  0_1457780151323_Untitled Sketch_bb.jpg

                  D Offline
                  D Offline
                  Dylano
                  wrote on last edited by
                  #71

                  @Elfnoir

                  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

                  Domoticz, with a lot of working hardware, include mysensors :-)
                  OpenPLI, RuneAudio, Solarmeter, etc......

                  Not a great builder of software and hardware, more a user...
                  Only i try to do my best :-(

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    Elfnoir
                    wrote on last edited by
                    #72

                    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.

                    1 Reply Last reply
                    0
                    • bisschopsrB Offline
                      bisschopsrB Offline
                      bisschopsr
                      wrote on last edited by
                      #73

                      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

                      Domoticz, P1 meter interface, MySensors and more to come!

                      1 Reply Last reply
                      0
                      • peerkersezuukerP Offline
                        peerkersezuukerP Offline
                        peerkersezuuker
                        wrote on last edited by
                        #74

                        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 Lamp

                        Hope this helps,
                        With Regard's
                        Peer

                        Domoticz / My Sensors / Z-Wave
                        https://www.kermisbuks.nl

                        peerkersezuukerP 1 Reply Last reply
                        2
                        • E Offline
                          E Offline
                          Elfnoir
                          wrote on last edited by Elfnoir
                          #75

                          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!
                          1 Reply Last reply
                          0
                          • peerkersezuukerP peerkersezuuker

                            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 Lamp

                            Hope this helps,
                            With Regard's
                            Peer

                            peerkersezuukerP Offline
                            peerkersezuukerP Offline
                            peerkersezuuker
                            wrote on last edited by
                            #76

                            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

                            Domoticz / My Sensors / Z-Wave
                            https://www.kermisbuks.nl

                            1 Reply Last reply
                            0
                            • peerkersezuukerP Offline
                              peerkersezuukerP Offline
                              peerkersezuuker
                              wrote on last edited by
                              #77

                              @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

                              Domoticz / My Sensors / Z-Wave
                              https://www.kermisbuks.nl

                              E 1 Reply Last reply
                              0
                              • peerkersezuukerP peerkersezuuker

                                @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

                                E Offline
                                E Offline
                                Elfnoir
                                wrote on last edited by
                                #78

                                @peerkersezuuker 0_1459719366114_Weather Station.fzz

                                And thanks for your feedback and support!

                                1 Reply Last reply
                                0
                                • peerkersezuukerP Offline
                                  peerkersezuukerP Offline
                                  peerkersezuuker
                                  wrote on last edited by
                                  #79

                                  So here it is :
                                  0_1459792588384_upload-3adeb2e3-0d4c-41e1-a7d7-e973e5081210

                                  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

                                  Domoticz / My Sensors / Z-Wave
                                  https://www.kermisbuks.nl

                                  1 Reply Last reply
                                  0
                                  • peerkersezuukerP Offline
                                    peerkersezuukerP Offline
                                    peerkersezuuker
                                    wrote on last edited by
                                    #80

                                    Oh yeah, a little source mentioning :
                                    Weather Station
                                    Weather Station Code

                                    Greetz Peer

                                    Domoticz / My Sensors / Z-Wave
                                    https://www.kermisbuks.nl

                                    1 Reply Last reply
                                    0
                                    • Dombo71D Offline
                                      Dombo71D Offline
                                      Dombo71
                                      wrote on last edited by
                                      #81

                                      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

                                      1 Reply Last reply
                                      0
                                      • gigiG Offline
                                        gigiG Offline
                                        gigi
                                        wrote on last edited by
                                        #82

                                        This is my project!!!!

                                        0_1459952652761_schema-2_bb.jpg

                                        // 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
                                        0_1459952879015_vera-image.jpg

                                        On board
                                        0_1459952958112_IMG_20160406_162541.jpg

                                        Vera lite - mysensors Ethernet gateway - AirWik sensor - Relay Module

                                        1 Reply Last reply
                                        0
                                        • gigiG Offline
                                          gigiG Offline
                                          gigi
                                          wrote on last edited by
                                          #83

                                          I purchased a solar kit

                                          Solar Panel
                                          battery 12v
                                          landstar solar charge controller

                                          I 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!!!!!

                                          Vera lite - mysensors Ethernet gateway - AirWik sensor - Relay Module

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          13

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular