URM07 (SEN0153): Setting the adress
I am trying to change the adress of these sensors with the next code. After using it, the blue LED in the sensor has not worked again. I would like to know if the sensor is broken or if I can fix it and how.
// # Pin VCC (URM07 V1.0) -> D3 (Arduino Leonardo)
// # Pin GND (URM07 V1.0) -> D2 (Arduino Leonardo)
// # Pin RX (URM07 V1.0) -> TX1/D1 (Arduino Leonardo)
// # Pin TX (URM07 V1.0) -> RX1/D0 (Arduino Leonardo)
#define header_H 0x55 //Header
#define header_L 0xAA //Header
#define device_Addr 0xAB //Address
#define data_Length 0x01 //Data length
#define set_adress_CMD 0x55 //Command: Set adress
#define set_adress 0x05 //Command: Change adress
#define checksum (header_H+header_L+device_Addr+data_Length+set_adress_CMD+set_adress) //Checksum
unsigned char i=0;
unsigned char Adress=0;
unsigned char Operation_confirmed=0;
unsigned char Rx_DATA[8];
unsigned char CMD[7]={
header_H,header_L,device_Addr,data_Length,set_adress_CMD,set_adress,checksum}; //Distance command package
void setup() {
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(3, HIGH); //Ultrasonic VCC
digitalWrite(2, LOW); //Ultrasonic GND
Serial1.begin(19200); //Serial1: Ultrasonic Sensor Communication Serial Port, Buadrate: 19200
Serial.begin(19200); //Serial: USB Serial Data output, baudrate: 19200
}
void loop() {
for(i=0;i<7;i++){
Serial1.write(CMD[i]);
}
delay(150); //Wait for the result
i=0;
while (Serial1.available()){ //Read the return data (Note: this demo is only for the reference, no data verification)
Rx_DATA[i++]=(Serial1.read());
}
Adress=(Rx_DATA[2]);
Operation_confirmed=(Rx_DATA[5]);
if (Operation_confirmed == 0xCC){
Serial.println("Operation completed");
}
else{
Serial.println("Operation Failed");
}
delay(1000);
Serial.println(Adress);
}
If you are not sure of its usage, there is a document in which all the data is explained.
Thanks!!