Blog 3: Wireless Communication and Remote Event Triggering
In the last blog, I interfaced the vibration sensor with Arduino to detect the landslides. This pretty much completes the sensing enclosure box, however, this vibration detected signal has to be sent to another Arduino at a remote location and trigger the alarm. In this blog, I will communicate between two Arduinos using the ASK RF modules operating at 433 MHz to send the vibration detected signal to another Arduino and trigger the audio-visual alarm. For the sake of simplicity, this blog will be divided into three subsections - Interfacing the LCD, wireless data transmission, and remote event triggering.
Interfacing the Grove LCD
The grove starter kit provided in the design challenge is really helpful as it contains almost all the parts that I will be using for this project. I will be using the Grove
LCD, the grove LEDs, and the grove buzzer from the starter kit.
I used an Arduino UNO for the alarm box as the grove sensors can be easily connected with the shield provided in the starter kit and the shield is only UNO compatible due to its form factor.
Here is the code for interfacing the Grove LCD with Arduino-
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Just Encase");
}
void loop() {
}
I'm using the grove rgb_lcd.h library for this. The library can be downloaded from the grove website. Many examples are also loaded with the library.
Here's the output of the above code-
The good thing about this LCD is that it uses I2C communication. It saves a lot of pins on the Arduino to connect other peripherals/sensors.
Wireless Data Transmission between Arduinos
The next step is to transmit the data wirelessly from the first Arduino (the sensor enclosure box). In the previous blog, I used an Arduino MKR WAN 1300 provided in the design challenge kit and interfaced a vibration sensor with it. Now, it's time to transmit the vibration detected signal from Arduino MKR WAN 1300 to this alarm enclosure box with an Arduino UNO. For this, I will use the ASK RF Tx/Rx module working at 433 MHz.
Here's the code for the transmitter -
//Transmitter code
int a; //variable to store the vibration sensor signal
void setup() {
// put your setup code here, to run once:
pinMode(5,INPUT);
Serial.begin(300);
}
void loop() {
// put your main code here, to run repeatedly:
a = digitalRead(5);
if(a==0)
{
Serial.write(a); //send the signal to ta Tx module
Serial.println("Vibration Detected");
}
}
Code for the receiver
//Receiver Code
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
int b; //variable to store the received signal from transmitter
void setup() {
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
}
void loop() {
if(Serial.available()>0)
{
b=Serial.read();
}
lcd.print(b);
delay(1000);
lcd.clear();
delay(1000);
}
The wiring diagram is as follows -
The Tx is made of Arduino MKR WAN 1300, the vibration sensor and the RF Tx module.
The Rx consists of Arduino UNO, LCD and the RF Rx module.
I tried a couple of tests with this, but it seems there is some problem with the RF modules. Irrespective of the vibration sensor's output, the received signal at the receiver end is corrupted and it always showed a 0 on the LCD.
I plan to drop this idea of having to separate boxes and went ahead with a single box with all the necessary components - The arduino MKR, vibration sensor, buzzer and LED for alarm.
The only limitation of this system is that the remote event triggering mechanism is not implemented and hence an early warning at a far distance cannot be provided. However, this will still do the intended task as well as evaluate and test the performance of the enclosure boxes which is the main aim. I'll look into the RF link problem in the near future.