Can someone run this command on a emonSD that has not had it’s serial ports altered? I don’t have anything running emonSD currently.
ls -la /dev/{tty{ACM,AMA,S,USB},serial}* 2>/dev/null
the result from a newly downloaded raspiOS installed to a Pi4 is
lrwxrwxrwx 1 root root 5 Jan 4 21:17 /dev/serial0 -> ttyS0
lrwxrwxrwx 1 root root 7 Jan 4 21:17 /dev/serial1 -> ttyAMA0
crw-rw---- 1 root dialout 204, 64 Jan 4 21:17 /dev/ttyAMA0
crw-rw---- 1 root dialout 4, 64 Jan 4 21:17 /dev/ttyS0
As you can see there are 4 lines, the first 2 lines are hyperlinks created by the OS at boot up and the second 2 lines are the 2 serial ports accessible on all Bluetooth&Wifi enabled Pi’s (3, 4 and ZeroW).
Only one port “/dev/ttyAMA0” is available on other Pi’s (A, B, 2 and Zero) so on those models there would only be 2 lines returned from the command above, one hyperlink and one actual serial port.
“/dev/ttyAMA0” is the MCU’s higher quality serial port made available (accessible) on all Pi’s
“/dev/tty S0” is the MCU’s lower quality serial port made available (accessible) on Pi’s with onboard bluetooth due to that onboard bluetooth using the higher quality “/dev/ttyAMA0” serial port on those devices by default.
“/dev/serial0” is always the physical GPIO port on all Pi’s and
“/dev/serial1” is only available on the BT Pi’s as it is always the onboard Bluetooth transceiver.
By default non-BT enabled Pi’s have the high quality “/dev/ttyAMA0” serial port mapped to the physical GPIO UART “/dev/serial0” and that is it, no options or variations etc.
Whereas by default, BT enabled Pi’s have that higher quality serial port “/dev/ttyAMA0” mapped to the BT transceiver “/dev/serial1” to provide good BT performance whilst the lower quality “/dev/ttyS0” port mapped to the physical GPIO UART “/dev/serial0”.
The BT enabled Pi’s with 2 accessible serial ports can have those ports mapped to various configurations at boot time by using overlays in the config.txt, those overlays are used at boot to map the serial ports, which creates those hyperlinks mentioned above and shown in the command output.
lrwxrwxrwx 1 root root 5 Jan 4 21:17 /dev/serial0 -> ttyS0
shows us that “ttyS0” is linked to the GPIO “/dev/serial0” and
lrwxrwxrwx 1 root root 7 Jan 4 21:17 /dev/serial1 -> ttyAMA0
shows us that “ttyAMA0” is linked to the BT “/dev/serial1”.
This leads to a common misconception that “ttyAMA0” and “/dev/serial1” are the same thing, that they address the same port, they do in this configuration, because they are linked together, but under other configurations they will not address the same port. The “ttyAMA0” addresses the higher quality serial port (in the MCU) and “/dev/serial1” addresses the BT, the same thing when they are connected (mapped) together.
I do not know what the current status is on the emonSD but it used to map the higher quality port to the GPIO for the emonPi/RFM2Pi boards as BT isn’t often used. Rather than swap the ports, they just dropped BT and mapped the GPIO to the better port, so for BT to work you would need to first map that connection by using a different overlay.
If the original mapping is/was left alone configured by default, both the GPIO UART and BT would function just fine **, I had thought (hoped?) this had been sorted in the latest images. Alternatively I think someone documented how to get BT working on a emonSD and put it in the emonhub repo (IIRC) but this was some time ago and may not still be relevant to the current images.
(** when I say “BT would function just fine” I mean with some small edits. We should not be addressing the GPIO UART via “ttyAMA0” as that is not always correct, we should be using “/dev/serial0” as that is always correct, hence why it is now used in cmdline.txt and not “ttyAMA0” as was true in Pi’s pre-BT days)
With the output from the above command we can see how the emonSD is currently mapped and determine what is needed, and @dlongson, if you can also post the output from your setup we can see if you’ve upset anything along the way and get your BT running (fingers crossed )
Sorry for the long post, but having explained this before here on the forum, apparently not very well, I thought I would try another way. Sorry if it’s excessively dumbed down or assumes too much.
[edit] I can’t find the info on using BT in the emonhub repo, must be elsewhere, I will post a link if I find it.