Set up LCD display, add to depth recording

This commit is contained in:
Pi 2022-09-04 11:59:20 +03:00
parent f2344d9386
commit a6c77f832a
4 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,17 @@
time and date, Voltage of depth sensor (V), Depth (m)
2022-09-04T11:50:21,0.716,-0.13
2022-09-04T11:50:24,0.716,-0.13
2022-09-04T11:50:27,0.716,-0.13
2022-09-04T11:50:31,1.12,12.74
2022-09-04T11:50:34,0.716,-0.13
2022-09-04T11:50:37,1.074,11.28
2022-09-04T11:50:40,1.154,13.82
2022-09-04T11:50:43,0.716,-0.13
2022-09-04T11:50:46,1.034,10.0
2022-09-04T11:50:49,1.234,16.37
2022-09-04T11:50:52,1.212,15.67
2022-09-04T11:50:55,0.714,-0.19
2022-09-04T11:50:58,0.716,-0.13
2022-09-04T11:51:01,0.716,-0.13
2022-09-04T11:51:04,0.716,-0.13
2022-09-04T11:51:07,0.716,-0.13
1 time and date Voltage of depth sensor (V) Depth (m)
2 2022-09-04T11:50:21 0.716 -0.13
3 2022-09-04T11:50:24 0.716 -0.13
4 2022-09-04T11:50:27 0.716 -0.13
5 2022-09-04T11:50:31 1.12 12.74
6 2022-09-04T11:50:34 0.716 -0.13
7 2022-09-04T11:50:37 1.074 11.28
8 2022-09-04T11:50:40 1.154 13.82
9 2022-09-04T11:50:43 0.716 -0.13
10 2022-09-04T11:50:46 1.034 10.0
11 2022-09-04T11:50:49 1.234 16.37
12 2022-09-04T11:50:52 1.212 15.67
13 2022-09-04T11:50:55 0.714 -0.19
14 2022-09-04T11:50:58 0.716 -0.13
15 2022-09-04T11:51:01 0.716 -0.13
16 2022-09-04T11:51:04 0.716 -0.13
17 2022-09-04T11:51:07 0.716 -0.13

View File

@ -0,0 +1,7 @@
time and date, Voltage of depth sensor (V), Depth (m)
2022-09-04T11:56:09,0.716,-0.13
2022-09-04T11:56:12,0.716,-0.13
2022-09-04T11:56:15,0.716,-0.13
2022-09-04T11:56:18,0.716,-0.13
2022-09-04T11:56:21,0.716,-0.13
2022-09-04T11:56:24,0.716,-0.13
1 time and date Voltage of depth sensor (V) Depth (m)
2 2022-09-04T11:56:09 0.716 -0.13
3 2022-09-04T11:56:12 0.716 -0.13
4 2022-09-04T11:56:15 0.716 -0.13
5 2022-09-04T11:56:18 0.716 -0.13
6 2022-09-04T11:56:21 0.716 -0.13
7 2022-09-04T11:56:24 0.716 -0.13

View File

@ -6,6 +6,12 @@ import busio
import adafruit_ads1x15.ads1015 as ADS import adafruit_ads1x15.ads1015 as ADS
from adafruit_ads1x15.analog_in import AnalogIn from adafruit_ads1x15.analog_in import AnalogIn
from time import sleep, strftime from time import sleep, strftime
from rpi_lcd import LCD
try:
lcd = LCD(bus=2)
except OSError:
lcd = None
# Create the I2C bus # Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA) i2c = busio.I2C(board.SCL, board.SDA)
@ -25,7 +31,7 @@ depthS = AnalogIn(ads, ADS.P1)
# Open the file to write down the results # Open the file to write down the results
timestr = time.strftime("%Y-%m-%dT%H-%M-%S") timestr = time.strftime("%Y-%m-%dT%H-%M-%S")
filename = "/home/shared/logger-raspi-setup/data/depth/" + timestr + "_depth_data.csv" filename = "/home/shared/hydrophonitor/data/depth/" + timestr + "_depth_data.csv"
#depthM = ((depthS.voltage * 31.848) - 22.93) #depthM = ((depthS.voltage * 31.848) - 22.93)
@ -47,6 +53,9 @@ with open(filename, "w", 1) as f:
print((str(voltage) + " V ") + (str(depthM) + " m ") + (str(roundvolts) + " V ") + (str(rounddepth) + " m")) print((str(voltage) + " V ") + (str(depthM) + " m ") + (str(roundvolts) + " V ") + (str(rounddepth) + " m"))
if lcd:
lcd.clear()
lcd.text((str(roundvolts) + " V ") + (str(rounddepth) + " m"), 1)
f.write(time.strftime("%Y-%m-%dT%H:%M:%S") + ",") f.write(time.strftime("%Y-%m-%dT%H:%M:%S") + ",")
f.write(str(roundvolts) + "," + str(rounddepth) + "\n") f.write(str(roundvolts) + "," + str(rounddepth) + "\n")

13
lcd-display/test_lcd.py Normal file
View File

@ -0,0 +1,13 @@
from rpi_lcd import LCD
from time import sleep
lcd = LCD(bus=2)
lcd.text('Hello World!', 1)
lcd.text('Raspberry Pi', 2)
lcd.text('is really', 3, 'center')
lcd.text('awesome', 4, 'right')
sleep(5)
lcd.clear()