-1

i have quite specific SW / HW problem probably related with serial communication...

My project is based on Raspberry Pi 4 + 7" Touch screen + ESP32 microcontroller and i have problem with screen touch function.

Project detailed architecture:

  1. on Raspberry Pi is running my application writen in Python 3 (+Kivy Framework) and reading data with pySerial library (source bellow)
  2. touch screen is connected with HDMI(video) + USB(touch),
  3. to next USB is connected development board with ESP32 microcontroler and pushing data via UART to Raspberry Pi

Data reading from ESP32 UART:

import serial
uart = serial.Serial(port="/dev/ttyUSB0", bytesize=8, baudrate=9600,
                     stopbits=1, timeout=0.2, parity='N')

Okey, and here is my problem:

When is connected only USB <-> UART data cable (touch screen isn't connected), everything works great: I am sending data from ESP32 microcontroller (over UART) and then reading it on Raspberry Pi with pySerial library (and vice versa: When i have connected touch screen and i don't have connected USB <-> UART cable, touch works fine too).

But when both USB Touch Screen and USB <-> UART are connected together, i cann't see any data from ESP32 microcontroller and of course, touch function isn't works...

Based on information written above, problem is probably with serial communication, respectively conflict between USB <-> UART and USB touch interfaces but i don't have experience how to fix or rebuild it.

Please, do someone experience / knowledge how to solve it? (if i forgot write some important information, of course, i can it add it here)

Update 12/22/2022:

lsusb - plugged in 2x UART dev + 1x Touch USB

1 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
2 Bus 001 Device 006: ID 0bda:3036 Realtek Semiconductor Corp. 
3 Bus 001 Device 005: ID 0bda:3036 Realtek Semiconductor Corp. 
4 Bus 001 Device 004: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP2102/CP2109 UART Bridge Controller [CP210x family] # UART 1
5 Bus 001 Device 003: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP2102/CP2109 UART Bridge Controller [CP210x family] # UART 2
6 Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
7 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I can't see Display USB TOUCH

lsusb - plugged in 1x UART dev + 1x Touch USB

1 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
2 Bus 001 Device 006: ID 0bda:3036 Realtek Semiconductor Corp.
3 Bus 001 Device 005: ID 0bda:3036 Realtek Semiconductor Corp.
4 -> Bus 001 Device 004: ID 0eef:0005 D-WAV Scientific Co., Ltd     # Display USB TOUCH
5 Bus 001 Device 003: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP2102/CP2109 UART Bridge Controller [CP210x family]    # UART 1
6 Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
7 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

What about the power supply i have external source (5V 4A) for Raspberry Pi 4 + ESP32 + 7" LCD with touch and i did't see problem with stability (but maybe this is a problem).

lukassliacky
  • 364
  • 7
  • 25
  • You might just not be using the correct /dev/ entries for the devices when they're both connected. Have you confirmed you're using the right ones? Or the ESP32 and the touch screen need more current than the Pi's USB ports can provide. I would try running a program like Blink on the ESP32 while plugging everything in together in order to confirm that it's even running. It's possible that providing the Pi 4 with a higher amperage power supply might solve the problem, if not and this is the issue you'll need to to externally power at least one of the two USB devices. Or – romkey Dec 20 '22 at 03:38
  • @romkey, thank you for your support. During my development i had connected two USB cables: UART from GPIO ports (/dev/ttyUSB0) and "build in" microUSB with REPL (/dev/ttyUSB1). My main.py file looks that`uart = UART(2, 9600) uart.init(9600, bits=8, parity=None, stop=1)` and works fine to a point when i connect next USB with Touch function of my screen. After that i can't see any transmitting strings from ESP32 and touch isn't works too :/ What about the power supply i have external source (5V 4A) for Raspberry Pi 4 + ESP32 + 7" LCD with touch and i did't have problem with stability. – lukassliacky Dec 21 '22 at 05:06
  • 1
    You need to rule out power supply issue. Measure the actual voltages and current draw at USB ports and RPi board when problem happens. The typical wall wart cannot deliver its rated amperage as claimed. Watch out for voltage sag as you increase the load by plugging in more USB devices. – sawdust Dec 22 '22 at 08:27
  • This post should be closed because it's off-topic. But it can't be closed since there's an active bounty. But the bounty probably isn't going to be awarded because the OP refuses to consider the most obvious issue that should always be investigated first. – sawdust Dec 22 '22 at 21:04
  • Yes, i agree, before this topic i had wrong point of view to described problem, but currently is probably offtopic. But how you said, i can't delete it because bounty is active. – lukassliacky Dec 22 '22 at 21:31

1 Answers1

1

/dev/ttyUSB0 might be changing every time according to plugging order. With newer Linux distros, each device you are plugging creates also a unique identifiable symlink under /dev/serial/by-id/ or /dev/serial/by-path.

So, I would suggest using one of those in python. If symlinks are not directly accessible, you might use os.path.realpath(path) to retrieve the real serial device.

goe1zorbey
  • 73
  • 5