transmitting and receiving data packets on arduino uno

Hello community!
I am a newbie with Arduino programming. I am trying a project of a tracking module using RF waves:
for this i am using 433MHz ask rf transmitter and receiver.
One thought is to send a counter of the number of times your Transmitter had sent data, and in the receiver, count the number of packets you received. we can calculate (# received / sent #) as a rough indicator of signal strength. i want to see it on LCD
I want to do this programming but i don't know how to do it. please give me code of transmitter and receiver.
Could some kind soul tell me how to fix this? Thank you very much in advance. I´m totally newbie!

The VirtualWire library is used to work with those radios. It comes with examples.

i am using below code foe transmitter.

#include<VirtualWire.h>
#include<VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
int estadoBoton=0;


void setup()
{
  // put your setup code here, to run once:



Serial.begin(9600);
Serial.println("setup");
vw_setup(2000);
vw_set_tx_pin(7);
pinMode(2,INPUT);

}

void loop() {
const char *msgBateria = "5;";
const char *msgEstado = "2;";
const char msgChar [] = "A";


for (int i = 0; i < 100; i++)
{
  vw_send((uint8_t *)msgchar, strlen(msgchar));

  delay (300);
}
delay(15000);
}
}
// put your main code here, to run repeatedly:

}
#include<VirtualWire.h>
#include<VirtualWire.h>

I think maybe you need to include that header file a few more times.

The code does something. You expect the code to do something. You are 0 for 2 on explaining things.

PaulS:

#include<VirtualWire.h>

#include<VirtualWire.h>



I think maybe you need to include that header file a few more times.

The code does something. You expect the code to do something. You are 0 for 2 on explaining things.

dear sir.. sorry for my mistake. @PaulS

Paul is trying to ask "What did it actually do?" and "What do you want it to do different?"

Without that information, we can't help much.

This is transmitter code

#include<VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
int estadoBoton=0;

void setup()
{
// put your setup code here, to run once:

Serial.begin(9600);
Serial.println("setup");
vw_setup(2000);
vw_set_tx_pin(7);
pinMode(2,INPUT);

}

void loop() {
const char *msgBateria = "5;";
const char *msgEstado = "2;";
const char msgChar [] = "A";

for (int i = 0; i < 100; i++)
{
vw_send((uint8_t *)msgChar, strlen(msgChar));

delay (300);
}
delay(15000);
}

// put your main code here, to run repeatedly:

and receiver code is...

#include<VirtualWire.h>

int count = 0;
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
Serial.begin(9600);
Serial.println("setup");

vw_set_ptt_inverted(true);
vw_setup(2000);
vw_set_rx_pin(8);
vw_rx_start();
}

void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
digitalWrite(5, true);
Serial.print("Got: ");

for(i = 0; i < buflen; i++)
{
Serial.print(buf*, HEX);*

  • Serial.print(" ");*
  • }*
  • Serial.println("");*
  • digitalWrite(5, false);*
  • }*
  • count++;*
  • Serial.print("count=");*
  • Serial.println(count);*

}

i am in confusion of how to connect 433MHz receiver data pin and 16 * 2 LCD pins with arduino. in LCD pins like rs, read/write and enable pins creating more confusions. please help if you can.

i want to count data packets at 433Mhz receiver side.... data is transmitted from 433MHZ transmitter connected with arduino. receiver is also connected with arduino and that arduino is connected with 16 *2 LCD.

i want to measure that data packets transmitted from receiver side. as i will go far away from transmitter it's count number will be decrease on receiver side. means i will get some idea about distance between transmitter and receiver.

Please use [ code ] tags. The forum software has eaten some of your code and turned it into smileys 8) and italics.

transmitter and receiver side arduino program is attached here.

transmitter.ino (541 Bytes)

receiver.ino (689 Bytes)

So, in some period of time, the transmitter will send A some number of times. How many times, in what period of time?

What, on the receiver side are you counting? Be careful how you answer that. It is probably not what you think you are.

What tells you that the transmitter is out of range? It is NOT what you are expecting. It is the fact that no data is received on the receiver for some period of time. That has NOTHING to do with counting anything. It has to do with knowing WHEN you last received data, and WHEN you should next expect to receive more data.

OOK receivers have an extremely non linear relationship between incoming signal to noise ratio of the input signal and the bit error rate of the demodulated output, which means that at the range limit of the receiver
you will see a rapid increase in bit errors .
If you are using Virtualwire which has integral error checking you will simply see either correct data or nothing.
There wont be a smooth linear relationship between the range and the error rate.
This type of method is useless for measuring range.

sir...@PaulS The tests I want to do is:
-In transmitter I put a loop that sends 100 packets.
-At the receiver want to count how many of these packages have arrived safely.

I could send exactly 100 packages with a delay in between of 15 seconds using transmitter code.

In the transmitter you transmit an extra number and increment it with every transmission.
For example a number 00...99. Or with integer: a byte 0...255 or an integer.
Let's do that 00...99. Make a global integer, and let it count from 0 to 99. Convert it to text of 00 to 99 and add it to the string.
In the receiver remember the previous number, and if you receive 62 and the previous number was 43, you have missed 18 transmissions.

so this way i am actually thinking. i have got this idea from arduino forum. link is given below.

http://forum.arduino.cc/index.php?topic=259438.0

I could send exactly 100 packages with a delay in between of 15 seconds using transmitter code.

OK. So, how long will those 100 packages take to arrive?

-At the receiver want to count how many of these packages have arrived safely.

Is that what you are counting?

  if (vw_get_message(buf, &buflen))
  {
    int i;
    digitalWrite(5, true);
    Serial.print("Got: ");

    for(i = 0; i < buflen; i++)
    {
      Serial.print(buf[i], HEX);
      Serial.print(" ");
    }
    Serial.println("");

    digitalWrite(5, false);
  }
  count++;

On every pass through loop(), this is the code (with the exception of the Serial.print() statements) that is executed. So, I'm asking again. What are you counting?

i am not as much aware of arduino programming sir , yes i have studied c language so i am getting some what idea. i am in confusion to understand what is counting here by arduino by using loop. sir if you have an idea than please help me to understand and clear things in my mind @sir PaulS

if you have an idea than please help me to understand and clear things in my mind

On every pass through loop(), you see if there is a packet to read. If there is a packet, you read it. Then, regardless of whether there was a packet to read, you increment count.

Now, it seems to me that if you wanted to count the number of packets received, you'd have the statement to increment the counter INSIDE the body of the if statement.

It also seems to me that if you expect n packets in m seconds, at some point you'd need to know when a packet arrives, so that you can see if that packet is in the m seconds window.

This leads to the idea that counting packets is silly. The sender should be sending a packet every n milliseconds. The receiver should record when it received a packet. It should also check that it has received a packet within the last n milliseconds. If it has, then the transmitter is within range. If not, then the receiver missed sending a packet. The assumption, when that happens, is that the transmitter has gone out of range or has gone dead. In either case, whatever should happen when the transmitter stops sending should happen when the time since the last message exceeds the promised time between messages.