1

I am trying to establish communication between a Raspberry Pi3 and a digital Sensor that has a RS-232 connection. I have bought a hat that also has a RS-232 port on it and can be connected to the rx and tx pins on the Pi. The Pi has raspbian installed and I am using Python 3 to write the code.

In the tutorials I read it says that i have to configure the Pi first to allow serial communication. I have done following steps:

Step 1:

sudo raspi-config -> Interfacing Options -> Serial -> [login shell accesible over serial? -> no] -> [serial port hardware enabled? -> yes]

Step 2:

sudo nano /boot/cmdline.txt 

change line to:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Step 3:

sudo nano /boot/config.txt 

add lines:

dtoverlay=pi3-miniuart-bt
enable_uart=1
force_turbo=1

Step 4:

 sudo apt-get install python-serial

After this setup i wrote a very short program in Python 3 to test it:

import serial
ser = serial.Serial('/dev/ttyAMA0', 9600)
ser.write(bytes(5, 'UTF8'))

The number 5 tells the sensor to change the displayed unit. The code runs without an error message but I dont see the unit of the sensor change. If I connect the RS232 to my laptop with a serial to usb converter and use Putty to monitor the serial port, I also do not see anyting being send.

It would be great if someone can tell me where my problem is. But I would also be happy about any input on how I can find a solution myself.

Many thanks in advance, Florian

1 Answers1

0

I think Raspberry Pi 3 uses a different device for the serial port. Try

ser = serial.Serial('/dev/ttyS0', 9600)
  • Could you provide a reference for your contribution? E.g. why do you think this is the correct port? – rsz Oct 01 '18 at 21:03
  • I don't recall where I saw this but it was in response to a similar problem. I know this works on the latest Raspberry Pi Zero. – user10443147 Oct 03 '18 at 11:23