@Robert.Wall, @TrystanLea, would it be possible to add an option to the emonTX firmware to send the serial output as a valid JSON string?
If there is no builtin method to convert the string, it would need the brackets and double quotes added.
My thoughts are that this could then more easily be read and sent on (just needs to be published to an MQTT topic) by other serial devices. e.g. an ESP with Tasmota.
The emonTx single-phase sketches are not mine. I suggested to Trystan that he should simplify the emonTx CM sketch because the complication added to try to force it to behave exactly like emonLibDS appeared to be creating problems.
Which there isn’t, to my knowledge…
The easy way is to use the pre-processor directives. The big advantage of those is the unwanted parts don’t compile and thus don’t carry a memory usage cost nor a run-time processing cost.
#define JSON at the top of the sketch (assuming you want JSON output, don’t if you don’t), and surround the pertinent
Serial.print statements thus:
Serial.print(", \"Vrms\":"); Serial.print(EmonLibCM_getVrms());
(Note the escaped double quotes.)