Howto setup Raspbian for serial read: Difference between revisions
(→-7-) |
(→-8-) |
||
Line 94: | Line 94: | ||
sudo systemctl disable hciuart | sudo systemctl disable hciuart | ||
==- | ==-6-== | ||
Reboot | Reboot | ||
sudo reboot & exit | sudo reboot & exit |
Revision as of 12:33, 12 July 2022
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. If using the image from Emoncms (emonpi) then this setup is not needed.
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-lite.img
Rasberry Pi OS 2020-08-20-raspios-buster-armhf-lite.img
Rasberry Pi OS 2020-12-02-raspios-buster-armhf-lite.img
Rasberry Pi OS 2020-01-11-raspios-buster-armhf-lite.img
Rasberry Pi OS 2021-03-04-raspios-buster-armhf-lite.img
Rasberry Pi OS 2021-05-07-raspios-buster-armhf-lite.img
Rasberry Pi OS 2021-10-30-raspios-bullseye-armhf-lite.img
Rasberry Pi OS 2022-04-04-raspios-bullseye-armhf-lite.img
Steps
-1-
The Raspberry pi OS must be installed and running.
To get a Raspberry Pi Os image you can either
Download the image from the raspberrypi website.
https://www.raspberrypi.org/software/operating-systems/
or
Make an image yourself using the Imager.
https://www.raspberrypi.com/software/
If you are running headless with the 'Raspberry Pi OS Lite' you will have to connect a keyboard and monitor for the very first time the raspberry is run. This is to allow access to the first time boot wizard. Also creating an empty 'ssh' file inside the /boot directory will be useful for connecting via ssh.
-2-
For what follow you must open a terminal window.
On the desktop version of Raspberry Pi OS just open a terminal.
On the headless version connect to the raspberry via ssh with the user/password you created.
-3-
Run the raspi-config tool
$ sudo raspi-config
Then disable the login uart
3 Interface Options <<-- Use option 5 Interfacing Options instead if using the image before 12 DEC 2020 P6 Serial
Would you like a login shell to be accessible over serial?
Select No to the login shell question.
Would you like the serial port hardware to be enabled?
Select Yes to the serial port hardware to be enabled question.
Select Ok at the summary.
Back at the menu select finish.
Would you like to reboot now?
Select No to the reboot question (we will do that later).
-4-
Edit the /boot/config.txt file
$ sudo nano /boot/config.txt
At the end of the file add the following line:
dtoverlay=disable-bt
(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=disable-bt" >> /boot/config.txt'
Save and Exit file.
-5-
[OPTIONAL]
Disable hciuart
sudo systemctl disable hciuart
-6-
Reboot
sudo reboot & exit
return to the ssh session again once the raspberrypi is up and running again.
-9-
Insert the RPICT board on the RPI. Configure and read from serial port
stty -echo -F /dev/ttyAMA0 raw speed 38400 cat /dev/ttyAMA0
At that point the data will be shown on the terminal. This is an example with the RPICT3T1 below.
Please refer to the dedicated page of the board for the details of each field.
The cat command above is the most basic form for reading out the data from any RPICT unit. Do not skip this test.
Note. Once step number 10 below completed you will be able to run these two commands using lcl-run.
lcl-run
-10-
[OPTIONAL] It might be useful to get the board with all utilities ready at this point. Just issue the commands below to install them:
Install python3-serial
sudo apt-get install python3-serial
Get the rpict package:
wget lechacal.com/RPICT/tools/lcl-rpict-package_latest.deb
Install it with
sudo dpkg -i lcl-rpict-package_latest.deb