We’ve been discussing how to develop the interactive features of the installation. I ordered some ultrasonic range finders (Devantech SFR-02 from Acroname) to see if they are suitable for our application.
I want to evaluate several things:
- How easy is it to interface several of these devices to a microcontroller?
- Can I use long (30′) ethernet cables to carry the control and data signals?
I hooked the sensor up as shown and found some Arduino code to interface with the sensor and gave it a try. Success! So why not try two?
Interfacing a second sensor was a bit more tricky. The wiring was straightforward: simply wiring the second sensor’s SDA SCL signals in parallel with the existing sensor. Setting the device address for the second sensor was not straightforward, however.
After reading the manual and trying unsuccessfully to set the device ID, I found a clue in the Arduino examples at Devantech’s website. The ranger uses 8-bit addresses while the Arduino uses only 7 bits. This explained why the Devantech documentation listed the default address of the SFR-02 as 0xE0, but the example Arduino code used address 0×70.
0xE0 (hex) = 1110000
Shifting this number right to obtain 7 bits
0111000 = 0x70 (hex)
One problem solved, but I still can’t get the unit to change its ID. More Googling turned up an Arduino Library for the SFR-02 by GrapeLabs which includes a ConfigureDeviceID function.