Herunterladen Diese Seite drucken

AZ-Delivery ADS1115 Bedienungsanleitung Seite 11

Werbung

Bevor wir mit der Verwendung dieses Moduls beginnen, müssen wir als
erstes die Library, namens "Adafruit_Python_ADS1x15" installieren. Öffnen
Sie die Terminal-App in Ihrem Raspbian und führen Sie diese Befehle
nacheinander aus:
sudo apt-get update
sudo apt-get install build-essential python-dev python-smbus git
git clone
https://github.com/adafruit/Adafruit_Python_ADS1x15
cd Adafruit_Python_ADS1x15
sudo python3 setup.py install
Nachdem die Library installiert wurde, müssen wir eine neue Datei mit dem
Namen "AnalogRead.py" erstellen und fügen folgenden Skript-Code ein:
import
time
import
Adafruit_ADS1x15
adc
=
Adafruit_ADS1x15.ADS1115()
GAIN
=
1
print('[press ctrl+c to end the
try:
# Main program loop
while
True:
values = adc.read_adc(0, gain=GAIN)
print('{0:>6}'.format(values))
time.sleep(0.5)
# Scavenging work after the end of the program
except
KeyboardInterrupt:
print('Script
end!')
Raspberry Pi Skript
# Create an ADS1115 ADC (16-bit) instance
script]')
# Read the ADC channel 0 value

Werbung

loading

Verwandte Produkte für AZ-Delivery ADS1115