This commit is contained in:
schinken 2017-03-05 17:32:39 +01:00
parent 6d88f6c013
commit 3c78d20461
2 changed files with 16 additions and 15 deletions

View file

@ -1,6 +1,7 @@
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <SoftwareSerial.h>
#include <ArduinoOTA.h>
#include <SimpleTimer.h>
#include "settings.h"
@ -18,31 +19,26 @@ float lastuSv = 0, currentuSv = 0;
void setup() {
WiFi.hostname("ESP-GeigerCounter");
WiFi.hostname(WIFI_HOSTNAME);
WiFi.mode(WIFI_STA);
mqttClient.setClient(wifiClient);
mqttClient.setServer(mqttHost, 1883);
Serial.begin(115200);
geigerCounterSerial.begin(BAUD_GEIGERCOUNTER);
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
mqttClient.setClient(wifiClient);
mqttClient.setServer(mqttHost, 1883);
ArduinoOTA.setHostname(WIFI_HOSTNAME);
ArduinoOTA.setPassword(OTA_PASSWORD);
ArduinoOTA.begin();
timer.setInterval(UPDATE_INTERVAL_SECONDS * 1000L, updateRadiationValues);
}
@ -150,4 +146,6 @@ void loop() {
Serial.write(in);
}
ArduinoOTA.handle();
}

View file

@ -15,8 +15,11 @@
#define BAUD_GEIGERCOUNTER 9600
const char* ssid = "----";
const char* password = "----";
const char* WIFI_HOSTNAME = "ESP-GeigerCounter";
const char* WIFI_SSID = "----";
const char* WIFI_PASSWORD = "----";
const char* OTA_PASSWORD = "foobar";
#define MQTT_TOPIC_CPM "sensor/radiation/cpm"
#define MQTT_TOPIC_USV "sensor/radiation/uSv"