Solar Powered Mini-Weather Station



  • I remember having one of those beginner electronic kits when I was young and I was so excited the day I listened to our local radio station with the crystal radio I built with the kit. Decades later now, I’m finally re-living my childhood with MySensors. It was fun back then and it is again. I’m definitely a noob at this, I’m not an electrical engineer, but I have a knack for adopting the work of others and applying it to my own world. So to start off this project, I first need to thank Hek and all the other more knowledgeable and capable people that have developed what I use. This is really fun.

    Many of the MySensor projects are weather related, and this one is no different. I figured if I can do simple sensoring, I’ll learn the basics necessary to move on to the more advanced technologies. I am so new to this that I had to buy a soldering iron and learn how to use it. Research and practice are all part of this, and to that end I’ve already built my Vera Serial Gateway and my first sensor – a battery powered temperature and humidity sensor that sits in my kitchen. This project is my attempt to extend that knowledge to a mini-weather station that operates outdoors.

    My requirements were simple: 1) Build an inexpensive outdoor weather station, 2) Use the low-power battery features found in the MySensors Arduino libraries, and 3) Integrate it into my Vera home automation environment. I first put a list together of the components I could put into the weather station to comply with my first requirement. The list goes as follows (I’ve been using eBay, usually in lots of 10):

    • Arduino Pro Mini 3.3v 8MHz processor @ $2.50 USD
    • NRF24L01+ Transceiver @ $0.90
    • DHT22 Humidity & Temperature sensor @ $3.50
    • BMP180 Barometric Pressure sensor @ $1.70
    • BH1750FVI Ambient Light Intensity sensor @ $2.10
    • Rain Sensor Module @ $1.30

    The weather station components total $12.00 USD without power and a project box. Humidity was actually the most expensive piece given that the BMP180 also provides temperature. The DHT11 is less costly, but doesn’t really provide the range for an outdoor sensor. I did look at adding some other sensors. For another $10 I could add Ultraviolet sensing, for $25 I could put in a lightning sensor, $45 for wind speed, and even more for wind direction and a rain gauge. All those others would be great to have, but too costly for this project. I might try my hand at building an anemometer to add to this, and I see others are working on rain gauges, but those are projects for another day.

    I then needed power and an enclosure. I could have put them in a large waterproof box ($2.70), a three cell AA battery holder ($0.80), and some DuraRabbit batteries for a year ($3.00). For an additional $6.50, I was ready to go. Oh, did I mention I was lazy? I don’t really want to swap out the batteries every six months (or less), so I decided to splurge and go the solar route.

    Add a 5v solar panel ($3.35) and a 3.7v 1000mAh li-ion battery ($3.75), and some way to charge the battery (Micro USB 5V 1A 18650 Lithium Battery Charger Board With Protection Module @ $0.75) instead, and my total project cost went to $22.55. Of that, over $10 went to the box, the panel and charger, and the battery. Then I found this.

    SolarLight.jpg

    It’s entitled “16 LED Solar Power Motion Sensor Security Lamp Outdoor Waterproof Light” (http://www.ebay.com/itm/271693521438) that you can get for $9.00. I now had a $21 weather station ready to be built.

    Taking apart the lamp, I removed the LED panel (worth at least $2.00) and the control board (this has some good stuff on it like a PIR, a light sensor, and the battery charging circuitry, but its use is well beyond my skills), and put them away for another project.

    LEDArray.jpg

    I took a 5x7cm fiberglass PCB and cut a few notches in the sides so the board would fit within the new project case. Using the mounting screws that held the LED board down, I had a good way to affix the circuit board to the case.

    5x7PBP.jpg

    Next, I laid out how to cram all these components (including the R1 at 1MΩ & R2 [a 3296W potentiometer 500kΩ] resistors for the voltage divider to track battery voltage and the capacitor for the radio) into the enclosure. I ended up with a tight fit, but very manageable.

    BoardLayout.jpg

    One rule I’ve learned is to always breadboard all the components and measure the performance. This is where I check the current being used during the sleep mode and I get to test my preliminary sketch. It is a very good use of my time as I’ve come upon some bad components in what little of this that I’ve done and this is where they can be identified.

    Breadboard.jpg

    When I started learning the how-to’s of this hobby, I bought all sorts of stuff. One of the first purchases was one of those boxes of 22-gauge wire. The first one was stranded, so then I had to try solid to see if it was any easier to work with. It is, but is still huge compared to what is needed for these low-current projects. I found some old computer cables that had 26-gauge stranded in them. Better, but not what I wanted. Finally I came upon some discussions of wire-wrapping. I now use 30-gauge solid, first installed with a wire-wrapping tool (what a scam and I even found a cheap one for less than $20.)

    I decided to add two additional features after breadboarding the circuit. First, I wanted a reset button that could be reached without taking the case apart. At times I’ve found my sensors need a quick reboot. A switch was added to the underside of the PCB and a hole in the underside of the case will allow me to use a paperclip to do a reset.

    The other feature I added was a jumper that I could use to enable or disable the rain sensor if I chose to at a later date. For some reason it adds a significant load to the circuit. Without the rain sensor enabled, the circuit idles at 270 µA. With it I get 0.98 mA during the gw.sleep command. If I was smart enough, I’m sure I could get that down, but that’s still something to be learned. The underside, as usual, looked like spaghetti.

    Wired.jpg

    After a little bit of solder (I’m actually getting pretty good at that part), I have a fully functional circuit. Since the Li-Ion charging component takes a micro-USB connection, I charged the battery fully and then adjusted the pot to get the AO output to be right at 1023. For this setup my voltmeter showed the battery at 4.15v. I then needed to calibrate the circuit to get to the lower end of the acceptable voltage range. I’ve seen several different numbers for the bottom end of a 3.7v li-ion battery, some down to 2.7v. I chose 3.3v as my lowest acceptable value and proceeded to drain the battery (those LED arrays came in handy after all) down to 3.0v to see what the circuit value came out to be. For my setup, at 3.3v I was getting a value of 800 from pin A0. I updated the sketch so that it would be equal to 0% (hopefully it never gets there.)

    I had one addition to make to the project case. The rain sensor has a board that needs to be exposed to the elements. I drilled a couple of holes in the front end of the case and found some connectors that would work. The hole in the original case for the PIR sensor was a great opening to pass the cable through. The results actually look pretty good, if I can say so myself.

    Rain.png

    A couple of last minute touch-ups: two holes in the lens of the light, one for the reset button and one for the pot that adjusts the sensitivity of the rain sensor. I also take off any LEDs on the circuit, even LED13 on the Arduino. Every little bit helps. Does an LED actually illuminate if no one is there to see it? The final product came out nice.

    FinalTop.jpg

    One last upload of the final sketch. I took all the weather prediction logic out of the pressure sketch to save room for the other components. The SLEEP_TIME parameter is set for once every minute. I also added some lines of code to have the sensor update all measurements once an hour. I really like the ability to see when a measurement was last updated. That’s a nice touch to the MySensors library.

        #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_RAIN 5
        
        #define DIGITAL_INPUT_RAIN_SENSOR 3 
        #define HUMIDITY_SENSOR_DIGITAL_PIN 4
        #define INTERRUPT DIGITAL_INPUT_RAIN_SENSOR-2
        
        boolean metric = false;
        int altitude = 221; // 741 feet above sealevel
        float lastBmpTemp = -1;
        float lastPressure = -1;
        float lastHum = -1;
        float lastTemp = -1;
        int BATTERY_SENSE_PIN = A0;
        int lastRainValue = -1;
        int lastBatteryPcnt = 0;
        int updateAll = 60;
        int updateCount = 0;
        uint16_t lastLux;
        unsigned long SLEEP_TIME = 60000;
        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 msgRain(CHILD_ID_RAIN, V_TRIPPED);
        
        void setup()  
        {
          analogReference(INTERNAL);
          gw.begin();
          dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
          bmp.begin();
          gw.sendSketchInfo("Weather Sensor", "1.0");
          gw.present(CHILD_ID_HUM, S_HUM);
          gw.present(CHILD_ID_TEMP, S_TEMP);
          gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
          gw.present(CHILD_ID_BARO, S_BARO);
          gw.present(CHILD_ID_BTEMP, S_TEMP);
          gw.present(CHILD_ID_RAIN, S_MOTION);
          pinMode(DIGITAL_INPUT_RAIN_SENSOR, INPUT);
          lightSensor.begin();
          metric = gw.getConfig().isMetric;
        }
        
        void loop()      
        {
          updateCount += 1;
          if (updateCount == updateAll) {
            lastTemp = -1;
            lastHum = -1;
            lastLux = -1;
            lastBmpTemp = -1;
            lastPressure = -1;
            lastRainValue = -1;
            lastBatteryPcnt = -1;
            updateCount = 0;
          }
          delay(dht.getMinimumSamplingPeriod());
          float temperature = dht.getTemperature();
          if (isnan(temperature)) {
              lastTemp = -1;
          } else if (temperature != lastTemp) {
            lastTemp = temperature;
            if (!metric) {
              temperature = temperature * 1.8 + 32.0;
            }
            gw.send(msgTemp.set(temperature, 1));
          }
          float humidity = dht.getHumidity();
          if (isnan(humidity)) {
              lastHum = -1;
          } else if (humidity != lastHum) {
              lastHum = humidity;
              gw.send(msgHum.set(humidity, 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;
          }
          int rainValue = digitalRead(DIGITAL_INPUT_RAIN_SENSOR);
          if (rainValue != lastRainValue) {
            gw.send(msgRain.set(rainValue==0?1:0));
            lastRainValue = rainValue;
          }
          int sensorValue = analogRead(BATTERY_SENSE_PIN);
          int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant;
          if (lastBatteryPcnt != batteryPcnt) {
            gw.sendBatteryLevel(batteryPcnt);
            lastBatteryPcnt = batteryPcnt;
         }
          gw.sleep(SLEEP_TIME);
        }
    

    Then a test to make sure it’s dumping out its results as it should

        sensor started, id 1
        send: 1-1-0-0 s=255,c=0,t=17,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
        read: 0-0-1 s=255,c=3,t=6,pt=0,l=1:I
        send: 1-1-0-0 s=255,c=3,t=11,pt=0,l=14,st=ok:Weather Sensor
        send: 1-1-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
        send: 1-1-0-0 s=0,c=0,t=7,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=1,c=0,t=6,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=2,c=0,t=16,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=3,c=0,t=8,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=4,c=0,t=6,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=5,c=0,t=1,pt=0,l=5,st=ok:1.4.1
        send: 1-1-0-0 s=1,c=1,t=0,pt=7,l=5,st=ok:80.8
        send: 1-1-0-0 s=0,c=1,t=1,pt=7,l=5,st=ok:28.2
        send: 1-1-0-0 s=2,c=1,t=23,pt=3,l=2,st=ok:83
        send: 1-1-0-0 s=4,c=1,t=0,pt=7,l=5,st=ok:80.6
        send: 1-1-0-0 s=3,c=1,t=4,pt=7,l=5,st=ok:1020
        send: 1-1-0-0 s=5,c=1,t=16,pt=2,l=2,st=ok:0
        send: 1-1-0-0 s=255,c=3,t=0,pt=1,l=1,st=ok:91
    

    Finally, we then go to Vera and make sure she’s happy.

    MIOS.jpg

    This has been a great learning experience for me as it’s my first documented project. I made a bunch of mistakes in between most of the steps you see here. I’ve practiced my soldering techniques for many, many hours. One battery went bye-bye when I didn’t notice the leads had crossed. The smoke was a real good indicator that I’d messed up. I’ve ruined my fair share of components, but I chalk it all up to experience and don’t dwell on them. This hobby is a lot less expensive than golf or fishing, even with my mistakes. I look forward to bigger and better as I continue learn. Thanks again, Hek. This is a hobby that I truly enjoy.


  • Admin

    Very nice @Salmoides. Really like the solar panel box you found och how you transformed it it your own thing!



  • @Salmoides

    I really like the way you express yourself in: "Decades later now, I’m finally re-living my childhood with MySensors. It was fun back then and it is again."

    This exactly describes the way I think about "Mysensors".

    Boozz


  • Admin

    @boozz
    Yeah, but back then we didn't have all these fun, cheap breakout boards. They are like pick and mix sweets for us amateurs. 🙂


  • Hero Member

    @Salmoides Well Done!! I love it!! and to answer your question... Yes,, an LED will illuminate if no one is there to see it.. 🙂



  • What a great project. I'm also a beginner, having a new hobby with my sons, looking back to my own childhood... One question, your luxmeter, is it hidden behind the collector? Does he gets direct sunlight? Does it works with direct sunlight?

    Looking forwards to your next project!

    Floris



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



  • you are welcome, thank you for sharing! I'm going to use a waterproof box with a transparent cover. did you connect your hum/temp to d4, rain to d3 and lux to a4 and a5? ( i dont have the barometer yet)



  • @floris, Yes, those are the pins I used. The BMP085 is also I2C, using the same pins as the lux sensor.



  • Great, thanks.



  • @floris Thanks for sharing.

    Do you use the battery provided with the solar panel ?

    Thanks



  • @Totche, the original 3v7, 1000mAh lion battery is tucked under the circuit board. You can see the arch of the plastic cover toward the bottom of the picture on the left, just below the DHT22. It is connected to the circuit with the black and red wired connector so it can easily be removed when working with the device.



  • Hi, did you feed the NRF24L01 directly from the 3.7 V battery? The specs are alowing 3.6 V max?!? And you are taking about a maximum output of over 4 V of the battery.
    That sound not healthy for the NRF.



  • @Andreas-Maurer You can connect the NRF24 on the VCC out from the arduino. because he used an arduino nano pro on 3.3 volt. and the arduino can handle voltages from 3.3 to 12 DC.



  • Hi, I have my weatherstation up and running. The only problem is my rainsensor. It's totally not accurate. Do you have the same?

    Floris



  • @floris, you have to adjust the sensitivity of the rain sensor. I splashed some water on the sensor pad and used a small screwdriver to adjust the potentiometer on the interface board until it triggered to my satisfaction. It took a few iterations to get it to trigger at the level I was looking for.



  • @Salmoides
    How is this sensor performing? I assume it has to be mounted where it can receive direct sunlight for charging the solar panel. Do you have problems with sunlight heating the enclosure and elevating temperature readings? I intercept readings from my neighbor's 433Mhz outdoor sensor and the temperature soars when the sensor is under direct summer sunlight.



  • @Salmoides great thread and project

    Was trying to follow the wiring on the back side of the board to wire my project and was wondering how you wrap the wires around the posts sticking through the board for soldering.
    Also is there a wiring diagram?



  • @5546dug Wire wrapping is done with a wire wrapping tool, it is done in lieu of soldering and can be easily undone or 'unwrapped'. It was very common for prototyping in the past.



  • @Dwalt Thanks for info but the slant I get from you is this is the old way and now it is just plain soldering.
    I also see wire size is an issue.


  • Hero Member

    @Salmoides said:

    Then I found this.

    SolarLight.jpg

    It’s entitled “16 LED Solar Power Motion Sensor Security Lamp Outdoor Waterproof Light” (http://www.ebay.com/itm/271693521438) that you can get for $9.00. I now had a $21 weather station ready to be built.

    Taking apart the lamp, I removed the LED panel (worth at least $2.00) and the control board (this has some good stuff on it like a PIR, a light sensor, and the battery charging circuitry, but its use is well beyond my skills), and put them away for another project.

    @Salmoides I mesure less than 1 V at the solar panel wires, which cannot power up the regulator for the arduino.

    Do you have the same mesure ?


  • Hero Member

    @epierre said:

    @ mesure less than 1 V at the solar panel wires, which cannot power up the regulator for the arduino.

    Do you have the same mesure ?

    I have a couple of these units as well and just checked one. It's a cloudy day, but under a bright light it reported 4.3V at the solar panel wires. You might have a bad unit.

    Cheers
    Al


  • Hero Member

    @5546dug I am using wire wrap as well (well, I am old...). The upside of wirewrap is that it does not require electricity, very zen like, you can't make fatal mistakes and you can rescue or replace an arduino without a reflow station. the downside is that there is a limit to the currents (its not bad, but don't try to wire 220v, 3A using wire wrap...), there is a limit to the amount of wires that go to the same post and at times it is slower than soldering (for someone who is practiced). it is very very good for prototyping.


  • Hero Member

    @Sparkman strange for I tested again and this was good...



  • @Salmoides I have tried compiling this code you supplied in the thread prior to uploading to the promini, but it has an issue with the bmp180 code , it cannot read the sea level pressure. I see you set your altitude at 221 meters but I am not able to comprehend the error code on line 101.
    enclosed is the screen shot of the issue.
    I use ver 1.4 and lib 1.4



  • Screenshot (53).png
    So dumb of me to forget screenshot



  • just not sure where the readSealevelPressure(altitude) parameter is found
    I donot see it in the sketch and cannot find it in github



  • It's defined in the Adafruit_BMP085 library .cpp file. Did you include the library?



  • I used the supplied code from @Salmoides first reply in this thread.



  • Edit

    @Pieter-Jan-Stiers , I have tried various combinations of the " include " line in the setup for BMP085 sensor part and it will not compile.

    I tried adding the file Adafruit_BMP085_Unified-master.h but the sketch said no such file existed.
    However I did download and extract from github and put it in the file ....users/documents/arduino/libraries, I see it in the IDE but that is all
    see screen shot at the moment I have it commented out and sketch still does not find read SealevelPressure

    Any ideas? As I said I am using the sketch from the first post in this thread from @Salmoides

    Do I need to create in setup the line

    include <Adafruit_BMP085.cpp>

    Screenshot (56).png


  • Hero Member

    Did you close & reopened Arduino IDE after you placed the new library?



  • Yes
    Is file placed is the right area?


  • Hero Member

    You can also try it via the menu 'Sketch -> Import Library ... '

    Also make sure you are method readSeaLevelPressure is spelled exactly like it is defined in the .h file...



  • @rvendrame I seem to beat a loss as to what to do next
    I tried putting the file thru the >file import method and still I get error messages saying cant compile as above.
    When I include the unified file there are additional errors all above my paygrade.
    I have messed with the line readSealevelPressure<altitude> and the include lines but get nowhere.
    I think there is reference to this in original .cpp file but # including this is also errors.
    I have remane the files after saving and rebooted ide a few times ...no luck.

    a
    Any ideas or is the file from @Salmoides not compatable anymore?



  • here is a screen shot of the latest errScreenshot (57).png or code(s)


  • Hero Member

    How is your 'Sketchbook location' defined? (in "preferences...") Looking into the error message, it looks you are mixing windows slash "\" and unix slash "/" ...



  • After consultation in the troubleshooting category, I downloaded afresh copy of Adafruit-BMP085-library into my arduino library overwriting what was there and now code compiles.
    So on to uploading the code to promini and see what the next issue might/will be.



  • @Salmoides Hi Salmoides,
    Great Project!!

    I had the sensors and was looking for a project like this!

    I got it to run on the breadboard, and sync with domoticz. and the plan is to power it out with some 18650 cells+solar panel, but i have some questions for you.

    1. aren't you using any resistors for the i2c sensors? or the dht22?
    2. how hare you connecting the battery? when fully charged it can go up to 4.2v i belive this whould burn some sensors.. are you connecting it to the arduino raw pin and feeding the sensors with the regulated 3.3v pin!?
    3. the potentiometer, are you using it only as a resistor? or are you regulating it?

    thanks for sharing, and here are some screenshots of my implementation.

    QuarterSizeRender.png
    domoticz_solar.png



  • I don't seem to be able to get the DHT22 working. I have stripped this project down to the following prototype, and am still not able to get the DHT22 to work. I'm using the DHT example (not MySensors) script and continue to get timeout errors for both Temp and Humidity. I have tried a 4.0k ohm, 10k omh and no resistor.

    DHT22 Solar_bb.png

    I am just wanting to know if I might be missing something, and to also verify that other people have got the DHT22 working with a Arduino Pro Mini 8mhs - 3.3 volt using its regulated vcc pin. I have ordered new DHT22 modules from a different source just to see what happens.

    Thanks in advance for any input.


  • Hardware Contributor

    One thing comes to mind is that DHT has 3.3v as minimum power.
    If you have a "weak" pro mini board delivere power below that maybe is a problem. Can you measure the power?

    I have a 3.3v pro mini running a DHT22 fine, so it should work - but I also know there is a big difference in different hardware even if its called pro mini.



  • @gbfromhb I did not use the resistor and no Vcc connection through it to D4.
    My output is straight to pro mini.
    Vcc and gnd make up the other two connections.



  • @5546dug thanks for the input. I had also tried it with 4k ohm, 10k ohm and no resistor and connection to VCC to pin 2 of the DHT.

    @sundberg84 thanks for your input as well. I tried two different Pro Minis also, but from the same supplier. I think I'm going to go after a new Pro Mini from a different supplier.


  • Mod

    @gbfromhb I seemed to have similar problems as you using the DHT22 (Straight from China, marked AM2302). Reported 2% hudity and 0 degrees, with data line directly connected to pin3 (no pullup) on 8MHz Pro Mini.
    Switched from the MySensors DHT library to this one: https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib
    Now works like a charm with the dht22_test.ino sketch:

    dht22_test.ino
    LIBRARY VERSION: 0.1.20
    
    Type,	status,	Humidity (%),	Temperature (C)	Time (us)
    DHT22, 	OK,	45.4,	25.9,	5216
    DHT22, 	OK,	45.7,	26.0,	5240
    DHT22, 	OK,	45.6,	26.0,	5136
    DHT22, 	OK,	45.4,	26.0,	5128
    DHT22, 	OK,	45.3,	26.1,	5176
    DHT22, 	OK,	45.1,	26.1,	5176
    ... etc ...
    
    

    You could give this library a try; it might work with yours!



  • @Yveaux thank you for the information. I was going to post my solution tomarrow morning. I found first the library you had suggested, and found a second one that I settled on. Yesterday my top thought on this was it was a timing issue, and the slower 8Mhz pro mini. I had ruled out voltage as the issue. The library you directed me in their last revision addressed timing issues with slower clock speeds. It did work great. I did find a different one that seems to have a few more functions that I need and it seems to work great also.

    https://github.com/adafruit/DHT-sensor-library

    I seemed to get more accurate temperature when I put a 10k ohm resistor between pin 1 and 2 on the DHT22.


  • Mod

    @gbfromhb Good to hear you've sorted things out!
    I'll give the Adafruit lib a try someday.


  • Admin

    If/when you guys have evaluated the best DHT library, maybe we should update the one distributed in the MySensors bundle?


  • Mod

    @hek tricky, as we seem to be the only ones having issues with the library included with MySensors. I only have one DHT22 so I cannot test with other sensors...



  • @hek I think this is a good idea to update the DHT library that is being distributed. I have tried the DHT11 & DHT22 on both of these these libraries and they seem to work. It is pretty interesting the revision logs for both of these have addressed lower clock speed issues that were resolved in different versions, and the current library that is being distributed has not been touched for over over 2 years. The library that @Yveaux is using has been updated in that last 6 months, and the one I'm currently using has been updated in the last month. Both of these libraries have been around for 3 or 4 years. There is also one more library that I was looking at that I have not tried and that is: https://github.com/piettetech/piettetech_dht.

    I choose the one I did, because it had some functions that enabled me to work with Fahrenheit easier.

    I don't think we are the only ones that have had issues with the DHT library that have been resolved by changing library. Take a look at the bottom of this post:
    http://forum.mysensors.org/topic/1894/pro-mini-is-giving-a-frequent-time-out-on-dth11-read-out/8


  • Admin

    Yep, would be great if someone had time to evaluate the different options and get back to me with a suitable choice.



  • Please add an wiring diagram. Especially for the solar panel, battery and connection to the Nano.



  • @5546dug Have you a wiring diagram?



  • I've build something like this that logs temperature to an SD card, so no radio or gateway involved. Been getting NaNs from my DHT22 every few readings since I switched from a 5v Pro Mini to a 3.3v one. This never happened on the 5v one, so I guess I'll try switching library as well!



  • @hek I like the following library https://github.com/adafruit/DHT-sensor-library (ladyada).

    This seems to be working fine with the Arduino Pro Mini 8mhz.
    Here is a MySensors example using this library:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik EKblad
     * Version 1.1 - Glenn Byron - September 6, 2015 - Converted to new DHT library written by ladyada 
     * 
     * DESCRIPTION
     * This sketch provides an example how to implement a humidity/temperature
     * sensor using DHT11, DHT21, DHT-22 
     * http://www.mysensors.org/build/humidity
     */
     
    #include <SPI.h>
    #include <MySensor.h> 
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define HUMIDITY_SENSOR_DIGITAL_PIN 2
    #define DHTTYPE DHT22
    // DHTTYPE choices: DHT11, DHT21, DHT22
    
    unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
    
    MySensor gw;
    DHT dht(HUMIDITY_SENSOR_DIGITAL_PIN, DHTTYPE);
    float lastTemp;
    float lastHum;
    boolean metric = false; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    
    void setup()  
    { 
      Serial.begin(115200);
      Serial.flush();
      Serial.println("MySensors: DHT example");
      
      gw.begin();
      dht.begin();
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Humidity", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
      
      metric = gw.getConfig().isMetric;
    
      delay(2000);
    }
    
    void loop()      
    {  
      float temperature = dht.readTemperature(!metric);
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        gw.send(msgTemp.set(temperature, 1));
        Serial.print("Temperature: ");
        Serial.println(temperature);
      }
      
      float humidity = dht.readHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          gw.send(msgHum.set(humidity, 1));
          Serial.print("Humidity: ");
          Serial.println(humidity);
      }
    
      gw.sleep(SLEEP_TIME); //sleep a bit
    }
    


  • @Bazeman

    If i'm not mistaken, the solor panel is directly connected to the power input of the solar charger. @Salmoides wired a mini/microUSB to the power cables to make it easy connect/disconnect. It's this one, from what I can see in the pictures. http://www.aliexpress.com/item/5PCS-Micro-USB-5V-1A-18650-Lithium-Battery-Charger-Board-With-Protection-Module/1852341893.html

    From there, it's pretty straight forward. The battery is connected to the B+ and B- leads. The OUT+ and OUT- would be connected to the VIN/RAW and GND on your Nano, respectively.



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



  • In The Netherlands they used to have it at Action .
    But haven't been there lately


  • Hero Member



  • There seems to be a similar one for sale right now at groupdeal.nl
    but just for another 9 hours or so...


  • Plugin Developer

    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 !


  • Mod

    @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


  • Plugin Developer

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


  • Mod

    @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


  • Plugin Developer

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


  • Mod


  • Plugin Developer

    This is similar to the one I have also bought at aliexpress 😉



  • Hello, thank you for this beautiful project.

    I have recreated it with a DHT22, a BMP180 and a BH1750FVI on a breadboard. From there everything is transferred to Domoticz via WiFi gateway. Everything is working properly. Only the light sensor makes problems ...

    The reading of the sensor gives correct values in Lux. These are sent right to the gateway. The Gateway appears to be wrong to interpret these values. It transmits incorrect values via WiFi.

    What can I do against it? Did anyone have an idea?

    I'm using MySensors 1.5 on Arduino 1.6.7.

    Thomas

    0_1454423311883_wrong_Lux.JPG



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



  • I have one of these lights and got it with the plan of dissembling it for this very project but it was too good lol so think I'll buy another to dissect. The only disappointing thing is how the light is always on at a dim level so drains the battery. I'd much rather have it only activate on motion detection with the PIR.



  • Dear...
    Great project...[ when i got my stuff i am going to build to...

    Only how do you use the motionsensor of this light...[ new one or do you use the build in one ]
    In the sketch is can not see this motionsensor?
    Only in our Vera controller is see arm and bypass?
    Can you set the level of the lights, in vera?
    Two times temperature?
    And how is your battery action in the winter-period?



  • Hi,

    Here is the fritzing shema ; could you please tell me if it is correct before I begin the building of the weather station ?

    Thanks for your support !

    0_1457780151323_Untitled Sketch_bb.jpg



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



  • Hi,
    The left resistor is a 1Mohm 2W(I'll confirm the power value once I'll received it), the right one is 4,7kohm, 1/4W.
    For the Hardware, I read the beginning of the post, but unfortunately I'm also a newby, and need to have a validation of this diagram, because I'm not sure if it is correct, and I don't want to burn my house if I'll do cabling mistakes 😉
    I am not able to put the file created under fritzing, but if someone wants it, tell me how to do it please.

    Thanks for your feedback!
    Regards.



  • Hi all,

    the lamp used as a basis for this desing is now frequently offered at Aliexpress. Price is around $10,-. DOn't know about quality, but looks very simular.

    Ralph



  • Hello All,
    Long time reader, first time poster.
    I've been building my-sensors in combo with Domoticz for a while now , and this project is one of my favorites.
    I can confirm that the fritzing schema is correct, i checked it against the one i build. (whish i had the schema earlier, it would have been so much easier ;-))
    I used the followin library from Rob Tillaart for the DHT22 (http://playground.arduino.cc/Main/DHTLib / https://github.com/RobTillaart/Arduino/tree/master/libraries/DHTlib) because the standard was not working...
    Change line 37 to dht DHT;
    comment out line 51
    From line 78 i changed the code to this :

    delay(2000);
          int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN);
          temp = DHT.temperature;
                 //Serial.print("Temperature DHT :");
                 //Serial.println(temp);
          if (isnan(temp)) {
              lastTemp = -1;
          } else if (temp != lastTemp) {
            lastTemp = temp;
            if (!metric) {
              temp = temp * 1.8 + 32.0;
            }
            gw.send(msgTemp.set(temp, 1));
            }
          hum = DHT.humidity;
          if (isnan(hum)) {
              lastHum = -1;
          } else if (hum != lastHum) {
              lastHum = hum;
              gw.send(msgHum.set(hum, 1));
          }
    

    And it is working like a charm.
    Now i ordered one of these : Wind Sensor
    I want to trie to get it working with this build.
    And indeed the lamp is stil available Solar Lamp

    Hope this helps,
    With Regard's
    Peer



  • Hi,
    Thanks for your help! I'm waiting for the LiPo charger, because I purchased a wrong one to pursue my implementation...

    • Could you tell me how I can comment our line 51 please? Just like this?
      'dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
    • Also, do you have already implement the Wind Speed Module, or it's under shipment? Do you use Domoticz as domotic software? It's to know how to implement this kind of child on it?
    • Is the solar panel providing enough power to have the weather station always working? (I'm living in France on Paris latitude, and I would like to know if the quantity of sun is enough, or I need a second solar panel)
    • And it appears my Barometric Pressure sensor gave me also the humidity and temperature; Why do we have 1DHT22 and 1BMP180 ?
    • And finally, how do you deal with the battery level, as I didn't see at the beginning of this post how it is implemented inside Vera? Because I would like to implement it in Domoticz
      Many thanks for your feedback!


  • Hi,
    Commenting is done with //
    so //dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
    The wind sensor is stil in shipment, so can't tell you anything about it, and i use Domoticz as controler software.
    I presume you have your gateway setup and connected, so the node should show up in domoticz with all the childs.
    I tested the the weather station only a few day's past monyh, because it is still under construction, but those day's it held out (I live near Eindhoven the Netherlands, so weather conditions are almost the same as yours ;-)).
    The battery reports through the potentiometer to A0, if the battery level = 100% the readout of A0 should be 1023 (adjustable with the portentio meter.
    Here is my sketch in total, althoug verry crude it works, it yust needs a lot of cleanup when i am done, but i need the sensor first to work.

       #include <SPI.h>
        #include <MySensor.h>  
        #include <dht.h>
        #include <BH1750.h>
        #include <Wire.h> 
        #include <Adafruit_BMP085.h>
        
        #define CHILD_ID_HUM 0
        #define CHILD_ID_TEMP 1
        #define CHILD_ID_LIGHT 2
        #define CHILD_ID_BARO 3
        #define CHILD_ID_BTEMP 4
        #define CHILD_ID_WINDSPEED 5
        #define CHILD_ID_RAIN 6
        #define CHILD_ID_RAINRATE 7    
        
        #define MESSAGEWAIT 500
        #define nRainIn A2
        #define DIGITAL_INPUT_RAIN_SENSOR 3
        #define HUMIDITY_SENSOR_DIGITAL_PIN 5
        #define ENCODER_PIN 2
        #define INTERRUPT DIGITAL_INPUT_RAIN_SENSOR-2
    
        //int encoder_pin = 7; // pulse output from the module
        unsigned int rpm; // rpm reading
        volatile byte pulses; // number of pulses
        unsigned long timeold;
        // number of pulses per revolution
        // based on your encoder disc
        unsigned int pulsesperturn = 1;
        boolean metric = false;
        int altitude = 16; // meters above sealevel
        float lastBmpTemp = -1;
        float lastPressure = -1;
        float lastHum = -1;
        float lastTemp = -1;
        double temp;
        double hum;
        int BATTERY_SENSE_PIN = A0;
        int lastRainValue = -1;
        int nRainVal;
        boolean bIsRaining = false;
        String strRaining = "NO";
        int lastBatteryPcnt = 0;
        int updateAll = 60;
        int updateCount = 0;
        uint16_t lastLux;
        // unsigned long SLEEP_TIME = 60000;
        unsigned long SLEEP_TIME = 600;
        int batteryBasement = 800;
        float batteryConstant = 100.0 / (1023 - batteryBasement);
            
        Adafruit_BMP085 bmp = Adafruit_BMP085();
        BH1750 lightSensor;
        dht DHT;
        MySensor gw;
    
        MyMessage msgHum(CHILD_ID_HUM, V_HUM);
        MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
        MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
        MyMessage msgBtemp(CHILD_ID_BTEMP, V_TEMP);
        MyMessage msgPressure(CHILD_ID_BARO, V_PRESSURE);
        MyMessage msgWindSpeed(CHILD_ID_WINDSPEED, V_WIND);    
        MyMessage msgRain(CHILD_ID_RAIN, V_TRIPPED);
        MyMessage msgRainRate(CHILD_ID_RAINRATE, V_RAIN);
    
        void counter()
        {
          //Update count
          pulses++;
        }
    
        void setup()  
        {
          analogReference(INTERNAL);
          gw.begin(incomingMessage, 3, true);  
          //dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
          bmp.begin();
          gw.sendSketchInfo("Weather Sensor", "1.0");
          gw.present(CHILD_ID_HUM, S_HUM, "WS Humidity");
          gw.present(CHILD_ID_TEMP, S_TEMP, "WS Temperature");
          gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "WS Lux");
          gw.present(CHILD_ID_BARO, S_BARO, "WS Pressure");
          gw.present(CHILD_ID_BTEMP, S_TEMP, "WS P Temperature");
          gw.present(CHILD_ID_WINDSPEED, S_WIND, "WS Windspeed");
          gw.present(CHILD_ID_RAIN, S_MOTION, "WS Rain");
          gw.present(CHILD_ID_RAINRATE, S_RAIN, "WS RainRate");
    
          pinMode(DIGITAL_INPUT_RAIN_SENSOR, INPUT);
          lightSensor.begin();
          metric = gw.getConfig().isMetric;
          pinMode(ENCODER_PIN, INPUT);
          //Interrupt 0 is digital pin 2
          //Triggers on Falling Edge (change from HIGH to LOW)
          attachInterrupt(0, counter, FALLING);
          // Initialize
          pulses = 0;
          rpm = 0;
          timeold = 0;
        }
        
        void loop()      
        {
          updateCount += 1;
          if (updateCount == updateAll) {
            lastTemp = -1;
            lastHum = -1;
            lastLux = -1;
            lastBmpTemp = -1;
            lastPressure = -1;
            lastRainValue = -1;
            lastBatteryPcnt = -1;
            updateCount = 0;
          }
          delay(2000);
          int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN);
          temp = DHT.temperature;
                 //Serial.print("Temperature DHT :");
                 //Serial.println(temp);
          if (isnan(temp)) {
              lastTemp = -1;
          } else if (temp != lastTemp) {
            lastTemp = temp;
            if (!metric) {
              temp = temp * 1.8 + 32.0;
            }
            gw.send(msgTemp.set(temp, 1));
            }
          hum = DHT.humidity;
          if (isnan(hum)) {
              lastHum = -1;
          } else if (hum != lastHum) {
              lastHum = hum;
              gw.send(msgHum.set(hum, 1));
          }
          uint16_t lux = lightSensor.readLightLevel();
          if (lux != lastLux) {
              gw.send(msgLux.set(lux));
              lastLux = lux;
          }
          float pressure = bmp.readSealevelPressure(altitude) * 0.01;
          float bmptemp = bmp.readTemperature();
          if (!metric) {
            bmptemp = bmptemp * 1.8 + 32.0;
          }
          if (bmptemp != lastBmpTemp) {
            gw.send(msgBtemp.set(bmptemp,1));
            lastBmpTemp = bmptemp;
          }
          if (pressure != lastPressure) {
            gw.send(msgPressure.set(pressure, 0));
            lastPressure = pressure;
          }
          
          nRainVal = analogRead(nRainIn);
                 Serial.print("RainVal :");
                 Serial.println(nRainVal);
          bIsRaining = !(digitalRead(DIGITAL_INPUT_RAIN_SENSOR));
                 Serial.print("Is Raining :");
                 Serial.println(bIsRaining);
          if(bIsRaining){
              strRaining = "YES";
          }
          else{
              strRaining = "NO";
          }
      
      //Serial.print("Raining?: ");
      //Serial.print(strRaining);  
      //Serial.print("\t Moisture Level: ");
      //Serial.println(nRainVal);
      //http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-rain-sensor-module-guide-and-tutorial/
    
          gw.send(msgRain.set(bIsRaining));
          nRainVal = nRainVal * -1;
          gw.send(msgRainRate.set(nRainVal));
          
          int sensorValue = analogRead(BATTERY_SENSE_PIN);
          int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant;
          if (lastBatteryPcnt != batteryPcnt) {
            gw.sendBatteryLevel(batteryPcnt);
            lastBatteryPcnt = batteryPcnt;
         }
    
         if (millis() - timeold >= 1000) {
            //Don't process interrupts during calculations
            detachInterrupt(0);
            rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses;
            timeold = millis();
            Serial.print("RPM = ");
            Serial.println(rpm,DEC);
            Serial.println(pulses);
            pulses = 0;        
            rpm = rpm,DEC;
            if (rpm == 0) {
              rpm = 1;
            }
            gw.send(msgWindSpeed.set(rpm, 1));
            //Restart the interrupt processing
            attachInterrupt(0, counter, FALLING);
          }
          gw.sleep(SLEEP_TIME);
        }
    
        void incomingMessage(const MyMessage & message) {
        // We only expect one type of message from controller. But we better check anyway.
         if (message.isAck()) {
           Serial.println("This is an ack from gateway");
         }
        }```
    And there is the puls counter which i abandoned for the wind speed meter (wanted to build my own with a optocoupler, but changed my mind).
    
    Hope this is helpfull.
    Regard's 
    Peer


  • @Elfnoir,
    Could you please send me the fritzing schema, or attach it here ?
    I want to add the windmeter i bought.
    I got it today, and with a little help from google i got it working.

    Greetz Peer



  • @peerkersezuuker 0_1459719366114_Weather Station.fzz

    And thanks for your feedback and support!



  • So here it is :
    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


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

    Greetz Peer



  • Please can you ex-plane how i can remove 1 of the sensors in the sketch...
    I will try to build more of this sensors...
    Only 1 rain and 1 baro is good for me



  • This is my project!!!!

    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



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



  • what are the resistors? Or what do you u use between the wires?
    Look simple to me..



  • @Dombo71 look a fritzing schematic



  • @gigi said:

    @Dombo71 look a fritzing schematic

    Can you share the fritzing file please





  • 0_1459971075004_schema-pannello-solare-2_bb.jpg

    New fritzing

    I have two questions?

    1. voltage divider for more 5 v (battery voltage 12-13 volts)
    2. I use a auto phone charger for step down (12v --> 5 V) - warmers if I close in a box?

    Thank



  • @gigi said:

    0_1459971075004_schema-pannello-solare-2_bb.jpg

    New fritzing

    I have two questions?

    1. voltage divider for more 5 v (battery voltage 12-13 volts)
    2. I use a auto phone charger for step down (12v --> 5 V) - warmers if I close in a box?

    Thank

    Is your fritzing correct?
    On the green wire (light sensor?) you measure on ground where I guess you should measure between the resistor and the sensor.



  • @Petjepet said:

    On the green wire (light sensor?) you measure on ground where I guess you should measure between the resistor and the sensor.

    0_1460011587951_LdrUp_down.jpg

    Is the same

    0_1460011676140_vdivider.jpg

    voltage divider



  • @gigi I know but in your breadboard picture the now mentioned V output is connected directly to ground. 😏

    0_1460012243066_Knipsel.JPG



  • @Petjepet I Know, thank

    on board as I did your chart

    0_1460012626053_schema-pannello-solare-2_bb-2.jpg
    Thank



  • Back to the weather station.
    I was having problems reporting wind speed to domoticz (in hardware my sensor was listed, but there was no device creation)
    After a question on their forum, i learned tha i had to implement gust and direction to the sensor becaus Domoticz is aspectiong these to before it vreates a device.
    I had to remove the rainrate because the sketch was getting to big.
    Here is the latest sketch i am using :

    
    
    
        #include <SPI.h>
        #include <MySensor.h>  
        #include <dht.h>
        #include <BH1750.h>
        #include <Wire.h> 
        #include <Adafruit_BMP085.h>
        #include <MySigningAtsha204.h>
        
        #define CHILD_ID_HUM 0
        #define CHILD_ID_TEMP 1
        #define CHILD_ID_LIGHT 2
        #define CHILD_ID_BARO 3
        #define CHILD_ID_BTEMP 4
        #define CHILD_ID_WINDSPEED 5
        #define CHILD_ID_RAIN 6
        
        #define MESSAGEWAIT 500
        #define DIGITAL_INPUT_RAIN_SENSOR 3
        #define HUMIDITY_SENSOR_DIGITAL_PIN 5
        #define ENCODER_PIN 2
        #define INTERRUPT DIGITAL_INPUT_RAIN_SENSOR-2
    
        const int  windSpeedPin = 2; // contact on pin 2 digital
        int windSpeedPinCounter = 0; // impuls counter
        int windSpeedPinStatus = 0; // actual impuls
        int windSpeedPinStatusAlt = 0; // oude Impuls-Status
        unsigned long windmeterStart;
        unsigned long windmeterStartAlt = 0;
        int windSpeed; // Variable voor Wind Speed
        int beaufort = 0; // Variable Wind in Beaufort
        const int windmeterTime = 10000;
        //float knoten = 0.0;
        //float wind = 0.0;
        unsigned int knoten;
        unsigned int wind;
       
        boolean metric = false;
        int altitude = 16; // meters above sealevel
        float lastBmpTemp = -1;
        float lastPressure = -1;
        float lastHum = -1;
        float lastTemp = -1;
        double temp;
        double hum;
        int BATTERY_SENSE_PIN = A0;
        int lastRainValue = -1;
        int nRainVal;
        boolean bIsRaining = false;
        String strRaining = "NO";
        int lastBatteryPcnt = 0;
        int updateAll = 60;
        int updateCount = 0;
        uint16_t lastLux;
        // unsigned long SLEEP_TIME = 60000;
        unsigned long SLEEP_TIME = 600;
        int batteryBasement = 800;
        float batteryConstant = 100.0 / (1023 - batteryBasement);
    
        MyTransportNRF24 radio;  // NRFRF24L01 radio driver
        MyHwATMega328 hw; // Select AtMega328 hardware profile
        MySigningAtsha204 signer(true); // Select HW ATSHA signing backend
        
        Adafruit_BMP085 bmp = Adafruit_BMP085();
        BH1750 lightSensor;
        dht DHT;
        MySensor gw(radio, hw, signer);
    
        MyMessage msgHum(CHILD_ID_HUM, V_HUM);
        MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
        MyMessage msgLux(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
        MyMessage msgBtemp(CHILD_ID_BTEMP, V_TEMP);
        MyMessage msgPressure(CHILD_ID_BARO, V_PRESSURE);
        MyMessage msgWindSpeed(CHILD_ID_WINDSPEED, V_WIND);
        MyMessage msgWGust(CHILD_ID_WINDSPEED, V_GUST);
        MyMessage msgWDirection(CHILD_ID_WINDSPEED, V_DIRECTION);   
        MyMessage msgRain(CHILD_ID_RAIN, V_TRIPPED);
    
        void setup()  
        {
          analogReference(INTERNAL);
          gw.begin(incomingMessage, 3, true);  
          //dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
          bmp.begin();
          gw.sendSketchInfo("Weather Sensor", "1.0");
          gw.present(CHILD_ID_HUM, S_HUM, "WS Humidity");
          gw.present(CHILD_ID_TEMP, S_TEMP, "WS Temperature");
          gw.present(CHILD_ID_LIGHT, S_LIGHT_LEVEL, "WS Lux");
          gw.present(CHILD_ID_BARO, S_BARO, "WS Pressure");
          gw.present(CHILD_ID_BTEMP, S_TEMP, "WS P Temperature");
          gw.present(CHILD_ID_WINDSPEED, S_WIND, "WS Windspeed");
          gw.present(CHILD_ID_RAIN, S_MOTION, "WS Rain");
    
          pinMode(DIGITAL_INPUT_RAIN_SENSOR, INPUT);
          lightSensor.begin();
          metric = gw.getConfig().isMetric;
        }
        
        // Wind Meter https://github.com/chiemseesurfer/arduinoWeatherstation/blob/master/weatherstation/weatherstation.ino
        
        float windmeter()
        {
            windmeterStart = millis(); // Actual start time measuringMessung
            windmeterStartAlt = windmeterStart; // Save start time
        
            windSpeedPinCounter = 0; // Set pulse counter to 0
            windSpeedPinStatusAlt = HIGH; // Set puls status High
        
            while ((windmeterStart - windmeterStartAlt) <= windmeterTime) // until 10000 ms (10 Seconds) ..
            {
                windSpeedPinStatus = digitalRead(windSpeedPin); // Read input pin 2
                if (windSpeedPinStatus != windSpeedPinStatusAlt) // When the pin status changed
                {
                    if (windSpeedPinStatus == HIGH) // When status - HIGH
                    {
                        windSpeedPinCounter++; // Counter + 1
                    }
                }
                windSpeedPinStatusAlt = windSpeedPinStatus; // Save status for next loop
                windmeterStart = millis(); // Actual time
            }
        
            windSpeed =  ((windSpeedPinCounter * 24) / 10) + 0.5; //  WindSpeed - one Pulse ~ 2,4 km/h, 
            windSpeed = (windSpeed / (windmeterTime / 1000)); // Devided in measure time in seconds
            Serial.print("wind Speed : ");
            Serial.println(windSpeed);    
            knoten = windSpeed / 1.852; //knot's
        
            return windSpeed;
        }
        
        void loop()      
        {
          updateCount += 1;
          if (updateCount == updateAll) {
            lastTemp = -1;
            lastHum = -1;
            lastLux = -1;
            lastBmpTemp = -1;
            lastPressure = -1;
            lastRainValue = -1;
            lastBatteryPcnt = -1;
            updateCount = 0;
          }
          delay(2000);
          int chk = DHT.read22(HUMIDITY_SENSOR_DIGITAL_PIN);
          temp = DHT.temperature;
                 //Serial.print("Temperature DHT :");
                 //Serial.println(temp);
          if (isnan(temp)) {
              lastTemp = -1;
          } else if (temp != lastTemp) {
            lastTemp = temp;
            if (!metric) {
              temp = temp * 1.8 + 32.0;
            }
            gw.send(msgTemp.set(temp, 1));
            }
          hum = DHT.humidity;
          if (isnan(hum)) {
              lastHum = -1;
          } else if (hum != lastHum) {
              lastHum = hum;
              gw.send(msgHum.set(hum, 1));
          }
          uint16_t lux = lightSensor.readLightLevel();
          if (lux != lastLux) {
              gw.send(msgLux.set(lux));
              lastLux = lux;
          }
          float pressure = bmp.readSealevelPressure(altitude) * 0.01;
          float bmptemp = bmp.readTemperature();
          if (!metric) {
            bmptemp = bmptemp * 1.8 + 32.0;
          }
          if (bmptemp != lastBmpTemp) {
            gw.send(msgBtemp.set(bmptemp,1));
            lastBmpTemp = bmptemp;
          }
          if (pressure != lastPressure) {
            gw.send(msgPressure.set(pressure, 0));
            lastPressure = pressure;
          }
          
          bIsRaining = !(digitalRead(DIGITAL_INPUT_RAIN_SENSOR));
          if(bIsRaining){
              strRaining = "YES";
          }
          else{
              strRaining = "NO";
          }
      
          //Serial.print("Raining?: ");
          //Serial.print(strRaining);  
          //Serial.print("\t Moisture Level: ");
          //Serial.println(nRainVal);
          //http://henrysbench.capnfatz.com/henrys-bench/arduino-sensors-and-input/arduino-rain-sensor-module-guide-and-tutorial/
    
          gw.send(msgRain.set(bIsRaining, 1));
    
          wind = windmeter();
          Serial.print("Wind : ");
          Serial.println(wind);
          int wdirection = 1;
          int wgust = 1;
          gw.send(msgWindSpeed.set(wind, 1));
          gw.send(msgWGust.set(wgust, 1));
          gw.send(msgWDirection.set(wdirection, 1));
          
          int sensorValue = analogRead(BATTERY_SENSE_PIN);
          int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant;
          if (lastBatteryPcnt != batteryPcnt) {
            gw.sendBatteryLevel(batteryPcnt);
            lastBatteryPcnt = batteryPcnt;
          }
          gw.sleep(SLEEP_TIME);
       }
    
        void incomingMessage(const MyMessage & message) {
        // We only expect one type of message from controller. But we better check anyway.
         if (message.isAck()) {
           Serial.println("This is an ack from gateway");
         }
        }
    
    

    regards Peer



  • Hi,
    It means that there is no possibility to implement wind speed on this weather station... ok.
    I've just received the good Li-Ion charging component, I can continue with the construction!

    I'll post if I will be facing for some trouble, or when it will be finished.



  • @Salmoides - I must congratulate you on a very neat and professional build.

    I'm not sure if you are still hanging around this forum but even if you aren't, others may find the following suggestion helpful.

    @Salmoides said*:

    With it [the rain detector] I get 0.98 mA [drain] during the gw.sleep command

    There is a very easy, but often overlooked, method to disable sensors to reduce battery drain that requires no additional components. Because the sensor draws approximately 1ma, that is well within the 'drive' capacity of an Arduino output pin (which is about 20ma). So, all you need to do is wire the "+" power pin of the rain sensor to a spare output pin and "digitalWrite(pin,HIGH)" to turn it on and "digitalWrite(pin,LOW)" to turn it off.

    IMPORTANT: You should check the specs of the processor you are using to make sure the I/O pin can 'drive' or 'source' more than the required current of the sensor you wish to switch. I'd suggest allowing a 50% safety margin.

    Paul



  • @AffordableTech

    Looks like a feasible idea, as my stn does consume all the battery on bad days, and yes I needed the diode between the solar and controller to get to the right voltage

    cheers doug



  • Hello, it a nice job
    I am french so I beg your pardon for my poor English
    Can you , please show me how the lipo and the solar cell are connected and how the arduino is powered by the little shield (Charger Board ) at the right of picture over the DHT ?
    Thanks



  • @gigi: Besides the already adressed error in the Fritzing I have anaother question. In the diagram there is a charge controller for 12V. The original design in this threat uses a 5V charging module. What module are you using or planning to use?
    Thanks Ralph



  • @Renard : Bonjour! Je fais le raccordement cette semaine j'espère, je galère sur la déclaration dans Domoticz et l'étalonnage pour controler la charge de la batterie, mais je dirais:

    • OUT+ et - sur RAW et GND de l'Arduino
    • B+ B- à la batterie
    • "+ et -" au panneau solaire, c'est ce qu'il me semble sur les photos.

    @bisschopsr : Hi, There is no charge controler 5 or 12 volts. On my Fritzing to understand better the scheme (Post #70), I draw batteries and solar panel, but Fritzings following are with 12volts charger, I don't know why. If you purchased a solar lamp, it's to avoid 5 or 12volts charger and use the sun 😉



  • Merci pour la réponse
    C 'est donc l'arduino qui gère la décharge..
    Je vais donc mettre "Arduino Compatible Solar Charger shield -LiPo rider" a la place ...

    Thanks for answer
    It is the arduino wich control the discharge
    I put "Arduino Compatible Solar Charger shield -LiPo rider" without control of lipo capacity


 

381
Online

7.5k
Users

8.4k
Topics

90.4k
Posts