Hi all
I have a problem: I want that a LED is ON as long as 3G is available. If only 2G (fallback) is available the LED should be off. How can I do this? Any ideas?
Hi all
I have a problem: I want that a LED is ON as long as 3G is available. If only 2G (fallback) is available the LED should be off. How can I do this? Any ideas?
You’d need to use the respective AT commands via Cellular.command()
.
To find out which commands are needed for that, you’d need to look in the ublox datasheet.
But IIRC @rickkas7 had something similar in his drawer a while back
If you use the CellularHelper library (also in the community libraries), this code should work:
#include "Particle.h"
#include "CellularHelper.h"
void setup() {
Serial.begin(9600);
pinMode(D7, OUTPUT);
waitUntil(Cellular.ready);
CellularHelperEnvironmentResponseStatic<1> resp;
CellularHelper.getEnvironment(CellularHelperClass::ENVIRONMENT_SERVING_CELL, resp);
if (resp.resp == RESP_OK) {
if (resp.service.isUMTS) {
Serial.printlnf("is3G=true");
digitalWrite(D7, HIGH);
}
else {
Serial.printlnf("is3G=false");
}
}
else {
Serial.printlnf("getEnvironment returned error %d", resp.resp);
}
}
void loop() {
}
You may want to do this every few minutes, in case the Electron is moving around.