print("Hello, ESP32!")
print("Gas Detector System ")
import machine
import time
# Define pin numbers
analog_pin_gas = machine.ADC(machine.Pin(34)) # Pin for gas sensor
analog_pin_pot = machine.ADC(machine.Pin(35)) # Pin for potentiometer
# Main loop
while True:
# Read analog value from gas sensor
gas_value = analog_pin_gas.read()
# Read analog value from potentiometer
pot_value = analog_pin_pot.read()
# Map potentiometer value (0-1023) to gas sensor sensitivity range (0-1023)
gas_value_scaled = int(gas_value * (pot_value / 1023))
# Print gas value
print("Gas value:", gas_value_scaled)
# Wait for some time before reading again
time.sleep(1)