I am reading Can data with Pcan, and I am transferring my Can data to my Raspberry Pi 4. With this code
import can
import serial
# CAN bus setup
can_bus = can.interface.Bus(bustype="pcan", channel="PCAN_USBBUS1", bitrate=9600)
# Serial port setup
ser = serial.Serial("ttySO", baudrate=9600)
while True:
# Read from CAN bus
received_msg = can_bus.recv()
if received_msg.arbitration_id == 0x18904001:
data_byte = received_msg.data[0]
inst_voltage = ((received_msg.data[2] << 8) | received_msg.data[3]) / 10
soc = received_msg.data[4]
# Print CAN data
print("CAN - Instant Voltage: {:.1f} V, SOC: {}%".format(inst_voltage, soc))
# Read from serial port
if ser.isOpen() and ser.in_waiting > 0:
serial_data = ser.readline().decode().strip()
print("Serial - Received:", serial_data)
I am trying to transfer that data to my Android app. I was stuck on the connection between the Raspberry Pi and the Android device. My Android device doesn't see the Raspberry Pi. What is wrong here? By the way, I can only use a wired connection. ( I prefer USB )