Pi ZERO running emoncms

(John Banks) #1

I’ve got a Pi ZERO successfully running emoncms.
Different to other forum posts, I did not need to first create the SDHC on a ‘non ZERO’ Pi. I just connected a non-powered USB hub to the Pi ZERO and then to that I connected a USB WiFi adapter and a USB2.0 to Ethernet adapter.

And it was NOT necessary to do an apt-get install & upgrade.

Once an emoncms account has been setup and a wifi connection established, the USB2.0 to Ethernet adapter is not needed & can be removed.

All seems to run OK except that LogIn > Setup > Administration under Server Information the Pi line is missing and more importantly so are the Reboot & Shutdown buttons.

The fix I used is to:

sudo nano /var/www/emoncms/Modules/admin/admin_main_view.php

Then scroll down to the //Raspberry Pi section and make changes to the first line:
Change b8:27:eb to ::** then write out, save & exit.

All Pi’s have a MAC address that starts b8:27:eb except the Pi Zero which has no eth0 device. And when a USB2.0 to Ethernet adapter is connected, emoncms sees the MAC address of that device.

Would welcome any suggestions for simple tests that could be run on a Pi ZERO and on a Pi3 for comparison that simulate the workload that emoncms imposes – not very demanding, I imagine.


(Craig Fryer) #2

I am surprised this is the only post I can find regarding running Emoncms on a RPi Zero.

I was thinking of trying it for a very low load situation for logging two or three sensor results every minute or even every five minutes.

In theory this task could be done on a ESP8266, but I had no luck getting the code working.


(John Banks) #3

Hi …

Two years ago I was starting to develop a monitoring system for a large PV installation – inverter 100 metres from the grid supply meter.

Tried ESP and struggled – finally settled on site wide wi-fi.

The Pi Zero was new/exciting so I tried it and managed to get an emon instance running – but then I could not replicate it.

There are few references to Pi Zero on the OEM Forum – may be indicative?


(Simon) #4

I’ve had emoncms running on a pi zero for a long time. Set up the lite version of raspbian installed emoncms according to the instructions. I have a disk attached. Also has an mqtt server and and nodered running.

Emoncms is connected to an emonTX and also via WiFi to an esp8266 system.


1 Like

(John Banks) #5

That’s good to hear - should be encouraging to others.
My different experience may be due to the fact I was trying to do it with the then current emonSD image and my then beginner skill level.


(Craig Fryer) #6

Thanks for the feedback. It also sounds like you have a fair bit running on it.


(Paul) #7

Me too! I have had emoncms running on a Pi Zero (not recently though) as I thought a Pi zero + emonTx would make a great alternative to the emonpi, much cheaper and twice as many CT’s. (see 4 CT emonBase using emonTx and Pi Zero W) I do not recall any issues, but that was a self-built image not the emonSD image.

There have been at least a couple of instances where I have assisted users to get wifi working on a Pi zero W when using the emonSD, this is/was a bit of a pain for Pi Zero users as the usual Raspbian method of adding a wpa_supplicant.conf file to the boot partition before fitting SDcard to the Zero was not possible with the emonSD since it was a read-only OS. So I know others have used emonSD on a Zero, but maybe the difficulties getting a network connection setup (with no Ethernet port) was just too tricky for some?

A search for “Pi Zero W” gets quite a few hits

There is a current discussion about some issues with a self-built image currently, which happens to be on a Pi Zero, but I don’t think that is the reason for the issues directly. (see Strange issues on own built emoncms running on raspberry pi zero w)

I see no reason for it not to work fine, but the lack of Zero users (or feedback from them) means there may well be unresolved issues, if you try it, please report back either way. It would be good to hear if all goes well, but also if it doesn’t go so well we can help resolve the issues and perhaps improve things for the Zero users.


(Simon) #8

There’s not actually a large load in terms of processing even though all these things are installed and running. EmonCMS does something only when it gets a data package to deal with. MQTT equally isn’t doing much unless there’s something to process and it’s pretty lightweight. In my case Nodered isn’t doing all that much - I just use it to get the weather info from wunderground.

I have other Pi’s around the house doing things like running a multi-room music server etc. At the price point of a Pi Zero (even with a hard drive) you wouldn’t think about integrating everything on one system.

I’d say that anyone thinking of setting up emonCMS on a Pi would be better served by following all the installation instructions rather than using the SD image. You’ll have more control and if like me you’re a PC or Mac person then you’ll learn loads.

But that notwithstanding, the Pi Zero is absolutely fine as a stand alone emonCMS device.



(Brian Orpin) #9

I use DietPi as a base OS as it’s base load is far below Raspbian Lite. I also like the interface for setting up WiFi, hostname etc. I also use Lighttpd as, again, it is less load heavy than Apache.

This is where some of the other work is heading - a more generic install script which would help here.


(Simon) #10

Here’s a netdata screen grab on the lite version of raspbian - it’s really not using a lot of the resources. So if you want to go bog standard Pi then you should be fine.

1 Like

(Brian Orpin) #11

