Hi,
I have a bit of code running on a Raspberry Pi using Node Red. I would like to convert it to Flowcode but I appear to have fallen at the first hurdle.
I have not got a Raspberry Pi licence yet but thought I would look first. I had a look at the webserver example https://www.matrixtsl.com/wiki/index.ph ... etworking) and tried adding a USB serial as that is what I thought I would need. It looks like this is not supported for the Pi, looking at the Node Red code the port is something like /dev/ttyUSB0. Is it possible to use USB serial ports on the Raspberry Pi with Flowcode?
Regards,
Bob
USB serial on Raspberry Pi
-
- Posts: 283
- http://meble-kuchenne.info.pl
- Joined: Sat Mar 19, 2022 4:53 pm
- Has thanked: 25 times
- Been thanked: 32 times
-
- Valued Contributor
- Posts: 192
- Joined: Wed Dec 02, 2020 7:28 pm
- Has thanked: 77 times
- Been thanked: 64 times
Re: USB serial on Raspberry Pi
USB serial is to implement a device that can be connected to a PC or Raspberry Pi. Probably the reverse of what you are looking for. To access a USB serial connected to the Raspberry Pi you need to use a serial component. The Raspberry Pi OS translates such devices to serial ports as suggested by the /dev/ttyXX naming.
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: USB serial on Raspberry Pi
Hi Bob,
If I correctly understand what you are trying to do,
and you already have device /dev/ttyUSB0 installed,
then you should be able to unlink the symlink /dev/serial1
(which is normally linked to /dev/ttyAMA0)
and link it to /dev/ttyUSB0 instead.
Then use the Flowcode UART component set to Channel 2,
which uses /dev/serial1
If I correctly understand what you are trying to do,
and you already have device /dev/ttyUSB0 installed,
then you should be able to unlink the symlink /dev/serial1
(which is normally linked to /dev/ttyAMA0)
and link it to /dev/ttyUSB0 instead.
Code: Select all
unlink /dev/serial1
ln -s /dev/ttyUSB0 /dev/serial1
which uses /dev/serial1
Re: USB serial on Raspberry Pi
Hi LeighM,
I am assuming I need to add that code somewhere in the config.txt file.
Which component do I need to use as when I look at UART (RS232) there is only software or channel 1, I wonder if it is because I have not got the licence yet? I am going to try on another PC as I did have a load of grief with ESP32 on windows7.
Are you limited to only the one USB/TTL serial device then? I had planned to use at least 2 but I can probably get away with using pins.
Bob
I am assuming I need to add that code somewhere in the config.txt file.
Which component do I need to use as when I look at UART (RS232) there is only software or channel 1, I wonder if it is because I have not got the licence yet? I am going to try on another PC as I did have a load of grief with ESP32 on windows7.
Are you limited to only the one USB/TTL serial device then? I had planned to use at least 2 but I can probably get away with using pins.
Bob
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: USB serial on Raspberry Pi
Hi,
Sorry, yes, it could be Channel 1, /dev/serial0
There are some differences between versions.
Ben,
Maybe the CAL UART Init could be extended with more channels, /dev/serial2 etc.,
then users can symlink to any installed serial devices.
Probably just need to repeat the same tx rx pins in the FCD, as these aren't used by the CAL anyway.
Although references to pins in the component could be confusing, what happens if they are not specified in the FCD?
Just a thought.
Sorry, yes, it could be Channel 1, /dev/serial0
There are some differences between versions.
Ben,
Maybe the CAL UART Init could be extended with more channels, /dev/serial2 etc.,
then users can symlink to any installed serial devices.
Probably just need to repeat the same tx rx pins in the FCD, as these aren't used by the CAL anyway.
Although references to pins in the component could be confusing, what happens if they are not specified in the FCD?
Just a thought.
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: USB serial on Raspberry Pi
Thanks Leigh some good suggestions there.
I'll add some more UART channels to the FCD and see if I can add a special case to the UART component so it can still work if pins are not provided.
I'll add some more UART channels to the FCD and see if I can add a special case to the UART component so it can still work if pins are not provided.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: USB serial on Raspberry Pi
I've made a change if you want to have a look and see what you think.
Now added 5 hardware UART channels to all RPI defintions which should list their /dev/serial0 - /dev/serial4 as part of the channel name.
I'm guessing that "Channel 1 - /dev/serial0" does still have the hardware UART pins so I've left those defined but the others are all software defined and so should hide the pin properties.
Now added 5 hardware UART channels to all RPI defintions which should list their /dev/serial0 - /dev/serial4 as part of the channel name.
I'm guessing that "Channel 1 - /dev/serial0" does still have the hardware UART pins so I've left those defined but the others are all software defined and so should hide the pin properties.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Valued Contributor
- Posts: 447
- Joined: Mon Dec 07, 2020 1:00 pm
- Has thanked: 81 times
- Been thanked: 243 times
Re: USB serial on Raspberry Pi
Thanks Ben.
A lot of edits eh, just a few missed
see attached
A lot of edits eh, just a few missed

- Attachments
-
- RPI_CAL_UART.c
- (15.52 KiB) Downloaded 577 times
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: USB serial on Raspberry Pi
Excellent thanks Leigh that's now been applied here, not sure how I missed those ones 

Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel