direwolf/telemetry-toolkit/telem-volts.py
WB2OSZ dd27f9960b Development snapshot 1.3 dev F.
Changes to be committed:
	modified:   .gitattributes
	modified:   CHANGES.md
	modified:   Makefile
	modified:   Makefile.linux
	new file:   Makefile.macosx
	modified:   Makefile.win
	modified:   aclients.c
	modified:   aprs_tt.c
	modified:   aprs_tt.h
	modified:   atest.c
	modified:   audio.c
	modified:   audio.h
	new file:   audio_portaudio.c
	new file:   audio_stats.c
	new file:   audio_stats.h
	modified:   audio_win.c
	modified:   ax25_pad.c
	modified:   ax25_pad.h
	modified:   beacon.c
	modified:   config.c
	modified:   config.h
	modified:   decode_aprs.c
	modified:   decode_aprs.h
	modified:   demod.c
	modified:   digipeater.c
	modified:   direwolf.c
	modified:   direwolf.h
	modified:   dlq.c
	modified:   doc/README.md
	modified:   doc/Raspberry-Pi-APRS.pdf
	modified:   doc/User-Guide.pdf
	new file:   doc/WA8LMF-TNC-Test-CD-Results.pdf
	modified:   dtime_now.c
	modified:   dtmf.c
	modified:   dw-start.sh
	modified:   encode_aprs.c
	modified:   encode_aprs.h
	modified:   gen_packets.c
	modified:   gen_tone.c
	modified:   gen_tone.h
	new file:   generic.conf
	modified:   grm_sym.h
	modified:   hdlc_rec.c
	modified:   hdlc_rec.h
	modified:   igate.c
	modified:   kiss.c
	modified:   kiss_frame.c
	modified:   kissnet.c
	modified:   latlong.c
	modified:   man1/direwolf.1
	modified:   mgn_icon.h
	modified:   misc/README-dire-wolf.txt
	new file:   misc/strlcat.c
	new file:   misc/strlcpy.c
	modified:   morse.c
	new file:   morse.h
	modified:   nmea.c
	modified:   pfilter.c
	modified:   ptt.c
	new file:   serial_port.c
	new file:   serial_port.h
	modified:   server.c
	modified:   symbols.c
	modified:   symbols.h
	new file:   telemetry-toolkit/telem-balloon.conf
	new file:   telemetry-toolkit/telem-balloon.pl
	new file:   telemetry-toolkit/telem-bits.pl
	new file:   telemetry-toolkit/telem-data.pl
	new file:   telemetry-toolkit/telem-data91.pl
	new file:   telemetry-toolkit/telem-eqns.pl
	new file:   telemetry-toolkit/telem-m0xer-3.txt
	new file:   telemetry-toolkit/telem-parm.pl
	new file:   telemetry-toolkit/telem-unit.pl
	new file:   telemetry-toolkit/telem-volts.conf
	new file:   telemetry-toolkit/telem-volts.py
	modified:   telemetry.c
	modified:   textcolor.c
	modified:   tq.c
	modified:   tt_text.c
	modified:   tt_text.h
	modified:   tt_user.c
	modified:   tt_user.h
	modified:   utm2ll.c
	modified:   version.h
	new file:   walk96.c
	modified:   xmit.c
2015-09-07 19:56:20 -04:00

37 lines
981 B
Python

#!/usr/bin/python
# Part of Dire Wolf APRS Telemetry Toolkit, WB2OSZ, 2015
# Derived from
# https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/master/Adafruit_ADS1x15/ads1x15_ex_singleended.py
import time, signal, sys
from Adafruit_ADS1x15 import ADS1x15
ADS1015 = 0x00 # 12-bit ADC
ADS1115 = 0x01 # 16-bit ADC
# Set ADC full scale to 2048 mV.
# Can't use original 4096 with 3.3V supply.
gain = 2048
# Select the sample time, 1/sps second.
# Longer is better to average out noise.
sps = 64
# Set this to ADS1015 or ADS1115 depending on the ADC you are using!
adc = ADS1x15(ic=ADS1115)
# Values for voltage divider on ADC input.
r1 = 1000000.
r2 = 100000.
# Read channel 0 in single-ended mode using the settings above
volts = adc.readADCSingleEnded(0, gain, sps) * 0.001 * (r1+r2) / r2
# Calibration correction specific to my hardware.
# (multiply by expected value, divide by uncalibrated result.)
#volts = volts * 4.98 / 4.889
print "%.3f" % (volts)