I am trying to complete a University assignment that involves a smoke sensor and garage door connected to an MCU.
I also have an old car that generates smoke.
I have created a python script that is supposed to detect when the smoke sensor value is greater than 150. If it is then the garage door is opened. Below is the Python code-:
from gpio import *
from time import sleep
def main():
# Setup analog and digital pins
#smoke_sensor_pin = 0 # Analog pin A0 for the smoke sensor
#garage_door_pin = 3 # Digital pin D3 for the garage door
# Initialize the garage door pin
pinMode(3, OUTPUT)
while True:
# Read smoke level from analog pin A0
smoke_level = analogRead(0)
print(smoke_level);
# Check if the smoke level exceeds the threshold (150)
if smoke_level > 150:
# Open the garage door
#digitalWrite(3, HIGH) # Sends signal to open the garage door
customWrite(3, "1")
else:
# Close the garage door
#digitalWrite(3, LOW) # Sends signal to close the garage door
customWrite(3, "0")
# Small delay before the next reading
sleep(1)
if __name__ == "__main__":
main()
The problem is the smoke sensor does not sense any smoke. If I print out the value in the Python script that represents the Analogue value from the smoke sensor it is always zero when the old car is running.
I have checked that all pins are correctly assigned and connected.
I have included a zip file of the pkt file and an image of the topology
I am using version 8.2.2
Topology