This commit is contained in:
Your Name
2025-03-18 16:24:22 +01:00
parent dffa639574
commit d07314262e
5 changed files with 139 additions and 2 deletions

27
windMeter/ads115.py Normal file
View 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")