I’m trying to use an ultrasonic sensor with the programmable XBee-PRO 900HP. Model is HC-SR04, data sheet is https://cdn.sparkfun.com/datasheets/Sensors/Proximity/HCSR04.pdf. This sensor is ubiquitous in the Arduino world.
To read the distance from the ultrasonic sensor I send a 10 microsecond pulse on the trigger pin and measure the duration of the return pulse on the echo pin, which is proportional to the measured distance. This code to measure the duration of the echo pulse is trivial on Arduino (e.g., http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/?ALLSTEPS) using Arduino’s pulseIn function, but I can’t figure out how to do the same on the XBee.
It seems like I should be using the input capture library to measure the echo pulse duration (is this correct?) but I’m struggling as I can’t find working code examples online that demonstrate how to drive an ultrasonic sensor using a programmable XBee.
Basically I want to know how to write the equivalent of Arduino’s pulseIn function for the XBee.
Any help much appreciated.