Hallo
can any one in this forum help me that how i can measure the communication time b/w two arduino uno boards
![]()
How much data are sending , and at what data rate? You capture millis() when you start sending, and millis() again when you get a response, then you'll know how much total time was used to send on both ends.
Electricity and radio waves travel at 186,000 miles/second, so you're not measuring that, but more how long the code take to run on both ends.
What do you mean by "the communication time"?
thank you sir for your reply. i am new to arduino. my programs are below what i do ...
transmitter code
#include<Wire.h>
unsigned long time;
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
Serial.print("Time: ");
time = micros();
int input=analogRead('AnalogInputpin');
Wire.beginTransmission(1);
Wire.write("10");
Wire.endTransmission();
Serial.println(time);
delay(500);
receiver code
#include<Wire.h>
const byte slavedId=1;
unsigned long time;
void setup()
{
Wire.begin(slavedId);
Wire.onReceive(receiveEvent);
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
}
void loop()
{
}
Serial.print("Time:");
time=micros();
void receiveEvent(int howMany)
{
if('acount==10')
{
int receivedValue=Wire.read();
receivedValue=Wire.read();
Serial.println(time);
{
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}
}
}
but sir with this code i can,t view result on serial monitor
I don't understand Reply #5 - what do you see on the Serial Monitor?
In both of your programs you have a line time=micros(); but in neither program have you got a line that saves the value of micros at the end of the timing interval. To measure how long something takes you need to save the start time and the end time and then the elapsed time is the difference.
And you cannot compare the value of micros() in one Arduino with the value in another Arduino because they will have started at different times.
...R
how to save time ????? i am new plz give me example .........and reply #5 i want to see the time on serial monitor but no value there
![]()
if('acount==10')What's that?
AWOL:
What's that?
A prime candidate for dead code removal. ![]()
ishtiaq:
how to save time
Why are you asking that when you already have the correct code in your program - time=micros();
Assuming that line of code is at the start of the interval you want to measure then you need a similar endTime=micros(); at the end of the interval. Then the interval can be calculated with
elapsedMicros = endTime - time;
Serial.print("Elapsed Micros ");
Serial.println(elapsedMicros);
...R
thank you sir....