Hi! I’d like to use a serial port on a BL4S160 board to send/receive data on the DIO ports.

I’d like to detect when a DIO input has changed, and if it has, send DIO information out thru the rs232 port. I’d also like to be able to receive information thru the rs232 port to be able to update the DIO ports.

Since this is pretty basic stuff I’d hate to spend time re-inventing the wheel again, so I’m wondering if there are any examples out there for doing this, or any example code snippets, etc. which would help in implementing this.

Thanks in advance!

The most obvious choice for this if you want to use an existing protocol is modbus.

The only issue here would be that you would probably have the BL4S160 configured as a Modbus slave device and the PC configured as a Modbus master. In this case the PC would periodically poll the slave to see if the digital input has changed state as opposed to the BL4S160 sending out a message when the state changes. I don’t know if this would be an issue for your application.


Thanks for the reply Peter!

Unfortunately, there will be no PC’s involved. I’ll be using 2 of the BL4S160 boards for communication to each other. They’ll be connected by a wireless rs232 link. One board will be a ‘master’ with a control box (buttons/switches/lights) tied to it, and the other will be a ‘slave’ box which will control and monitor DIO (might add A/D monitoring too at a later date).

In that case set up one of the BL4S160s as a Modbus master and the other as a Modbus slave. This will allow for analog and digital values to be passed between the two over RS232.

Is the RS232 wireless link a long range one or short range? For a short range you could have used the BL4S150 with the zigbee modules in transparent serial link mode to avoid the need for an external interface.


Thank you very, very much for the quick reply Peter! The wireless link is a long-range link, hence inability to use ZigBee.

Where can I look to read/learn more about Modbus?

If I setup the boards as Modbus master/slave, will everything be transparent? i.e. if a digital input is changed on one board, will ythat automatically be sensed and a message sent out via rs232 to the other board? I’m guessing there will be more code involved?

BTW, I a novice with these BL4S boards, but have used the RCM3000 series Rabbit modules in the past (~10 years ago).

Thanks a bunch!!!

Have a look at this recent thread for some info on where to find the modbus examples from Rabbit.,9022

The modbus protocol docs are readily available on

It is not transparent. You would have to write the code on the master to read and update the I/O on the slave. You can define the mapping between the BL5S160 I/O and the Modbus registers and coils etc which suits your application best.