We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

User avatar
Gebrey
Posts: 4
Joined: Sat Jul 13, 2024 3:09 pm

Gas Sensor MQ-7 Arduino and Raspberry Pi Hardware schematic

Sat Jul 13, 2024 3:17 pm

EDITED (I HAD A WRONG PINOUT OF THE MODULE ANALOG OUT INVERTED WITH DIGITAL OUT - THE SCHEME IS CORRECTED NOW)

Hallo everyone,
I'm Gabriel. I'm new to this world. I used to spend time in analog electronic and now I feel a bit confused by some tutorials about logic digital signals.

My goal is to sense sensors (gas sensor and DHT22) with Arduino Nano and show the result on a LCD2004 display.
My second goal is to do the same in Raspberry Pi environment.

The tutorial I've found is this.
https://www.bujarra.com/sensor-de-humo- ... i/?lang=en

But something doesnt convince me.


ARDUINO (Analog/Digital 5V)

CASE1:
- gas sensor (A/D output avaible) @5V
- analog signal from MQ-7 to Analog GPIO

CASE2:
- gas sensor (A/D output avaible) @5V
- digital signal from MQ-7 to Digital GPIO

CASE3:
- gas sensor (A/D output avaible) @5V
- analog signal from MQ-7 to MCP3008
- MCP3008 via SPI (digital) to GPIO


RASPBERRY (Digital 3.3V)

CASE1:
- gas sensor (A/D output avaible) @5V
- digital signal passes to level shifter 5V->3.3V
- 3.3V digital signal to Digital GPIO

CASE2A (TUTORIAL):
- gas sensor (A/D output avaible) @5V
- digital signal passes to level shifter 5V->3.3V
- 3.3V digital signal to MCP3008
(why?? Just to achieve 8 channel - 8 sensor - using just 4 pin SPI comunication? if i have 1 sensor is useless to use a MCP3008 like that?)
- MCP3008 via SPI (digital) to GPIO

CASE2B (TUTORIAL if sensor signal type is analog but wrong labeled in images):
- gas sensor (A/D output avaible) @5V
- analog signal (???) pass to level shifter 5V->3.3V (is it possible???)
- 3.3V analog signal to MCP3008
- MCP3008 via SPI (digital) to GPIO

Can you help me to understand how things going in the tutorial schematic?
Raspberry-Pi-Gas-Sensor-MQ2-Steckplatine-768x390.png
Raspberry-Pi-Gas-Sensor-MQ2-Steckplatine-768x390.png (227.12 KiB) Viewed 1176 times
Last edited by Gebrey on Fri Jul 19, 2024 6:50 pm, edited 1 time in total.

User avatar
neilgl
Posts: 11167
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near The National Museum of Computing

Re: Gas Sensor MQ-7 Arduino and Raspberry Pi Hardware schematic

Mon Jul 15, 2024 7:14 pm

if i have 1 sensor is useless to use a MCP3008 like that
Yes. You could use an MCP3002 (2 channel) instead of the MCP3008. He probably used an MCP3008 as they are very common/cheap.

Case2B as the gas sensor AD output can be up to 5V, we use a voltage divider (two resistors) so that no more than 3V3 is seen by the MCP3008 (which is running at 3V3).

ghp
Posts: 4413
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany

Re: Gas Sensor MQ-7 Arduino and Raspberry Pi Hardware schematic

Tue Jul 16, 2024 6:29 am

analog signal (???) pass to level shifter 5V->3.3V (is it possible???)
The breadboard view shows a small board which is possibly a "level shifter". Such level shifters are usually digital devices and are not suitable for analog signals.
As already mentioned by neilgl you can use a voltage divider build from two resistors.

User avatar
Gebrey
Posts: 4
Joined: Sat Jul 13, 2024 3:09 pm

Re: Gas Sensor MQ-7 Arduino and Raspberry Pi Hardware schematic

Fri Jul 19, 2024 6:26 pm

neilgl wrote:
Mon Jul 15, 2024 7:14 pm
if i have 1 sensor is useless to use a MCP3008 like that
Yes. You could use an MCP3002 (2 channel) instead of the MCP3008. He probably used an MCP3008 as they are very common/cheap.

Case2B as the gas sensor AD output can be up to 5V, we use a voltage divider (two resistors) so that no more than 3V3 is seen by the MCP3008 (which is running at 3V3).
OMG I just notice that I had a wrong pinout reference. The 4th pin is ANALOG. 😆
MQ7-Gas-Sensor-Pinout.png
MQ7-Gas-Sensor-Pinout.png (79.16 KiB) Viewed 1179 times
Everything makes sense now.

Sorry guys

Can you tell me if:
- is possible to feed the level shifter with analog signal as done in the scheme?

We agreed that voltage divider method is the best for analog signal but... why this guy use a level shifter? Why does he succed??


- is ever possible to feed a MCP3008 with digital signal?
I think not since a digital signal is read as analog 0V (low state) and analog 5V (high state). Like the sensor is giving lowest value and higher value only. If is a % sensor I expect to see a fast switching (digital signal freq) between the two values of 0 and 100%.

Thanks
Last edited by Gebrey on Fri Jul 19, 2024 6:48 pm, edited 1 time in total.

User avatar
Gebrey
Posts: 4
Joined: Sat Jul 13, 2024 3:09 pm

Re: Gas Sensor MQ-7 Arduino and Raspberry Pi Hardware schematic

Fri Jul 19, 2024 6:38 pm

ghp wrote:
Tue Jul 16, 2024 6:29 am
analog signal (???) pass to level shifter 5V->3.3V (is it possible???)
The breadboard view shows a small board which is possibly a "level shifter". Such level shifters are usually digital devices and are not suitable for analog signals.
As already mentioned by neilgl you can use a voltage divider build from two resistors.
The original image
https://www.bujarra.com/wp-content/uplo ... latine.png

User avatar
Gebrey
Posts: 4
Joined: Sat Jul 13, 2024 3:09 pm

Re: Gas Sensor MQ-7 Arduino and Raspberry Pi Hardware schematic

Fri Jul 19, 2024 7:02 pm

SOLVED

Ok it is evident that Im newbie.

The level shifter is not a bidirectional mosfet module neither a traditional monodirectional mosfet module.

It's a TRAP!
20240719_205810.jpg
20240719_205810.jpg (256.16 KiB) Viewed 1171 times
As you can see, these cheapie use a mosfet to L>H and a simple 50-50 voltage divider for H>L path.

And my not so smart tutorial use these modules.... as voltage divider.
Ahahahahhahah 😆

What a mess!

Using just 2 resistor matched to obtain 3V is too hard??

So everything is right NOW.

THE CASE
MQ-7 analog out > voltage divider > 3.3V analog signal to MCP3008 > digital 3.3V signal to Raspberry.

Eureka.

Have a nice day guys!

Return to “Automation, sensing and robotics”