Calibration of EmonTH
I recently bought four EmonTHs with the aim of using them in house heating tests.
I did a calibration run checking their output between 6-40C? (30-80%RH?) against a SENSIRON SHT31 I bought from RS Electronics. Although it has its own errors to think about it, the SHT31 is my new standard against which I calibrate the EMONTHs.
(https://uk.rs-online.com/web/p/sensor-development-tools/1237130/)
Surprisingly little re-calibration is actually needed and I am pleased that the sensor in the EmonTHs are quite accurate. The only recalibration needed is to scale the humidity result by 0.95 on one of the EmonTH sensors.
For this I will need to adjust the Arduino Sketch that runs the EmonTH.
PlatformIO and EmonTH2
The openenergymonitor website gives a guide to using PlatformIO as a code editor.
However, support for PlatformIO from Emon team might be hard to get.
You may be better off sticking to the Arduino IDE code editor if support is key, although at this point I have battled through the PlatformIO environment using Google for support and it seems to be OK for me.
Here is my experience with PlatformIO and compiling and Uploading an updated sketch to an EmonTH2 with my new scaling factors.
Get PlatformIO
It will download updates, if in doubt updates have been applied restart it
I clone the EmonTH folder onto my harddrive.
$ git clone https://github.com/openenergymonitor/emonth2
PlatformIO (PIO for short) uses a directory tree on the LHS and opens files into Projects. PIO uses workspaces and has a Platformio.ini file to organise folders in the directory according to function.
You can open from PIO using the Import Arduino Project function, however I chose Open and directed to the …emonth2 folder and all files were brought in successfully.
There are some problems that need to be resolved before use.
The workspace file has a reference to emontx3 instead of emonth2. I assume that should be changed so I changed it(?)
PIO wont resolve library dependencies when you hit Compile. That is because the current library dependencies found in PIO.ini file looks like this;
[common]
lib_deps_external =
DallasTemperature @3.7.7
JeeLib @c057b5f4c0
SI7021 @c5ce0922ef
However, the JeeLib library wont be found because @c057b5f4c0 is invalid
Likewise SI7021@c5ce0922ef has the same problem
Without these libraries and their dependents you cant compile.
To fix this I reached into the EmonTX3 folder and stripped out the libraries there as replacements.
[common]
lib_deps_external =
DallasTemperature @3.7.7
https://github.com/jcw/jeelib.git#f097c0039c926881d80a74bec7a7aa020de610ee
SI7021
With these new library references I can compile successfully and all library dependencies are pulled.
Finally I had an error saying that PIO couldnt find the src code directory. This requires a reference in the PIO.ini file to be added;
[platformio]
default_envs = emonth2
src_dir = src
Changing the src code for calibration results
The lines of code you need to change are 405,406
emonth.temp = (data.celsiusHundredths*0.1);
emonth.humidity = (data.humidityBasisPoints*0.1);
Here I change the 0.1 to 0.095 in Line 406 to scale my humidity reading following my calibration results.
Compile is successful (forget the best practice warnings and errors) and then go to Upload. You can use Serial Monitor in PIO to monitor the EmonTH output.
(tip: first time I changed the scaling to 0.05 just to make sure I was uploading successfully and having an effect on the output, before finally setting it to 0.95).
I will now finally check to see that the EmonTH does work with the EmonBase I have and post again down below. If it doesnt work I am going to be upset.