Electron Signal Strength LED Algorithm

The easiest would be to map the range via tha map() function.

Give this a shot

  int strength = map(RSSI, -131, -51, 0, 5);

You may have to tweak the boundaries (-131/-51) a bit to get the mid point of each category right.

And this is the code from the firmware repo

void system_display_rssi() {
    /*   signal strength (u-Blox Sara U2 and G3 modules)
     *   0: < -105 dBm
     *   1: < -93 dBm
     *   2: < -81 dBm
     *   3: < -69 dBm
     *   4: < - 57 dBm
     *   5: >= -57 dBm
     */
    system_prepare_display_bars();
    int rssi = 0;
    int bars = 0;
#if Wiring_WiFi == 1
    rssi = WiFi.RSSI();
#elif Wiring_Cellular == 1
    CellularSignal sig = Cellular.RSSI();
    rssi = sig.rssi;
#endif
    if (rssi < 0) {
        if (rssi >= -57) bars = 5;
        else if (rssi > -68) bars = 4;
        else if (rssi > -80) bars = 3;
        else if (rssi > -92) bars = 2;
        else if (rssi > -104) bars = 1;
    }
    DEBUG("RSSI: %ddB BARS: %d\r\n", rssi, bars);

    system_display_bars(bars);
}
7 Likes