Difference between revisions of "Howto setup Raspbian for serial read"

From lechacal
Jump to: navigation, search
Line 59: Line 59:
Run the raspi-config tool
Run the raspi-config tool
  $ sudo raspi-config
  $ sudo raspi-config
Then disable the login uart
Then disable the login uart
  5 Interfacing Options
  3 Interfacing Options     <<-- Use option 5 instead is using a n image earlier than 12 DEC 2020
  P6 Serial
  P6 Serial

Revision as of 10:03, 3 January 2021

This howto will cover the steps to setup a Rasperrypi for reading CSV stream from RPICT series board.

Hardware and OS

This applies to all Raspberrypi.

Tested with OS:
Raspbian Jessie 2017-06-21-raspbian-jessie.img
Raspbian Stretch 2017-09-07-raspbian-stretch-lite.img
Raspbian Stretch 2018-06-27-raspbian-stretch-lite.img
Raspbian Stretch 2018-10-09-raspbian-stretch-lite.img
Raspbian Stretch 2018-11-13-raspbian-stretch-lite.img
Raspbian Buster 2019-06-20-raspbian-buster-lite.img
Raspbian Buster 2020-02-13-raspbian-buster-lite.img

Rasberry Pi OS 2020-05-27-raspios-buster-armhf.img
Rasberry Pi OS 2020-08-20-raspios-buster-armhf.img

If the image from Emoncms (emonpi) is used then this setup is not needed.



Download the image from the raspberrypi website. https://www.raspberrypi.org/downloads/raspberry-pi-os/


Write the image to the SD card. Follow instructions given by the raspberrypi website.



Once the image written create an empty file called ssh in the boot section of the image.


Power up the raspberrypi and connect it to the ethernet network.
Access the raspberrypi with ssh.

Linux based OS

This is as simple as issuing.

$ ssh pi@raspberrypi

Use password raspberry

On other systems (windows, ios)

We recommend to use the putty tool. Download here
As above use
hostname: raspberrypi
user: pi
password: raspberry

This will give you access to a terminal window in which you can issue commands on the raspberrypi.


Run the raspi-config tool

$ sudo raspi-config

Then disable the login uart

3 Interfacing Options     <<-- Use option 5 instead is using a n image earlier than 12 DEC 2020
P6 Serial

Select No to the login shell question.
Select Yes to the serial port hardware to be enabled question.

Select Ok at the summary.

Back at the menu select finish.

Select No to the reboot question (we will do that later).


Update the Raspbian OS.

sudo apt-get update


This step must be performed regardless if you have a Raspberrypi 3 or 4.

Edit the /boot/config.txt file

$ sudo nano /boot/config.txt

At the end of the file add the following line:


(note the above will disable bluetooth - if bluetooth is needed do not execute this step and use ttyS0 instead of ttyAMA0 for what follows).
A one liner of the above command would be
sudo bash -c 'echo "dtoverlay=pi3-disable-bt" >> /boot/config.txt'

Save and Exit file.


Disable hciuart

sudo systemctl disable hciuart



sudo reboot & exit

return to the ssh session again once the raspberrypi up and running again.


Insert the RPICT board on the RPI. Configure and read from serial port

stty -F /dev/ttyAMA0 raw speed 38400
cat /dev/ttyAMA0


[OPTIONAL] It might be useful to get the board with all utilities ready at this point. Just issue the commands below:

sudo apt-get install python-serial
wget lechacal.com/RPICT/tools/lcl-rpict-config.py.zip
unzip lcl-rpict-config.py.zip
sudo mv lcl-rpict-config.py /usr/local/bin