Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertAlexBarbu committed May 15, 2024
1 parent 280c4fd commit fb7ea18
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion rpi/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
dhtDevice = adafruit_dht.DHT11(board.D23)
# tm = tm1637.TM1637(clk=5, dio=4) # GPIO 5 for clock and GPIO 4 for dio

# GPIO.setmode(GPIO.BOARD)
# GPIO.setmode(GPIO.BOARD) or GPIO.setmode(BCE)
resistorPin = 7
redLedPin = 18
buzzerPin = 24
Expand Down
Binary file added rpi/image copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion rpi/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"luminosity": luminosityMessage,
"rain": True
}
print(data);
print(data)
db.child("Status").push(data)
db.update(data)
print("Sent to Firebase")
Expand Down
34 changes: 20 additions & 14 deletions rpi/temp_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random
import datetime
import RPi.GPIO as GPIO
from gpiozero import DigitalInputDevice

config = {
"apiKey": "AIzaSyBme5hGShcyPNOfRCl0HgSNJU5MmOfbg8Q",
Expand All @@ -14,12 +15,14 @@
}

firebase = pyrebase.initialize_app(config)

db = firebase.database()

#replace D23 with the GPIO pin you used in your circuit
dhtDevice = adafruit_dht.DHT11(board.D23)
resistorPin = 7
rainPin = 18
rainDevice = DigitalInputDevice(rainPin)
rain = False

while True:

Expand All @@ -33,30 +36,33 @@
while(GPIO.input(resistorPin) == GPIO.LOW):
diff = time.time() - currentTime
print(diff * 10000000)
luminosityMessage = ""
time.sleep(1)
if (diff * 10000000> 6000):
# too cloudy
print("It's cloudy")
if (diff * 10000000 > 6000):
luminosityMessage = "cloudy"
else:
luminosityMessage = "sunny"

# Rain Detection Part
if(rainDevice.is_active):
rain = True
else:
# sunny
print("It's sunny")
rain = False

# Temperature/Humidity Part
try:
# Print the values to the serial port
temperature_c = dhtDevice.temperature
temperature_f = temperature_c * (9 / 5) + 32
humidity = dhtDevice.humidity
print(
"Temp: {:.1f} F / {:.1f} C Humidity: {}% ".format(
temperature_f, temperature_c, humidity
)
)
data = {
"Temperature": temperature_c,
"Humidity": humidity,
"Datetime": datetime.datetime.now()
"temperature": temperature_c,
"humidity": humidity,
"datetime": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"luminosity": luminosityMessage,
"rain": rain
}
print(data)
db.child("Status").push(data)
db.update(data)
print("Sent to Firebase")
Expand Down

0 comments on commit fb7ea18

Please sign in to comment.