I’m using a Davis anemometer to measure wind direction and speed. Direction is a wind vane attached to a 20k pot. I’ve plugged that into A0, and I’ve also attached power to 3.3v (3V3 pin) and ground (GND pin) appropriately. See this description of the device.
I think I should get 12 bits of resolution with the 20k pot giving values of approx 0-4096. However I only get 8-bit resolution values of 0-255.
Any ideas?
EDIT: is it that the device is expecting to scale over 5v?
Can you post the relevant code portions? analogRead() will return values between 0 and 4095 but you’d also need to store them in an appropriate variabel.
Not seeing your code does make this a guessing game.
This is the devices internal wind direction schematic from the document you cited:
The document equates pin 2 to Vcc, pin 4 to Gnd, and pin 3 to the signal (analog voltage) that denotes wind direction.
Effectively, this circuit is just a voltage divider. Assuming Vcc = 3.3 volts, the signal is zero when the 20K pot is turned to zero, and the signal would be around 0.071v when the 20k pot is turned to 20k. Since analog reads range from 0 = 0v to 4095 = 3.3v, and this device returns 0 to 0.071 volts, the analog reading would range from 0 to ~88.
The problem is that the 909k resistor overpowers the 20k pot, I’m not sure of the best way to fix this. Hopefully, someone else can.
I’ve also noticed the values seem to have an odd distribution. The first 270 degrees returns values from 0 to 96, but the last 90 degrees goes from 96 to 255!
I put the pot on a meter off the circuit and it’s evenly distributed across the 20k ohms.
What do you get when remove the external circuitry and leaving A0 float, connect to GND and connect to 3v3?
My Boron 2G/3G on 1.1.1 gives me the expected values between 0 and 4095.