====== Wirnetâ„¢ iBTS: Power supply management ====== The Wirnet iBTS gateway can be powered with an Ethernet cable (PoE injector) or/and an auxiliary power supply (solar panel, battery). When both PoE **and** external power supply are plugged, the gateway uses the highest voltage available. The VIN_9V corresponds to VIN_POE.\\ * **POE power supply** - VIN_9V has the POE Value.\\ * **External power supply** - VIN_9V has the external power supply. VPORT_MEAS has not to be considered for power supply. \\ \\ ===== Low power detect ===== Power loss can be detected by polling the value of the VIN_9V signal. It should fall down near 0V when both, PoE and Aux power, are lost. The first action to take when the VIN_9V value decreases is to stop the LoRa module. This will decrease the consumption so the gateway will have enough time to stop. The voltage value can be obtained with the following methods: Note that power loss can be detected only if the gateway is equipped with a backup battery ! ==== Since release 4.2 ==== Get the value //VIN_POE// with the tool //sensors//: root@klk-lpbs-0605F5:~# sensors | grep POE VIN_POE: +52.61 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("VIN_POE", &voltage); ==== On older releases ==== ++++On older releases (click to expand)| Get the value //VIN_9V// with the tool //adc//: root@klk-lpbs:~# adc 4 VIN_9V=48979mV or: FILE * pf_file = NULL; u32 u32_adc_value = 0; pf_file = fopen ("/sys/bus/iio/devices/iio:device1/in_voltage0_raw", "r"); if(pf_file != NULL) { fscanf (pf_file, "%d\n", &value); fclose (pf_file); pf_file = NULL; } u32_adc_value=( (value * 3300) / 4096 ); u32_adc_value = ((u32_adc_value* 485) / 15); ++++ \\ \\ ===== Voltage measurement ===== Since version 4.2, All internal voltage measurement can be obtained using the following tool: root@klk-lpbs-0605F5:~# sensors klk_lpbs_adc-isa-0000 Adapter: ISA adapter VDD_CORE: +1.37 V NVCC_DRAM: +1.35 V 3V3_FDP: +3.30 V NVCC_3V3: +3.30 V VIN_POE: +52.61 V VCC_5V: +5.03 V VPOWER: +9.05 V VPORT_MEAS: +53.19 V On all versions, you can also use the following tool: root@klk-lpbs:~# adc VDD_CORE=1372mV NVCC_DRAM=1354mV 3V3_FDP=3283mV NVCC_3V3=3288mV VIN_9V=48435mV VCC_5V=5008mV VPOWER=9139mV VPORT_MEAS=48435mV