You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expands discussion on hardware serial and Bluetooth devices. Follows
on from #690 and includes more information about how to enable the
devices under Bookworm.
Research triggered by comments appended to #761.
Signed-off-by: Phill Kelley <[email protected]>
@@ -278,7 +278,7 @@ The third method is *portable*, meaning a flow can conceptually refer to "this"
278
278
279
279
``` yaml
280
280
extra_hosts:
281
-
- "host.docker.internal:host-gateway"
281
+
- "host.docker.internal:host-gateway"
282
282
```
283
283
284
284
If you use this method, your flows can refer to "this" host using the domain name "host.docker.internal".
@@ -436,7 +436,9 @@ To communicate with your Raspberry Pi's GPIO you need to do the following:
436
436
437
437
Don't try to use 127.0.0.1 because that is the loopback address of the Node-RED container.
438
438
439
-
## Serial Port Access { #accessSerial }
439
+
## Serial Devices { #accessSerial }
440
+
441
+
### USB devices { #usbSerial }
440
442
441
443
Node-RED running in a container *can* communicate with serial devices attached to your Raspberry Pi's USB ports. However, it does not work "out of the box". You need to set it up.
442
444
@@ -452,7 +454,6 @@ You have three basic options:
452
454
453
455
``` yaml
454
456
devices:
455
-
- …
456
457
- "/dev/ttyUSB0:/dev/ttyUSB0"
457
458
```
458
459
@@ -477,8 +478,7 @@ You have three basic options:
477
478
478
479
``` yaml
479
480
volumes:
480
-
- …
481
-
- /dev:/dev:ro
481
+
- /dev:/dev:ro
482
482
```
483
483
484
484
> The "read-only" flag (`:ro`) prevents the container from doing dangerous things like destroying your Raspberry Pi's SD or SSD. Please don't omit that flag!
@@ -496,8 +496,8 @@ You have three basic options:
496
496
497
497
``` yaml
498
498
device_cgroup_rules:
499
-
- 'c 1:* rw' # access to devices like /dev/null
500
-
- 'c 188:* rmw' # change numbers to your device
499
+
- 'c 1:* rw' # access to devices like /dev/null
500
+
- 'c 188:* rmw' # change numbers to your device
501
501
```
502
502
503
503
In the above:
@@ -525,6 +525,102 @@ At the time of writing (Feb 2023), it was not possible to add `node-red-node-ser
525
525
RUN npm install node-red-node-serialport --build-from-source
526
526
```
527
527
528
+
### hardware serial port { #piSerial }
529
+
530
+
Historically, `/dev/ttyAMA0` referred to the Raspberry Pi's serial port. The situation became less straightforward once Pis gained Bluetooth capabilities:
531
+
532
+
* On Pis *without* Bluetooth hardware:
533
+
534
+
- `/dev/ttyAMA0` means the serial port; and
535
+
- `/dev/serial0` is a symlink to `/dev/ttyAMA0`
536
+
537
+
* On Pis *with* Bluetooth capabilities:
538
+
539
+
- `/dev/ttyS0` means the serial port; and
540
+
- `/dev/serial0` is a symlink to `/dev/ttyS0`
541
+
542
+
In addition, whether `/dev/ttyS0` (and, therefore, `/dev/serial0`) are present at runtime depends on adding the following line to `config.txt`:
543
+
544
+
```
545
+
enable_uart=1
546
+
```
547
+
548
+
And, if that isn't sufficiently confusing, the location of `config.txt` depends on the OS version:
549
+
550
+
* Bullseye (and earlier): `/boot/config.txt`
551
+
* Bookworm: `/boot/firmware/config.txt`
552
+
553
+
Rolling all that together, if you want access to the hardware serial port from Node-RED, you need to:
554
+
555
+
1. Add `enable_uart=1` to `config.txt`.
556
+
2. Reboot.
557
+
3. Add a device-mapping to Node-RED's service definition:
558
+
559
+
``` yaml
560
+
devices:
561
+
- /dev/serial0:/dev/«internalDevice»
562
+
```
563
+
564
+
where `«internalDevice»` is whatever device the add-on node you're using is expecting, such as `ttyAMA0`.
565
+
566
+
4. Recreate the Node-RED container by running:
567
+
568
+
``` console
569
+
$ cd ~/IOTstack
570
+
$ docker-compose up -d nodered
571
+
```
572
+
573
+
### Bluetooth device { #bluetoothSupport }
574
+
575
+
If you enable the `node-red-contrib-generic-ble` add on node, you will also need to make the following changes:
576
+
577
+
1. If you are running Bookworm, you will need to use `sudo` to edit this file:
578
+
579
+
```
580
+
/boot/firmware/config.txt
581
+
```
582
+
583
+
You need to add this line to the end of the file:
584
+
585
+
```
586
+
dtparam=krnbt=off
587
+
```
588
+
589
+
You then need to reboot. This adds the Bluetooth device to `/dev`.
590
+
591
+
2. Find the the Node-RED service definition in your `docker-compose.yml`:
592
+
593
+
* Add the following mapping to the `volumes:` clause:
* These changes are *specific* to the Raspberry Pi. If you need Bluetooth support on non-Pi hardware, you will need to figure out the details for your chosen platform.
618
+
* Historically, `/dev/ttyAMA0` meant the serial interface. Subsequently, it came to mean the Bluetooth interface but only where Bluetooth hardware was present, otherwise it still meant the serial interface.
619
+
620
+
On Bookworm and later, if it is present, `/dev/ttyAMA1` means the Bluetooth Interface.
621
+
622
+
On Bullseye and later, `/dev/serial1` is a symbolic link pointing to whichever of `/dev/ttyAMA0` or `/dev/ttyAMA1` means the Bluetooth interface. This means that `/dev/serial1` is the most reliable way of referring to the Bluetooth Interface. That's why it appears in the `devices:` clause above.
623
+
528
624
## Sharing files between Node-RED and the Raspberry Pi { #fileSharing }
529
625
530
626
Containers run in a sandboxed environment. A process running inside a container can't see the Raspberry Pi's file system. Neither can a process running outside a container access files inside the container.
@@ -1457,27 +1553,3 @@ All remaining lines of your original *Dockerfile* should be left as-is.
1457
1553
### Applying the new syntax { #july2022build }
1458
1554
1459
1555
Run the [re-building the local Node-RED image](#rebuildNodeRed) commands.
1460
-
1461
-
## Bluetooth support { #bluetoothSupport }
1462
-
1463
-
If you enable the `node-red-contrib-generic-ble` add on node, you will also need to make the following changes to the Node-RED service definition in your `docker-compose.yml`:
1464
-
1465
-
* Add the following mapping to the `volumes:` clause:
* These changes are *specific* to the Raspberry Pi. If you need Bluetooth support on non-Pi hardware, you will need to figure out the details for your chosen platform.
1483
-
* Historically, `/dev/ttyAMA0` meant "the serial interface" on Raspberry Pis. Subsequently, it came to mean "the Bluetooth interface" where Bluetooth support was present. Now, `/dev/serial1` is used to mean "the Bluetooth interface".
0 commit comments