PlatformIO on emonpi can't access tty port

I’m modifying the firmware to return real and apparent power from both CTs in order to use these to calculate the power factor in a Virtual Feed in emoncms. I’ve bought 4 emonpi units and am doing this with all of them.

I have completed this on one emonpi unit - happy days!

On the second unit however, the firmware builds but PlatformIO fails to upload. Upon trying to connect to /dev/ttyAMA0 it fails with message: “*** [upload] Device or resource busy”

Any ideas? Do I need to open the unit and start checking connections?



Nice work.Have you stopped emonhub?

sudo service emonhub stop

Also I think platformio will require sudo

Good thought.

The page I followed last time had both of those in it. Part 1/3: PlatformIO open-source embedded development ecosystem - Blog | OpenEnergyMonitor

Today I was using Firmware Modification - Guide | OpenEnergyMonitor which doesn’t mention either.

However, even stopping emoncms and using sudo to run pio … I’m getting the same error.

I’m going to work on the next one and see if it behaves differently.

Never mind! It helps if you stop the right service.

I stopped emoncms … now having had lunch I paid attention and stopped emonhub.

Thanks Glyn.

Excellent. Ah yes, it’s emonhub you need to stop. Emonhub is a python service which reads the serial data from the emonPi on /dev/ttyAMA0 and posts to Emoncms / MQTT.

The section 3b “Using ttyAMA0 GPIO to upload direct to emonPi” at the end of the Platformio blog post mentiones that stopping emohub is required.