{"id":243026,"date":"2026-06-22T15:00:05","date_gmt":"2026-06-22T13:00:05","guid":{"rendered":"https:\/\/emariete.com\/co2-gadget-guia-mqtt\/"},"modified":"2026-07-07T09:10:00","modified_gmt":"2026-07-07T07:10:00","slug":"co2-gadget-mqtt-guide","status":"publish","type":"post","link":"https:\/\/emariete.com\/en\/co2-gadget-guia-mqtt\/","title":{"rendered":"CO2 Gadget MQTT Guide: Home Assistant, Alarms and Remote Commands"},"content":{"rendered":"<p class=\"wp-block-paragraph\">The integration of CO2 Gadget with Home Assistant via MQTT is fully automatic thanks to MQTT Discovery: as soon as your meter connects to the broker, Home Assistant creates all the sensors, configuration entities and selectors without you having to touch the YAML. Here you\u2019ll find the full list of topics, supported remote commands and examples of automations.<\/p>\n\n\n\n\n\n\n<div style=\"background:#fff8dc;border:1px solid #e6c300;border-radius:8px;padding:12px 16px;margin:12px 0;font-size:14px;line-height:1.5;color:#333\">\n<strong>Documentation is currently being updated.<\/strong> We are currently reviewing and improving all our pages. You may come across a broken link or some content that hasn\u2019t been finalised yet. If you spot anything that isn\u2019t quite right, please help us fix it at <a href=\"https:\/\/github.com\/melkati\/CO2-Gadget\/issues\" style=\"color:#0066cc\">GitHub<\/a>.\n<\/div>\n\n\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<p class=\"wp-block-paragraph\">The protocol <strong>MQTT<\/strong> enables CO2 Gadget <strong>publish<\/strong> its real-time measurements of CO\u2082, temperature, humidity, battery level and particulate matter (PM), as well as <strong>receive remote commands<\/strong> to calibrate the sensor or change the settings. In addition, the functionality of <strong>Home Assistant Discovery<\/strong> makes integration with your home automation system completely automatic.<\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Basic MQTT configuration<\/h2>\n\n\n<p class=\"wp-block-paragraph\">To use MQTT, you need to have the <strong>Wi-Fi enabled<\/strong>. You can configure MQTT via the meter\u2019s menu, the website or the MyAmbiance app.<\/p>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Parameter<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><strong>Enable MQTT<\/strong><\/td><td>Enable or disable MQTT (ON \/ OFF)<\/td><\/tr><tr><td><strong>Topic<\/strong><\/td><td>Root of the topics where the data will be published (default `CO2-Gadget`)<\/td><\/tr><tr><td><strong>Client ID<\/strong><\/td><td>Unique device identifier on the broker (default `mqttClientId` macro)<\/td><\/tr><tr><td><strong>IP Broker<\/strong><\/td><td>The IP address of your MQTT broker (Mosquitto, etc.)<\/td><\/tr><tr><td><strong>Port<\/strong><\/td><td>Broker port (default 1883)<\/td><\/tr><tr><td><strong>Username \/ Password<\/strong><\/td><td>Authentication with the broker (optional)<\/td><\/tr><tr><td><strong>Discovery Prefix<\/strong><\/td><td>Discovery prefix (default `homeassistant\/`)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<p class=\"wp-block-paragraph\">Connection retries: <code>secondsBetweenRetries = 15 s<\/code>, <code>maxMQTTmqttConnectionRetries = 2<\/code>. Buffer PubSubClient: 1024 bytes.<\/p>\n\n\n<p class=\"wp-block-paragraph\">You can access the settings via the website: <code>http:\/\/ip<em>del<\/em>meter\/preferences.html<\/code>, or from the on-screen menu: <strong>Settings \u2192 MQTT Configuration<\/strong>.<\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Topics published by your CO\u2082 monitor<\/h2>\n\n\n<p class=\"wp-block-paragraph\">Once connected to the broker, CO2 Gadget publishes the measurements to the following topics (using the root topic you have configured):<\/p>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Topic<\/th><th>Value<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>`topic\/co2`<\/td><td>892<\/td><td>CO\u2082 in ppm<\/td><\/tr><tr><td>`topic\/temp`<\/td><td>24.50<\/td><td>Temperature in \u00b0C<\/td><\/tr><tr><td>`topic\/humi`<\/td><td>45.20<\/td><td>Relative humidity at %<\/td><\/tr><tr><td>`topic\/voltage`<\/td><td>4.10<\/td><td>Battery voltage at <strong>V<\/strong> (float)<\/td><\/tr><tr><td>`topic\/battery`<\/td><td>85<\/td><td>Battery percentage at <strong>%<\/strong> (int)<\/td><\/tr><tr><td>`topic\/pm1`<\/td><td>5<\/td><td>PM1.0 (\u00b5g\/m\u00b3) if a PM sensor is present<\/td><\/tr><tr><td>`topic\/pm25`<\/td><td>12<\/td><td>PM2.5 (\u00b5g\/m\u00b3) if a PM sensor is present<\/td><\/tr><tr><td>`topic\/pm4`<\/td><td>8<\/td><td>PM4.0 (\u00b5g\/m\u00b3) if a PM sensor is present<\/td><\/tr><tr><td>`topic\/pm10`<\/td><td>15<\/td><td>PM10 (\u00b5g\/m\u00b3) if a PM sensor is present<\/td><\/tr><tr><td>`topic\/uptime`<\/td><td>`12d 03h 45m`<\/td><td>Time on, readable format<\/td><\/tr><tr><td>`topic\/freeMem`<\/td><td>102400<\/td><td>Free heap space in bytes<\/td><\/tr><tr><td>`topic\/wifiRSSI`<\/td><td>-65<\/td><td>WiFi RSSI in dBm<\/td><\/tr><tr><td>`topic\/IP`<\/td><td>`192.168.1.50`<\/td><td>Current IP address of the meter<\/td><\/tr><tr><td>`topic\/MAC`<\/td><td>`AA:BB:CC:\u2026`<\/td><td>ESP32 MAC address<\/td><\/tr><tr><td>`topic\/hostname`<\/td><td>`CO2-Gadget`<\/td><td>mDNS hostname<\/td><\/tr><tr><td>`topic\/status`<\/td><td>`OK`<\/td><td>Availability (Last Will and Testament)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Alarm topics<\/h2>\n\n\n<p class=\"wp-block-paragraph\">CO2 Gadget also displays messages when the configured concentration levels are reached. The alarms have <strong>hysteresis<\/strong> to prevent oscillations: <code>PIN<em>HYSTERESIS = 100 ppm<\/code> for the GPIO outputs, <code>BUZZER<\/em>HYSTERESIS = 50 ppm<\/code> for the buzzer. The outputs are reset when <code>co2 &lt; co2RedRange \u2212 hyst<\/code>.<\/p>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Topic<\/th><th>Payload ON<\/th><th>Payload OFF<\/th><\/tr><\/thead><tbody><tr><td>`topic\/green`<\/td><td>Normal level<\/td><td>The orange alert level has been exceeded<\/td><\/tr><tr><td>`topic\/orange`<\/td><td>Orange alert<\/td><td>Hysteresis drop<\/td><\/tr><tr><td>`topic\/network`<\/td><td>Red alert<\/td><td>Hysteresis drop<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Home Assistant Automatic Discovery<\/h2>\n\n\n<p class=\"wp-block-paragraph\">If you enable <strong>MQTT Discovery<\/strong>, CO2 Gadget <strong>It configures itself automatically in Home Assistant<\/strong> without you having to do a thing. They are recorded <strong>13 organisations<\/strong> under the prefix <code>homeassistant\/<\/code>:<\/p>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Organisation<\/th><th>Class<\/th><th>Icon<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>`battery`<\/td><td>diagnostic<\/td><td>`mdi:battery`<\/td><td>Battery percentage (%)<\/td><\/tr><tr><td>`voltage`<\/td><td>diagnostic<\/td><td>`mdi:flash`<\/td><td>Battery voltage (V)<\/td><\/tr><tr><td>`co2`<\/td><td>sensor<\/td><td>`mdi:molecule-co2`<\/td><td>CO\u2082 in ppm<\/td><\/tr><tr><td>`temp`<\/td><td>sensor<\/td><td>`mdi:temperature-celsius`<\/td><td>Temperature (\u00b0C)<\/td><\/tr><tr><td>`humi`<\/td><td>sensor<\/td><td>`mdi:water-percent`<\/td><td>Relative humidity (%)<\/td><\/tr><tr><td>`PM1`, `PM2.5`, `PM4`, `PM10`<\/td><td>sensor<\/td><td>`mdi:air-filter`<\/td><td>Particulate matter (\u00b5g\/m\u00b3, only if a PM sensor is present)<\/td><\/tr><tr><td>`freeMem`<\/td><td>diagnostic<\/td><td>`mdi:memory`<\/td><td>Free heap (bytes)<\/td><\/tr><tr><td>`wifiRSSI`<\/td><td>diagnostic<\/td><td>`mdi:wifi`<\/td><td>WiFi RSSI (dBm)<\/td><\/tr><tr><td>`uptime`<\/td><td>diagnostic<\/td><td>`mdi:clock-time-eight-outline`<\/td><td>Time on<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<p class=\"wp-block-paragraph\"><strong>Device information:<\/strong> <code>manufacturer = emariete.com<\/code>, <code>model = CO2 Gadget<\/code>, <code>hw<em>version = FLAVOUR<\/code>, <code>sw<\/em>version = \" ()\"<\/code>, <code>configuration<em>url = http:\/\/<\/code>. The <code>object<\/em>id<\/code> is generated as <code>co2<em>gadget<\/em><\/code> (fallback). Also compatible with <strong>OpenHAB<\/strong> y <strong>HomeSeer<\/strong>.<\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Remote commands via MQTT<\/h2>\n\n\n<p class=\"wp-block-paragraph\">As well as uploading data, you can control your meter remotely:<\/p>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Topic<\/th><th>Payload<\/th><th>Function<\/th><\/tr><\/thead><tbody><tr><td>`topic\/calibration`<\/td><td>400<\/td><td>Forced calibration (400\u20132000 ppm)<\/td><\/tr><tr><td>`topic\/ambientpressure`<\/td><td>1013<\/td><td>Pressure compensation (mbar)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">ThresholdManager: smart posts<\/h2>\n\n\n<p class=\"wp-block-paragraph\">The system of <strong>smart thresholds<\/strong> evaluates 4 independent channels (<strong>Display<\/strong>, <strong>BLE<\/strong>, <strong>MQTT<\/strong>, <strong>ESP-NOW<\/strong>). Each channel only sends a message when the value crosses the configured threshold \u2014 this prevents unnecessary MQTT traffic in low-power mode. Configurable from the page <code>\/low_power.html<\/code> (4 tabs, one per channel) and from <code>getThresholdsAsJson<\/code> \/ <code>saveThresholds<\/code>. Ideal for saving battery life and reducing bandwidth usage on the broker.<\/p>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Solution<\/th><\/tr><\/thead><tbody><tr><td>It does not connect to the broker<\/td><td>Check the broker\u2019s IP address and ensure Wi-Fi is enabled<\/td><\/tr><tr><td>There is no data in HA<\/td><td>Check that the root topic matches<\/td><\/tr><tr><td>Discovery isn't working<\/td><td>Enable MQTT Discovery in the settings<\/td><\/tr><tr><td>Values are not updated<\/td><td>Check the thresholds in ThresholdManager<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<h2 class=\"wp-block-heading\">Important notes<\/h2>\n\n\n<ul class=\"wp-block-list\">\n<li>MQTT requires Wi-Fi to be enabled<\/li>\n<li>In LOW_POWER mode, the frequency depends on the wake cycles<\/li>\n<li>No cloud services \u2014 everything on your local network<\/li>\n<li><strong>CO2 Gadget offers more comprehensive MQTT integration than most commercial meters<\/strong><\/li>\n<\/ul>\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n<p class=\"wp-block-paragraph\"><em>Did you find this helpful? Share this article. Have a look at the <a href=\"https:\/\/emariete.com\/en\/co2-gadget-guide-menu\/\">Menu Guide<\/a>. Any questions? Ask on the <a href=\"https:\/\/t.me\/emariete_chat\">Telegram group<\/a> or open a <a href=\"https:\/\/github.com\/melkati\/CO2-Gadget\/issues\">issue on GitHub<\/a>.<\/em><\/p>\n<div class=\"essb_break_scroll\"><\/div>","protected":false},"excerpt":{"rendered":"<p>CO2 Gadget MQTT Guide. Integrate your high-quality CO\u2082 sensor with Home Assistant: publish CO\u2082, temperature, humidity, battery level and PM data; receive remote commands; set up alarms with hysteresis; and enable automatic discovery.<\/p>","protected":false},"author":1,"featured_media":243273,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[13,14,16],"tags":[24,71,33,39],"class_list":["post-243026","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-co2-gadget","category-domotica","category-medidor-co2","tag-co2-gadget","tag-co2-gadget-guias","tag-home-assistant","tag-mqtt"],"modified_by":null,"uagb_featured_image_src":{"full":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739.jpeg",1376,768,false],"thumbnail":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739-150x150.jpeg",150,150,true],"medium":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739-300x167.jpeg",300,167,true],"medium_large":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739-768x429.jpeg",768,429,true],"large":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739-1024x572.jpeg",1024,572,true],"1536x1536":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739.jpeg",1376,768,false],"2048x2048":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739.jpeg",1376,768,false],"trp-custom-language-flag":["https:\/\/emariete.com\/wp-content\/uploads\/2026\/07\/Gu\ufffda_MQTT_blue_banner_202607050739-18x10.jpeg",18,10,true]},"uagb_author_info":{"display_name":"Mariete","author_link":"https:\/\/emariete.com\/en\/author\/admin_xlyz052h\/"},"uagb_comment_info":0,"uagb_excerpt":"Gu\u00eda MQTT de CO2 Gadget. Integra tu medidor de CO\u2082 de alta calidad con Home Assistant: publica CO\u2082, temperatura, humedad, bater\u00eda y PM, recibe comandos remotos, configura alarmas con hist\u00e9resis y activa el Discovery autom\u00e1tico.","_links":{"self":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts\/243026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/comments?post=243026"}],"version-history":[{"count":12,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts\/243026\/revisions"}],"predecessor-version":[{"id":243281,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/posts\/243026\/revisions\/243281"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/media\/243273"}],"wp:attachment":[{"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/media?parent=243026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/categories?post=243026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emariete.com\/en\/wp-json\/wp\/v2\/tags?post=243026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}