1

Is there any other way to integrate raspberry pi with mq sensors?? I've been successful with one mcp3002 and one mq-2 sensor but is it possible to add another mq sensor (mq4,mq6) and should i provide more ADC?? I tried to plug two different mq sensors (mq-2 and mq-6) to one mcp3002 but all I got was one same value. Could somebody share his/her experience about sensors with me?? Thanks.

This is my current circuit on my Pi: enter image description here

The detailed schema I use: enter image description here

The code and the library I use (basically both the mcp libraries are the same, except the channel part at lower lines)

enter image description here enter image description here enter image description here

and here is the compilation result enter image description here

sorry for the long post :)

2
  • You connected the sensors to the MCP3002 incorrectly or more likely you read the MCP3002 incorrectly. Post the code you use and post a photo of your set-up.
    – joan
    May 3, 2015 at 8:49
  • @joan sorry it took me so long, I have updated the details :)
    – Evorio
    May 6, 2015 at 14:20

1 Answer 1

2

I think the problem is with the call to the other modules from sensors.py. You are using

smokeLevel=mcp1.readAnalog()
lpgLevel=mcp2.readAnalog()

As you have not specified the device or the channel the defaults of device 0 channel 0 will be used.

Try

smokeLevel=mcp1.readAnalog(0, 0)
lpgLevel=mcp2.readAnalog(0, 1)

By the way, and this is a personal view, it is much easier if you cut&paste code for questions. I found it awkward to look at the code and impossible to cut&paste from an image.

3
  • you think so?? sorry my bad, i thought placing codes in screenshots will make it simpler because you can see the whole code by right clicking it and select view image. I'll make sure i won't do that in the future. btw, you suggestion works for me, thanks a lot. my next problem is why doesn't my sensor values return to zero when there's no smoke or any gas occurred?? i stop the program, run it again and the values won't reset to 0 so i have to wait it decrease gradually. why is that??
    – Evorio
    May 8, 2015 at 11:23
  • As I say that was just a personal view, and may be tied in to the way I work. Don't let it sway you unduly. You'd have to look at the sensor datasheets to see how long they take to recover, or perhaps they need to be reset? By the way I think your post is an excellent example of how to ask a question and provide the information needed.
    – joan
    May 8, 2015 at 11:36
  • I don't know if you can reset the devices. That's why I suggested you check the datasheet. As for connecting more than one device the second is connected exactly the same as the first with the single exception of the chip select being connected to a different gpio (tyically gpio8 for the first, gpio7 for the second). I'd remove your e-mail address unless you want lots of spam.
    – joan
    May 10, 2015 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.