Sensor value transmission without using Encoder and decoder
Introduction:
In RF communication based application we use encoder and decoder IC’s HT12E and HT12D. These chips convert the serial data in to parallel data and parallel data in to serial. We can control the load or just switch ON/OFF the load connected to HT12D using switches connected to HT12E. But using this method we can’t send continuously changing values like sensor output values. Sensor output values are variable analog values, which varies as physical quantity changes. If we send sensor output as a data from Tx, we can achieve great designs in RF communication applications. By using Arduino Virtualwire library, we can achieve this.
So the new and different approach in this project is, we are sending analog data or continuously varying data by using RF 434Mhz Tx and Rx modules and microcontrollers serial port. The project does not require serial to parallel and parallel to serial converter or encoder/decoder chips HT12E / HT12D
Description:
In this project transmitter (Tx) and receivers (Rx) modules are directly connected to the microcontrollers, so circuit construction is easy. But we have to use two microcontrollers , one is for the transmitter and another for the receiver. Tx module data pin is connected to Txd pin of 1st microcontroller and Rx module data pin connected to Rxd of 2nd micro controller. As per virvualwire library Txd and Rxd default pins are 12 and 11 digital pins in arduino respectively.
Micro controller gets analog value from sensor, converts it into digital data stream (serial) and transmits it using Tx module. At receiver side Rx module receives this data stream and gives to micro controller. The sensor data is continuously sent to receiver so, if any change in sensor output it will be immediately displayed on LCD at receiver side.
Isn’t it really very interesting? Do you want to learn how it is done? How it is build? OK, let us start. First collect the required components and equipments. Here is the list.
Required components and equipments:
Sr. no. Name of component Required quantity
1 RF Tx module(434Mhz) 1
2 RF Rx module(434Mhz) 1
3 LDR 1
4 LCD 1
5 1 K Pot 1
6 10 K resistor 1
7 Arduino pro mini development board 2
8 Battery – 9V 2
9 Bread board 2
10 connecting wires
Circuit diagram:
Procedure:
Transmitter section:
Step1: connect Tx module 2nd pin to the 12th pin of Arduino board, 1st pin to the ground and 3rd pin to the Vcc.
Step2: connect LDR in pulldown configuration with 10Kohms resistor, and connect junction point to the analog pin 2 of Arduino board.
Receiver section:
Step1: connect Rx module 1st pin to the ground and 4th pin to the Vcc.
Step2: connect receiver module 2nd pin to the Arduino 11th pin.
Step3: connect Arduino 2nd pin to LCD En pin (6), 3rd pin to Rs pin (4), and 4,5,6,7 pins to LCD D5,D6,D7,D8 pins respectively.
Step4: connect RW pin (5) of LCD to ground.
Step 5: connect pins 1 and 16 of LCD to ground and 2 and 15 to Vcc. Connect 1 K pot to 3rd pin as shown to vary LCD brightness
Working:
1. In this project serial data is sent from one microcontroller to another microcontroller using virtual wire Arduino library.
2. LDR sensor output given as analog input to Arduino
3. Arduino converts this analog value into digital serial bit stream and sends it to receiver using Tx module through 12th pin
4. Rx module at receiver side receives this digital serial bit stream and gives it to micro controller at 11th pin
5. The received data is displayed on LCD. The variations in the sensor values we can observe in LCD.
6. Because of direct wireless link data transmitting and reception we can observe every variation in the sensor value.
Pictures:
Precautions:
1. When connecting Tx and Rx , check once default configuration of microcontroller Tx and Rx pins as per Virtual library.
Project Source Code
Project Source Code
###
#include <VirtualWire.h>// LED'sconst int ledPin = 13;// Sensorsconst int Sensor1Pin = A2;// const int Sensor2Pin = 3;int Sensor1Data;//int Sensor2Data;char Sensor1CharMsg[4];void setup() {// PinModes// LEDpinMode(ledPin,OUTPUT);// Sensor(s)pinMode(Sensor1Pin,INPUT);// for debuggingSerial.begin(9600);// VirtualWire setupvw_setup(2000); // Bits per sec}void loop() {// Read and store Sensor 1 dataSensor1Data = analogRead(Sensor1Pin);// Convert integer data to Char array directlyitoa(Sensor1Data,Sensor1CharMsg,10);// DEBUGSerial.print("Sensor1 Integer: ");Serial.print(Sensor1Data);Serial.print(" Sensor1 CharMsg: ");Serial.print(Sensor1CharMsg);Serial.println(" ");delay(1000);// END DEBUGdigitalWrite(13, true); // Turn on a light to show transmittingvw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));vw_wait_tx(); // Wait until the whole message is gonedigitalWrite(13, false); // Turn off a light after transmissiondelay(200);} // END void loop...Receiver:#include <VirtualWire.h>// LED'sint ledPin = 13;// Sensorsint Sensor1Data;// RF Transmission containerchar Sensor1CharMsg[4];void setup() {Serial.begin(9600);// sets the digital pin as outputpinMode(ledPin, OUTPUT);// VirtualWire// Initialise the IO and ISR// Required for DR3100vw_set_ptt_inverted(true);// Bits per secvw_setup(2000);// Start the receiver PLL runningvw_rx_start();} // END void setupvoid loop(){uint8_t buf[VW_MAX_MESSAGE_LEN];uint8_t buflen = VW_MAX_MESSAGE_LEN;// Non-blockingif (vw_get_message(buf, &buflen)){int i;// Turn on a light to show received good messagedigitalWrite(13, true);// Message with a good checksum received, dump it.for (i = 0; i < buflen; i++){// Fill Sensor1CharMsg Char array with corresponding// chars from buffer.Sensor1CharMsg[i] = char(buf[i]);}// Null terminate the char array// This needs to be done otherwise problems will occur// when the incoming messages has less digits than the// one before.Sensor1CharMsg[buflen] = '