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.3k 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.
  • soifS soif

    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 !

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

    @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

    http://yveaux.blogspot.nl

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

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

      YveauxY 1 Reply Last reply
      0
      • soifS soif

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

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

        @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

        http://yveaux.blogspot.nl

        soifS 1 Reply Last reply
        0
        • YveauxY Yveaux

          @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

          soifS Offline
          soifS Offline
          soif
          Plugin Developer
          wrote on last edited by
          #63

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

          1 Reply Last reply
          0
          • 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
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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