Menu

Sparkfun weather kit 80422

Gintautas
2021-07-03
2021-07-06
  • Gintautas

    Gintautas - 2021-07-03

    Hello,
    I have a problem getting working this analog wind direction and speed device.
    FIRMWARE RELEASE 119-6.
    The direction sensor is defined as "#define WINDDIRECTION80422" in the "controllerconfig.h" as well as "#define WINDDIRECTIONSENSOR" is uncommented.
    I have correct directions displayed in Serial monitor when I use TEST_WINDDIRECIONANALOG script.
    The same values for the directions are entered in the "winddirection.h"
    I had 0 readings for the Direction in the web page until I have added "#define ANALOGDIRECTIONSENSOR" in the "controllerconfig.h" just below "#define WINDDIRECTIONSENSOR".
    After this I get two values only: 270 at W direction and 315 at all remaining directions.
    The same I can see in the serial monitor if I select wrong sensor - WINDDIRECTIONLIYUAN- in the test script (just for test).
    But in the main firmware correct sensor is selected.
    Similar situation with the speed sensor - get readings in the test script and no readings in the main firmware despite that correct sensor (#define ANEMOMETER80422 7) is defined.
    What am I doing wrong?

    Gintautas

     
  • brownrb

    brownrb - 2021-07-04

    Hi
    You did not tell me what kind of sensors you have -a link to where it was purchased perhaps?

    Let us concentrate on wind direction first, I will come back to wind speed later.

    If the TEST_WINDDIRECIONANALOG test program works, and displays the proper directions,
    then
    in the controller config you should have

    #define WINDDIRECTIONSENSOR 1
    #define WINDDIRECTIONLIYUAN 2
    

    Next
    I had 0 readings for the Direction in the web page until I have added "#define ANALOGDIRECTIONSENSOR" in the "controllerconfig.h" just below "#define WINDDIRECTIONSENSOR".

    I do not think that is correct

    In file winddirection.h, line 61 change

    #ifdef ANALOGDIRECTIONSENSOR
    
    to this
    
    #if defined(WINDDIRECTION80422) || defined(WINDDIRECTIONLIYUAN)
    

    and let me know if this fixes the wind direction issue.,

    Note: The analog type sensors that use voltage to determine the direction are extremely sensitive to voltage changes thus also unreliable. A small change in voltage will have a dramatic effect on the direction calculated. This is not your issue though. I just point this out because we noticed this during testing and was affecting the directions being read.

    The difference you get *only two directions' has nothing to do with this and more with the coding error in the file.

     
  • brownrb

    brownrb - 2021-07-04

    What test file did you use for the anemometer?

    If you used the test file TEST_WINDSPEED_ADAFRUIT and it gave you reasonable speed values, then your config for the controllerconfig.h would be

    #define WINDSPEEDSENSOR 1
    
    #define ADAFRUITANEMOMETER 2
    
     

    Last edit: brownrb 2021-07-04
  • Gintautas

    Gintautas - 2021-07-04

    Hello Robert,
    the kit is from the Mouser: https://eu.mouser.com/ProductDetail/SparkFun/SEN-15901?qs=YwPsRIUVAOdCNLFQoffCEg%3D%3D
    It is the same Winddirection sensor as in "'Home / Wind Direction Sensor / WINDDIRECTIONANALOG/SparkFun Assembly SEN-08942.pdf" and the Windspeed sensor is from the same kit - it makes two contact closures in one rotation.
    I would like, if I may, to add a comment regarding connection of this Sparkfun kit. The RJ connector of the kit has 4 pins - 1 /4 for the Direction and 2/3 for the Speed sensors. In "mySQM+ pdf" for every of sensors three wires are shown for the connection what is impossible. It could be several ways to connect it but as it is in the attached pictures should be OK.

    About Wind direction: I have modified the winddirection.h, line 61 as you suggest and removed "#ifdef ANALOGDIRECTIONSENSOR" from the controllerconfig.h - makes no sense - the same 270 and 315 directions only.

    Windspeed.
    I putted a blower in front of the anemometer and got aprox. 2 revolutions per second (4 pulses) what should be about 9.6 km/h of wind speed according to the sensor datasheet.
    For a wind speed test I tried both :TEST_ANEMOMETER3DPRINT and TEST_ANEMOMETER3DPRINT-2 scripts and both shows wind speed but in little bit different ways. The fist one returns values in "Calculation1" and "Calculation2" (the last one is something unreal) and 30s average. The second script returns "Calculation1" and 30s average. Both scripts returns about 4 times lower value in compare with what should be theoretically. But this is not a problem - it could be adjusted by changing "Pulses per revolution" (now I entered 2) or "Arm length"

     
  • Gintautas

    Gintautas - 2021-07-04

    Forgot to mention once again - wind speed works in test only.

     
  • brownrb

    brownrb - 2021-07-05

    Hi

    Using TEST_ANEMOMETER3DPRINT and TEST_ANEMOMETER3DPRINT-2 is wrong. Code written for a different sensor will not work with what you have. So please do not try that because it only confuses things further

    For the SparkFun J11 connector, the pins are

    Station RJ11
    1 GND                               : J11:GND
    2 Anemometer pin 1 - to J11:SIG
    3 Anemometer pin 2 - wire to 3.3V : J11:3V3 
    4 Wind direction (0-4.78V) - wire to Digital IO Pin with 1K series resistor and 2.2K pullup to 3.3V : J12:SIG
    

    So essentially there are 3 wires for Anenometer (gnd-pin1, 3,3v-pin2 and sig-pin3)
    and for the wind direction has two pins which are gnd-pin1 and sig-pin4. That is the wiring you have.

    With the Sparkfun kit, you should be using (for wind direction)

    #define WINDDIRECTIONSENSOR 1
    #define WINDDIRECTION80422 3
    

    and for wind speed

    #define WINDSPEEDSENSOR 1
    #define ANEMOMETER80422 7
    

    in the controller_config.h file

    To make progress on this issue, I will need you to run an attached program and enter values into a spreadsheet. When completed I will need to look at the results to compare it against the firmware code.

    We can concentrate on the wind sensor using a test program - I have attached the test program I want you to use. It is TEST_WINDDIR_SPARKFUN

    When you run this program (please do not make any changes to it), it will monitor the direction signal. You will need a compass (your phone has GPS? or direction?)

    The other file I have attached is SparkFun Wind Direction Voltages which is a spreadsheet.

    When you run the test program, the idea is to use the compass to set the direction vane to a particular direction and note the adc value for that direction, saving it into the spreadsheet

    This means you can do this inside. Also, after programming the device with this test program, use the serial monitor of the Arduino IDE to watch the program output.Set the Arduino Serial monitor speed to 115200.

    First you would set the direction value to North. Then watch the program ouput in the serial monitor window, and let it do say 4-6 readings which may vary a little between each reading. In the spreadsheet enter the lowest reading for that direction into ADC Count LOWEST and the highest reading for that direction into ADC Count HIGHEST

    Repeat for all other directions (Next would be NNE then after that NE and so on).
    When you have done all the durections please Save the spreadsheet and email it back to me.

    That will help me a great deal in making progress on this issue.

    Regards
    Robert

     

    Last edit: brownrb 2021-07-05
  • Gintautas

    Gintautas - 2021-07-05

    Hi,

    So essentially there are 3 wires for Anenometer (gnd-pin1, 3,3v-pin2 and sig-pin3)
    and for the wind direction has two pins which are gnd-pin1 and sig-pin4. That is the wiring you have.

    That is not correct. The 80422 Anemometer and direction Sensor has no common wires on RJ11.
    Two wires for Anemometer and two for Direction sensor. You can check it at "'Home / Wind Direction Sensor / WINDDIRECTIONANALOG/SparkFun Assembly SEN-08942.pdf" and I attached the picture.
    But it is a Matter of external connections only.
    For me, as electronic engineer, is not clear what voltage divider schematic should I use for your design :) ? In a pdf it is noted that 5V used for pull up and 2k to gnd, now you say 3.3V. Basically there is not big deal what design to use, the question is what should be the range of voltages at the SIG pin? It is obvious that MAX<3.3V. What should be the MIN at 112.5 degrees, because it depends on divider resistances and design. Could you please comment the spreadsheet that I am attached? We need to agree on terms and conditions :).

     
  • brownrb

    brownrb - 2021-07-05

    Hi
    I am currently going through the documentation I have acquired and previous code and wiring for the sensors when these were developed during the early stages of the project. We had a group of users who were "beta testers" who had varying equipment/sensors so in most cases I was reliant on their feedback. This is not their fault, I was not the best documenter in recording everything. I really could not afford to purchase every sensor and thus the beta users were an immense help to me in testing out code on their sensors.

    There are some issues and it looks like at some point the Liyuan and Sparkfun sensors ended up sharing wrong values, connections and code. The WINDDIRECTIONANALOG is a good example of something that got obsolete some time ago. I am pretty sure the Wind Speed is also affected.

    My apologies for that.

    The resistor R4 and R5 on the PCB should be R4=1k and R5=2K if using the Sparkfun sensor. The purpose of this is to drop the voltage range of the input signal from 0-5V to 0-3.3V before going to the ESP32 pin.

    The PDF omits a number of details and needs updating as well as the wiring diagrams, to make things clearer.

    There is no 3V3 connection on J12, only 5V
    J12-5V
    J12-GND
    J12-Signal

    To make this work
    The wind direction sensor connects to J12 on the PCB.
    Pin1 J12-GND
    Pin4 J12-SIG (plus an external pullup resistor of 10K to 5V )

    The PCB resistors R4(1k)/R5(2k) will drop the voltage range of 0-5V to 0-3.3V
    so 0-3.3V (well not quite) will appear on the ESP32 pin. The voltage range on the J12-Sig will be 0-5v,

    Diagram attached

    The spreadsheet
    The values derived from the PDF are not much use. That is designed for a 5V system and we are using 3.3V, and scaling the values was not that accurate . What we did was use a spreadsheet like I attached earlier, wired up the sensor, ran the program I also I attached earlier,
    We started at North direction with program running and entered in the adc value for North into cell G8. Using the multimeter we also read the voltage and entered that into Cell D8.

    Next we moved to East, and again got the adc value and voltage and that went into Cell G12 and cell D12.

    And continued on till we had done all the directions. We then used those values in winddirection.h

    If you can do this on your system that would be great. The adc values and voltages may differ from our own values because from memory I think we used a different value for the pullup.

    The adc value is the most important. The voltage reading is not and can be ignored. All I need is the ADC Count Average for each direction. If you can do that it would be a great help.

    As stated before, I am in the process now of updating the documentation, firmware and diagrams etc to reflect what it shouldve been, if you can asisst with the spreadsheet that would help immensely and we should have you up and running in short order.

    regards
    Robert

     
  • Gintautas

    Gintautas - 2021-07-05

    Hi,
    you should not apologies for anything, you do hard work.
    I know what is to keep the docs up to date :)
    I simulated different resistances for the divider and did a few tests with different nominal resistors. And found for this moment, that the best separation in ADC values at the toughest situation - E/ENE - (where the difference of the sensor resistance is smallest) is: R4 is shorted and R5 is 20k, 10k pull up.
    The values in the spreadsheet is using these nominals.

    In case of use R4 - 1k and R5 - 2k the result is very low voltage on the ESP pin because of more than 4 times dividing and very little difference between steps.
    The spreadsheet is sent.

    Regards
    Gintautas

     
  • brownrb

    brownrb - 2021-07-06

    Hi Gintautas
    It may be that a 10K pullup is to high.
    I will take a look again

     
  • brownrb

    brownrb - 2021-07-06

    Hi Gintautus
    I did the spreadsheet with both 10K pullup and 5K pullup using the 1k/2k divider
    This shows the voltage at SIG pin and voltage at ESP32 data pin and the adc count reading.

    I think that the 5K pullup is a better option, but I do not see an issue with the E/ENE readings.
    The spreadsheet attached is an attempt to work out the resultant voltage at the esp32 pin using 5V supply, and what the adc count will be, as well as the values to use in the coding from lowest adc count to highest adc count. It also shows the difference between count values, with 10k pulling showing a lowest value betwen counts of 55, but for the 5K resistor this jumps to 95. And gives a good spread of adc count values of 500 - 3972

    That is if I coded the spreadsheet correctly.
    If you agree then I will begin coding it based on the values of pullup 5K, r4=1k, r5=2k
    In the spreadsheet,
    1. Calculate Rtotal and Current for the sensor based on 5V input
    2. Calculate the voltage drop across the pullup resistor
    3. Calculate the voltage to the SIG pin
    4. Calculate the voltage using the 1k/2k divider
    5. Calculate the voltage on the ESP32 adc pin
    6. Calculate the adc count based on the voltage on the ESP32 adc pin
    7. Sort these by adc count on next sheet - lowest to highest
    8. Calculate midpoint adc value between steps
    9. and we have the if adc_count < val for the code
    10. Finally also calculate difference range between adc_counts for each direction

    Cheers
    Robert

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.