Remove output to Serial1
This commit is contained in:
@@ -36,10 +36,10 @@ void onWifiConnect(const WiFiEventStationModeGotIP& event);
|
||||
void onWifiDisconnect(const WiFiEventStationModeDisconnected& event);
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason);
|
||||
void onMqttSubscribe(uint16_t packetId, uint8_t qos);
|
||||
/* void onMqttSubscribe(uint16_t packetId, uint8_t qos);
|
||||
void onMqttUnsubscribe(uint16_t packetId);
|
||||
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total);
|
||||
void onMqttPublish(uint16_t packetId);
|
||||
void onMqttPublish(uint16_t packetId); */
|
||||
|
||||
//leds b_led(B_LED);
|
||||
leds g_led(G_LED, 100);
|
||||
@@ -47,8 +47,8 @@ leds g_led(G_LED, 100);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600, SERIAL_8N1);
|
||||
Serial1.begin(9600);
|
||||
Serial1.println("Booting"); // "Загрузка"
|
||||
//Serial1.begin(9600);
|
||||
//Serial1.println("Booting"); // "Загрузка"
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.hostname("MidRoom");
|
||||
@@ -81,10 +81,10 @@ void setup() {
|
||||
|
||||
mqttClient.onConnect(onMqttConnect);
|
||||
mqttClient.onDisconnect(onMqttDisconnect);
|
||||
mqttClient.onSubscribe(onMqttSubscribe);
|
||||
/* mqttClient.onSubscribe(onMqttSubscribe);
|
||||
mqttClient.onUnsubscribe(onMqttUnsubscribe);
|
||||
mqttClient.onMessage(onMqttMessage);
|
||||
mqttClient.onPublish(onMqttPublish);
|
||||
mqttClient.onPublish(onMqttPublish); */
|
||||
mqttClient.setServer(mqtt_server, 1883);
|
||||
|
||||
pinMode(MOV_SENS, INPUT_PULLUP);
|
||||
@@ -96,7 +96,7 @@ void setup() {
|
||||
digitalWrite(P_SENS, HIGH);
|
||||
digitalWrite(B_LED, HIGH);
|
||||
digitalWrite(R_LED, HIGH);
|
||||
Serial1.println(F("Begin MH-Z19"));
|
||||
//Serial1.println(F("Begin MH-Z19"));
|
||||
for(int i = 0; i < 5; i++){
|
||||
Serial1.print('.');
|
||||
delay(1000);
|
||||
@@ -125,30 +125,30 @@ void setup() {
|
||||
//Serial1.println(F("End Begin MH-Z19"));
|
||||
|
||||
Wire.begin();
|
||||
Serial1.println(F("Begin BME"));
|
||||
//Serial1.println(F("Begin BME"));
|
||||
bool status = bme.begin(BME280_ADDRESS_ALTERNATE);
|
||||
|
||||
|
||||
if (!status) {
|
||||
Serial1.println(F("Could not find a valid BME280 sensor, check wiring, address, sensor ID!"));
|
||||
//Serial1.println(F("Could not find a valid BME280 sensor, check wiring, address, sensor ID!"));
|
||||
}
|
||||
else{
|
||||
delay(100);
|
||||
p = bme.readPressure();
|
||||
t = bme.readTemperature();
|
||||
h = bme.readHumidity();
|
||||
Serial1.print(F("T: "));
|
||||
/* Serial1.print(F("T: "));
|
||||
Serial1.print(t);
|
||||
Serial1.print(F("\tH: "));
|
||||
Serial1.print(h);
|
||||
Serial1.print(F("\tP: "));
|
||||
Serial1.println(p);
|
||||
Serial1.println(p); */
|
||||
}
|
||||
|
||||
connectToWifi();
|
||||
|
||||
cRun = millis();
|
||||
Serial1.println(F("Start Loop"));
|
||||
//Serial1.println(F("Start Loop"));
|
||||
//(R_LED, HIGH);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void loop() {
|
||||
//r_led.tick();
|
||||
if (digitalRead(MOV_SENS) != old_mov){
|
||||
old_mov = digitalRead(MOV_SENS);
|
||||
Serial1.println(F("Change mov detected"));
|
||||
//Serial1.println(F("Change mov detected"));
|
||||
mqttClient.publish("/home/midroom/move", 1, false, old_mov ? "1" : "0");
|
||||
}
|
||||
|
||||
@@ -169,8 +169,8 @@ void loop() {
|
||||
cRun = millis();
|
||||
//if(mqttClient.connected()) digitalWrite(R_LED, LOW); else digitalWrite(R_LED, HIGH);
|
||||
adc = analogRead(A0);
|
||||
Serial1.print(F("ADC: "));Serial1.println(adc);
|
||||
Serial1.print(F("MQTT: "));Serial1.println(mqttClient.connected());
|
||||
// Serial1.print(F("ADC: "));Serial1.println(adc);
|
||||
// Serial1.print(F("MQTT: "));Serial1.println(mqttClient.connected());
|
||||
if(abs(adc - lastADC) > 50){
|
||||
lastADC = adc;
|
||||
itoa(adc, v, 10);
|
||||
@@ -178,7 +178,7 @@ void loop() {
|
||||
}
|
||||
if(meas){
|
||||
//Serial1.println(adc);
|
||||
Serial1.println("Measure");
|
||||
// Serial1.println("Measure");
|
||||
|
||||
pt = bme.readPressure();
|
||||
tt = bme.readTemperature();
|
||||
@@ -188,13 +188,13 @@ void loop() {
|
||||
Serial1.print(F("\tH: "));
|
||||
Serial1.print(ht);
|
||||
Serial1.print(F("\tP: "));
|
||||
Serial1.println(pt);
|
||||
*/ if(!isnan(pt))
|
||||
Serial1.println(pt); */
|
||||
if(!isnan(pt))
|
||||
p += (pt - p) / 60.0f ;
|
||||
else
|
||||
/* else
|
||||
{
|
||||
Serial1.println(F("Error BME"));
|
||||
}
|
||||
} */
|
||||
|
||||
if(!isnan(tt))
|
||||
t += (tt - t) / 30.0f ;
|
||||
@@ -206,8 +206,8 @@ void loop() {
|
||||
else{
|
||||
if(minCnt % 5 == 0){
|
||||
co2 = mhz19.getCO2();
|
||||
Serial1.print("CO2: ");
|
||||
Serial1.println(co2);
|
||||
/* Serial1.print("CO2: ");
|
||||
Serial1.println(co2); */
|
||||
digitalWrite(P_SENS, HIGH);
|
||||
bme.begin(BME280_ADDRESS_ALTERNATE);
|
||||
meas = true;
|
||||
@@ -252,28 +252,28 @@ void loop() {
|
||||
}
|
||||
|
||||
void connectToWifi() {
|
||||
Serial1.println(F("Connecting to Wi-Fi..."));
|
||||
// Serial1.println(F("Connecting to Wi-Fi..."));
|
||||
//Serial1.flush();
|
||||
WiFi.begin(ssid, password);
|
||||
}
|
||||
|
||||
void connectToMqtt() {
|
||||
Serial1.println(F("Connecting to MQTT..."));
|
||||
// Serial1.println(F("Connecting to MQTT..."));
|
||||
//Serial1.flush();
|
||||
mqttClient.connect();
|
||||
}
|
||||
|
||||
void onWifiConnect(const WiFiEventStationModeGotIP& event) {
|
||||
Serial1.println(F("Connected to Wi-Fi."));
|
||||
/* Serial1.println(F("Connected to Wi-Fi."));
|
||||
Serial1.print(F("IP: "));
|
||||
//Serial1.flush();
|
||||
Serial1.println(WiFi.localIP());
|
||||
Serial1.println(WiFi.localIP()); */
|
||||
digitalWrite(R_LED, LOW);
|
||||
connectToMqtt();
|
||||
}
|
||||
|
||||
void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
|
||||
Serial1.println(F("Disconnected from Wi-Fi."));
|
||||
// Serial1.println(F("Disconnected from Wi-Fi."));
|
||||
//Serial1.flush();
|
||||
mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
|
||||
wifiReconnectTimer.once(2, connectToWifi);
|
||||
@@ -281,10 +281,10 @@ void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
|
||||
}
|
||||
|
||||
void onMqttConnect(bool sessionPresent) {
|
||||
Serial1.println(F("Connected to MQTT."));
|
||||
/* Serial1.println(F("Connected to MQTT."));
|
||||
Serial1.print(F("Session present: "));
|
||||
//Serial1.flush();
|
||||
Serial1.println(sessionPresent);
|
||||
Serial1.println(sessionPresent); */
|
||||
//digitalWrite(B_LED, HIGH);
|
||||
//digitalWrite(R_LED, LOW);
|
||||
//uint16_t packetIdSub =
|
||||
@@ -300,7 +300,7 @@ void onMqttConnect(bool sessionPresent) {
|
||||
}
|
||||
|
||||
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
|
||||
Serial1.println("Disconnected from MQTT.");
|
||||
// Serial1.println("Disconnected from MQTT.");
|
||||
//digitalWrite(B_LED, LOW);
|
||||
//digitalWrite(R_LED, HIGH);
|
||||
if (WiFi.isConnected()) {
|
||||
@@ -309,7 +309,7 @@ void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
|
||||
digitalWrite(B_LED, HIGH);
|
||||
}
|
||||
|
||||
void onMqttSubscribe(uint16_t packetId, uint8_t qos) {
|
||||
/* void onMqttSubscribe(uint16_t packetId, uint8_t qos) {
|
||||
// //Serial1.println("Subscribe acknowledged.");
|
||||
// //Serial1.print(" packetId: ");
|
||||
// //Serial1.println(packetId);
|
||||
@@ -335,3 +335,4 @@ void onMqttPublish(uint16_t packetId) {
|
||||
//g_led.start();
|
||||
}
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user