Can use bssid and channel to save power

It's much faster to connect to wifi, so less power hungry
This commit is contained in:
Mathieu Maret 2019-05-13 22:11:38 +02:00
parent b19406af98
commit 27145540e1

View File

@ -37,6 +37,8 @@ Adafruit_MQTT_Publish *mqtt_voltage;
const char *ssid = "XXXXX"; const char *ssid = "XXXXX";
const char *password = "XXXXX"; const char *password = "XXXXX";
uint8_t bssid[6] = {0x14, 0x0C, 0x76, 0xB1, 0x37, 0x32};
int32_t channel = 11; //0 for Auto
ADC_MODE(ADC_VCC); ADC_MODE(ADC_VCC);
void setup() void setup()
@ -135,11 +137,15 @@ int doMeasure()
IPAddress gateway(192, 168, 0, 254); IPAddress gateway(192, 168, 0, 254);
IPAddress subnet(255, 255, 255, 0); IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet); WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password); WiFi.begin(ssid, password, channel, bssid);
int retry = 10;
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
delay(100); delay(100);
Serial.print("."); Serial.print(".");
if (retry < 0)
continue;
retry --;
} }