The RS485 Bricklet can be used to extend the features of Bricks by the capability to send and receive differential data with RS-485.
It supports full- and half-duplex and has configurable termination.
You can use the Bricklet in RS485, Modbus RTU master and Modbus RTU slave mode.
In RS485 mode you can send and receive arbitrary data. The Modbus modes are fully Modbus compliant. In Modbus RTU master mode you can write and read any coils/registers from a slave. In Modbus RTU slave mode you can provide data for coil/register reads and you receive the data that a Modbus master writes to the coils/registers.
This Bricklet ist not galvanically isolated to the Tinkerforge system. This means that there is a direct electrical connection between the terminals of the Bricklet and the rest of the system. Dependent of the application this can lead to undesired connections, ground loops or short circuits. These problems can be prevented by using the Bricklet together with a Isolator Bricklet.
Property | Value |
---|---|
Current Consumption | 64mW (12.8mA at 5V, idle) |
Baudrate | 100 - 2000000 baud |
Parity | none / odd / even |
Stop bits | 1 / 2 |
Word length | 5 / 6 / 7 / 8 |
Duplex | half / full |
Dimensions (W x D x H) | 40 x 40 x 14mm (1.57 x 1.57 x 0.55") |
Weight | 13g |
In full-duplex mode you have to connect TX+, TX-, RX+, RX- and GND.
In half-duplex mode TX+ / RX+ and TX- / RX- are shorted, so you can connect either TX+ / TX- / GND or RX+ / RX- / GND. You can also use this to chain-connect other devices.
The DIP switches on the Bricklet can be used to configure duplex and termination configuration.
You can configure between Full-Duplex and Half-Duplex and you can enable or disable a 120 Ohm termination resistor.
A legend of the different configuration possibilities can also be found in the bottom of the Bricklet.
The total termination resistance in a single bus has to be 120 Ohm. Because of this only DIP switch 1 is on and DIP switch 4 stays off in Half-Duplex terminated mode. Otherwise both 120 Ohm termination resistors would be connected in parallel due to the TX+/RX+ and TX-/RX- connections resulting in 60 Ohm total termination resistance.
The Bricklet can be configured to operate on Modbus RTU master/slave mode. In this mode Modbus specific protocol messages can be sent and received. A Modbus master can send a request to a Modbus slave connected to the bus. These Modbus functions are based on callbacks.
To better understand the general concept a scenario is described. In this scenario two RS485 Bricklets are present on the bus. One operating in Modbus master mode and the other in Modbus slave mode. The Modbus master wants to read 4 registers starting with the register 400002 (e.g. the second holding register) from Modbus slave at address 8:
For details of these functions refer to the programming interface section.
All of the available Modbus functions can also be used in Brick Viewer:
To test a RS485 Bricklet you need to have Brick Daemon and Brick Viewer installed. Brick Daemon acts as a proxy between the USB interface of the Bricks and the API bindings. Brick Viewer connects to Brick Daemon. It helps to figure out basic information about the connected Bricks and Bricklets and allows to test them.
Connect the RS485 Bricklet to a Brick with a Bricklet Cable. Connect the RX+ to the TX+ pin and the RX- to the TX- pin with two cables to make the Bricklet read back its own output. Configure the DIP switches to full duplex mode, with half termination (1: on, 2: off, 3: off, 4: off). This is a diversion from the normal Full-Duplex terminated setting, because the Bricklet talks back to itself for this test. Otherwise the total termination resistance would be 60 Ohm instead of 120 Ohm if both 120 Ohm termination resistors would be connected in parallel.
If you connect the Brick to the PC over USB, you should see a new tab named "RS485 Bricklet" in the Brick Viewer after a moment. Select this tab. Set the mode to RS485 and the duplex option to full duplex and then click Save Configuration. If everything went as expected you can now type some text into the input editbox and hit enter. The same text should then show up in the textarea above.
After this test you can go on with writing your own application. See the Programming Interface section for the API of the RS485 Bricklet and examples in different programming languages.
A laser-cut case for the RS485 Bricklet is available.
The assembly is easiest if you follow the following steps:
Below you can see an exploded assembly drawing of the RS485 Bricklet case:
Hint: There is a protective film on both sides of the plates, you have to remove it before assembly.
See Programming Interface for a detailed description.
Language | API | Examples | Installation |
---|---|---|---|
C/C++ | API | Examples | Installation |
C/C++ for Microcontrollers | API | Examples | Installation |
C# | API | Examples | Installation |
Delphi/Lazarus | API | Examples | Installation |
Go | API | Examples | Installation |
Java | API | Examples | Installation |
JavaScript | API | Examples | Installation |
LabVIEW | API | Examples | Installation |
Mathematica | API | Examples | Installation |
MATLAB/Octave | API | Examples | Installation |
MQTT | API | Examples | Installation |
openHAB | API | Examples | Installation |
Perl | API | Examples | Installation |
PHP | API | Examples | Installation |
Python | API | Examples | Installation |
Ruby | API | Examples | Installation |
Rust | API | Examples | Installation |
Shell | API | Examples | Installation |
Visual Basic .NET | API | Examples | Installation |
TCP/IP | API | ||
Modbus | API |