IRIV PiControl - Updating address/baud rate of moist Sensor

IRIV PiControl - Updating address/baud rate of moist Sensor

By the end of this guide you will update the address and baud rate of the 3 in 1 moist Sensor  on IRIV 

 

Hardware

 

 

Connection Diagram

 

Note: Please remember to handle all connections with care and double-check connections for accuracy.

Note : the DC voltage used is 24V.

 

 

 Programming with Node-RED

 

Inser an inject node from the coomon platter. we will use this one to send command 

 

 

Insert a function to the flow.

In this function add the following code.

let current_id = 0x01
let new_address = 0x03
var buf = Buffer.from([current_id, 0x06, 0x02, 0x00, 0x00, new_address, 0xC8, 0x73]);
msg.payload = buf;
return msg;

 

Note that the current_id is set to 1 as defulte and you need to change it in case you changed the id before. 

While new_address is the address that you want to set/

The last 2 items in the buffer 0xC8 and 0x73 is the crc, which are values depending on the first 6 items and you will need to calculate that .

 

Insert a serial request node.

 

 

Set the proerties as the following.

Note: in case you did not recive a respone from the port, change the baud rate to 4800.

 

 

insert a debug function

 

 

Connect the nodes, click on the square in the timestamp to send the changing command.

Check the debug side bar. if you recived a respone that means that the address is changed successfully

 

 

Now add another inject and function nodes to send the change baud rate command.

the code for the change baud rate is as following : 

let current_id = 0x01
let new_speed = 0x02 // from data sheet 0x02 = 4800 baud rate
var buf = Buffer.from([current_id, 0x06, 0x02, 0x01, 0x00, new_speed, 0x58, 0x73]);
msg.payload = buf;
return msg;

 

 

 

Connect the function node to the server. send the command and check for a respone 

 

 

 

Note that you will need to update the proberites of the server in case you changed the baud rate for the sensor to respone the command.

If you want to know more on how to get readings out of this sensor follw this link.