====== Wirnetâ„¢ iStation: Power supply management ====== The Wirnet iStation gateway includes an internal backup battery allowing to detect power loss. \\ \\ ===== Battery charge ===== Level of battery charge can be monitored through **VCC_BACKUP** ADC sensor. This backup battery is charged on main power called **12V_POE** so taking into account hardware implementation, maximum value of VCC_BACKUP is around 11.8V (main 12V - 0.2V). In the following example, a few time after a cold boot, we can see that Backup battery is charging (5.9V instead 11.8V). root@klk-wiis-05005E:~# sensors | egrep 'POE|BACKUP' 12V_POE: +12.03 V VCC_BACKUP: +5.93 V \\ \\ ===== Low power detect ===== As examples, power loss could be detected by these 2 methods (to be adapted depending on the application and use-case): - basic detection: polling the value of the 12V_POE ADC every second. When it falls under 10V (confirmed with 5 consecutive reads), application must launch power-down sequence. - early detection: polling the value of the 12V_POE and VCC_BACKUP. If VCC_BACKUP value is greater than 12V_POE, it means that main power is now supplied by backup battery. Application can launch power-down sequence. The first thing to do in power-down sequence is to power down lora modem as soon as possible to disable its power consumption. The voltage values can be obtained with the following methods: root@klk-wiis-05005E:~# sensors | egrep 'POE|BACKUP' 12V_POE: +12.02 V VCC_BACKUP: +11.89 V ++++Examples with power loss early detected| root@klk-wiis-05005E:~# sensors | egrep 'POE|BACKUP' 12V_POE: +12.02 V VCC_BACKUP: +11.89 V root@klk-wiis-05005E:~# sensors | egrep 'POE|BACKUP' 12V_POE: +11.35 V VCC_BACKUP: +11.75 V root@klk-wiis-05005E:~# sensors | egrep 'POE|BACKUP' 12V_POE: +11.17 V VCC_BACKUP: +11.57 V root@klk-wiis-05005E:~# sensors | egrep 'POE|BACKUP' 12V_POE: +11.12 V VCC_BACKUP: +11.51 V ++++ or, in C with [[https://en.wikipedia.org/wiki/Lm_sensors|lmsensors]] library: #include static int get_sensor_voltage(const char * pName, double * pVoltage) { const sensors_chip_name *chip; const sensors_feature *feature; const sensors_subfeature * subfeature; int chip_nr, i; char *label = NULL; double voltage = 0; int result = -1; int ret; ret = sensors_init(NULL); if (ret != 0) { syslog(LOG_ERR, "[%s:%d] err %d in sensors_init\n", __FUNCTION__, __LINE__, ret); return result; } chip_nr = 0; while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) { i = 0; while ((feature = sensors_get_features(chip, &i))) { label = sensors_get_label(chip, feature); if (label != NULL) { subfeature = sensors_get_subfeature(chip, feature, SENSORS_SUBFEATURE_IN_INPUT); if ((strcmp(pName, label) == 0) && (subfeature != NULL)) { if (sensors_get_value(chip, subfeature->number, &voltage) == 0) { *pVoltage = voltage; result = 0; } } free(label); label = NULL; } } } sensors_cleanup(); return result; } double voltage = 0; get_sensor_voltage("12V_POE", &voltage); On first HW versions of Wirnet iStation (Board ID starting with 03XXXX or 04XXXX), Backup battery doesn't work exactly like expected, please avoid to use it or contact support team for further details. \\ \\ ===== Voltage measurement ===== All internal voltage measurement can be obtained using the following tool: root@klk-wiis-05005E:~# sensors klk_wiis_adc-isa-0000 Adapter: ISA adapter VDD_CORE: +1.39 V NVCC_DRAM: +1.34 V VCC_DIG_1V8: +1.85 V NVCC_3V3: +3.29 V 12V_POE: +12.03 V VCC_BACKUP: +11.53 V VCC_5V: +4.94 V VCC_RF: +1.93 V