Menu

Wind Speed 3DPrint version

molino
2022-11-07
2022-12-24
  • molino

    molino - 2022-11-07

    I added an anemometer to the project, 3D print version. After assembly and code changing, I tested it.
    I don't know why, but speed doesn't get lower than 300kph. I went through the code to see if something wasn't right, but couldn't find anything.

    Any ideas on how to solve this issue?

    Thanks
    Miguel

     
  • molino

    molino - 2022-11-08

    Robert, after trying to find the problem, I guess something went wrong.
    The controller stays on reboot status. After troubleshoot, I found out that if deactivate the wind speed sensor, all goes ok. Measured R3, still 100K ohm, the voltage drop at the keyes 024 module is 3.3v as expected. I switched the module to make sure the problem wasn't there, still same result. Any ideas?

    Thanks
    Miguel

     
  • brownrb

    brownrb - 2022-11-08

    Hi Miguel

    Not a lot of information to go on,

    So let me get my head around this for a moment.
    A wind speed sensor was added, it was enabled, then you programmed the controller,
    then it was working ok, not rebooting, but wind speed was always 300
    So far so good?

    Then, you attempted to make some changes, and then the controller just kept rebooting?
    Then you disabled the wind speed sensor and controller worked fine.
    So far so good?

    I need more information
    version of firmware (it should be 133)
    arduino core esp32 version (should be 2.0.5)
    controller_config.h
    Are you using PCB or your own board, or just connecting wires?
    Is any debugging enabled?
    How long is the connection wire running from the controller to the 3D-print sensor
    Is it twisted pair cable?

    Change R3 to 10K , because 100k is too high.
    On the DO wire of the sensor to J11 -SIG, as you slowly rotate the wind sensor with power on, it should be low level (gnd) most of the time, then go High (3,3V) when the magnet is in line with the sensor. You will see the sensor led light up when the magnet is detected.

    All things being equal, a value of 300 would indicate there is something wrong with the DO input, triggering abnormal interrupts. Windspeed is related to interrupts, the higher the interrupts the higher the wind speed.

    There is a sensitivity pot on the sensor. You can adjust this with power on. The idea is, using a multimeter, move the magnet position to where it is away from the sensor. Then slowly rotate and see when the logiv level on SIG changes to 3.3V. If the DO goes high well before the sensor reaches the magnet then you need to decrease the sensitivity a bit. This might take a few tries before getting it right. Use the LED on the module as a guide.

    Another thing is to add a 100nF capacitor across sig and gnd - on the sensor, not the PCB. To try and reduce any noise on the SIG wire.

    Another thing is the keyes module. Which one did you purchase? Link? It is 3V3 right?

    I will look at putting together a separate updated 3dprint test ptogram, but the above should get you closer to a result.

    Regards
    Robert

     
  • molino

    molino - 2022-11-08

    Robert thanks for the detailed steps. Will do it when possible
    I have it on a pcb, I'll check if the module is 3.3v version, I actually had some debugging lines activated, will deactivate them. 100K was installed per PDF.

     
  • brownrb

    brownrb - 2022-11-08

    If the keyes sensor has the light coming on and off when the magnet is near, then that is a sign it is working at 3V3
    Just make sure that the Pin D0 is being used, not A0

    Yeah, I know the PDF says 100k, my bad, it is one of the few things that has not been changed over time, the interface was designed for another sensor, which looked promising but in reality turned out to be useless, and thus rather than generate a new PCB we sorta just stuck with the old. There have been significant changes from the beginning.

    I will get round at some stage to change things, am working on the next update so maybe.

    Regards
    Robert

    Attached is sample test code - it compiles but have not has chance to test it - its getting past my bed time,

     

    Last edit: brownrb 2022-11-08
  • molino

    molino - 2022-11-10

    Robert, thank you for all the support.
    First issue about looping the reboot status has been solved by copying an original wind_speed.ccp and wind_speed.h back to the folder and upload it.

    I changed R3 to 10K as recommended. Next I made sure that the hall sensor was working OK. Connected it to an arduino nano type, ran some code to read the digital output and analog output and I get digital 1 when a magnet gets close, so I feel no more testing is needed for the sensor. I used a multimeter to make sure that 3.3v response would be present on the SIG wire, and it was.

    Now, in terms of wind speed calculations, I went to upload the test codes you sent and here the outcome:

    Calculation 2 always gets lower values in the range of 4-6 kph when I spin it continuously by hand. I thing the value is a bit low, but that's a matter of calibrating it.
    What is strange is the interrupts count, if I do 60rpm manually, in 30s it will report like 1800 ish, which doesn't make any sense. I have two magnets there, the count would be, at most, 60 in 30s.

    The same value of 1800 ish is reported too if I simply align the magnet with the sensor and leave it as is. And running the mysqm code, on the main page where all the values are shown, leaving the magnet align with the hall sensor will give something like Wind spd 41258.05 kph (Avg: 41350.34, Max: 43101.82) (actual read)

    So, my conclusions are that something is wrong with the code and interrupts count, but not being an expert, I can't actually confirm it

     
  • brownrb

    brownrb - 2022-11-11

    Hi Molino

    Let me ramble a bit first. Using older portions of code with the latest release is a bad idea. I know the latest code works, older versions of files, no, not so much, A significant amount of code and time has been spent on windspeed, Release 132 also included a windspeed fix. Anything before that had issues in one way or another. I have a high degree of confidence in the code because it has, as mentioned, been tested against a pulse generator, by others.

    Just because it works on Nano does not mean much, a nano is 5V not 3V3

    The test programs were trialled code early in the prototype phase, so I very much expect that the values would be incorrect. The calculations of wind speed in the earlier tests is inaccurate to say the least. Ignore the difference between calculations 1 and 2.

    • I have two magnets there,*
      Now that is a problem. The code is written for 1 magnet. the 3d design of the anemometer only used a single magnet. Using two magnets is really not necessary. It has an advantage at slow wind speeds, but at higher wind speeds with the unit rotating fast, it is problematic, I would probably think that the esp32 detecting interrupts on that pin might be asking a bit much, considering all the other work that it has to do.

    *running the mysqm+ code, on the main page where all the values are shown, leaving the magnet align with the hall sensor will give something like *

    Hmm. From what I have read, the interrupt sense on pins works a little different than advertised. It actually captures edge pulse transistions, for both falling and rising. Then it calculates from the previous pin state and the current pin state whether is is "rising" or "falling".

    That would seem to indicate that there is rapid fluctuations high/low, to get to 1800.
    60rpm is 1 rev per second, 2 magnets - 2 changes per second. So the interrupt count over 30s would be 2 x 30 = 60, not 1800, so something else is going on to cause the interrupt rate you are seeing.

    It would be interested in putting an oscilloscope on the sig line to view the pulses. Speaking from knowledge gained in posts, a signal pulse generator was used to view the pulses and pulse waveforms. With the input pulses at a fixed rate, it was easy to trigger the waveforms display on the oscilloscope. And that is how we know that the calculations in the current firmware are correct. Never bothered to go back and fix the test programs.

    Possible things to consider
    I do not know how long your lead is from the anemometer to your controller. The longer the lead the higher the issues, and if shielded twisted pair is not used, it is easy to add noise to the sig line, hence recommendation to use 100nf capacitor to try and cut down on the noise.

    How close is the magnet to the sensor?
    You adjusted the sensitivity pot on the sensor?
    What is the link to the sensor you purchased (there are differences in the sensors purchased from different suppliers)?

    I would probably
    1. add the capacitor
    2. use 4pr twisted sheilded cable
    3. Increase the sensitivity pot a bit (it might be marginal, you would not see this on the leds, but would see it with an oscilloscope). The high interrupt count seems to suggest the sensitivity is low.

    Generally, when a fault is found, I have to try and build a system like the one the user has. I have a much higher chance of doing that if I know how the user system is configured etc. Without that, I cannot recreate the user environment and thus have little change of "recreating the problem".

    The more information I have the better I am to recreate your system here. Otherwise it is like looking for a needle in a haystack. This code is large and pretty much a killer app for the ESP32. Every thing has to try an play nice, there is a lot of interaction between parts of the code.

    To build a system just like yours I need to know some things, which is why I ask for things like

    version of firmware (it should be 132 or higher)
    arduino core esp32 version (should be 2.0.5)
    arduino IDE 1.8.19
    controller_config.h
    Is any debugging enabled?
    How long is the connection wire running from the controller to the 3D-print sensor?
    Is it twisted pair cable?
    How close is the magnet to the sensor?
    What is the link to the sensor you purchased (there are differences in the sensors purchased from different suppliers)?
    Did you make any changes to hardware or software (other than ssid/password) that differs from the pcb design, and firmware 132 or higher?

    If you want to communicate by email, please find my gmail address (in pdf), it might be quicker.
    When coding an update (which I am right now) I check email once a day, but these sites every few days,

    Regards
    Robert

    I do attach a more updated wind speed test, which I spent time today writing

     
  • molino

    molino - 2022-11-15

    Robert,

    after spending time on this, I decided to switch the KY-024 with a standard reed switch and now reading are fine. Maybe something is wrong with the 3 modules I purchased a couple of years ago.
    I went on and tried to add the printed wind direction feature with the AS600 module. First time I connected it burnt. Multimeter reads 8v across GND and 5V on J13 with everything connected and with nothing connected except the ESP32 module too.

    Current setup on the resistors as follows:
    R1 - 10K
    R2 - 10K
    R3 - 10K
    R4 - 67K
    R5 - 100K
    Capacitors on C1 through C6, D1, J3 per instructions
    No D2
    version of firmware 132
    arduino core esp32 version 2.0.5
    arduino IDE 1.8.19

    Sensors installed are all except RTC and OLED is type 0.96''
    Thanks
    Miguel

     

    Last edit: molino 2022-11-15
  • brownrb

    brownrb - 2022-11-16

    *Multimeter reads 8v across GND and 5V on J13 *

    At that point I would be shutting things down before it catches fire. If what u say is correct, I would suspect that most sensors and esp32 connected would be damaged. The 5V line is common to most sensors.

    Where is the 8V coming from?
    What PCB are you using, version number?
    IC2 is the voltage regulator - it is L7805, which drops 12v in to 5V to the board
    There should be no way you get a reading of 8V anywhere

     
  • molino

    molino - 2022-12-06

    Just a follow up on this. By my mistake I installed a LM7808, maybe that's why I got 8V in the circuit, at least in some terminals. Re-did the whole board now.

    For the wind speed sensor, I swapped the hall effect module for a reed switch, dropping the ground line on that sensor. Works just fine, probably a mis-behaved sensor, although I tried with KY-021 and the problem persists.

    Regarding the wind direction sensor, I can't make it work, any ideas on this matter? Thank you

     
  • brownrb

    brownrb - 2022-12-07

    Hi
    Please run the test winddir3dprint program in the tests folder, watch the serial output,
    if the sensor is found, slowly rotate the direction vane to see if the degrees change

    If the sensor is not found, check your connections as outlined in the PDF
    If the message AS5600 magnet issue, then the magnet is not close enough to the sensor face

    Run the program, highlight the text output, then paste into a text file and post here

    Output looks like this
    NOTE: SENSOR CONNECTED BUT NO MAGNET

    Magnet NOT found
    ams5600 NOT found
    Wind direction : 0 degrees
    ams5600 NOT found
    Wind direction : 0 degrees
    ams5600 NOT found

    Wind direction : 0 degrees

    NOTE: NOW RESTART WITH MAGNET NEAR SENSOR AND ROTATED BY HAND
    rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
    Magnet found
    ams5600 found
    raw angle = 90.13
    Wind direction : 90 degrees
    ams5600 found
    raw angle = 95.00
    Wind direction : 95 degrees
    ams5600 found
    raw angle = 96.22
    Wind direction : 96 degrees
    ams5600 found
    raw angle = 105.01
    Wind direction : 105 degrees
    ams5600 found
    raw angle = 103.88
    Wind direction : 103 degrees
    ams5600 found
    raw angle = 103.70
    Wind direction : 103 degrees
    ams5600 found
    raw angle = 87.61
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 305.11
    Wind direction : 305 degrees
    ams5600 found
    raw angle = 86.83
    Wind direction : 86 degrees
    ams5600 found
    raw angle = 87.70
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 87.78
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 290.84
    Wind direction : 290 degrees
    ams5600 found
    raw angle = 87.78
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 87.87
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 87.78
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 87.78
    Wind direction : 87 degrees
    ams5600 found
    raw angle = 87.87
    Wind direction : 87 degrees
    ams5600 found

     
  • molino

    molino - 2022-12-08

    Robert thanks for the reply. I tried it, always sensor not found.

    Grabbed the same sensor, different sketch on a arduino nano and I can read the sensor, The I2C address on your test sketch and on the one I found on a website is the same. The only thing here that is not most recent version, is the PCB, I'm on the rev12, is that an issue?

    Thanks
    Miguel

     
  • brownrb

    brownrb - 2022-12-08

    When you say ran on a nano,
    was there anything different between the two tests - any change in magnet, magnet position, magnet orientation etc?

    Please post the nano sketch

    I have a reasonable level of confidence in the code because I also run a 3D print windspeed and have not noticed any issues. It took a little fiddling to get the gap right, but other than that was good.

    Regards
    Robert

     
  • brownrb

    brownrb - 2022-12-08

    Hi
    I'm on the rev12, is that an issue?

    No, rev12 circuit for wind direction is the same as rev14

    Regards
    Robert

     
  • molino

    molino - 2022-12-08

    Sketch is attached.
    Per the 3dprint test script in v132 of the firmware, I always get the message "AS5600 not found", which I assume that it means it can't get connection with the sensor, rather than being a matter of how close/far apart the magnet is. Am I thinking this wrong?

    "was there anything different between the two tests - any change in magnet, magnet position, magnet orientation etc?"
    Completely free hand, just making small manual adjustments to the distance to see if any values would come up

    Thanks again
    Miguel

     

    Last edit: molino 2022-12-08
  • brownrb

    brownrb - 2022-12-09

    Hi Miguel
    i would try the i2c_programm in the test folder, with the sensor attached.

    If it does not find the sensor then this points to a wiring issue.
    There are 4 wires in I2C, vcc, gnd, and sck (clock) and sda (data).

    If the program I2C scanner does not find the sensor, then nothing else will, pointless to try the firmware if I2C scanner does not find it. So the goal is to get it working with I2C_scanner then everything will work. So if you are going to try something, use the i2c scanner program to test any wire changes.

    You have indicated you are using a PCB with the ESP32. What is the target you chose in the Arduinp IDE?

    I use ESP32 Dev Module.

    With the Dev module, the I2c pins are defined in controller_defines.h as

    // PIN DEFINITIONS FOR SENSORS
    // I2C PINS
    #define I2CDATAPIN 21
    #define I2CCLKPIN 22  // scl
    

    That means SDA goes to pin21 and SCL goes to pin22. On the PCB the header J13,
    j13.gnd to the gnd pin on the module sensor
    j13.5v to the vcc pin on the module sensor
    j13.SDA to the sda pin on the module
    j13.SCL to the scl pin on the module

    Next is the setup() code that starts I2C

      boot_msg_println("I2C INTERFACE START");
      Wire.begin(I2CDATAPIN, I2CCLKPIN);
    

    If nothing else helps, you could try Wire.begin() with no parameters. There are some other boards like the WEMOS that require the use of other pins for I2C devices.

     
  • molino

    molino - 2022-12-10

    Robert, thanks for all the help. Was able to run i2c scanner and figured that the problem was wiring. Afterwards ran the wind dir test sketch and was getting values back. I saw someone talking about having a diametrically magnet instead of an axial one, do you think that this is the proper route to go?

    Thanks again
    Cheers

     
  • brownrb

    brownrb - 2022-12-11

    I started out by purchasing the AS sensor, but it did not come with a magnet. I tried a couple of ones I had lying around (from the 3D print) but they did not work either. I looked at the data sheet

    Went back to purchase another AS device, I made sure that it came with a magnet, and it worked first time. No issues at all.

    There is information in the AS sensor PDF datasheet that references the use of magnets.
    In particular, under General Description, pg1, at the top -

    This contactless system measures the absolute angle of a diametric magnetized on-axis magnet.

     
  • molino

    molino - 2022-12-24

    Robert, thanks for the info.

    I ran i2c scanner, AS5600 shows up with address 0x36, then ran test winddir, as5600 was found, magnet on a perfect position and degrees where moving just perfect. Without moving anything, I uploaded firmware 132 (winddir 3d print is uncommented) and I see no changes in wind direction.
    Any idea on what might be wrong?

    Disregard, wire issues

    Thanks
    Miguel

     

    Last edit: molino 2022-12-24
  • brownrb

    brownrb - 2022-12-24

    Hi
    So there is some improvement that now the sensor is being found.

    However, firmware 132 gave you no change in Wind Direction. This is nothing to do with you or connection.

    Yesterday I pre- released v133-14 to the test team. Please send me an email (address in pdf etc)
    and I can give you access to that pre-release, so you can try it and see if the bug has been fixed.

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