I am newbie who is learning how to using the sensor on the raspberry pi 3b module. Recently i have a project is need to use the MQ2 smoke sensor for detect the smoke. And i have follow this website http://www.learningaboutelectronics.com/Articles/MQ-2-smoke-sensor-circuit-with-raspberry-pi.php tutorial. But it doesn't work.And the error message on the below.
import time import botbook_mcp3002 as mcp # smokeLevel= 0 def readSmokeLevel(): global smokeLevel smokeLevel= mcp.readAnalog() def main(): while True: # readSmokeLevel() # print ("Current smoke level is %i " % smokeLevel) # if smokeLevel > 120: print("Smoke detected") time.sleep(0.5) # s if_name_=="_main_": main()
0 down vote accept
Thank you for joan the answer.Its work.
After that, i test the mq2 sensor by using on fire paper. But it always print "Current smoke level is 0"
Is it the code or other problem? Does anyone have same problem..??