Compare commits

..

2 Commits

Author SHA1 Message Date
80ea2dcec8 Remove redundant MQTT subscribe 2026-03-11 16:21:06 +01:00
505ff1ac98 Update README 2026-03-11 16:20:59 +01:00
4 changed files with 5 additions and 9 deletions

View File

@@ -2,6 +2,10 @@
CO2 sensor that collects and sends its data via MQTT to a server. The board of the sensor is the Wemos D1 mini ESP32 and the sensor is a SCD41.
#+ATTR_HTML: :width 40%
[[./board.jpg]]
** Pinout of the board
#+ATTR_HTML: :width 40%
@@ -9,7 +13,7 @@ CO2 sensor that collects and sends its data via MQTT to a server. The board of t
** Dependencies
- [[https://github.com/Sensirion/arduino-i2c-scd4x][Sensirion I²C SCD4X Arduino Library]]
- [[https://github.com/knolleary/pubsubclient][PubSubClient]]
- [[https://github.com/marvinroger/async-mqtt-client][Async MQTT client]]
- [[https://github.com/bblanchon/ArduinoJson][ArduinoJSON]]
** Configuration

BIN
board.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -20,8 +20,6 @@ void connect_mqtt();
void wlan_connection_handler(WiFiEvent_t event);
void on_mqtt_connection(bool session);
void on_mqtt_disconnection(AsyncMqttClientDisconnectReason reason);
size_t construct_json(float *data, char *buffer, int buffer_size);

View File

@@ -3,7 +3,6 @@
void initialize_wlan() { WiFi.onEvent(wlan_connection_handler); }
void initialize_mqtt() {
mqtt_client.onConnect(on_mqtt_connection);
mqtt_client.onDisconnect(on_mqtt_disconnection);
mqtt_client.setServer(config->mqtt_host, config->mqtt_port);
mqtt_client.setCredentials(config->mqtt_user, config->mqtt_password);
@@ -32,11 +31,6 @@ void wlan_connection_handler(WiFiEvent_t event) {
}
}
void on_mqtt_connection(bool session) {
Serial.println("MQTT connected");
mqtt_client.subscribe(config->topic, 2);
};
void on_mqtt_disconnection(AsyncMqttClientDisconnectReason reason) {
Serial.println("MQTT disconnected");