Chapter 3. Connecting Sensors - Measure the Real Things

The objectives of this book are to build a Home Security System, control domestic appliances by electronically controlled systems with sensors, and monitor them from a dashboard. First, we need to consider that our sensors are connected to an end device that can read the signals and transmit them to the network.

For the end devices, we will use Arduino boards to acquire the readings from the sensors. We can see that the Raspberry Pi doesn't have analog inputs. For this reason, we use an Arduino board to read that signals.

In the previous chapter, we talked about how to connect devices to the Raspberry Pi; in this section, we will see how to interface sensors with Arduino boards to see how to read real signals from different applications for real measurements. We will cover the following topics in this chapter:

  • Using a flow sensor to calculate the volume of water
  • Measuring the concentration of gas with a sensor
  • Measuring the level of alcohol with a sensor
  • Detecting fire with a sensor
  • Measuring the humidity for plants
  • Measuring the level of water in a recipient
  • Measuring temperature, humidity and light and display data in an LCD
  • Detecting motion with a PIR sensor
  • Detecting if the door is open with a reed switch
  • Detecting who can get in the house with a fingerprint sensor

It's important to consider the fact that we need to communicate our system to the real world. Since we are working on building a home security system, we need to learn how to connect and interact with some necessary sensors to use them in our system.

In the next section, we will cover the sensors that you will need to read the data you use in the domotics and security system.

Measuring flow sensor to calculate the volume of water

We need to take automatic measurements from the water that we're using in the home. For this project, we will use a sensor to perform this reading and make the reading of measurement automatic.

To make this project, we need the following materials:

Flow Water Sensor and Arduino UNO board:

Measuring flow sensor to calculate the volume of water

Hardware connections

Now we have the connections for out flow sensor. We can see that it has three pins -- the red pin is connected to +VCC 5 volts, the black one is connected to GND, and the yellow pin is connected to pin number 2 of the Arduino board as seen in the following image:

Hardware connections

Reading the sensor signal

An interrupt is used for the pulses generated by the passage of water to be accounted as follows:

attachInterrupt(0, count_pulse, RISING); 

The interruption is of type RISING counts the pulses that pass from a low state to a high:

Function for counting pulses: 
 
voidcount_pulse() 
{ 
pulse++; 
} 
..................Content has been hidden....................

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