EmonPI/EmonCMS and Arduino IDE

Hi,

Back again after a couple of weeks… I’ve got a bit of a peculiar setup with 2 Raspberry PIs and an Arduino Duo.

  • PI (One) is essentially my emonPI - it is coupled up to an Arduino Uno running emonLibCM (Thanks for the “Heads Up” @Robert.Wall) by USB cable. The Arduino is fed by a CT sensor, AC current sensing, pulse counting and temperature. I have Arduino IDE installed on this PI so I can remote access via VNC Viewer to allow “tinkering”.
  • PI (Two) is my EmonCMS (built from the emonPI SD card image)

I’m considering merging the PI hardware, running a single PI with the emonPI/CMS SD image. The Arduino would be linked with the single PI by USB cable to provide both power and the serial link.

My only concern is that I’ll still want to tinker. I don’t think I’ll be able to install VNC Viewer and Arduino IDE on the PI as well, or is there a solution to do so?

In order to tinker, I’d then need to take laptop into the garage and directly couple up with the USB link. I’d prefer not to but there is a balance to be had with how often I’d be tinkering.

BTW, I’ve got ESP8266 cards due to arrive in the week - another potential upgrade to my project…

Thanks in Advance

The “emonPI SD Card” is built from the “Lite” Raspberry Pi OS image, but it is still based on Raspberry Pi OS, so anything you have on another RPi running that OS can also be installed onto the emonSD, you’d need to download and install any other required components. (See https://www.raspberrypi.org/software/operating-systems/ for differences between “Lite” and other options)

It might be easier to simply install the emonCMS stack on your Pi (one) since that already has the other components you require and their dependencies?
You have seen the instructions on building the emonSD yourself I presume?

See Option 2 from there, which will take you to GitHub - openenergymonitor/EmonScripts: Emoncms Stack Installation and Update scripts

You can then use the backup module to backup the emonCMS data in your Pi (two) and restore it onto your Pi (one) after you’ve installed emonCMS onto it if you wanted to keep what you’ve got so far.

2 Likes

That sounds very promising Greebo. I’d followed Option 3 first time around on Pi (Two) so will take a look at Option 2.

Not too fussed about losing data at this stage as I’m still finding my feet but if it’s easy enough to do, I might as well.

Thanks

Tried this but it didn’t go too well, not sure what I did wrong. I guess I should’ve stopped and asked more advice before I ended up having a PI I could no longer SSH on to, or VNC view. The first bit about creating a raspian lite image seemed superfluous as I was starting with a PI with Raspian, Arduino IDE and VNC viewer already installed but then I wasn’t sure about partition sizing and that was probably where my existing install screwed up.

Since tried doing a fresh PI (Full) OS build with Option 2. I know it says Lite OS but I wanted desktop, Arduino and VNC Viewer and wasn’t sure what other dependencies would be required. Suffice to say, that failed as the partition ran out of space whilst I sudo apt-get update at the beginning.

So I’m at a crossroad now -
either build emonSD image and install (and then possibly try and put the VNC viewer / Arduino IDE software on there - not sure if this is possible if there is no desktop option)
or follow option 2 from step 1 and possibly install VNC viewer / Arduino IDE / desktop.

Quite an unproductive and frustrating day but hey ho… Answers on a postcard…

If you take us through exactly what you did step by step, the collective experience on here may be able to see where it went wrong and what to do differently next time.

It is definitely achievable to have all you’ve described on a single Pi.

Much appreciated Greebo. I think the mistake I made was performing the sudo apt-get update / sudo apt-get upgrade too early (before the partitions resizing were completed - I hadn’t performed step 9, reinstating the old cmdlime.txt etc…). I have since restarted using the lite OS image and managed to perform the updates once I’d completed step 12. For the sake of another hour, I’m going to re-build a full Raspian image and proceed through to step 12.

What would be the best point to install Arduino IDE, VNC Viewer etc…

Thanks

Yes on first boot, go and get a hot drink and drink it, then come back. We have seen instances where the initial apt calls do fail.

There is limited space on root - the SD card is designed and optimised to just run emoncms. Adding other things can cause issues. There is no GUI installed (it is based on Lite) so VNC viewer is not required I’d suggest.

1 Like

Totally appreciate that @borpin - wanted the viewer and Arduino IDE so that I can remote onto the emonPI to tinker with the Arduino sketch.

There’s really two* (main) options here:

  1. Use a standard Raspberry Pi full desktop Image from the Raspberry Pi foundation, and then install emonCMS on top of that using the instructions I posted previously, OR
  2. Use the emonSD image, and then install the relevant extra components you require on top, such as the desktop components, VNC, Arduino etc.

Using Option 2 has the benefit of the “low write” configuration designed to reduce write load on the SD card, prolonging its life considerably, but it has the disadvantage that the partition sizes are set up for a particular use case (as @borpin pointed out).

Using Option 1 has the benefit of starting with a full desktop RPi, but you miss out on the “default setup” to give you all of the low-write benefits of the emonSD. That isn’t to say you can’t achieve the same configuration of course, it just means you may have to do some tinkering, or you just live with the fact that after about a year or so, your SD card will stop being able to write and you’ll need to start again with another card.
Experiences here have varied, I’ve had my cards “wear out” a few times now (I have a number of Pi’s) and each time, the card has gone read-only and I’ve been able to simply take an image of the card and write it to a new card, plug the new card back into the Pi and it carried on like nothing had happened. Others have had the file system corrupted and lost everything. YMMV!

* there’s many more than two options of course, but those are the most straight forward!

2 Likes

Thanks @Greebo … I got there eventually…

Partly bad timing for me… Would you believe that I sent my laptop off for repair Saturday morning. I’ve got another one (this one) but guess what it doesn’t have… a SD card slot which I’d taken for granted on my other one. Its slowed me down a little but I’ve got an ancient laptop that does have a card reader.

I have news… In the last 24h, I’ve pursued the second of your options above and got the PI working, fully updated, running emonCMS, VNC Viewer and Arduino IDE. In my haste, I managed to download the full Raspian image with desktop and all the “useful” software and despite this, I still managed to get emonCMS to install and work. Admittedly, emonHub described itself as fatally wounded but I wasn’t too happy with all the useful software being on the PI and potentially slowing it down.

I’ve since rebuilt the PI using your second option with Raspian (with desktop). It seems to run perfectly fine and emonCMS and all its components seem to be happy.

Noted re: the SD card life. I am tempted to utilise an external drive eventually so I’ll accept that I’ll probably kill a couple of SD cards in the meantime.

All I’ve got to do now is get the Arduino to talk to emonCMS. I managed to get this working on the old 2 PI setup using the http interfacer to getting it to communicate with essentially itself should be easier (naive) or I could venture and use the ESP8266 cards that have arrived today - that seems a bit OTT given that the Arduino and PI are connected by USB, separated by 50mm.

You can use exactly the same method you used previously, or any number of other options with increasing complexity :slight_smile:

Seriously though, you do not need any other components or devices to get the data out of the Arduino and into EmonCMS, assuming you still have them connected via serial (USB) cable, so if you get stuck, ask away.

1 Like

Got the new emonPi working nicely with the Arduino.

One last question (for now)… I’ve still got the water meters MQTT’ing from another PI to the old emonCMS PI. I’m not too bothered by the historical elec data on it (because its only a few weeks, and using the emonLib whereas I’m now using emonLibCM) but interested in possibly porting my water meter data across.

The backup and archive functions refer to all econCMS account data being overwritten. Should I have backed up / imported the old emonCMS first before I set up the new one, or can I somehow just extract the data and import the data across but not impact any existing settings on the new one? Its not a major issue - it won’t take me too long to adjust the MQTT settings to direct it to the new econCMS, setup up the new feeds etc.

Point the old system to the MQTT broker on the EmonPi.

Use the sync facility to create the Feed on the New EmonPi. Then setup the Input processing to feed the new Feed.

1 Like