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

Loading…
Cancel
Save