ArduinoGeneral

srf01 detection

userHead Hugues.Thifault 2023-03-20 10:09:48 168 Views1 Replies

I'm using many 01SRF01 ultrasound sensor with different address on the same pin. 

Everything is working fine. But the project require that the number of sensor will change. I want to detect if the sensor exist before reading the sensor because if I try to read the missing sensor, the program crash.

Is there a way to detect if a srf01 is connect on a specific address? Since every sensor is on the same pin, I can't figure how to detect the available of a single address sensor.


Thanks.

icon 03srf01_assemble.zip 1KB Download(0)
2023-06-06 18:25:50

To change the address of the SRF01 you must have only one sonar connected. Write the sequence of three commands in the correct order followed by the address. For example; to change the address of a sonar currently at 1 (the default shipped address) to 5, write the following to address 1; (0xA0, 0xAA, 0xA5, 0x05 ). These commands must be sent in the correct sequence to change the address, additionally, No other command may be issued in the middle of the sequence. The sequence must be sent as four separate commands to the current address of the sonar. i.e. "break" 0x01, 0xA0 then "break" 0x01, 0xAA, then "break" 0x01, 0xA5 and finally "break" 0x01, 0x05. When done, you should label the sonar with its new address. Take care not to set more than one sonar to the same address, there will be a bus collision and very unpredictable results. The new address is stored in flash memory on the SRF01 and will remain, even if power is removed until deliberately changed.

 

userHeadPic jenna