Howto setup Raspbian for serial read: Difference between revisions

From lechacal
Jump to navigation Jump to search
No edit summary
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:


[https://lechacal.com/docs/RPICT/Howto_setup_Raspbian_for_serial_read/ VIEW THE NEW DOCUMENTATION INSTEAD HERE]


This howto will cover the steps to setup a Rasperrypi for reading CSV stream from RPICT series board.
This howto will cover the steps to setup a Rasperrypi for reading CSV stream from RPICT series board.
Line 6: Line 7:
This applies to all Raspberrypi. If using the image from Emoncms (emonpi) then this setup is not needed.
This applies to all Raspberrypi. If using the image from Emoncms (emonpi) then this setup is not needed.


Tested with OS: <br>
Latest tested OS for this guide: <br>
Raspbian Jessie '''2017-06-21-raspbian-jessie.img'''<br>
Raspberrypi OS Released: 2023-12-05<br>
Raspbian Stretch '''2017-09-07-raspbian-stretch-lite.img'''<br>
Both for Lite and Desktop variants.
Raspbian Stretch '''2018-06-27-raspbian-stretch-lite.img'''<br>
Raspbian Stretch '''2018-10-09-raspbian-stretch-lite.img'''<br>
Raspbian Stretch '''2018-11-13-raspbian-stretch-lite.img'''<br>
Raspbian Buster  '''2019-06-20-raspbian-buster-lite.img''' <br>
Raspbian Buster  '''2020-02-13-raspbian-buster-lite.img''' <br>
 
Rasberry Pi OS '''2020-05-27-raspios-buster-armhf-lite.img''' <br>
Rasberry Pi OS  '''2020-08-20-raspios-buster-armhf-lite.img''' <br>
Rasberry Pi OS  '''2020-12-02-raspios-buster-armhf-lite.img''' <br>
Rasberry Pi OS  '''2020-01-11-raspios-buster-armhf-lite.img''' <br>
Rasberry Pi OS  '''2021-03-04-raspios-buster-armhf-lite.img''' <br>
Rasberry Pi OS  '''2021-05-07-raspios-buster-armhf-lite.img''' <br>
 
Rasberry Pi OS  '''2021-10-30-raspios-bullseye-armhf-lite.img''' <br>
Rasberry Pi OS  '''2022-04-04-raspios-bullseye-armhf-lite.img''' <br>


=Steps=
=Steps=
Line 43: Line 29:
https://www.raspberrypi.com/software/
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.
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. Alternatively you can just use the imager software from above to setup username and ssh before flashing.


==-2-==
==-2-==
Line 59: Line 45:


Then disable the login uart
Then disable the login uart
  3 Interface Options    <<-- Use option ''5 Interfacing Options'' instead if using the image before 12 DEC 2020
  3 Interface Options    
P6 Serial
 
I6 Serial Port     <<-- might also be found as ''I5 Serial Port''


'''Would you like a login shell to be accessible over serial?'''<br>
'''Would you like a login shell to be accessible over serial?'''<br>
Select '''No''' to the login shell question.<br>
Select '''No''' to the login shell question.<br>
[[File: 001_login_shell_question.png]]


'''Would you like the serial port hardware to be enabled?'''<br>
'''Would you like the serial port hardware to be enabled?'''<br>
Select '''Yes''' to the serial port hardware to be enabled question.<br>
Select '''Yes''' to the serial port hardware to be enabled question.<br>
[[File: 002_serial_enable.png]]


Select '''Ok''' at the summary.
Select '''Ok''' at the summary.
[[File: 003_serial_setup.png]]


Back at the menu select '''finish'''.
Back at the menu select '''finish'''.
Line 82: Line 75:
At the end of the file add the following line:
At the end of the file add the following line:
  dtoverlay=disable-bt
  dtoverlay=disable-bt
Enter the line exactly as it is show above without adding whitespaces.
Save and Exit file.
<small>(note the above will disable bluetooth - if bluetooth is needed do not execute this step and use ttyS0 instead of ttyAMA0 for what follows).<br>
<small>(note the above will disable bluetooth - if bluetooth is needed do not execute this step and use ttyS0 instead of ttyAMA0 for what follows).<br>
A one liner of the above command would be<br>
[alternative] A one liner to include the above line in the config file would be<br>
sudo bash -c 'echo "dtoverlay=disable-bt" >> /boot/config.txt'
sudo bash -c 'echo "dtoverlay=disable-bt" >> /boot/config.txt'
</small>
</small>


Save and Exit file.
For Raspberrypi 5 only also add the line below
dtoverlay=uart0


==-5-==
==-5-==
Line 94: Line 93:
  sudo systemctl disable hciuart
  sudo systemctl disable hciuart


==-8-==
==-6-==
Reboot
Reboot
  sudo reboot & exit
  sudo reboot & exit
return to the ssh session again once the raspberrypi is up and running again.
return to the ssh session again once the raspberrypi is up and running again.


==-9-==
==-7-==
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.<br>
[[File:Screenshot_2021-03-12_21-27-04.png]]
 
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:
It might be useful to get the board with all utilities ready at this point. Just issue the commands below to install them:


Line 126: Line 110:
Install it with
Install it with
  sudo dpkg -i lcl-rpict-package_latest.deb
  sudo dpkg -i lcl-rpict-package_latest.deb
==-8-==
Last step is testing the serial port.
/!\ DO NOT SKIP THIS TEST /!\<br>
This is the most basic test to confirm you are able to read from the serial port. If it fails do not continue your setup. Instead carefully review the configuration setup described above.<br>
If you encounter issues with your own application or some custom configuration then do run this test again to make sure the serial port is still operational.
Insert the RPICT board on the RPI. Configure and read from serial port
stty -echo -F /dev/ttyAMA0 raw speed 38400
cat /dev/ttyAMA0
Note these two command above can be run directly using
lcl-run
At that point the data will be shown on the terminal. This is an example with the RPICT3T1 below.<br>
[[File:Screenshot_2021-03-12_21-27-04.png]]
Please refer to the dedicated page of the board for the details of each field.

Latest revision as of 11:28, 19 January 2024

VIEW THE NEW DOCUMENTATION INSTEAD HERE

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.

Latest tested OS for this guide:
Raspberrypi OS Released: 2023-12-05
Both for Lite and Desktop variants.

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. Alternatively you can just use the imager software from above to setup username and ssh before flashing.

-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     
I6 Serial Port     <<-- might also be found as I5 Serial Port

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

Enter the line exactly as it is show above without adding whitespaces.

Save and Exit file.

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

For Raspberrypi 5 only also add the line below

dtoverlay=uart0

-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.

-7-

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


-8-

Last step is testing the serial port.

/!\ DO NOT SKIP THIS TEST /!\
This is the most basic test to confirm you are able to read from the serial port. If it fails do not continue your setup. Instead carefully review the configuration setup described above.
If you encounter issues with your own application or some custom configuration then do run this test again to make sure the serial port is still operational.

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

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

Note these two command above can be run directly using

lcl-run

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.