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:
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.
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:
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:
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++;
}
3.137.220.44