void GetStatus() {
//Serial.print(F("signal strength:"));
SIM800L.println("AT+CSQ"); // SIGNAL STRENGTH
delay(500);
if (SIM800L.find(": ")) { // decode reply
while (SIM800L.available()) {
char c = SIM800L.read();
if (c != '\n') Serial.write(c); // replace new line with space
else Serial.print(" ");
}
}
else Serial.print(F("n/a"));
Serial.println();
}
para tomar el valor de la señal, pero me da como resultado:
while (SIM800L.available()) {
char c = SIM800L.read();
if (c == ',') break;
if (c != '\n')
Serial.write(c); // replace new line with space
else
Serial.print(" ");
}
Esto te quita todo lo que sigue luego del ,
no verás ,0 ni el OK
// libraries
#include <GSM.h> // https://www.arduino.cc/en/Reference/GSM
// PIN Number
#define PINNUMBER ""
// initialize the library instance
GSM gsmAccess(true); // include a 'true' parameter to enable debugging
GSMScanner scannerNetworks;
GSMModem modemTest;
// Save data variables
String IMEI = "";
// serial monitor result messages
String errortext = "ERROR";
void setup()
{
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("GSM networks scanner");
scannerNetworks.begin();
// connection state
boolean notConnected = true;
// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while(notConnected)
{
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
notConnected = false;
else
{
Serial.println("Not connected");
delay(1000);
}
}
// get modem parameters
// IMEI, modem unique identifier
Serial.print("Modem IMEI: ");
IMEI = modemTest.getIMEI();
IMEI.replace("\n","");
if(IMEI != NULL)
Serial.println(IMEI);
}
void loop()
{
// scan for existing networks, displays a list of networks
Serial.println("Scanning available networks. May take some seconds.");
Serial.println(scannerNetworks.readNetworks());
// currently connected carrier
Serial.print("Current carrier: ");
Serial.println(scannerNetworks.getCurrentCarrier());
// returns strength and ber
// signal strength in 0-31 scale. 31 means power > 51dBm
// BER is the Bit Error Rate. 0-7 scale. 99=not detectable
Serial.print("Signal Strength: ");
Serial.print(scannerNetworks.getSignalStrength());
Serial.println(" [0-31]");
}
y si usas esta ecuación, convertería tu 0-31 a 0-100%