Compile calibration changes

I’m trying to calibrate my emonpi following the steps described here:
However, when I try to change the coefficients and voltage values inside the src.ino file at emonpi/firmware/src/ folder, the measurements are not affected at all.

I tried restarting the Emonhub on the web, and then, compiling through ./ but the measurements remain the same as before. So, I would like to know how to calibrate the emonpi not with the scales in the emonhub, but with the source code.

Help !!!
Thank you so much!!

Welcome, David.

Your problem is, the calibration instructions apply to the Atmel front end, which is the “emon” part of the emonPi, and it’s totally separate from the Pi part, the two communicate via a serial link.

You need to compile the source either on your computer or on the Pi, find the compiled .hex file, then upload that via the serial link.
for the instructions to do that.

But even when you’ve done it, there’s a big danger that if you update emonCMS, you’ll overwrite your calibrated sketch and lose your work.

This is why I always recommend adjusting the "scales = " line in emonhub.conf.

When/if you do update emonCMS, choose the “wrong” option, in your case choose “emonBase”. That will try to communicate with the Atmel at the wrong baud rate, and fail - which is what you want.

1 Like

@glyn.hudson is likely best to help with the compile script. compiles the firmware but does not upload. You could try running:

pio run -t upload

Simplifying the calibration procedure for the emonpi is on our development list. We are planning to make it possible to calibrate from the emoncms web interface.

1 Like

This should work, however you will need to stop emonhub first sudo service emonhub stop

However, there is currently an issue where your calibration will be overwritten each time the emonPi / Emoncms is updated. We are currently working on a solution for this see:

In the meantime a better (and easier IMO) way to calibrate the emonPi is to edit emonhub.conf. This can be done via local Emoncms Setup > EmonHub > Edit .

To enter the scalor for the emonPi you will need to edit the relevant value node ID 5 e.g

Another way to apply calibration is via Emoncms Input Processing

I had already explained the reasons for that, and the dangers of taking that route, but in the top post @David.arevalo specifically asks how to do it in the front end.

We don’t know where David is in the world, it might be Colombia, so it is very likely that it’s necessary for him to alter PHASECAL, which cannot (presently) be done in emonhub.conf.

Thank you very much for your answers guys!

As you mentioned, my problem was that I had to upload the file I was compiling. I achieved this through the command ./ and everything went well with my calibration (yesterday). However, as I continued working with the modified-emonpi I realized that it no longer identified the values of the emontx that it had associated with it.

But back to my original question, the best option to calibrate is through the emonHub and the scales. Thank you so much :smiley:

The only reasons I can think of to explain that are either that you had inadvertently removed the part of the code that operates the RFM69CW radio receiver and sends the received values through to emonhub, or you had changed the wrong part of emonhub.conf.

Changing the calibration constants should not have done anything to other parts of your system.

Hi @Robert.Wall and @DanteRocket18 !!!

As I told you in a previous post, I also edited the emonpi/firmware/src/src.ino because I was calibrating the devices in a more accurate way, due to the EmonHub didn’t allow me to be so accurate (I modified Ical1, Ical2, Vcal_USA) and it’s was great. However, when I compiled and uploaded the src.ino I realised that my EmonPi was no longer reading the EmonTx. Only when I rebooted it, but the emonpi read the Tx for 20 seconds and then it did not read anymore.

Did you know why it happens? It looks like if the RF was disabled !! :frowning:

Thank you !

I’ve moved your post back into this thread, where it makes a lot more sense. Don’t start a new thread, or hang onto a different one, each time - it doesn’t help.

Short answer - no. Longer answer - you’ve changed something you should not have changed and that you think you have not changed.
And as I don’t know exactly what you changed, I can only guess.

Did you get your source files from here: emonpi/firmware/src at master · openenergymonitor/emonpi · GitHub ?

As far as I’m aware, those should work.
Am I right to think that you are seeing the emonPi’s own readings in emonHub/emonCMS, but not the remote emonTx?

Have you accidentally reconfigured the receiver to a different frequency band or group? you might have done this by sending something like “8b” (868 MHz band) or “123g” (Network Group 123) on the serial interface from the Pi. Those should be “4b” and “210g” for 433 MHz / 210, in order to receive from a standard emonTx.

Does the emonHub log tell you anything useful?

But if you have only changed the voltage and current amplitude calibration constants, I don’t see why you did this, because those can be adjusted equally effectively in emonHub (though “power1_plus_power2” must be a compromise). It is only the phasecal constant which cannot be changed there, and that is the one thing you have not adjusted.

If you cannot find out what you have done wrong, the easy solution is to update your emonPi, which should overwrite your changes and get it working again.