Browse Source

WiFiMulti

lightsleep
Hendrik Langer 7 years ago
parent
commit
71eaa48cc3
  1. 15
      src/main.cpp

15
src/main.cpp

@ -6,6 +6,7 @@
#include <Arduino.h> #include <Arduino.h>
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h> #include <ESP8266HTTPClient.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
@ -19,8 +20,8 @@
#include <SDS011.h> #include <SDS011.h>
const char* server = "ingress.opensensemap.org"; const char* server = "ingress.opensensemap.org";
const char* ssid = "Freifunk"; //const char* ssid = "Freifunk";
const char* password = ""; //const char* password = "";
constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden
@ -61,6 +62,8 @@ static constexpr unsigned long logging_period_ms = 60000;
ADC_MODE(ADC_VCC); ADC_MODE(ADC_VCC);
ESP8266WiFiMulti wifiMulti;
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085); Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
DHT dht(DHT22_PIN, DHTTYPE); DHT dht(DHT22_PIN, DHTTYPE);
SDS011 sds; SDS011 sds;
@ -69,10 +72,12 @@ unsigned long geiger_previousMillis;
void ICACHE_FLASH_ATTR sendValues() { void ICACHE_FLASH_ATTR sendValues() {
WiFi.forceSleepWake(); WiFi.forceSleepWake();
WiFi.begin(ssid, password); WiFi.mode(WIFI_STA);
Serial.print("Connecting to wifi"); wifiMulti.addAP("nether.net", "password1");
wifiMulti.addAP("LNet", "password2");
wifiMulti.addAP("Freifunk", "");
int tries = 0; int tries = 0;
while (WiFi.status() != WL_CONNECTED) { while (wifiMulti.run() != WL_CONNECTED) {
tries++; tries++;
Serial.print("."); Serial.print(".");
if (tries > 20) { if (tries > 20) {

Loading…
Cancel
Save