Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python examples rework #27

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
python: navio: Navio: add ADC Navio+ support
Make ADC module for Navio+ and add this module in __init__ file
  • Loading branch information
Igor Anokhin committed Jan 10, 2018
commit 5520231ca07a06edca8db342d2f125d1cc69bdba
36 changes: 36 additions & 0 deletions Python/navio/Navio/ADC.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from adafruit_ads1x15 import ADS1x15

class ADC():
ADS1015 = 0x00 # 12-bit ADC
ADS1115 = 0x01 # 16-bit ADC

# Select the gain
# gain = 6144 # +/- 6.144V
gain = 4096 # +/- 4.096V
# gain = 2048 # +/- 2.048V
# gain = 1024 # +/- 1.024V
# gain = 512 # +/- 0.512V
# gain = 256 # +/- 0.256V

# Select the sample rate
# sps = 8 # 8 samples per second
# sps = 16 # 16 samples per second
# sps = 32 # 32 samples per second
# sps = 64 # 64 samples per second
# sps = 128 # 128 samples per second
sps = 250 # 250 samples per second
# sps = 475 # 475 samples per second
# sps = 860 # 860 samples per second

# Initialise the ADC using the default mode (use default I2C address)
# Set this to ADS1015 or ADS1115 depending on the ADC you are using!

channel_count = 4

def __init__(self):
self.adc = ADS1x15(ic=self.ADS1115)

def read(self, ch):
return self.adc.readADCSingleEnded(ch, self.gain, self.sps)


1 change: 1 addition & 0 deletions Python/navio/Navio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .adafruit_ads1x15 import ADS1x15
from .Led import Led
from .ADC import ADC