anujd9
Posts: 4
Joined: Tue Jul 26, 2016 8:24 pm

How to do serial communication on Raspberry pi 3 using putty

Mon Oct 03, 2016 7:30 pm

Hi. On windows, I have a project in which I communicate with a nordic bluetooth dongle using serial communication over putty. I want to port the project to Raspberry Pi.
Now, I have putty installed on Raspberry Pi 3. I just want to verify that to communicate with the dongle using serial communication, I need to use the USB to serial TTL wire and connect the dongle to that USB and the wires to serial ports of Raspberry pi 3 and then access the serial port using putty and the name of com port being used. Is this method correct ??
Thanks :)

enik1
Posts: 6
Joined: Tue Sep 27, 2016 8:26 am

Re: How to do serial communication on Raspberry pi 3 using p

Wed Oct 05, 2016 10:46 am

As far as I know Putty is an SSH client working over Internet. It is not built for serial communication.

Enik
AWT and Swing developer
Last edited by enik1 on Fri Nov 18, 2016 6:05 pm, edited 1 time in total.

pcmanbob
Posts: 10173
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: How to do serial communication on Raspberry pi 3 using p

Wed Oct 05, 2016 12:00 pm

Putty can be used for serial comms.
just select serial , then the comport you want to use and comms speed the speed.

Image
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: How to do serial communication on Raspberry pi 3 using p

Wed Oct 05, 2016 2:03 pm

I don't think you even need putty for what you are trying to do on a linux box. Simply look at the output of /dev/ttyUSB0 (or 1) to read what's being sent.

sudo tail -f /dev/ttyUSB0

That will print the output directly to the terminal, you can write in exactly the same way with echo "bla bla bla" > /dev/ttyUSB0. Exactly what you would need putty for on a Windows box. Only problem with this method is you can't set the baud / stop / data bits. Only way I know how to do that is with a programming language, not the native shell.

As for connecting the device, I don't know anything about it, (so this is a guess). But I doubt you would need to connect it to the USB port and the GPIO tx/rx pins. Plug it in, look in the system logs and see what the pi recognizes it as. My bet is you'll get a /dev/ttyUSB0/1 device and you can use that for communication

User avatar
daveake
Posts: 188
Joined: Thu Jul 12, 2012 12:07 am

Re: How to do serial communication on Raspberry pi 3 using p

Wed Oct 05, 2016 9:34 pm

stty is the command to configure serial ports.

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: How to do serial communication on Raspberry pi 3 using p

Wed Oct 05, 2016 10:07 pm

If the Bluetooth dongle you're talking about is something like this: Nordic nRF51 Dongle (first Google hit), that plugs in to USB, there's no need to connect it to the Pi's serial I/O pins. Just plug it into a USB port on the Pi.

I have an app that reads "serial" data from an Arduino that's plugged into a USB port on the Pi, using a library called PySerial that should already be on your Pi. Reading and printing data is as easy as this:

Code: Select all

#!/usr/bin/env python3

import serial

port = '/dev/ttyACM0'
bps  = 57600

ser = serial.Serial(port, bps)

while True:
    line = ser.readline()                 # read bytes until line-ending
    line = line.decode(encoding='UTF-8')  # convert to string
    line = line.rstrip('\r\n')            # remove line-ending characters
    print(line)
You could likely start from there (copy into a file called, say, "usbcat", then "chmod 755 usbcat", and then run it with "./usbcat" and stop it with control-C), change the port and speed to meet your needs (the setup call to Serial can take all sorts of other parameters as needed), and have a bit of code that you can expand to do whatever you want with the device.

Return to “General discussion”