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

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. Problem with Wind Speed sensor

Problem with Wind Speed sensor

Scheduled Pinned Locked Moved Troubleshooting
53 Posts 6 Posters 14.7k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rnollenR Offline
    rnollenR Offline
    rnollen
    wrote on last edited by rnollen
    #12

    Thanks; but how to go further from here then :) Is there a way to create a sketch for this device? And how to attach it to a Nano board?

    I got a manual from the supplier: https://1drv.ms/w/s!AmsPyx0xoB6jjYo0PZZRazdA3-vPpw for this device. But I already see a difference with the wires :) But to give it a start then, according to the manual it counts the pulses and that gives a windspeed :)

    AWIA 1 Reply Last reply
    0
    • rnollenR rnollen

      Thanks; but how to go further from here then :) Is there a way to create a sketch for this device? And how to attach it to a Nano board?

      I got a manual from the supplier: https://1drv.ms/w/s!AmsPyx0xoB6jjYo0PZZRazdA3-vPpw for this device. But I already see a difference with the wires :) But to give it a start then, according to the manual it counts the pulses and that gives a windspeed :)

      AWIA Offline
      AWIA Offline
      AWI
      Hero Member
      wrote on last edited by
      #13

      @rnollen Hi, the manual is a bit confusing in that it mentions a "serial protocol" and also a table is mentioned with voltages and wind speed. As yours iw 3 wire we can assume it is not a RS485 output.

      Then there are you need to dertermine what kind of output it is either NPN or PNP. : PNP needs a "pull down" resistor. NPN needs a "pull up". resistor..Best thing is to test the different options with the volt meter.

      According to the table the "average" voltage should vary with the rotating spreed.

      Note that I make a lot of assumptions.... but: If you get a voltage on your meter that changes with the rotating spreed than it is time to connect the nan. With the assumption that there are pulses, best thing is to write a routine which counts the pulses in a certain time frame e.g 10 secs. (connect the nano with a either a digital or analog pin, but read with digitalread(),. There should be many examples on the web.

      Have fun

      rnollenR 1 Reply Last reply
      0
      • rnollenR Offline
        rnollenR Offline
        rnollen
        wrote on last edited by rnollen
        #14

        @AWI . I will try to find out. But for the record later, can I simply connect the 5V, ground and the Yellow dataline directly to the arduino ? Or do I still need a resistor somewhere?
        Then I will try to find I sketch to read the digital pin. Can i maybe use other pulse sketches as an example?
        I will do the Volt test, I know that the volt test remains the same when I rotate on the same speed. Don't know for sure, if I rotate faster if the volt's are the same then as before. I thought not, but I will test later tonight.

        AWIA 1 Reply Last reply
        0
        • rnollenR rnollen

          @AWI . I will try to find out. But for the record later, can I simply connect the 5V, ground and the Yellow dataline directly to the arduino ? Or do I still need a resistor somewhere?
          Then I will try to find I sketch to read the digital pin. Can i maybe use other pulse sketches as an example?
          I will do the Volt test, I know that the volt test remains the same when I rotate on the same speed. Don't know for sure, if I rotate faster if the volt's are the same then as before. I thought not, but I will test later tonight.

          AWIA Offline
          AWIA Offline
          AWI
          Hero Member
          wrote on last edited by AWI
          #15

          @rnollen If you keep the voltage at 5v you can directy connect to the arduino pin. You still need a pull-up/down resistor though.

          pin D13 on the nano has a LED connected to it. It may help you in observing what is going on. A LED is much faster than a volt meter..

          rnollenR 1 Reply Last reply
          0
          • AWIA AWI

            @rnollen If you keep the voltage at 5v you can directy connect to the arduino pin. You still need a pull-up/down resistor though.

            pin D13 on the nano has a LED connected to it. It may help you in observing what is going on. A LED is much faster than a volt meter..

            rnollenR Offline
            rnollenR Offline
            rnollen
            wrote on last edited by rnollen
            #16

            @AWI said:

            @rnollen If you keep the voltage at 5v you can directy connect to the arduino pin. You still need a pull-up/down resistor though.

            pin D13 on the nano has a LED connected to it. It may help you in observing what is going on. A LED is much faster than a volt meter..

            Sorry for all the questions :) But I am a noob on this matter. I do know something of scripting, but electronics is not something where I am familiar with.
            But to summarize then how to connect it; The yellow line, will go through a resistor (which one?) and that is connected to D13. Black is Ground, Red is 5 Volt? Is this correct? And is this setup only for testing or also as the final solution later on, because the D13 is also used for the radio? Problem is: I don't know exactly what a LED is in you're example :)

            Edit-> Also send questions to the supplier. Maybe he can gives me an answer if it is PNP or NPN device. Also asked for schematics and how to calculate the pulses.

            1 Reply Last reply
            0
            • rnollenR Offline
              rnollenR Offline
              rnollen
              wrote on last edited by
              #17

              When I use the volt meter and I rotate, then the volts are pretty much the same. Rotating faster, doesn't give me higher values.
              As a test I have attached it to my Arduino nano using a 10k Pullup resistor. Found a little example sketch regarding the LED on the arduino site. As the very first test I can see the light bling on the arduino when I rotate the windmeter. Rotating it harder will make the light bling faster, rotating slower and it blings slowly. So the pulses seems to come through.

              But now, I need a vary small and basic way to start counting the pulses when it rotates. I have tried to create a very small sketch (using an example of the Arduino website). But that is not working OK. Tried to modify the examples for powermeter and watermeter which are also pulse sketches, but at this stage it has too much code.
              Does anyone have a very small example sketch to start with for my setup?

              1 Reply Last reply
              0
              • AWIA AWI

                @rnollen Hi, the manual is a bit confusing in that it mentions a "serial protocol" and also a table is mentioned with voltages and wind speed. As yours iw 3 wire we can assume it is not a RS485 output.

                Then there are you need to dertermine what kind of output it is either NPN or PNP. : PNP needs a "pull down" resistor. NPN needs a "pull up". resistor..Best thing is to test the different options with the volt meter.

                According to the table the "average" voltage should vary with the rotating spreed.

                Note that I make a lot of assumptions.... but: If you get a voltage on your meter that changes with the rotating spreed than it is time to connect the nan. With the assumption that there are pulses, best thing is to write a routine which counts the pulses in a certain time frame e.g 10 secs. (connect the nano with a either a digital or analog pin, but read with digitalread(),. There should be many examples on the web.

                Have fun

                rnollenR Offline
                rnollenR Offline
                rnollen
                wrote on last edited by
                #18

                @AWI said:
                ..... There should be many examples on the web.

                Have fun
                Unfortunately I cannot find any working example code. Found all kind of stuff on the internet, but nothing that will give me some valuable data.
                I think that the examples on the internet mostly uses an pull up anemometer, as far as I can see the Arduino Nano also have a internal one which you can activate on the sketch. But basically, when I use a resistor, which is connected on the yellow and red wire, I am still stuck on the sketch I cannot find something desent (and small), that gives me something valuable. I now know why the windmeter is not an example on the Mysensors site :) Way to difficult :).

                AWIA 1 Reply Last reply
                0
                • rnollenR rnollen

                  @AWI said:
                  ..... There should be many examples on the web.

                  Have fun
                  Unfortunately I cannot find any working example code. Found all kind of stuff on the internet, but nothing that will give me some valuable data.
                  I think that the examples on the internet mostly uses an pull up anemometer, as far as I can see the Arduino Nano also have a internal one which you can activate on the sketch. But basically, when I use a resistor, which is connected on the yellow and red wire, I am still stuck on the sketch I cannot find something desent (and small), that gives me something valuable. I now know why the windmeter is not an example on the Mysensors site :) Way to difficult :).

                  AWIA Offline
                  AWIA Offline
                  AWI
                  Hero Member
                  wrote on last edited by AWI
                  #19

                  @rnollen It shouldn't be so complicated.. there are a many ways to do it. Start in the learning curve with the most simple method of counting pulses using the arduino builtin method pulseIn(). (non MySensors, basic arduino). You should be able to see the pulse frequency on the serial port when turning the rotor.

                  const int anemometerPin = 4 ; // wherever you connected the anemometer
                  unsigned long timePeriod = 0;  
                  unsigned long timeon = 0;
                  unsigned long timeoff =0;
                  
                  void setup()
                  { pinMode(anemometerPin, INPUT_PULLUP);
                    Serial.begin(9600);
                  }
                  
                  void loop()
                  {
                     timeon = pulseIn(anemometerPin,HIGH); // Measured Time On
                     timeoff = pulseIn(anemometerPin,LOW); // Measure Time Off
                     timePeriod = timeon + timeoff; // total period = on + off 
                     float frequency  = 1000000.0/timePeriod; // calculate the frequency
                     Serial.println(frequency);
                     delay(1000);
                  }
                  
                  
                  1 Reply Last reply
                  0
                  • rnollenR Offline
                    rnollenR Offline
                    rnollen
                    wrote on last edited by
                    #20

                    @AWI Thanks, I will give it a try. Today I also received some additional info. The device is a NPN model. Type 12CM, according to the supplier it is 12 pulses for 1m/s per second. But the manual says that this model is 10 pulses for 1m/s.

                    So basically I could now connect the device as NPN, only I need to find out how :)

                    AWIA 1 Reply Last reply
                    0
                    • rnollenR rnollen

                      @AWI Thanks, I will give it a try. Today I also received some additional info. The device is a NPN model. Type 12CM, according to the supplier it is 12 pulses for 1m/s per second. But the manual says that this model is 10 pulses for 1m/s.

                      So basically I could now connect the device as NPN, only I need to find out how :)

                      AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by
                      #21

                      @rnollen good news. Npn needs a pull-up so the sketch above should be able to do it. It uses the internal pull-up of the Arduino. I am curious to the outcome.

                      rnollenR 1 Reply Last reply
                      0
                      • AWIA AWI

                        @rnollen good news. Npn needs a pull-up so the sketch above should be able to do it. It uses the internal pull-up of the Arduino. I am curious to the outcome.

                        rnollenR Offline
                        rnollenR Offline
                        rnollen
                        wrote on last edited by rnollen
                        #22

                        @AWI said:

                        @rnollen good news. Npn needs a pull-up so the sketch above should be able to do it. It uses the internal pull-up of the Arduino. I am curious to the outcome.

                        It does not work entirely correct I think. In the serial Monitor I see "Inf" as outcome of the sketch :( Don't see exactly where that is coming from :)

                        Maybe something wrong with the wiring? I Attached the 12V DC to red and blue. The Yellow, connected it to the breadboard and a cable from the D7 also to this connection. I took a 4.7K resistor, connected also to this group and the other side of this resistor I connected to the 5V of the Arduino? Is that correct?

                        When I remove the resistor: then this is my outcome of the sketch:
                        12.82
                        inf
                        inf
                        3.36
                        1.88
                        55.06
                        inf
                        37037.03
                        inf
                        333333.34
                        30.95
                        17.43
                        inf
                        142857.14
                        inf
                        125000.00
                        500000.00
                        500000.00
                        90909.10
                        500000.00
                        39.47
                        inf
                        250000.00
                        500000.00
                        inf
                        20.54
                        45.67
                        58823.53
                        inf
                        9.88
                        inf
                        inf
                        9.17
                        inf

                        Then I got some numbers, but what they mean :) The very high numbers are when rotating..

                        AWIA 1 Reply Last reply
                        0
                        • rnollenR rnollen

                          @AWI said:

                          @rnollen good news. Npn needs a pull-up so the sketch above should be able to do it. It uses the internal pull-up of the Arduino. I am curious to the outcome.

                          It does not work entirely correct I think. In the serial Monitor I see "Inf" as outcome of the sketch :( Don't see exactly where that is coming from :)

                          Maybe something wrong with the wiring? I Attached the 12V DC to red and blue. The Yellow, connected it to the breadboard and a cable from the D7 also to this connection. I took a 4.7K resistor, connected also to this group and the other side of this resistor I connected to the 5V of the Arduino? Is that correct?

                          When I remove the resistor: then this is my outcome of the sketch:
                          12.82
                          inf
                          inf
                          3.36
                          1.88
                          55.06
                          inf
                          37037.03
                          inf
                          333333.34
                          30.95
                          17.43
                          inf
                          142857.14
                          inf
                          125000.00
                          500000.00
                          500000.00
                          90909.10
                          500000.00
                          39.47
                          inf
                          250000.00
                          500000.00
                          inf
                          20.54
                          45.67
                          58823.53
                          inf
                          9.88
                          inf
                          inf
                          9.17
                          inf

                          Then I got some numbers, but what they mean :) The very high numbers are when rotating..

                          AWIA Offline
                          AWIA Offline
                          AWI
                          Hero Member
                          wrote on last edited by AWI
                          #23

                          @rnollen the "inf" means infinite and is caused by a 0 division. You can try to remove the line starting with 'float' and print the time values.
                          I assume you changed the anemometer pin in the sketch to d7...?
                          And connected the gnd of 12v and 5v together?

                          rnollenR 1 Reply Last reply
                          0
                          • AWIA AWI

                            @rnollen the "inf" means infinite and is caused by a 0 division. You can try to remove the line starting with 'float' and print the time values.
                            I assume you changed the anemometer pin in the sketch to d7...?
                            And connected the gnd of 12v and 5v together?

                            rnollenR Offline
                            rnollenR Offline
                            rnollen
                            wrote on last edited by
                            #24

                            @AWI said:

                            @rnollen the "inf" means infinite and is caused by a 0 division. You can try to remove the line starting with 'float' and print the time values.
                            I assume you changed the anemometer pin in the sketch to d7...?

                            I have did some additional testing. The DC12 is wrong I think, when I use that then the whole sketch does not give any values back. Now used the 5V of the arduino, then I got something readings using this sketch. I have added some additional serial print lines for logging. But when times are zero, then the frequency is INF and that happens when I don't rotate, so that looks OK I think
                            ..
                            Timeon: 0
                            Timeoff: 0
                            TimePeriod: 0
                            Frequency: inf
                            Timeon: 0
                            Timeoff: 87951
                            TimePeriod: 87951
                            Frequency: 11.37
                            Timeon: 24222
                            Timeoff: 22899
                            TimePeriod: 47121
                            Frequency: 21.22
                            Timeon: 24960
                            Timeoff: 27680
                            TimePeriod: 52640
                            Frequency: 19.00
                            Timeon: 27545
                            Timeoff: 28273
                            TimePeriod: 55818
                            Frequency: 17.92
                            Timeon: 63310
                            Timeoff: 0
                            TimePeriod: 63310
                            Frequency: 15.80

                            The serial.print lines:
                            Serial.print("Timeon: ");
                            Serial.println(timeon);
                            Serial.print("Timeoff: ");
                            Serial.println(timeoff);
                            Serial.print("TimePeriod: ");
                            Serial.println(timePeriod);
                            Serial.print("Frequency: ");
                            Serial.println(frequency);

                            But any idea, because I am still lost don't know exactly what the conclusion of this is :)

                            AWIA 2 Replies Last reply
                            0
                            • rnollenR rnollen

                              @AWI said:

                              @rnollen the "inf" means infinite and is caused by a 0 division. You can try to remove the line starting with 'float' and print the time values.
                              I assume you changed the anemometer pin in the sketch to d7...?

                              I have did some additional testing. The DC12 is wrong I think, when I use that then the whole sketch does not give any values back. Now used the 5V of the arduino, then I got something readings using this sketch. I have added some additional serial print lines for logging. But when times are zero, then the frequency is INF and that happens when I don't rotate, so that looks OK I think
                              ..
                              Timeon: 0
                              Timeoff: 0
                              TimePeriod: 0
                              Frequency: inf
                              Timeon: 0
                              Timeoff: 87951
                              TimePeriod: 87951
                              Frequency: 11.37
                              Timeon: 24222
                              Timeoff: 22899
                              TimePeriod: 47121
                              Frequency: 21.22
                              Timeon: 24960
                              Timeoff: 27680
                              TimePeriod: 52640
                              Frequency: 19.00
                              Timeon: 27545
                              Timeoff: 28273
                              TimePeriod: 55818
                              Frequency: 17.92
                              Timeon: 63310
                              Timeoff: 0
                              TimePeriod: 63310
                              Frequency: 15.80

                              The serial.print lines:
                              Serial.print("Timeon: ");
                              Serial.println(timeon);
                              Serial.print("Timeoff: ");
                              Serial.println(timeoff);
                              Serial.print("TimePeriod: ");
                              Serial.println(timePeriod);
                              Serial.print("Frequency: ");
                              Serial.println(frequency);

                              But any idea, because I am still lost don't know exactly what the conclusion of this is :)

                              AWIA Offline
                              AWIA Offline
                              AWI
                              Hero Member
                              wrote on last edited by
                              #25

                              @rnollen this looks much better. You get frequencies in the 10 to 20 range when rotating. The inf when you're not rotating are caused by timer overflow so nothing wrong there.
                              Now it is time for a more dedicated measurement. Basically replace the standard arduino routines with your own version. It is middle of the night here so I have to leave it for tomorrow...

                              1 Reply Last reply
                              0
                              • rnollenR rnollen

                                @AWI said:

                                @rnollen the "inf" means infinite and is caused by a 0 division. You can try to remove the line starting with 'float' and print the time values.
                                I assume you changed the anemometer pin in the sketch to d7...?

                                I have did some additional testing. The DC12 is wrong I think, when I use that then the whole sketch does not give any values back. Now used the 5V of the arduino, then I got something readings using this sketch. I have added some additional serial print lines for logging. But when times are zero, then the frequency is INF and that happens when I don't rotate, so that looks OK I think
                                ..
                                Timeon: 0
                                Timeoff: 0
                                TimePeriod: 0
                                Frequency: inf
                                Timeon: 0
                                Timeoff: 87951
                                TimePeriod: 87951
                                Frequency: 11.37
                                Timeon: 24222
                                Timeoff: 22899
                                TimePeriod: 47121
                                Frequency: 21.22
                                Timeon: 24960
                                Timeoff: 27680
                                TimePeriod: 52640
                                Frequency: 19.00
                                Timeon: 27545
                                Timeoff: 28273
                                TimePeriod: 55818
                                Frequency: 17.92
                                Timeon: 63310
                                Timeoff: 0
                                TimePeriod: 63310
                                Frequency: 15.80

                                The serial.print lines:
                                Serial.print("Timeon: ");
                                Serial.println(timeon);
                                Serial.print("Timeoff: ");
                                Serial.println(timeoff);
                                Serial.print("TimePeriod: ");
                                Serial.println(timePeriod);
                                Serial.print("Frequency: ");
                                Serial.println(frequency);

                                But any idea, because I am still lost don't know exactly what the conclusion of this is :)

                                AWIA Offline
                                AWIA Offline
                                AWI
                                Hero Member
                                wrote on last edited by
                                #26

                                @rnollen time for "Take 2" I created it in Codebender to make sure it compiles. Could not test functionality yet.

                                The "take 2" code implements a non-blocking measurement of the frequency of the anemometer (pulses per second). It should be safe for overflow.
                                Take 3 could be to translate it to m/s windspeed according to your type of anemometer and finally:
                                Take 4 MySensors' ise it!!

                                https://codebender.cc/sketch:347690

                                1 Reply Last reply
                                1
                                • rnollenR Offline
                                  rnollenR Offline
                                  rnollen
                                  wrote on last edited by rnollen
                                  #27

                                  @AWI Hmm.. I see this:
                                  1000.00
                                  1000.00
                                  1000.00
                                  1000.00
                                  1000.00
                                  1000.00
                                  1000.00
                                  1000.00
                                  1000.00
                                  500.00
                                  1000.00
                                  0.00
                                  inf
                                  1000.00
                                  0.00
                                  0.00

                                  Don't think that this is correct right? Am I doing something wrong, or does these numbers say anything to you :)

                                  AWIA 1 Reply Last reply
                                  0
                                  • rnollenR rnollen

                                    @AWI Hmm.. I see this:
                                    1000.00
                                    1000.00
                                    1000.00
                                    1000.00
                                    1000.00
                                    1000.00
                                    1000.00
                                    1000.00
                                    1000.00
                                    500.00
                                    1000.00
                                    0.00
                                    inf
                                    1000.00
                                    0.00
                                    0.00

                                    Don't think that this is correct right? Am I doing something wrong, or does these numbers say anything to you :)

                                    AWIA Offline
                                    AWIA Offline
                                    AWI
                                    Hero Member
                                    wrote on last edited by AWI
                                    #28

                                    @rnollen was a short night... :sweat:

                                    Forgot the return lastFrequencyI changed the sketch in last post. No guarantee that it works, don't have the hardware.

                                    1 Reply Last reply
                                    0
                                    • rnollenR Offline
                                      rnollenR Offline
                                      rnollen
                                      wrote on last edited by
                                      #29

                                      @AWI Sorry for the late reply, I got the flu :( But did test the sketch, but I got the same results basically.. Mostly 1000, inf and sometimes a 500? So what can be wrong here?

                                      Thanks for all you're efforts so far!! Really appreciate it :)

                                      AWIA 1 Reply Last reply
                                      0
                                      • rnollenR rnollen

                                        @AWI Sorry for the late reply, I got the flu :( But did test the sketch, but I got the same results basically.. Mostly 1000, inf and sometimes a 500? So what can be wrong here?

                                        Thanks for all you're efforts so far!! Really appreciate it :)

                                        AWIA Offline
                                        AWIA Offline
                                        AWI
                                        Hero Member
                                        wrote on last edited by AWI
                                        #30

                                        @rnollen No problem, I hope you recovered well. Haven't looked at the sketch until now and discovered that I must have been suffering from something too... I added a missing line but still can't test it. Please give it a try..

                                        1 Reply Last reply
                                        0
                                        • rnollenR Offline
                                          rnollenR Offline
                                          rnollen
                                          wrote on last edited by
                                          #31

                                          @AWI I am still ill, while doing this :) Hopefully tomorrow will be better, Hahaha.. :)
                                          But, the results looks promising and OK I guess :)
                                          8.13
                                          10.87
                                          14.08
                                          20.00
                                          27.78
                                          23.81
                                          25.64
                                          10.75
                                          0.00
                                          1.81
                                          12.66
                                          11.49
                                          10.75
                                          10.00
                                          9.35
                                          8.85
                                          8.33
                                          7.87

                                          It's 0 when I am not turning it around, so that is OK. Low number, when rotating it slowly. High number when rotating it fast :)

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


                                          15

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


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

                                          • Don't have an account? Register

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