Projects components
Materials:
-Waterproof Box
: The other components will be put inside this box
:Must be waterproof but needs small holes to allow water to detect the sensor
-Arduino board
: Arduino boards are versatile, open-source electronics platforms used for creating interactive
projects by allowing users to read inputs from sensors and control outputs like LEDs or motors,
all through a simple, C/C++ based programming language and software environment.
-Water level sensor
: Water sensors detect the presence of water and, when placed in locations where water should
not be present, a leak
: How does it work?
The operation of the water level sensor is fairly simple.
The power and sense traces form a variable resistor (much like a potentiometer) whose
resistance varies based on how much they are exposed to water.
: Hardware Overview
The sensor has ten exposed copper traces, five of which are power traces and the remaining
five are sense traces. These traces are interlaced so that there is one sense trace between
every two power traces.
Normally, power and sense traces are not connected, but when immersed in water, they are
bridged.
-GSM Board
: With an Arduino GSM shield and the GSM library, you can enable your Arduino to
make/receive calls, send/receive SMS, and connect to the internet via GPRS networks.
A Typical Workflow
To upload code to an Arduino board using the IDE, one typically does the following:
1. Install your board - this means installing the right "package" for your board. Without the
package, you can simply not use your board. Installing is done directly in the IDE, and is a quick
and easy operation.
2. Create a new sketch - a sketch is your main program file. Here we write a set of instructions
we want to execute on the microcontroller.
3. Compile your sketch - the code we write is not exactly how it looks like when uploaded to our
Arduino: compiling code means that we check it for errors, and convert it into a binary file (1s
and 0s). If something fails, you will get this in the error console.
4. Upload your sketch - once the compilation is successful, the code can be uploaded to your
board. In this step, we connect the board to the computer physically, and select the right serial
port.
5. Serial Monitor (optional) - for most Arduino projects, it is important to know what's going on
on your board. The Serial Monitor tool available in all IDEs allow for data to be sent from your
board to your computer.
Anatomy of an Arduino Board
While all Arduino boards differ from each other, there are several key
components that can be found on practically any Arduino. Let's take a look at
the image below:
Key components of an Arduino board.
1. Microcontroller - this is the brain of an Arduino, and is the component that we
load programs into. Think of it as a tiny computer, designed to execute only a
specific number of things.
2. USB port - used to connect your Arduino board to a computer.
3. USB to Serial chip - the USB to Serial is an important component, as it helps
translating data that comes from e.g. a computer to the on-board microcontroller.
This is what makes it possible to program the Arduino board from your computer.
4. Digital pins - pins that use digital logic (0,1 or LOW/HIGH). Commonly used for
switches and to turn on/off an LED.
5. Analog pins - pins that can read analog values in a 10 bit resolution (0-1023).
6. 5V / 3.3V pins- these pins are used to power external components.
7. GND - also known as ground, negative or simply -, is used to complete a circuit,
where the electrical level is at 0 volt.
8. VIN - stands for Voltage In, where you can connect external power supplies.
Depending on the Arduino board, you will find many more components.
The items listed above are generally found on any Arduino board.
How Does a Water Level Sensor Work?
The operation of the water level sensor is fairly simple.
The power and sense traces form a variable resistor (much like a potentiometer) whose
resistance varies based on how much they are exposed to water.
This resistance varies inversely with the depth of immersion of the sensor in water:
● The more water the sensor is immersed in, the better the conductivity and
the lower the resistance.
● The less water the sensor is immersed in, the poorer the conductivity and
the higher the resistance.
The sensor generates an output voltage proportional to the resistance; by measuring this
voltage, the water level can be determined.
Water Level Sensor Pinout
The water level sensor is extremely simple to use and only requires three pins to connect.
S (Signal) is an analog output pin that will be connected to one of your Arduino’s analog inputs.
+ (VCC) pin provides power to the sensor. It is recommended that the sensor be powered from
3.3V to 5V. Please keep in mind that the analog output will vary depending on the voltage
supplied to the sensor.
– (GND) is the ground pin.
Wiring a Water Level Sensor to an Arduino
Let’s hook up the water level sensor to the Arduino.
To begin, connect the + (VCC) pin on the module to 5V on the Arduino and the – (GND) pin to
ground.
One well-known issue with these sensors is that they have a shorter lifespan
because they are constantly exposed to moisture. Moreover, constantly applying
power to the sensor while immersed in water significantly accelerates the rate of
corrosion.
To avoid this, it is recommended that the sensor be turned on only when taking
readings.
One easy way to do this is to connect the sensor’s power pin to a digital pin on
an Arduino and set it to HIGH or LOW as needed. So, we’ll connect the + (VCC)
pin to the Arduino’s digital pin #7.
Finally, connect the S (Signal) pin to the Arduino’s A0 ADC pin.
The wiring is shown in the image below.
Basic Arduino Example
After constructing the circuit, upload the following sketch to your Arduino.
// Sensor pins
#define sensorPower 7
#define sensorPin A0
// Value for storing water level
int val = 0;
void setup() {
// Set D7 as an OUTPUT
pinMode(sensorPower, OUTPUT);
// Set to LOW so no power flows through the sensor
digitalWrite(sensorPower, LOW);
[Link](9600);
}
void loop() {
//get the reading from the function below and print it
int level = readSensor();
[Link]("Water level: ");
[Link](level);
delay(1000);
}
//This is a function used to get the reading
int readSensor() {
digitalWrite(sensorPower, HIGH); // Turn the sensor ON
delay(10); // wait 10 milliseconds
val = analogRead(sensorPin); // Read the analog value form sensor
digitalWrite(sensorPower, LOW); // Turn the sensor OFF
return val; // send current reading
}
After uploading the sketch, open the Serial Monitor window to view the output.
When the sensor is dry, it will output a value of 0; however, as the sensor is
immersed in water, the output will gradually increase.
SIM900A Modem is built with Dual Band GSM/GPRS based SIM900A modem
from SIMCOM. It works on frequencies 900/ 1800 MHz. SIM900A can search
these two bands automatically. The frequency bands can also be set by AT
Commands. The baud rate is configurable from 1200-115200 through AT
command. The GSM/GPRS Modem is having internal TCP/IP stack to enable
you to connect with internet via GPRS. SIM900A is an ultra compact and
reliable wireless module. This is a complete GSM/GPRS module in a SMT
type and designed with a very powerful single-chip processor integrating
AMR926EJ-S core, allowing you to benefit from small dimensions and cost-
effective solutions.
Specification
Dual-Band 900/ 1800 MHz
GPRS multi-slot class 10/8GPRS mobile station class B
Compliant to GSM phase 2/2+
Dimensions: 24*24*3 mm
Weight: 3.4g
Control via AT commands (GSM 07.07 ,07.05 and SIMCOM enhanced
AT Commands)
Supply voltage range : 5V
Low power consumption: 1.5mA (sleep mode)
Operation temperature: -40°C to +85 °
Step 1: Material Preparation
In this tutorial, you will need :
1. GSM SIM900A (MINI V3.9.2)
2. Arduino Uno Board and USB
3. Jumper Wire
4. Power adapter 5V
5. SIM card
6. Breadboard
Step 2: Booting Up SIM900A
1. Insert your SIM card to GSM module and lock it. (picture 1 and 2)
2. power up your gsm by connecting it to Arduino's 5V and GND (picture 3)
3. Connect the Antenna (picture 4)
4. Now wait for some time (say 1 minute) and see the blinking rate of ‘status
LED’ or ‘network LED’ (D6, refer picture 5) //GSM module will take some time
to establish connection with mobile network//
5. Once the connection is established successfully, the status/network LED
will blink continuously every 3 seconds. You may try making a call to the
mobile number of the sim card inside GSM module. If you hear a ring back,
the gsm module has successfully established network connection.
You can see a TTL pin with 3VR, 3VT, 5Vr, 5VT, VCC and GND on your
sim900a near your power supply pin. You have to connect GSM's 5VT to
Arduino D9 and GSM's 5VR to Arduino's D10 for serial communication
between arduino and sim900a module.
Step 4: Basic AT Command
1. To change sms sending mode : AT+CMGF=1
[Link]("AT+CMGF=1");
2. To read SMS in text mode : AT+CNMI=2,2,0,0,0
[Link]("AT+CNMI=2,2,0,0,0");
3. To make a call : ATD+60XXXXXXXXX; //replace X with number you want
to call, change +60 to your country code
[Link]("ATD+60XXXXXXXXX;");
4. To disconnect / hangup call : ATH
[Link]("ATH");
5. To redial : ATDL
[Link]("ATDL");
6. To receive a phone call : ATA
[Link]("ATA");
Step 5: Library