Skip to content

readValues()

Arnd edited this page Apr 20, 2017 · 2 revisions

readValues(Index,RPM,mAmps[,CommsErr,DeviceErr][,ResetValues]);

This function will read the collected readings from the device number passed in as "Index", which is a c++ type index starting at 0 for the first device. Zeros are returned if the index is out of bounds. The values for "RPM" and "mA" are returned as averages since the last call to this function, unless the optional "ResetReadings" parameter is set to "false". When the compressor turns off the values for RPM and MilliAmps are returned as zeroes. The number of readings processed is returned as the optional function value. The two parameters for CommsErrors and ErrorStatus will return the number of communications errors encountered since the last call (the protocol data sentences have checksums, if the checksum doesn't match then the sentence is ignored and the error count incremented) and if the device goes into error mode then the raw code(s) are returned, they can be decoded as per the FDC1 Communication Protocol document.


Example:

CubigelClass Cubigel(&Serial1);// Instantiate with fridge on HW1 //

...

void loop() {
  uint8_t  RPM;
  uint16_t mA;
  delay(10000); // wait 10 seconds
  uint16_t readingCount = Cubigel.readValues(0,RPM,mA); // read values //
  Serial.print("Fridge RPM is ");
  Serial.print(RPM);
  Serial.print(", milliamps are ");
  Serial.print(mA);
  Serial.print(" (");
  Serial.print(readingCount);
  Serial.println(" readings)");
} // of main loop