As mentioned last night, I’m going to (eventually) walk through the four cardinal directions (N, E, S, W) and the four ordinal directions (NE, SE, SW, NW) and record the voltage values from both AN0 and AN1 signals. Sooner or later, I’ll probably just plot the whole thing and get it figured out. Trying to get daytime work, home project efforts, AND this trigonometry worked out is my limiting factor. Hope to be past some of that by next week.
Tuesday evening I found out just how non-linear is the ESP32 ADC circuit response, especially so above 3.1 VDC which is precisely what is coming out of the AN0 and AN1 signals. Two options: (a) apply a voltage divider resistor to each of AN0 and AN1, and reduce the voltage range coming into the ESP32 ADC circuit, or (b) wire in an ADS1115 external ADC chip to obtain more accurate readings. I’m a software guy, so I’ll go for the more accurate solution, (b). The ADS1115 is well supported in ESPHome, and easy enough to add to the configuration.
The ADS1115 certainly seems to provide more accurate voltage measurements. That’s the good news. I’m beginning to suspect the DEN line from the vane sensor board plays a significant role. I’ll have to wire that signal into the ADS1115 to determine what role that may be. Currently, with only AN0 and AN1 signals (plus Vcc and GND) I often receive voltage readings less that one-half volt from both AN0 and AN1, and the vane isn’t changing direction when this happens. Definitely a head-scratcher, and it really should not be so difficult. Oh, well. Just have to keep observing, possibly calibrating, and see what happens. I believe I’ve almost got it figured out. First, the voltages returned are from 0.000 to 3.300, which puts 1.650 VDC as the mid-point. Subtracting 1.650 from each AN0 and AN1 value returned will effectively assign a negative sign on one or both values when necessary. These signs determine whether the direction is in quadrant 1, 2, 3, or 4. In quadrant 1 (upper-right, or 0-to-90 degrees) there is no offset, the arctangent of the two values can be converted from radians to degrees and used. In quadrant 2, 90 degrees is added; quadrant 3, 180 degrees; quadrant 4, 270 degrees. The actual voltage values returned cannot be taken as absolute indicators. It’s only their trigonometric relationship that matters. Still need to re-assemble the entire device and perform final wiring/soldering to start comparing and monitoring the data for accuracy.
One final item. Apparently, it’s strongly beneficial to add a 100nF capacitor between GND and 5VDC on the ESP32. This seems to help stabilize the I2C devices (ADS1115 specifically) sourcing 5VDC from the ESP32 board.