1 minute read
8 Hacking with Sensors
8
Hacking with Sensors
Chapters 6, 7, and 8 all overlap somewhat, as many sensors are also modules and both can often be used with an Arduino.
In this chapter, we will look at how to use a range of sensors, whether with a little supporting electronics or as an input to an Arduino, or sometimes both.
How to Detect Noxious Gas
In this section, you will use a methane sensor (Figure 8-1).
While they look like they should be expensive, these sensors are really quite low cost. They include a small heater (connected between the two H connections) and a catalytic sensing element whose resistance changes depending on the concentration of methane. Although the project will run on batteries, it will burn through them pretty quickly because these sensors have a heating element that will consume 150 to 200 mA.
The sensing of methane does have lots of sensible scientific and industrial uses. However, we will use this technological know-how for the puerile activity of … detecting farts.
You Will Need
To experiment with this gas sensor, you will need the following items.
Quantity Names Item 1 D1 LED 1 R1 10kΩ trimpot 1 R2 10kΩ resistor 1 R3 470Ω resistor 1 IC1 LM311 comparator Appendix Code K1 K1 K2 K2 S7
194 Hacking Electronics
Quantity Item
Appendix Code 1 Methane sensor MQ-4 M11 1 Piezo buzzer (with own oscillator) M10 1 Solderless breadboard T5 Solid-core jumper wire T6 1 4 × AA battery holder H1 1 4 × AA batteries 1 Battery clip H2 1 * Arduino Uno/Leonardo M2/M21 1 * USB lead; Type B for Uno, Micro USB for Leonardo
* Only required if you want to connect the detector to an Arduino.
The piezo sounder must be of the type that includes its own oscillator circuit and will work at 6V.
The LM311 Comparator
Figure 8-2 shows the schematic diagram for the gas detector.
The key to this circuit is the comparator IC (LM311). Comparators, as the name suggests, compare voltages. If the voltage at its “+” connection is greater than the voltage at its “–”
Figure 8-1 A methane sensor
Figure 8-2 Schematic diagram for the gas detector