Sorry, I didn’t notice the “PM” flag at the top. Here it is:
The setting in emonhub is nothing more than an option of 2 strings “240V” and “110V”, they have no numerical value, the strings could have been “UK” and “US” or the setting could have been usamode “True” or “False”.
github.com
setting = self._jee_settings[key]# convert bools to intsif str.capitalize(str(setting)) in ['True', 'False']: setting = int(setting == "True")
As you can see above, those 2 strings simply get converted to 2 other strings “1p” and “2p”.
Those commands get sent via serial just like the baseid, group, frequency and quietmode as documented in the serial output (that never gets seen by the user).
github.com
long unsigned int start_press=0; // Record time emonPi shutdown push switch is pressed
bool quiet_mode = true;
const char helpText1[ ] PROGMEM = // Available Serial Commands"\n"
"Available commands:\n"
" <nn> i - set node IDs (standard node ids are 1..30)\n"
" <n> b - set MHz band (4 = 433, 8 = 868, 9 = 915)\n"
" <nnn> g - set network group (RFM12 only allows 212, 0 = any)\n"
" <n> c - set collect mode (advanced, normally 0)\n"
" ...,<nn> a - send data packet to node <nn>, request ack\n"
" ...,<nn> s - send data packet to node <nn>, no ack\n"
" ...,<n> p - Set AC Adapter Vcal 1p = UK, 2p = USA\n"
" v - Show firmware version\n"
" <n> q - set quiet mode (1 = don't report bad packets)\n";
//-------------------------------------------------------------------------------------------------------------------------------------------
// SETUP ********************************************************************************************
//-------------------------------------------------------------------------------------------------------------------------------------------
void setup()
Once in the emonpi firmware those command strings set the “USA” boolean.
github.com
case 'p': // set Vcc Cal 1=UK/EU 2=USA
if (value)
{
if (value==1) USA=false;
if (value==2) USA=true;
}
break;
that boolean get used both in the setup()
github.com
delay(100);
if (USA)
{
Vcal = Vcal_USA; // Assume USA AC/AC adatper is being used, set calibration accordingly
Vrms = Vrms_USA;
}
else
{
Vcal = Vcal_EU;
and again the main() loop
github.com
now = millis();
if (USA)
{
Vcal = Vcal_USA; // Assume USA AC/AC adatper is being used, set calibration accordingly
Vrms = Vrms_USA;
}
else
{
Vcal = Vcal_EU;
to simply select one of 2 pairs of pre-determined Vcal and Vrms values
github.com
const unsigned long BAUD_RATE= 38400;
github.com
const float Ical1= 90.9; // (2000 turns / 22 Ohm burden) = 90.9
const float Ical2= 90.9;
If the intention was to make this as long, complex and obscure as humanly possible it’s a fantastic piece of code, otherwise it’s not so hot.
In short, when you set “110V” in emonhub, (I think) you will get either a Vrms of 120 or a Vcal of 130 depending on whether the AC adapter is present, what you don’t get is 110V, unless the FW is pre-December 2017 (v2.8.4) when Vrms_USA got changed from 110 to 120.
github.com/openenergymonitor/emonpi

by glynhudson on 03:57PM - 21 Dec 17 UTC
changed 1 files with 2 additions and 2 deletions .