diff options
author | ars <asav1410@gmail.com> | 2020-06-17 15:59:52 +0100 |
---|---|---|
committer | ars <asav1410@gmail.com> | 2020-06-17 15:59:52 +0100 |
commit | f665f78155047838dc924634ebe4128f7add5542 (patch) | |
tree | fa0b6d2fd4a7b26d7fac2d557066044384d33010 /dev_scripts/vane_values.py |
Diffstat (limited to 'dev_scripts/vane_values.py')
-rw-r--r-- | dev_scripts/vane_values.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/dev_scripts/vane_values.py b/dev_scripts/vane_values.py new file mode 100644 index 0000000..b6b6803 --- /dev/null +++ b/dev_scripts/vane_values.py @@ -0,0 +1,11 @@ +# create voltage divider for use with MCP3008 ADC +def volt_div(r1, r2, vIn): + vOut = (vIn * r2)/(r1 + r2) + return round(vOut,3) + +# calculate vOut values for each wind direction using known resistances from datasheet, 3.3 V from RPi and 4.7K ohm resistor + +resistances = [33000, 6570, 8200, 891, 1000, 688, 2200, 1410, 390, 3140, 16000, 14120, 120000, 42120, 64900, 21880] + +for i in range(len(resistances)): + print(resistances[i],volt_div(5000, resistances[i], 3.3)) |