Removed run command from setup.sh
This commit is contained in:
6
main.py
6
main.py
@@ -22,7 +22,7 @@ if __name__ == "__main__":
|
|||||||
# Setup for Hardware
|
# Setup for Hardware
|
||||||
DHT22_PIN = 4
|
DHT22_PIN = 4
|
||||||
dht_device = adafruit_dht.DHT22(4)
|
dht_device = adafruit_dht.DHT22(4)
|
||||||
file = '/home/pi/code/dht22/log.csv'
|
file = './log.csv'
|
||||||
|
|
||||||
with open(file,'a') as f:
|
with open(file,'a') as f:
|
||||||
|
|
||||||
@@ -31,7 +31,6 @@ if __name__ == "__main__":
|
|||||||
data = get_sensor_data(dht22=dht_device)
|
data = get_sensor_data(dht22=dht_device)
|
||||||
if data:
|
if data:
|
||||||
temperature, humidity = get_sensor_data(dht22=dht_device)
|
temperature, humidity = get_sensor_data(dht22=dht_device)
|
||||||
# current_time = datetime.now().strftime("%D %H:%M:%S")
|
|
||||||
current_time = datetime.now(pytz.timezone('UTC')).strftime("%D %H:%M:%S")
|
current_time = datetime.now(pytz.timezone('UTC')).strftime("%D %H:%M:%S")
|
||||||
print(f'{humidity:.2f}% {temperature:.2f}degF')
|
print(f'{humidity:.2f}% {temperature:.2f}degF')
|
||||||
f.write(f'{current_time},{temperature:.2f},{humidity:.2f}\n')
|
f.write(f'{current_time},{temperature:.2f},{humidity:.2f}\n')
|
||||||
@@ -40,7 +39,8 @@ if __name__ == "__main__":
|
|||||||
"datetime": current_time,
|
"datetime": current_time,
|
||||||
"temperature": temperature,
|
"temperature": temperature,
|
||||||
"humidity": humidity,
|
"humidity": humidity,
|
||||||
"location": "basement"
|
# Be Sure To Edit Location
|
||||||
|
"location": "living_room"
|
||||||
}
|
}
|
||||||
creds = get_db_creds("./.creds.json")
|
creds = get_db_creds("./.creds.json")
|
||||||
conn = connect_db(creds["db"], creds["host"], creds["user"], creds["passwd"])
|
conn = connect_db(creds["db"], creds["host"], creds["user"], creds["passwd"])
|
||||||
|
|||||||
3
setup.sh
3
setup.sh
@@ -3,6 +3,3 @@ apt update && apt upgrade -y && apt install python3-dev python3-pip python3-psyc
|
|||||||
|
|
||||||
# Install Python modules.
|
# Install Python modules.
|
||||||
pip3 install RPi.GPIO psycopg2 adafruit-circuitpython-dht pytz
|
pip3 install RPi.GPIO psycopg2 adafruit-circuitpython-dht pytz
|
||||||
|
|
||||||
# Start the python script.
|
|
||||||
/usr/bin/python3 main.py
|
|
||||||
|
|||||||
Reference in New Issue
Block a user