Analog sensors

As we have mentioned before, there are many analog sensors that we can use. We talked about raindrop and smoke sensors in the GPIO chapter because they have a digital output that works as a trigger, but those sensors also provide an analog output. There are many other components we can also use, such as light dependent resistors, moisture sensors, or just potentiometers.

In most cases, an analog sensor works just as a variable resistor that varies depending on the characteristic you want to measure, be it temperature, light, CO2 particles in the air, water, and so on.

Also in most cases, the variability of the resistance is not linear, but has the shape of a 1/x function. That is caused by the fact that you can't get 0 or infinite resistance. You can see a couple of examples in the following diagram:

The most common way to use analog sensors is to measure a few checkpoints beforehand and use them as triggers. Light variable resistors, for example, are commonly used to decide to turn on the lights when it is dark enough, a moisture sensor could open a tap to water a plant when it is getting too dry, and so on.

When working with analog sensors, you can use a potentiometer to test the logic and then replace it with the real sensor.

In the same way as you can replace any GPIO sensor with a button and any single GPIO output with a LED to test the logic, you can replace any analog sensor with a potentiometer, which is handier and also safer (imagine that you are testing a CO2 alarm).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.192.3