The latest emonSD for emonPi / emonBase seemed to work out of the box with the RasPi3, however it became apparent that something rather important was missing...serial comms with the emonPi's ATmega328!
The emonPi communicates with the RasPi via GPIO 14/15 which on the Model B,B+ and Pi2 is mapped to UART0. However on the Pi3 these pins are mapped to UART1 since UART0 is now used for the Bluetooth module. However UART1 is software UART and baud rate is dependent to clock speed which can change with the CPU load, under voltage and temperature; therefore not stable enough. One hack is to force the CPU to a lower speed ( add core_freq=250 to /boot/cmdline.txt)which cripples the Pi3 performance.
A better solution for the emonPi is to disable BT and map UART1 back to UART0 (ttyAMA0) so we can talk to the emonPi in the same way as before.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
To disable onboard Pi3 Bluetooth and restore UART0/ttyAMA0 over GPIOs 14 & 15 modify:
sudo nano /boot/config.txt
Add to the end of the file
We also need to run to stop BT modem trying to use UART
sudo systemctl disable hciuart
See RasPi device tree commit for pi3-disable-bt and raspi forum thread discussion.
Reboot and test serial coms with:
sudo minicom -D /dev/ttyAMA0 -b38400
Although it may be useful to have the bluetooth enabled - could be used to connect to some solar inverters directly.
Perhaps its time the emonPI moves to a USB interface? Or look to wire in the RFM module directly to the PI SPI interface (this has already been done)
I know it's a shame to disable, but Bluetooth usb adapters cost between £3-£5. It's more important the core functionality of the emonPi works well. The inclusion of onboard Wifi on the Pi3 is a big plus. That will save the user £9. Therefore, even if they have to buy a BT adapter, they will still be saving money, and have 50% more processing power. :-)
Although currently neither BT or Wifi on Pi3 work in the emonPi case, we are looking at getting some acrylic end plate options made.
It seems there is a way of having the bluetooth enabled with the software UART and a lower speed rate. Look towards the bottom of this thread
I've not tested it yet
Great! Using pi3-miniuart-bt might do the trick.
However there is a note regarding reduced baudrate on ttyAMA0.....
From the forum:
"I've pushed the overlay (pi3-miniuart-bt) to the source trees. It will appear in the next release, or you can download prebuilt one here. The commit message says:
Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore
UART0/ttyAMA0 over GPIOs 14 & 15. Note that this may reduce the maximum
It is also necessary to edit /lib/systemd/system/hciuart.server and
replace ttyAMA0 with ttyS0.
If cmdline.txt uses the alias serial0 to refer to the user- accessable port
then the firmware will replace with the appropriate port whether or not
this overlay is used."
Thank you for your instructions to get the ttyAMA0 back on the header of RP3 according RP2.
It works fine on the normal baud rates. But on the RPi2, I could change the uart-clock rate in order to get the midi baudrate (31250 baud) . The trick was to add the following to config.txt: init_uart_clock=2441406 and init_uart_baud=38400. And, at the end of the line in cmdline.txt: bcm2708.uart_clock=3000000. After rebooting, I could send and receive midi data at the 38400 baud rate, because it was in fact, 31250 baud.
If i do this same trick with RP3 per your instructions above, the baud rate does not change. Though after a vcgencmd measure_clock uart command, it reports 2441604.
Do you have any clue how to get the trick done on the RP3?
Duplicate post deleted
Please don't make duplicate posts - Moderator, BT
Sorry, I have no experience in changing baud rates for MIDI. I recommend posting on the RasPi forums
Tweets by @Openenergymon
Open-source tools for energy monitoring and analysis. This project uses the GNU General Public Licence