How to get accurate milliseconds? I need to calculate the delay of sending data from arduino a to arduino b
I tried to use DS3231 but milliseconds can not get me. What should i do to get accurate milisecond from DS3231?
You have to calculate your own milliseconds, DS3231 only outputs seconds.
How are you sending the data, and what are you measuring from-to?
I would use micros(), 1000 us = 1ms
I am sending data using nrf24l01. Is it accurate using micros? I once used a millis, on arduino A every 1 second I sent the packet. I send also millis arduino A recorded to arduino B, when the package arrived at arduino B I get millis now when the packet is received, but the difference is very far. So i try using DS3231 to get the time but i have trouble getting milisecond. dapatkah anda membantu saya?
DS3231 has also 32768Hz output, even default. Connect it to the timer/counter with e.g. prescaling 32, 1.024ms can be obtained. Millisecond counter can work by the same way as it is in Arduino's wiring.c. You can see there how the problem with the remainder is solved. You can achieve better accuracy with smaller prescaler/divisor but it never fits exactly to 1ms rate. The 32768Hz frequency fits to 1s. On ATmegas is Timer/Couter2 designated for this job to obtain exactly 1s, e.g. with prescaler 128 and counter overflow at 256.
Hang on a milli, did you think that the millis on Arduino A and B were synched up somehow? Did they start at the same time?
Jimmy
ahmat:
I need to calculate the delay of sending data from arduino a to arduino b
If you are using acks in the NRF simply time the radio.write() function (with a micros()).
It will only return after successfull delivery, or after the specified retries.