MySensors weather station


  • Hardware Contributor

    @dbemowsk - maybe we could do some sort of basic PCB to use with your project later on and MySensors people can buy and assemble both PCB and 3d printed thereself. Well that for the future. Good luck!


  • Mod

    @dbemowsk awesome what you're doing in openscad! :+1:
    I wonder if we could come up with a design that also incorporates a rain meter and all electronics...



  • @Yveaux I have been working on the rain gauge that I will use with this. I will probably start posting the pics for the rain gauge in this thread from now on and just link the other thread to this one.

    One other part that I haven't mentioned that I want to incorporate is a vented radiation shield like this to hold some of the sensors like temp, humidity, barometric pressure, etc.. I could possibly fit the MySensors board in this.
    0_1492609871971_upload-c7184435-2dae-4656-ba4b-2aa10de8616a

    Just did a quick google image search on "home weather station" and found a few that I could possibly use as models for the design since the wind sensor parts are similar to mine:
    0_1492610587524_upload-3edce7d8-df62-41ef-b664-aa07c550e9d4
    0_1492610971206_upload-9424bd18-349f-413e-8e48-114f5cf3fd62



  • @sundberg84 I love the idea of putting together a board for this. I would probably hold off though until I get the hardware built to know what we are dealing with. If we do it, it could be designed with connectors for all of the sensors and be set up as some sort of modular design so that people could build as much or as little of the project as they want.


  • Hardware Contributor

    @dbemowsk - sounds like a good plan!



  • Can I make a suggestion? Reverse the placement of the nuts to the top part, and the little machine screws to the bottom part of the housing. That way it will be easier to keep the water out as it will not creep in to the gap between the ABS and the screw. That capillary action will also work upside down, but good old gravity counters that to a great degree.


  • Mod

    @dbemowsk I have exactly the same weather station as the first one (Alecto DKW-2012 in my case).
    I would very much like to have all sensors integrated into a single unit, not having single units (wind, rain, temp) interconnected with some bars.
    This would also have a much higher WAF :nail_care: IMHO
    Maybe I'd better sit down and drawn something to get the creativity flowing ;-)

    What material did you use to print it BTW?


  • Mod

    For what I read ASA filaments are uv resistant and can sustain outdoor exposure.



  • @Yveaux You can NEVER forget the WAF. Luckily, my wife is to the point of just asking, "so what are you building now".



  • @DavidZH Good point. Reversing these should not be a big problem. Just a matter of re-designing the internal rotors that hold the magnets. I'd have to do that because one side has more room than the other. They are only like 15 minute prints anyway

    Thanks for the suggestion.



  • So Monday I should have my new reed switches and should be able to start working on the board for the wind sensors. For the anemometer, the setup is pretty simple. The rotor has a magnet (red arrow) that passes by the reed switch (blue arrow) to count the revolutions.
    0_1492875963522_upload-373e9c0b-f453-4328-97fc-62a7be9b5cc1

    The reed switch wire for the anemometer will pass through the hole at the edge (green arrow) and connect to the direction rotor PCB. Had a small problem when I was cutting the board (blue arrow), but it should still be usable for the prototype. The red lines (red arrow) are where the reed switches will get mounted for the wind direction rotor.
    0_1492876264052_upload-b165feee-93e0-48a9-b1d0-4c2af21c550e

    The direction rotor has a small round magnet (blue arrow) which should face the nose cone of the wind direction vane and will pass by the magnetic reed switches mounted on the round PCB
    0_1492876688706_upload-57ee9f7c-ac97-4704-855f-72e916d8eb07

    The circuit board mounting plate will get sandwiched between the top and bottom covers and have the main connection wire feed through the side hole near the wind direction magnet in the previous pic.
    0_1492877066850_upload-e840a1bf-f9b5-4b42-bfcb-4b18d46d47cf

    Later I will post the proposed schematic for how this will all connect to the pro mini. I will also hopefully have some test code for the setup.



  • So I was playing around a bit on the circuits.io website and came up with this for a test circuit. Each push button switch represents a reed switch for the direction rotor.
    0_1492881263412_upload-beb662b0-043a-4250-aedd-3a51ac3497f1

    The idea is to separate the 8 reed switches into two banks which will only use 2 analog IO lines to handle all 8 switches. The first bank of reed switches will be for North, South, East and West. The second bank will be for Northeast, Southeast, Southwest and Northwest. My main reason for doing it this way was due to the fact that the MySensors library API uses V_DIRECTION for the wind direction and is a number between 0 and 360. I needed a way to get more accurate than just 0, 45, 90, 135, 180 etc... which I could do tying all of the reed switches to 1 analog IO line. With this design, I can catch the directions when the magnet is in-between 2 of the reed switches and activating both giving me another 1/8 step of accuracy.

    Below is the code that I tested on the above circuit. The code should handle debouncing of the reed switches. With the reed switch and magnet rotor setup in place, the code should never reach a 999 value. It should always return a value between 0 and 337 based on the direction of the wind.

    int old_NSEW = 0, old_NeSeSwNw = 0;
    
    void setup() {
      Serial.begin(9600);
      pinMode(A0, INPUT);
      pinMode(A1, INPUT);
    }
    
    int getNSEW()
    {
      int i, z, sum;
      int button;
    
      sum = 0;
      for (i=0; i < 4; i++)
      {
         sum += analogRead(A0);
      }
      z = sum / 4;
      //Serial.println(z);
      if (z > 1021) button = 999;                                           
      else if (z > 357 && z < 361) button = 0;                     
      else if (z > 405 && z < 409) button = 90;                
      else if (z > 467 && z < 471) button = 180;                
      else if (z > 551 && z < 555) button = 270;  
      else button = 999;
    
      return button;
    }
    
    int getNeSeSwNw()
    {
      int i, z, sum;
      int button;
    
      sum = 0;
      for (i=0; i < 4; i++)
      {
         sum += analogRead(A1);
      }
      
      z = sum / 4;
      //Serial.println(z);
      if (z > 1021) button = 999;                                              
      else if (z > 357 && z < 361) button = 45;                     
      else if (z > 405 && z < 409) button = 135;                
      else if (z > 467 && z < 471) button = 225;                
      else if (z > 551 && z < 555) button = 315;  
      else button = 999;
    
      return button;
    }
    
    
    void loop ()
    {
      int NSEW, NeSeSwNw, NSEW_curr, NeSeSwNw_curr, triggered_NSEW, triggered_NeSeSwNw;  
      NSEW = getNSEW(); 
      NeSeSwNw = getNeSeSwNw();
      if (NSEW != old_NSEW)
      {
          delay(50);        // debounce
          NSEW_curr = getNSEW();
    
          if (NSEW == NSEW_curr)
          {
             old_NSEW = NSEW;
             triggered_NSEW = NSEW;
            if (NSEW == 999 || NeSeSwNw == 999) {
               triggered_NSEW = NSEW;
            } else if (NSEW < NeSeSwNw) {
               triggered_NSEW = ((NeSeSwNw - NSEW) / 2) + NSEW;
            } else {
               triggered_NSEW = NSEW - ((NSEW - NeSeSwNw) / 2);
            }
             Serial.println(triggered_NSEW);
          }
       }
      if (NeSeSwNw != old_NeSeSwNw)
      {
          delay(50);        // debounce
          NeSeSwNw_curr = getNeSeSwNw();
    
          if (NeSeSwNw == NeSeSwNw_curr)
          {
             old_NeSeSwNw = NeSeSwNw;
            if (NSEW == 999 || NeSeSwNw == 999) {
               triggered_NeSeSwNw = NeSeSwNw;
            } else if (NSEW < NeSeSwNw) {
               triggered_NeSeSwNw = ((NeSeSwNw - NSEW) / 2) + NeSeSwNw;
            } else {
               triggered_NeSeSwNw = NeSeSwNw - ((NSEW - NeSeSwNw) / 2);
            }
            Serial.println(triggered_NeSeSwNw);
          }
       }
    }
    

    Does anyone see any issues in this approach to the wind direction?

    Next I plan on working on the code for the anemometer to calculate wind speed. I could possibly have that figured out later today.


  • Mod

    Personally I think you may have issues with the position when magnet will be around the middle of 2 sensors because it could either trigger both or none of them so magnet strength will be crucial to your setup. I still think the optical sensor used by the other weather stations is a preferred solution



  • @gohan the diameter of the circuit board is 52mm or a radius of 26mm. From the center of the shaft to the center of the magnet is 17.75mm. The reed switches I ordered were 7mm long. I had to get shorter ones because of the tight space they will be in. The magnet's diameter is 4.25mm and it is a pretty strong neodymium magnet. Calculating the circumference to the center of where the magnet is mounted on the rotor, that is 111.5mm. Dividing that by 8 gives a distance between the reed switches of 13.94mm. I tested with a different reed switch that I had and found that the detection distance from magnet to reed switch is roughly 5mm plus or minus a smidge. The rotor should be fairly close to the reed switches if my calculations are correct. I can't say 100% till I get the reed switches and build the assembly, but I think I am going to be fine. I think worst case, I might have to get a slightly larger magnet, and even if I did it wouldn't have to be more than 1 to 2 millimeters bigger than the one I have.


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.