2019-06-10 19:45:25 +01:00
# modbusmaster
## Disable Bluetooth on RPi3
Add at the end of `/boot/config` :
dtoverlay=pi3-disable-bt
Remove mentions of `serial0` from `/boot/cmdline` .
## Enable rs485 mode
Use the submodule rpirtscts to enable to alternate functions of the related
pins at the RPi MCU. It is submoduled here, can be found directly at https://github.com/mholling/rpirtscts
cd rpirtscts
gcc -o rpirtscts rpirtscts.c
sudo ./rpirtscts on
This needs to be done at every boot.
2019-06-10 19:56:09 +01:00
Kudos to danjperron, cmp. https://www.raspberrypi.org/forums/viewtopic.php?f=98& t=224533& hilit=rs+485#p1383709
2019-06-10 19:45:25 +01:00
2019-06-11 11:57:25 +02:00
(Note, please: This software is under the GPL 3.0 license. However, I do not derive from this software, I use it in an unchanged way. It is not integrated into my sources, it just needs to be called once the RPi has booted.)
2019-06-10 19:45:25 +01:00
2019-06-10 19:48:41 +01:00
## Pinout
2019-06-10 19:56:09 +01:00
Find a good pinout diagram at https://raw.githubusercontent.com/ppelleti/hs-wiringPi/master/pin-diagram.png.
2019-06-10 19:48:41 +01:00
TX is at GPIO14, RX is at GPIO15 and RTS (control line for transmitter enable) is at GPIO17.
2019-06-10 19:45:25 +01:00
2019-06-11 11:38:46 +02:00
## Schematics

2019-06-10 19:45:25 +01:00
## Python snippet to test
2019-06-11 11:49:01 +02:00
(See also `./snippets/test1.py` .)
2019-06-10 19:45:25 +01:00
import serial.rs485
2019-06-10 19:58:54 +01:00
ser=serial.rs485.RS485(port='/dev/ttyAMA0',baudrate=2400)
2019-06-10 19:45:25 +01:00
ser.rs485_mode = serial.rs485.RS485Settings(False,True)
ser.write('a test'.encode('utf-8'))
2019-06-10 19:56:09 +01:00
Find an signal screenshot here:
2019-06-10 19:57:35 +01:00
2019-06-10 19:56:09 +01:00

2019-06-11 11:49:01 +02:00
Channel 1 in yellow has the TX line (GPIO14), channel 3 in purple has the RTS (GPIO17, transmitter enable line).
2019-06-10 19:57:35 +01:00
2019-06-10 19:45:25 +01:00