Really basic set up for emonCMS and Raspberry Pi?

Are you telling the truth there, or has a naming confusion crept in already? - I mean, what else do you have, because just a Raspberry Pi and emonCMS is not enough - you need something to measure the power/energy in the first place.

Is this thread relevant Emon system tips for absolute beginners? or is that a different system?

Is there any reason to suspect it does not have the operating system as well? If you bought the SD card from the OEM shop, it will be the OS plus emonCMS.

Other than the Guide, no. If you do look at the guide, you have effectively got an emonBase, but (as you didn’t mention anything other than a RPi) without the radio module, so you won’t get data from an emonTx or emonTH via that route.

Fire up a web browser and look at your router to see which devices are connected to your LAN.
Put the SD Card into the card slot in the RPi, connect the power and wait for it to start up.
Check your router again. You should see a new device - your RPi. Look at the “Dotted IP Address” that the router has given it (something like 192.168.1.74) and go to that address with your browser. You should see either the emonCMS set-up page or the emonCMS login page. The first time, you will need to set up your account name for emonCMS and invent a password (these are only for emonCMS itself). Take care to record both somewhere safe, because resetting them is painful.

{I always connect first time via Ethernet direct to the router - I find that’s a lot more straightforward than via the Wi-Fi method}

DON’T pull the power on your RPi - always (whenever possible) do a graceful shut-down via the Admin menu, or you risk a corrupted SD card.

Thanks Robert,
Thanks for those first steps and yes, I do have other bits & pieces. and yes, I am following the other thread, perhaps I should have asked about this on that… sorry for confusion.

My distribution board blew up so I’m taking the opportunity to build the sub-metering system inside a new DIN rail box next to the main distribution board box.

  • I have 3 x DIN rail mounted Modbus submeters; whole-current meters not clamps/CT.
  • I have some fancy RS485 cable.
  • I have an adaptor from RS485 to USB to plug into the Raspberry pi.
  • I have a DIN-rail box to put the RPi inside.
  • I have an RPi power pack 2.5A.
  • I have an SD card from PiHut, and they say it has the OS on it, but obviously not emonCMS (I didn’t see the SD cards on the OEM shop).
  • I have downloaded emonCMS to my laptop; “emonSD-08May21 (Stable)”
  • I have a Cat5e network, but if I can’t install a new Cat5e line then I will connect via wifi.

I have found The Guide… Of the 5 elements I think my system will just have emonCMS - the other bits are different from what’s in the guide.

It seems that I should do the setup in 2 steps: 1) emonCMS to RPi on the desk connected by ethernet to the router, and to the laptop where I have downloaded emonCMS, with a screen and keyboard connected to the RPi before I switch it on, then install software with the RPi …

then 2) then install the RPi inside the distribution board, connect it to the meters it will read, and connect to the router by wifi.

Does that make sense to you? I’m learning all the time, I very much appreciate the good guidance online and the input from various people!

That seems a sensible way to go.

Rather than try to put emonCMS onto the SD card you bought, I suggest you flash (“Etcher” is the tool I recommend - there are others) the SD card with the downloaded image, which as I mentioned, is a complete working system. We will all know your starting point if you do that. Etcher is very straightforward - the SD card must be 16 GB¹ or bigger, and if it’s bigger, then while it’s in your laptop, use GParted to expand the data partition (it’s the one that is not boot or rootfs) as far as it will go. GParted is also fairly obvious but make absolutely certain you are looking at and working on the SD Card - or you’ll screw up you laptop, possibly fatally. The only catch with GParted is you pick what you want to do, then start it off as a separate operation.
Also, while the SD Card is in your laptop, you must enable ssh - see emonPi SSH disabled by default
or, if you want the really hard way now but a lot easier in the future, set up a pair of “key files” on your laptop & the RPi: Command Line Cheatsheet - #3 by Robert.Wall

You won’t need a screen and keyboard connected to the RPi (I’ve never done it that way. :smiley: )

I’d also modify step 2, to
Put the Wi-Fi credentials in while it’s still connected by Ethernet. Setup → WiFi. Drop the Ethernet connection and check the Wi-Fi.

Then, connect at least one of your Modbus meters on the bench and get it working with something appearing, first in emonHub and then on the Inputs page of emonCMS. (Note: you can’t create an input in emonCMS, they appear when valid data arrives.)

Only then would I think about installing it in it’s permanent home.
There’s a lot of fairly recent material about RS485 connections and whether an earth is needed

The Guide sections, that are nearest to what you need, look to be
https://guide.openenergymonitor.org/setup/connect/
and
https://guide.openenergymonitor.org/setup/local/

¹Note: If your SD card is smaller than 16 GB, it can be done (I have an 8 GB image) but it is tortuous to shrink an image, whereas it is trivial to expand a partition once it is on the SD card.

