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