#include Finder6M f6m_print; Finder6M f6m; Finder6M f6m_2; Finder6M f6m_3; constexpr uint8_t MODBUS_6M_DEFAULT_ADDRESS = 1; constexpr uint8_t MODBUS_6M_ADDRESS = 7; //number 2 constexpr uint8_t MODBUS_6M_ADDRESS_2 = 2; // number 3 constexpr uint8_t MODBUS_6M_ADDRESS_3 = 3; // number 4 void setup() { Serial.begin(38400); if (!f6m.init()) { while (1) ; } f6m.setModbusAddress(MODBUS_6M_ADDRESS, MODBUS_6M_DEFAULT_ADDRESS); f6m.measureAlternateCurrent(MODBUS_6M_ADDRESS); f6m.disableEnergyStoring(MODBUS_6M_ADDRESS); if (!f6m.saveSettings(MODBUS_6M_ADDRESS)) { while (1) ; } if (!f6m_2.init()) { while (1) ; } f6m_2.setModbusAddress(MODBUS_6M_ADDRESS_2, MODBUS_6M_DEFAULT_ADDRESS); f6m_2.measureAlternateCurrent(MODBUS_6M_ADDRESS_2); f6m_2.disableEnergyStoring(MODBUS_6M_ADDRESS_2); if (!f6m_2.saveSettings(MODBUS_6M_ADDRESS_2)) { while (1) ; } if (!f6m_3.init()) { while (1) ; } f6m_3.setModbusAddress(MODBUS_6M_ADDRESS_3, MODBUS_6M_DEFAULT_ADDRESS); f6m_3.measureAlternateCurrent(MODBUS_6M_ADDRESS_3); f6m_3.disableEnergyStoring(MODBUS_6M_ADDRESS_3); if (!f6m_3.saveSettings(MODBUS_6M_ADDRESS_3)) { while (1) ; } } void loop() { Serial.println("** Reading 6M at address " + String(MODBUS_6M_ADDRESS)); int IdAddress = f6m.getMachineId(MODBUS_6M_ADDRESS); Serial.println("MACHINE IDD ==== " + String(IdAddress)); // Voltage and Current transformer ratio float tvRatio = f6m.getTVRatio(MODBUS_6M_ADDRESS); printFloat("Voltage transformer ratio", tvRatio); float taRatio = f6m.getTARatio(MODBUS_6M_ADDRESS); printFloat("Current transformer ratio", taRatio); // Energy measurements double energy = f6m.getEnergy(MODBUS_6M_ADDRESS); printMeasurement("Energy in kWh", energy); double posEnergy = f6m.getEnergyPositive(MODBUS_6M_ADDRESS); printMeasurement("Positive energy in kWh", posEnergy); double negEnergy = f6m.getEnergyNegative(MODBUS_6M_ADDRESS); printMeasurement("Negative energy in kWh", negEnergy); // Other measurements double voltageRMS = f6m.getVoltageRMS(MODBUS_6M_ADDRESS); printMeasurement("Voltage RMS in V", voltageRMS); double currentRMS = f6m.getCurrentRMS(MODBUS_6M_ADDRESS); printMeasurement("Current RMS in mA", currentRMS); double activePower = f6m.getActivePower(MODBUS_6M_ADDRESS); printMeasurement("Active Power in W", activePower); double reactivePower = f6m.getReactivePower(MODBUS_6M_ADDRESS); printMeasurement("Reactive Power in var", reactivePower); double apparentPower = f6m.getApparentPower(MODBUS_6M_ADDRESS); printMeasurement("Apparent Power in VA", apparentPower); double powerFactor = f6m.getPowerFactor(MODBUS_6M_ADDRESS); printMeasurement("Power factor", powerFactor); double frequency = f6m.getFrequency(MODBUS_6M_ADDRESS); printMeasurement("Frequency in Hz", frequency); double thd = f6m.getTHD(MODBUS_6M_ADDRESS); printMeasurement("THD", thd); // Status uint16_t status = f6m.getStatus(MODBUS_6M_ADDRESS); printStatus(status); ////// Serial.println("** Reading 6M at address " + String(MODBUS_6M_ADDRESS_2)); int IdAddress_2 = f6m_2.getMachineId(MODBUS_6M_ADDRESS_2); Serial.println("MACHINE IDD ==== " + String(IdAddress_2)); // Voltage and Current transformer ratio float tvRatio2 = f6m_2.getTVRatio(MODBUS_6M_ADDRESS_2); printFloat("Voltage transformer ratio", tvRatio2); float taRatio2 = f6m_2.getTARatio(MODBUS_6M_ADDRESS_2); printFloat("Current transformer ratio", taRatio2); // Energy measurements double energy2 = f6m_2.getEnergy(MODBUS_6M_ADDRESS_2); printMeasurement("Energy in kWh", energy2); double posEnergy2 = f6m_2.getEnergyPositive(MODBUS_6M_ADDRESS_2); printMeasurement("Positive energy in kWh", posEnergy2); double negEnergy2 = f6m_2.getEnergyNegative(MODBUS_6M_ADDRESS_2); printMeasurement("Negative energy in kWh", negEnergy2); // Other measurements double voltageRMS2 = f6m_2.getVoltageRMS(MODBUS_6M_ADDRESS_2); printMeasurement("Voltage RMS in V", voltageRMS2); double currentRMS2 = f6m_2.getCurrentRMS(MODBUS_6M_ADDRESS_2); printMeasurement("Current RMS in mA", currentRMS2); double activePower2 = f6m_2.getActivePower(MODBUS_6M_ADDRESS_2); printMeasurement("Active Power in W", activePower2); double reactivePower2 = f6m_2.getReactivePower(MODBUS_6M_ADDRESS_2); printMeasurement("Reactive Power in var", reactivePower2); double apparentPower2 = f6m_2.getApparentPower(MODBUS_6M_ADDRESS_2); printMeasurement("Apparent Power in VA", apparentPower2); double powerFactor2 = f6m_2.getPowerFactor(MODBUS_6M_ADDRESS_2); printMeasurement("Power factor", powerFactor2); double frequency2 = f6m_2.getFrequency(MODBUS_6M_ADDRESS_2); printMeasurement("Frequency in Hz", frequency2); double thd2 = f6m_2.getTHD(MODBUS_6M_ADDRESS_2); printMeasurement("THD", thd2); // Status uint16_t status2 = f6m_2.getStatus(MODBUS_6M_ADDRESS_2); printStatus(status2); ///////// Serial.println("** Reading 6M at address " + String(MODBUS_6M_ADDRESS_3)); int IdAddress3 = f6m_3.getMachineId(MODBUS_6M_ADDRESS_3); Serial.println("MACHINE IDD ==== " + String(IdAddress3)); // Voltage and Current transformer ratio float tvRatio3 = f6m_3.getTVRatio(MODBUS_6M_ADDRESS_3); printFloat("Voltage transformer ratio", tvRatio3); float taRatio3 = f6m_3.getTARatio(MODBUS_6M_ADDRESS_3); printFloat("Current transformer ratio", taRatio3); // Energy measurements double energy3 = f6m_3.getEnergy(MODBUS_6M_ADDRESS_3); printMeasurement("Energy in kWh", energy3); double posEnergy3 = f6m_3.getEnergyPositive(MODBUS_6M_ADDRESS_3); printMeasurement("Positive energy in kWh", posEnergy3); double negEnergy3 = f6m_3.getEnergyNegative(MODBUS_6M_ADDRESS_3); printMeasurement("Negative energy in kWh", negEnergy3); // Other measurements double voltageRMS3 = f6m_3.getVoltageRMS(MODBUS_6M_ADDRESS_3); printMeasurement("Voltage RMS in V", voltageRMS3); double currentRMS3 = f6m_3.getCurrentRMS(MODBUS_6M_ADDRESS_3); printMeasurement("Current RMS in mA", currentRMS3); double activePower3 = f6m_3.getActivePower(MODBUS_6M_ADDRESS_3); printMeasurement("Active Power in W", activePower3); double reactivePower3 = f6m_3.getReactivePower(MODBUS_6M_ADDRESS_3); printMeasurement("Reactive Power in var", reactivePower3); double apparentPower3 = f6m_3.getApparentPower(MODBUS_6M_ADDRESS_3); printMeasurement("Apparent Power in VA", apparentPower3); double powerFactor3 = f6m_3.getPowerFactor(MODBUS_6M_ADDRESS_3); printMeasurement("Power factor", powerFactor3); double frequency3 = f6m_3.getFrequency(MODBUS_6M_ADDRESS_3); printMeasurement("Frequency in Hz", frequency3); double thd3 = f6m_3.getTHD(MODBUS_6M_ADDRESS_3); printMeasurement("THD", thd3); // Status uint16_t status3 = f6m_3.getStatus(MODBUS_6M_ADDRESS_3); printStatus(status3); } void printFloat(String label, float n) { Serial.println(" " + label + " = " + (f6m_print.toUint32(n) != INVALID_DATA ? String(n) : String("read error!"))); }; void printMeasurement(String label, double n) { Serial.println(" " + label + " = " + (n != (INVALID_DATA / 100.0) ? String(n) : String("read error!"))); }; void printStatus(uint16_t status) { Serial.println(" Status: "); Serial.println(" flash settings error : " + String(status & FINDER_6M_STATUS_BITMASK_FLASH_SETTINGS_ERROR)); Serial.println(" flash calibration error : " + String((status & FINDER_6M_STATUS_BITMASK_FLASH_CALIBRATION_ERROR) >> 1)); Serial.println(" voltage over range : " + String(f6m_print.isVoltageOverRange(status))); Serial.println(" voltage under range : " + String(f6m_print.isVoltageUnderRange(status))); Serial.println(" zero crossing detecting : " + String((status & FINDER_6M_STATUS_BITMASK_ZERO_CROSSING_DETECTING) >> 6)); Serial.println(" energy storing error : " + String((status & FINDER_6M_STATUS_BITMASK_ENERGY_STORING_ERROR) >> 10)); Serial.println(" energy initialization error : " + String((status & FINDER_6M_STATUS_BITMASK_ENERGY_INIT_ERROR) >> 11)); Serial.println(" current over range : " + String(f6m_print.isCurrentOverRange(status))); Serial.println(" current under range : " + String(f6m_print.isCurrentUnderRange(status))); };