update
This commit is contained in:
27
windMeter/ads115.py
Normal file
27
windMeter/ads115.py
Normal file
@@ -0,0 +1,27 @@
|
||||
'''
|
||||
Script to test the abs115 an analog-to-digital converter
|
||||
sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/windMeter/ads115.py
|
||||
|
||||
'''
|
||||
import time
|
||||
import board
|
||||
import busio
|
||||
import adafruit_ads1x15.ads1115 as ADS
|
||||
from adafruit_ads1x15.analog_in import AnalogIn
|
||||
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
ads = ADS.ADS1115(i2c)
|
||||
channel = AnalogIn(ads, ADS.P0)
|
||||
|
||||
print("Testing ADS1115 readings...")
|
||||
readings = []
|
||||
|
||||
for i in range(5):
|
||||
voltage = channel.voltage
|
||||
readings.append(voltage)
|
||||
print(f"Voltage: {voltage:.6f}V")
|
||||
time.sleep(1)
|
||||
|
||||
# Calculate and display the mean
|
||||
mean_voltage = sum(readings) / len(readings)
|
||||
print(f"\nMean voltage: {mean_voltage:.6f}V")
|
||||
Reference in New Issue
Block a user