diff --git a/esp8266-geigercounter.ino b/esp8266-geigercounter.ino index df474e6..babfd4b 100644 --- a/esp8266-geigercounter.ino +++ b/esp8266-geigercounter.ino @@ -19,13 +19,12 @@ float lastuSv = 0, currentuSv = 0; void setup() { - WiFi.hostname(WIFI_HOSTNAME); - WiFi.mode(WIFI_STA); - Serial.begin(115200); geigerCounterSerial.begin(BAUD_GEIGERCOUNTER); - delay(10); + + WiFi.hostname(WIFI_HOSTNAME); + WiFi.mode(WIFI_STA); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); while (WiFi.status() != WL_CONNECTED) { @@ -34,7 +33,7 @@ void setup() { } mqttClient.setClient(wifiClient); - mqttClient.setServer(mqttHost, 1883); + mqttClient.setServer(MQTT_HOST, 1883); ArduinoOTA.setHostname(WIFI_HOSTNAME); ArduinoOTA.setPassword(OTA_PASSWORD); @@ -69,7 +68,7 @@ void updateRadiationValues() { void connectMqtt() { while (!mqttClient.connected()) { - if (mqttClient.connect("geigercounter", MQTT_TOPIC_LAST_WILL, 1, true, "disconnected")) { + if (mqttClient.connect(WIFI_HOSTNAME, MQTT_TOPIC_LAST_WILL, 1, true, "disconnected")) { mqttClient.publish(MQTT_TOPIC_LAST_WILL, "connected", true); } else { delay(1000); diff --git a/settings.h.example b/settings.h.example index 38f19f2..5ea0d47 100644 --- a/settings.h.example +++ b/settings.h.example @@ -15,7 +15,7 @@ #define BAUD_GEIGERCOUNTER 9600 -const char* WIFI_HOSTNAME = "ESP-GeigerCounter"; +const char* HOSTNAME = "ESP-GeigerCounter"; const char* WIFI_SSID = "----"; const char* WIFI_PASSWORD = "----";