After some research, I found this article:
https://groups.google.com/g/node-red/c/pvY36rlRUdI
Essentially, what the article is saying is that you can format a serial output stream in a rather simple manner and directly import that serial into any PC (via serial or serial-USB or Bluetooth serial) and NodeRED has serial "connectors" that can process the serial stream. Items in the stream can be parsed easily and then attached to a variety of gauges or graphs.
The Rotax engine monitor already had a serial debug stream! All that had to be done to make this NodeRED compatible was just some edits to the debug functions that did the serial printing. So easy!
Here is some code to show how easy it was:
Note that the prefix "{" and suffix "}" that closes the JSON are hardcoded. This was just being lazy on my part
![Surprised :o](./images/smilies/icon_e_surprised.gif)
Because of the hardcoding, analog_0() must be called first and thermo11() must be called last.
To test you formatting, capture data to a text file and copy & paste output here: https://jsonlint.com/
Code: Select all
void loop() {
analog_0(); // A0 Water temperature
analog_1(); // A1 Oil temperature
analog_2(); // A2 Oil Pressure
analog_10(); // A10 Amps measured
analog_12(); // A12 Battery voltage measured
analog_15(); // A15 Fuel pressure
thermo_0(); // Exhaust Gas left
thermo_1(); // To be determined ... uncomment function in JSON tab
thermo_2(); // To be determined
thermo_3(); // To be determined
thermo_4(); // To be determined
thermo_5(); // To be determined
thermo_6(); // To be determined
thermo_7(); // To be determined
thermo_8(); // To be determined
thermo_9(); // To be determined
thermo_10(); // To be determined
thermo_11(); // To be determined
delay(5000);
}
Code: Select all
/* Faux JSON file format https://groups.google.com/forum/#!topic/node-red/pvY36rlRUdI */
void analog_0(void) {
float temp = EngineCoolantTemp();
Serial.print("{\"H2O_Tmp\":"); Serial.print(temp); Serial.print (",");
}
void analog_1(void) { /* Oil temperature */
float temp = float(EngOilTemp() );
Serial.print ("\"Oil_Tmp\":"); Serial.print(temp); Serial.print(",");
return;
}
void analog_2(void) { /* Engine Oil Pressure */
float temp = float (EngineOilPres());
Serial.print("\"Oil_Prs\":"); Serial.print(temp); Serial.print(",");
return;
}
void analog_10(void) { /* Amps measured */
float temp = float (BatteryAmps());
Serial.print("\"Current\":"); Serial.print(temp); Serial.print(",");
return;
}
void analog_12(void) { /* Battery voltage measured */
float temp = float (BatteryVoltage());
Serial.print("\"Voltage\":"); Serial.print(temp); Serial.print(",");
return;
}
void analog_15(void) { /* Gasoline fuel pressure */
float temp = fuelPressure(); /* fuel pressure is a fp math function */
Serial.print("\"Gas_Prs\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_0(void) { /* Exhaust Gas left */
int temp = float (thermocouple_channel( 0));
Serial.print("\"EGT_1\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_1(void) {
int temp = float (thermocouple_channel( 1));
Serial.print("\"EGT_2\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_2(void) {
int temp = float (thermocouple_channel( 2));
Serial.print("\"EGT_3\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_3(void) {
int temp = float (thermocouple_channel( 3));
Serial.print("\"EGT_4\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_4(void) {
int temp = float (thermocouple_channel( 4));
Serial.print("\"EGT_5\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_5(void) {
int temp = float (thermocouple_channel( 5));
Serial.print("\"EGT_6\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_6(void) {
int temp = float (thermocouple_channel( 6));
Serial.print("\"EGT_7\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_7(void) {
int temp = float (thermocouple_channel( 7));
Serial.print("\"EGT_8\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_8(void) {
int temp = float (thermocouple_channel( 8));
Serial.print("\"EGT_9\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_9(void) {
int temp = float (thermocouple_channel( 9));
Serial.print("\"EGT_10\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_10(void) {
int temp = float (thermocouple_channel(10));
Serial.print("\"EGT_11\":"); Serial.print(temp); Serial.print(",");
return;
}
void thermo_11(void) {
int temp = float (thermocouple_channel(11));
Serial.print("\"EGT_12\":"); Serial.print(temp); Serial.print("}\n");
return;
}