When I bought the SD card from PiHUT :
“32GB, Class 10 A1 SanDisk MicroSD card pre-installed with the NOOBS Raspberry Pi operating system (containing Raspberry Pi OS).” and “Ready to use – plug it in and you’re ready to go”

I connected the RPi by ethernet to the router, then I put in this SD card, and switched on the power. I plugged a spare screen into the RPi HDMI, and a mouse, and I saw it going through an install process, then it stopped sending a signal to the screen… Can you (or anyone) tell me if this means it’s finished, or if something has gone wrong…

next step is to install emonCMS - I’m contemplating buying a pre-loaded SD for that too…

I seem to have installed the OS now.

They would say that, wouldn’t they? But ready to go where? They probably didn’t have emonCMS in mind when that was written.

I didn’t understand your logic until the second post appeared. Now I think I do.

There is nothing permanent inside your Raspberry Pi. Think of the SD card as the equivalent of the HDD (or SSD) in your Laptop. The SD card IS the OS. Take it out of your RPi and you have nothing. It won’t boot, there’s no OS in the Pi itself. You didn’t install the OS in the Pi, you set up the OS on the SD card and commissioned it.

According to the post releasing the latest emonCMS emonSD-08May21 Beta release, it is based on Raspberry Pi OS, which is not the same as NOOBS. If you go down the route of using the install scripts to put emonCMS onto the NOOBS OS, I won’t be able to help you because I’m not a RPi expert, and I think generally the support available from us will not be as extensive as it would be if you stay with the May 21 image you’ve downloaded.

If you don’t want to overwrite NOOBS, you can always image it to your laptop and then re-use the SD card, or you can of course buy a new empty SD card and write the emonCMS image to that, or buy the pre-loaded SD card from The Shop.

Thanks, I didn’t realsie that the SD will now stay inside the RPi. I guess I have to take it out to install emonCMS as well… or maybe I can do that from the RPi via ethernet? I have the emon 08May21 release saved on my laptop but annoyingly it has no SD slot.

When I had the SD in the RPi, it came up with install options, and I selected Raspberry Pi (full) 32 bit OS. I wonder then if Noobs is just the bit of software that helps “noobs” like me to get set up?
It’s now doing a very slow “download & install updates” and it just says Raspberry Pi Operating System, nothing about noobs.
I will try to post a photo of the screen.

I wouldn’t know the answer to either of those, so I can’t help you. As I see it, you can either buy the pre-loaded SD card, or buy a card reader/writer. That might well be the better option long-term.

I really need either @TrystanLea or @borpin to help me out here.

Now that the OS is all updated, I’ve found the internet connection direct from the RPi - is there any reason I can’t download the emonCMS directly from the openenergymonitor github directly?
I checked the OS using cat /etc/os-release and it says “Raspbian GNU / Linux 10 (buster)” which I understand means Raspberry Pi OS version 10. I think “noobs” was a bit of a red herring.

That’s essentially it.
NOOBS stands for New Out Of Box Software.

Ref:

No reason. But if you do download the image and write it to the SD card you’ve written NOOBS on, everything on the card now will be overwritten by the emonSD image. As Robert mentioned a bit earlier, if you want to save the current contents of your SD card, you can save it to another device (e.g. laptop computer) as an image file before you overwrite the card with the emonSD image.

Otherwise, if you don’t mind losing what’s on the card now, simply write the emonSD image to the card.
Balena Etcher is one utility available that can do the job.

The Raspberry Pi Imager is another.

That said, the image method is the preferred way to get emonCMS up and running quickly with the fewest
number of problems.

There is another installation method, but it is quite a bit more involved.
As you are new to OEM, I’d recommend using the image.

Thank you Bill.
I don’t mind losing what’s on the SD, as long as the emonSD contains everything, including the OS… I think it does - it says it is “Based on Debian Raspberry Pi OS (32-bit) Lite, 2021-03-04”. The SD is 32GB.

  • You say I start with the SD in my laptop - as it has no SD, is there any reason I can’t do this all direct on the RPi? I found it helpful to have the screen etc plugged into the RPi so I could see what’s going on.
  • you say “first in emonHub…” I assume that will be accessible on the RPi when the emonSD has been installed.
  • The meters I bought come with two connections only for RS485/modbus, so there’s no allowance for an earth anyway.

Is the following the right procedure? I am assuming all will be done directly on the RPi (rehearsing here to follow later!):

  1. Download & install Etcher from: https://etcher.download/
  2. Download and install GParted from: GParted -- Download
  3. Download and save the image file “emonSD-08May21.img” from: Home · openenergymonitor/emonpi Wiki · GitHub (done already)
  4. Open Etcher and use it to set up the SD with emonSD
  5. Open GParted and expand the data partition (it’s the one that is not boot or rootfs ) as far as it will go
  6. Enable ssh OR set up a pair of key files following Robert’s guide.
  7. Set up wifi credentials (although I intend to connect by ethernet when installed)
  8. Connect a meter (although it won’t be measuring anything) to the RPi.
    (I assume for this test I can use any wire, I don’t have to use the fancy & fiddly RS485 cable that I have for the final installation).
  9. Open emonHub on the RPi, check you can see meter readings.
  10. Open your emonCMS online account, check you can see meter readings

