0

That is driving me nuts so I need your help.

Master : PC with Ubuntu, a USB to serial converter (chipset CP2102), connected to Arduino Uno Pin 10, 11 and GND. The Arduino Uno is plugged in the same PC.

Port for the converter is /dev/ttyUSB1 Port for the Arduino is /dev/ACM0

I tried to communicate by Serial through the converter (I do not want to use ACM0 as it is buggy and sometimes suddenly change to ACM1, messing up my big testing program).

On Arduino side :

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int inByte = 0; // incoming serial byte
void setup() {
 Serial.begin(9600);
 mySerial.begin(9600);
}
void loop() {
 if (mySerial.available()) {
 char inByte = mySerial.read();
 mySerial.println(inByte);
 Serial.println(inByte);
 }
 delay(10);
}

The Python script (simple one to debug)

import serial
arduino = serial.Serial('/dev/ttyUSB1', 9600)
arduino.timeout=0.5
arduino.bytesize=8
arduino.stopbits=1
code=49 #ASCII Code for 1
arduino.write(chr(code).encode('utf-8'))
print(chr(code))
print(chr(code).encode('utf-8'))
print(arduino.readline()) 
print("done") 
arduino.close()

When I run it, I have on Arduino Serial monitor a g

and Python script output

1
b'1'
b'Ly\x00'
done

By the way, the very same code over /dev/ttyACM0 and standard serial rather than Softwareserial works perfectly (as long as the port remains ACM0 of course)

asked Jun 24, 2016 at 3:42

1 Answer 1

1

That is all me, look for an answer for ages, finally post a question, to end up finding the answer in the following hour...

this is because Arduino takes TTL as input and not RS-232...

similar here : https://electronics.stackexchange.com/questions/42584/arduino-uno-weird-characters-sent-to-com-softwareserial

answered Jun 24, 2016 at 3:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.