Hello everyone,
I m going to ask a same question which is asked many times before.(but not in active link)
I am trying to make a RF TX-RX pair to communicate nearly upto 120m in open.
I am using RX & TX module whose datasheets and my schematics are attached below.
I read that to increase distance I need to increase power but in room when I increase my voltage from 5 to 14V but i could manage to just increase distance by 3meter. Right now in open I am getting nearely 40meter range with 12V.
I am using simple wire of 17.3 cm for antenna!
Here are some of my requirements!
I need portable tx so need small omni directional antenna!
small tx unit.( so can take along with you)
Will HT12E and Ht12D could improve range by proper encoding?
I am using baud rate of 2400 as I read decreasing baud can improve range!
SO what can I do to improve my distance of communication!
Please answer if any body know about it all suggestion will be a great help!
Thanks.
Yatin
#include <VirtualWire.h> // Wireless transmitter/receiver library
// RF Link Transmitter - Sparkfun MO-SAWR-A, 434MHz, WRL-08946
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with RF module.
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
// uses default pin 12 for transmit data
// uses default pin 11 for receive data
// end of notes
// ***********************************************************************
byte ledPin = 13;
// create an array to store data to be sent out
char msg[10]; // extra char added for address
int analogvalue1 = 0x12;
int analogvalue2 = 0x34;
int analogvalue3 = 0x56;
int analogvalue4 = 0x78;
// ***********************************************************************
// set up the pins as Inputs, Outputs, etc.
void setup()
{
/* Setup the pin directions, write inputs High to turn on internal pullups */
pinMode (ledPin, OUTPUT);
// Initialise the IO and ISR for VirtualWire
vw_setup(2000); // Bits per sec
} // end of void Setup()
// ***********************************************************************
// Main loop for reading the keypad and sending the button pushed out
// (with a unique address to be added eventually by reading 0-F from currently unused pins)
void loop()
{
// add your code here to read in the 4 analog values
//
//
// now put the data into an array with a couple of sync bytes
msg[0] = 'b';
msg[1] = 4;
msg[2] = highByte (analogvalue1);
msg[3] = lowByte (analogvalue1);
msg[4] = highByte (analogvalue2);
msg[5] = lowByte (analogvalue2);
msg[6] = highByte (analogvalue3);
msg[7] = lowByte (analogvalue3);
msg[8] = highByte (analogvalue4);
msg[9] = lowByte (analogvalue4);
for (int x = 0; x<10; x=x+1){
Serial.println(msg[x], HEX);
}
digitalWrite(ledPin, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg)); // send the character out
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(ledPin, false); // turn off the flash of LED
} // end of void loop
Rx code
#include <VirtualWire.h>
byte ledPin = 13;
int analog1;
int analog2;
int analog3;
int analog4;
void setup() // stuff that runs once before looping forever
{
// Initialise the Wireless Receiver IO and ISR
// set Virtual Wire data input to Pin 9 from 11
vw_set_rx_pin(9);
// set the Bits per sec
vw_setup(2000);
// Start the receive PLL running
vw_rx_start();
Serial.begin(9600);
}
void loop(){
// **********************************************************************************************
// look for wireless input or for unsolicited message from arduino2
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
digitalWrite(ledPin, LOW); // Turn on LED to show working a message
// Message with a good checksum received, dump it.
Serial.println("Got: "); // Show on PC for debugging
for (i = 0; i < buflen; i++)
{
Serial.print((buf[i],HEX));
}
digitalWrite(ledPin, HIGH);
Serial.println(""); // spaces it out for the monitor
// put the bytes together
analog1 = buf[2]<<8 + buf[3];
analog2 = buf[4]<<8 + buf[5];
analog3 = buf[6]<<8 + buf[7];
analog4 = buf[8]<<8 + buf[9];
Serial.println(analog1, HEX);
Serial.println(analog2, HEX);
Serial.println(analog3, HEX);
Serial.println(analog4, HEX);
}
}
Hey CrossRoads,
Thanks for your suggestions!
I was only trying to send data on serial.write nothing else I didn't know that I cant communicate on UART!
I will try on your suggestion and will post my improvement! Thanks!
Is that virtual wire can be replace with simple UART code with HT12E and HT12d encoder decoder pair in communication?
Thanks,
Yatin
yatin:
I am using simple wire of 17.3 cm for antenna!
Here are some of my requirements!
I need portable tx so need small omni directional antenna!
small tx unit.( so can take along with you)
You seem to be getting to the limit of what these units can do with a basic single wire antenna.
Improving both the TX & RX unit antennas will give you some signal gain, you can consider a dipole antenna preferably at both ends.
In it's simplest form get 2 pieces of 173mm wire, connect one piece vertically from the antenna connection point and another pointing downwards from the earth (ground or 0v) connection point. Now both of these wires should be in the same plane e.g. vertical with the TX/RX unit in the middle.
Obviously this can be a bit difficult to maintain in a straight line (axis) so position it inside a bit of plastic pipe.
The other obvious challenge is to find some way to install the new dipole antenna remote to the TX/RX module, for this coaxial cable is allowed, infact you can even consider making the whole antenna from a length of coax and strip out the inner core as one side of the dipole antenna and use the remaining outer copper screen as the other side of the dipole.
The basics of these designs are as in the following link. Please let us know how you go
hey CrossRoads,
I read that library, it has check sum function to check the data, so is that a bidirectional communication?
Cant we make a unidirectional using this?
hey Rbright,
Thanks for your suggestions!
I will try to change antennas but it will be difficult so i will first try with coding end if i cant get what I need I will try in your way!
Thanks for your suggestion!
CrossRoads,
I was trying to use your code but its receiver program is giving me following error, I didnt found any wrong in it so posting error here hope you can help me out on it!
I really don't no why they don't getting compiled in my Arduino 1.6.6 also I can able to compile virtualwire Receiver example available with library, I also checked that my data pin of receiver module is getting data but my on serial port I am getting nothing after execution of program, I am only getting setup statement!
Code that I am using is
For TX
#include <VirtualWire.h> // Wireless transmitter/receiver library
// RF Link Transmitter - Sparkfun MO-SAWR-A, 434MHz, WRL-08946
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with RF module.
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
// uses default pin 12 for transmit data
// uses default pin 11 for receive data
// end of notes
// ***********************************************************************
byte ledPin = 13;
// create an array to store data to be sent out
char msg[10]; // extra char added for address
int analogvalue1 = 0x01;
int analogvalue2 = 0x02;
int analogvalue3 = 0x03;
int analogvalue4 = 0x04;
// ***********************************************************************
// set up the pins as Inputs, Outputs, etc.
void setup()
{
/* Setup the pin directions, write inputs High to turn on internal pullups */
pinMode (ledPin, OUTPUT);
Serial.begin(9600);
// Initialise the IO and ISR for VirtualWire
vw_setup(2000); // Bits per sec
} // end of void Setup()
// ***********************************************************************
// Main loop for reading the keypad and sending the button pushed out
// (with a unique address to be added eventually by reading 0-F from currently unused pins)
void loop()
{
// add your code here to read in the 4 analog values
//
//
// now put the data into an array with a couple of sync bytes
msg[0] = 'b';
msg[1] = 4;
msg[2] = highByte (analogvalue1);
msg[3] = lowByte (analogvalue1);
msg[4] = highByte (analogvalue2);
msg[5] = lowByte (analogvalue2);
msg[6] = highByte (analogvalue3);
msg[7] = lowByte (analogvalue3);
msg[8] = highByte (analogvalue4);
msg[9] = lowByte (analogvalue4);
for (int x = 0; x<10; x=x+1){
Serial.print(msg[x], HEX);
}
digitalWrite(ledPin, true); // Flash a light to show transmitting
vw_send((uint8_t *)msg, strlen(msg)); // send the character out
vw_wait_tx(); // Wait until the whole message is gone
digitalWrite(ledPin, false); // turn off the flash of LED
delay (1000);
} // end of void loop
And for RX
// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.write("setup");
// Initialise the IO and ISR
//vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
digitalWrite(13, true); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i], HEX);
Serial.print(" ");
}
Serial.println("");
digitalWrite(13, false);
}
}
OK, IDE don't want me to define analog 1 to analog 4 variables in global if I define them on void loop it got compiled but still nothing happening on serial monitor at receiver side don't no why!
There is mentioned that UART dont have sych bits causing more noise as RX have AGC and it has diff gain when data comes and it is out of synch too! So will it work if i send 0x55 or 0xAA data before sending my actual data for better sych? or still I need to shift from UART?
How much range should I get with Rf module without antenna for in house application?
Currently I am trying for 20 meter with One glass door (metallic frame) and 3 walls with wooden door(metallic frame) could I am at my maximum range or can I have any further with that many obstacles?
I am keeping 300 baud rate
simple 173 mm wire antenna
12V for transmitter module and 5V for RX module!
I need reliable communication My problem is I want continuous data after 10 seconds but problem is when I send data 50 times it only receives it on 36/41/33 times so I cant work on it as my application is security based! so if some one open door when system is on It need to send data and RX need to receive it but it cant have a missing frames! I can accept at max 4998 for 5000 attempts!
I am still using serial port with "AAA555" prefix for getting synchronization and 1&0 balancing.
Can any one suggest me on this?
Thanks in advance.
Yatin