Many thanks!

I found a thread saying I can install Etcher direct on the RPi, so this should all be good to go now.

A µSD card reader will solve that issue. Here’s an example:

https://www.amazon.co.uk/Beikell-High-speed-Adapter-Supports-MMC-Compatible-Windows/dp/B07L9VT8YY/ref=sr_1_3?dchild=1&keywords=usb+micro+sd+card+reader&qid=1628532637&sr=8-3

You don’t have to buy this specific reader. As long as the one you buy has a USB connector that matches the USB ports on your laptop machine, and a µSD card slot, it should work.

Indeed it does. The image is a “complete package.” i.e apps and OS all in one.

Although there is a method that enables installing emonSD directly on the Pi, it’s more involved than simply
writing the image file to a µSD card. As I mentioned earlier, the image is the recommended method.
Once you have a USB-µSD card reader, writing the image will be quick and easy.

Yes, emonHub is part of the emonSD image and will be available after the image is written to the SD card.

Yes and no.

Steps 1 through 5 are performed on your laptop computer. Step 6 is performed on both the RPi and your laptop computer. Step 8 will involve the RPi and your laptop machine, Step 9 and 10 will be performed on your laptop computer. If you won’t be using Wi-Fi at all, e.g. testing, you won’t need to do step 7.

  1. Yes. Performed on your laptop computer.

  2. This assumes a computer running Linux is available. If not, you can download and burn a copy of
    gparted live to a CD. If your laptop computer lacks a CDROM drive, gparted live can be written to, then
    booted from, a USB storage device. Get gparted live here: GParted -- Live CD/USB/PXE/HD

  3. As you mentioned, this one’s done.

  4. Yes. Performed on your laptop computer.

  5. Step 2 applies here as well. Performed on your laptop computer.

  6. You’ll generate the keys on your laptop, then copy them to your Pi.
    i.e. you enable SSH on the Pi AND set up a pair of keys.

  7. If you’re not going to use Wi-Fi, then you don’t need to set up Wi-Fi credentials.
    That assumes you’ll be using ethernet during testing as well as the final installation.

  8. Yes. You should be able to use any wire for testing your setup. Unless the distance betwenn your RPi
    and meters is short (a few metres) you’ll want to use the correct wire for your permanent installation.
    BTW, what’s the make and model of your meters?

  9. Yes. This can be done remotely via SSH as well as directly on the RPi.

  10. Yes. As the early versions of the RPi generally lack the raw “horsepower” to be usable web browsing
    platforms, most users do this step using another computer. That changed with the introduction of the RPi 4 as the “4” does have sufficient “oomph” to do the job.


Getting Modbus instruments “up and running” is not difficult, but neither is it trivial. At this point, I’d suggest
getting emonSD running first. Once you have it working properly, then tackle the Modbus part.

Another red herring.
The USB-SD card reader route is the way to go.

Brilliant, thank you VERY much, I have ordered a card reader/adapter as you suggest and will wade through those very comprehensive looking and clear instructions tomorrow.
Cheers,
Daniel

YVW,S!

What OS do you run on your laptop computer?

Robert’s instructions assume logging into the RPi from a machine running Linux.
(the link is in post 4, in this thread. Command Line Cheatsheet - #3 by Robert.Wall)

The next post in that thread has instructions applicable to a Windows box.

Thanks Bill,

My laptop runs Windows 10. I’ll look for those instructions.

Bill - sorry, but I can’t find the post to which you referred with instructions for a Windows machine (when you wrote “The next post in the thread has instructions applicable to a Windows box”). I can’t see anything that looks like a similar set of instructions… Would you mind please sharing a direction or link or just copying them here? The next post I can see is your one about another red herring. It may be that the thread I see is different from what you see? Just guessing from other platforms. Many thanks!

The link is in post 4 of this thread.
Command Line Cheatsheet - #3 by Robert Wall
(drag the light blue vertical bar at the right side of your screen upward, until the first number changes to 4).
slider

The instructions for a Windows box are in the second post of that thread

I note that nearly all the instructions end with a cheery “And you’re good to go”.
How, though, do I know that it is good to go? When I tried the first time and I set up the Raspberry pi with the raspberry OS the screen which was plugged into it showed a home screen like Windows does. This screen also showed a “power off” function - I understand teh Raspberry like sto be switched off rather than unplugged.
Now I’ve installed emonSD and I have just a black screen with a command line “pi@emonpi:~ $”. Is there something else needing doing?

Dear Bill, thank you I found some instructions, I have done the thing with the SD card, which is now in the RPi, it has run through lots of activity and now it’s asking for a emonpi login.
I have looked all over for login & password details but can find none. Am I missing something?