tuning
This commit is contained in:
@ -8,13 +8,13 @@
|
||||
#include <DallasTemperature.h>
|
||||
|
||||
|
||||
#define DEBUG
|
||||
// #define SLEEP
|
||||
// #define DEBUG
|
||||
#define SLEEP
|
||||
|
||||
//const char* ssid = "EG-WLAN";
|
||||
//const char* password = "shae3sheuthai2oluNgiqueiyahyumeiphughi8jequeil6taethooyeik1joh5";
|
||||
const char* ssid = "iPhone";
|
||||
const char* password = "wollud123456";
|
||||
const char* ssid = "EG-WLAN";
|
||||
const char* password = "shae3sheuthai2oluNgiqueiyahyumeiphughi8jequeil6taethooyeik1joh5";
|
||||
//const char* ssid = "iPhone";
|
||||
//const char* password = "wollud123456";
|
||||
//const char* ssid = "WLan-KI-Pro";
|
||||
//const char* password = "sVAPHCmo";
|
||||
|
||||
@ -22,6 +22,8 @@ const char* mqttServer = "broker.hottis.de";
|
||||
const uint16 mqttPort = 8883;
|
||||
const char* mqttUsername = "esp1";
|
||||
const char* mqttPassword = "test1234";
|
||||
const char* clientId = "espTherm1";
|
||||
const char* topic = "IoT/espThermometer2/espTherm1/measurement";
|
||||
//const char* mqttServer = "172.16.2.15";
|
||||
//const char* mqttServer = "10.11.184.91";
|
||||
|
||||
@ -51,8 +53,8 @@ void setup() {
|
||||
client.setServer(mqttServer, mqttPort);
|
||||
|
||||
sensors.begin();
|
||||
uint8_t num = sensors.getDeviceCount();
|
||||
#ifdef DEBUG
|
||||
uint8_t num = sensors.getDeviceCount();
|
||||
Serial.print("device count: ");
|
||||
Serial.println(num);
|
||||
#endif
|
||||
@ -67,8 +69,8 @@ void setup() {
|
||||
}
|
||||
|
||||
void setup_wifi() {
|
||||
|
||||
delay(10);
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
#ifdef DEBUG
|
||||
Serial.println();
|
||||
@ -79,7 +81,7 @@ void setup_wifi() {
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
delay(50);
|
||||
#ifdef DEBUG
|
||||
Serial.print(".");
|
||||
#endif
|
||||
@ -100,7 +102,9 @@ void reconnect() {
|
||||
Serial.print("Attempting MQTT connection...");
|
||||
#endif
|
||||
// Attempt to connect
|
||||
if (client.connect("ESP8266Client2", mqttUsername, mqttPassword)) {
|
||||
//char clientId[128];
|
||||
//snprintf(clientId, 127, "esp%s", WiFi.macAddress().c_str());
|
||||
if (client.connect(clientId, mqttUsername, mqttPassword)) {
|
||||
#ifdef DEBUG
|
||||
Serial.println("connected");
|
||||
#endif
|
||||
@ -142,8 +146,8 @@ void read_thermometer() {
|
||||
uint32_t duration = millis() - startTime;
|
||||
|
||||
|
||||
char topic[128];
|
||||
snprintf(topic, 127, "IoT/espThermometer2/%s/measurement", WiFi.macAddress().c_str());
|
||||
//char topic[128];
|
||||
//snprintf(topic, 127, "IoT/espThermometer2/%s/measurement", WiFi.macAddress().c_str());
|
||||
char payload[128];
|
||||
snprintf(payload, 127, "%d.%d %ld", t1, t2, duration);
|
||||
client.publish(topic, payload, true);
|
||||
|
Reference in New Issue
Block a user