That’s an interesting tool - not come across that although I find it is installable by DietPi’s software install system. Did that but needed to bind it to the fixed IP but WOW that is really interesting!

I can even pull it into Home Assistant :smile:


(Simon) #12

I guess that’s the difference with using vanilla raspbian for the pi. It installs without any hassle.

My only problem is remembering the port address when I want to take a look at what’s going on!!

Great utility though, think I first came across it through Peter Scargill’s blog.


1 Like

(Paul) #13

That netdata looks pretty impressive!

I’m gonna drop a couple of links here to come back too

I can think of a million uses for it, but the first thing that springs to mind for this project is Disk writes and the discussions around RO FS’s and the log file management.

I’d really like to find some time to look closer at it.

1 Like

(Craig Fryer) #14

After hitting some problems with Apache when doing an install with Raspbian Lite and then getting no where with the standard emonSD, I appear to have succeeded with Brian’s guide.

I had never used Dietpi before and became a little confused with some of the difference in usernames and passwords used between Dietpi and standard installation process. Once I have done some more testing, I will let you know how it is going.

I was using USB-Ethernet as the access method for all of these installs.

1 Like

(Brian Orpin) #15

Yes I wondered about disk writes to SD Card. Only installed it on my VMs ATM.

For static IP machines I found I had to edit the config.


(Brian Orpin) #16

Be interested to know what you had an issue with. I need to revisit the guide as the base OS has changed since I did that and check it is still OK. They have added in something around the base passwords (to avoid default passwords).

I have now also put SSL onto my main setup and that works flawlessly.


(Simon) #17

And this was one of the reasons for basing the SD image on Raspbian Lite a few years back. The Pi community has millions of users and a very active forum where many issues are ironed out. And Raspbian Lite is more than lite enough for emonCMS etc.

DietPi has a much smaller community and when the last decision was made appeared to be run by just one person - so it’s much liter (but you don’t need that) but you may or may not be able to get any support with issues.



(Brian Orpin) #18

Not sure what you are getting at here Simon.

For me it is the right tool for the job. I run Emoncms on a DietPi VM (can’t really do that with Raspbian) so it works for me and may well work for others - I’m not advocating wholesale move, but it is an extremely stable, viable alternative to Raspbian that actually uses the same repo base (just does not include some unnecessary elements). In addition, it has some extremely handy tools for things like setting a static IP, disabling console, enabling Bluetooth etc.

It is lighter (so less power, writes etc), it has a builtin RamLog system (so none of the issues seen eleswhere with full logs) and there is tons of support from the 2 main developers (note the rapid updates in versions). I pointed out recently that one of their recent improvements had removed the end of boot banner with the IP address in it (so, so useful). Came back within 12 hours acknowledging the issue and stating it will return in next version. You do not see that sort of response with Raspbian.

Remember as well, it is not a new OS, it is simply a packaged version of Debian (which is all Raspbian is). It is often actually better as it will pick up more recent versions of some packages where the Debian/Raspbian repos are lagging.



(Bill Thomson) #19

One quick and easy way to look at wrtes to disk is:

cat /proc/diskstats

which can be filtered through grep to eliminate any irrelevant data.

e.g. cat /proc/diskstats | grep /dev/mmcblk0p2

Output looks similar to this:

 8 0 sda 17721 4972 1080556 344316 3734 4908 170192 135240 0 90668 479588
 8 1 sda1 52 0 4176 1256 0 0 0 0 0 1244 1256
 8 2 sda2 51 0 4238 1584 0 0 0 0 0 1272 1584
 8 3 sda3 2 0 4 92 0 0 0 0 0 92 92
 8 5 sda5 55 0 4496 1148 0 0 0 0 0 1144 1148
 8 6 sda6 17449 4972 1060282 338496 3730 4908 170192 135176 0 90020 473700
 8 7 sda7 46 0 4128 1084 0 0 0 0 0 1072 1084
11 0 sr0 0 0 0 0 0 0 0 0 0 0 0

Here’s what the fields represent:

1 - major number
2 - minor mumber
3 - device name
4 - reads completed successfully
5 - reads merged
6 - sectors read
7 - time spent reading (ms)
8 - writes completed
9 - writes merged
10 - sectors written
11 - time spent writing (ms)
12 - I/Os currently in progress
13 - time spent doing I/Os (ms)
14 - weighted time spent doing I/Os (ms)

Kernel 4.18+ appends four more fields for discard
tracking putting the total at 18:

15 - discards completed successfully
16 - discards merged
17 - sectors discarded
18 - time spent discarding
1 Like

(Paul) #20

Another is to use

sudo cat /sys/block/mmcblk0/stat

so that no further filtering is required.

Fields are similar I think, doc’d at

These commands are all well and good, but you need to be sure of what you’re reading and they are only instantaneous unless you set up a script to poll regularly and record over a period or set an interval so the data output is updated.

A nice easily scrolled/zoomed graph that is sync’d to other results like RAM and CPU usage etc makes things much better.

It was avoiding these command lines that made this utility so appealing to me.

1 Like