Sending multiple sensor data from arduino to python

So I have this problem,I'm trying to send sensor data from arduino to python through serial communication.
But the output is a kind of wierd.
Does anyone have an idea on this?

Arduino code: to send sensor data




    void setup(){

    Serial.begin(9600);
    
    }

    void loop(){

    int sensor1 = 20;
    int sensor2 = 40;
    int sensor3 = 60;
    Serial.write(sensor1);

    }


python code: to receive sent data from arduino



    import serial,time
    ser = serial.Serial("/dev/ttyACM1",9600,timeout=1)
    while True:
        data = ser.read()
        time.sleep(1) 
        print("data:",data)

output :

data: b'\x14'

target :

data: 20

second target : sending multiple sensor data in a single serial.write().

data: 20 40 60

Did you mean to use write, instead of print?

write or print if it results on target output would be nice.

What happened when you tried?

Some comments of the demo-codes on this website are wrong but it show how to "translate" bytes to different formats. Scroll down to

The data coming from the serial line looks kind of funny:
b'481\r\n'

best regards Stefan

b'\x14'` means it's a binary data, a byte with an hexadecimal value of 14 which is 20 in decimal ➜ hence what you sent

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.