<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Esphome on foosel.net</title><link>https://foosel.net/tags/esphome/</link><description>Recent content in Esphome on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Fri, 14 Jul 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/esphome/feed.xml" rel="self" type="application/rss+xml"/><item><title>Why ESPHome might fail compiling a custom component with 'fatal error: string: No such file or directory'</title><link>https://foosel.net/til/why-esphome-might-fail-compiling-a-custom-component/</link><pubDate>Fri, 14 Jul 2023 00:00:00 +0000</pubDate><guid>https://foosel.net/til/why-esphome-might-fail-compiling-a-custom-component/</guid><description>&lt;p&gt;I just spent several hours trying to figure out why ESPHome refused to compile a custom component I was working on. The error message I got was&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Compiling .pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o
In file included from src/esphome/components/sound_pressure/sound_pressure_sensor.h:3,
from src/esphome/components/sound_pressure/sound_pressure_sensor.c:1:
src/esphome/core/component.h:3:10: fatal error: string: No such file or directory
3 | #include &amp;lt;string&amp;gt;
| ^~~~~~~~
compilation terminated.
Compiling .pioenvs/datenzwerg-sleepy/src/main.cpp.o
*** [.pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o] Error 1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Other external and internal components compiled just fine, so that was quite a head scratcher, until I just &lt;em&gt;finally&lt;/em&gt; noticed something in my source tree: my custom component&amp;rsquo;s source file had the file ending &lt;code&gt;.c&lt;/code&gt; instead of &lt;code&gt;.cpp&lt;/code&gt;. And that caused all of this, a quick rename from &lt;code&gt;sound_pressure_sensor.c&lt;/code&gt; to &lt;code&gt;sound_pressure_sensor.cpp&lt;/code&gt; resolved the compilation error 🤦‍♀️&lt;/p&gt;</description><content:encoded><![CDATA[<p>I just spent several hours trying to figure out why ESPHome refused to compile a custom component I was working on. The error message I got was</p>
<pre tabindex="0"><code>Compiling .pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o
In file included from src/esphome/components/sound_pressure/sound_pressure_sensor.h:3,
                 from src/esphome/components/sound_pressure/sound_pressure_sensor.c:1:
src/esphome/core/component.h:3:10: fatal error: string: No such file or directory
    3 | #include &lt;string&gt;
      |          ^~~~~~~~
compilation terminated.
Compiling .pioenvs/datenzwerg-sleepy/src/main.cpp.o
*** [.pioenvs/datenzwerg-sleepy/src/esphome/components/sound_pressure/sound_pressure_sensor.c.o] Error 1
</code></pre><p>Other external and internal components compiled just fine, so that was quite a head scratcher, until I just <em>finally</em> noticed something in my source tree: my custom component&rsquo;s source file had the file ending <code>.c</code> instead of <code>.cpp</code>. And that caused all of this, a quick rename from <code>sound_pressure_sensor.c</code> to <code>sound_pressure_sensor.cpp</code> resolved the compilation error 🤦‍♀️</p>
<p>And since it was utterly impossible for me to find anything about this particular problem online, I decided to share my mishap with all of you here, so that in the future someone else doing an internet search for this will have more luck than me today and not waste hours on this 😅</p>
]]></content:encoded></item><item><title>TFA Dostmann meets ESPHome</title><link>https://foosel.net/blog/2022-01-03-tfa-dostmann-meets-esphome/</link><pubDate>Mon, 03 Jan 2022 00:00:00 +0000</pubDate><guid>https://foosel.net/blog/2022-01-03-tfa-dostmann-meets-esphome/</guid><description>Integrating a CO2 sensor into my HA setup</description><content:encoded><![CDATA[<p>I attended RC3 from December 27th until December 30th. While it was (once again)
only a virtual edition of the Chaos Communication Congress, at least this time
around I managed to have a similar experience to 36c3, as in, I spent the last two days
mostly hanging out with a bunch of fellow geeks in a fun location (a jitsi conference
that also included a camera pointing at an aquarium full of fish) and nerding out
while tinkering around with electronics.</p>
<p>And thus I finally integrated the CO2 sensor unit I bought a couple weeks ago into
my Home Automation setup, with the help of a Wemos D1 Mini and <a href="https://esphome.io">ESPHome</a>. At first
I went with an ESP12, a voltage regulator and a <a href="https://github.com/schinken/esp8266-co2monitor">different firmware</a>,
but that didn&rsquo;t work out due to the ESP not wanting to behave (my guess is I didn&rsquo;t wire the barebone module
up correctly or the voltage regulator was causing issues) and I also got some weird readings
reported by the firmware (20k ppm CO2 - I know the air in my office can get bad after a couple of hours of
coding, but not THAT bad).</p>
<p>The CO2 sensor is an &ldquo;AIRCO2NTROL MINI&rdquo; from TFA Dostmann, but it is also available under other names
with a very similar case and more or less the same internals, as I learned from the
<a href="https://esphome.io/components/sensor/zyaura.html">ESPHome docs</a>. Where my Dostmann edition seems to differ from the majority is the
pin order of the internal debug port, which turned out to have CLK and DATA swapped
in my case, which caused me quite the headache and a bit of frustration. So just for future reference,
the pin order I found in my device is 5V - Data - CLK - Gnd from left to right with the hose to the left:</p>
<p><img alt="The pinout of the sensor&rsquo;s debug port, 5V - Data - CLK - Gnd" loading="lazy" src="/blog/2022-01-03-tfa-dostmann-meets-esphome/tfa-dostmann-pinout.jpg"></p>
<p>I hooked these up to the Wemos D1 Mini (clone) like this:</p>
<p><img alt="A wiring diagram of how to hookup the Wemos D1 mini to the debug port, 5V to 5V, Gnd to Gnd, Data to D1 and CLK to D2" loading="lazy" src="/blog/2022-01-03-tfa-dostmann-meets-esphome/tfa-dostmann-wemos-d1-wiring.png"></p>
<p>So 5V to 5V, Gnd to Gnd, Data to D1 and CLK to D2.</p>
<p>The ESPHome config I then flashed to the D1 is the following:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#f92672">esphome</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">dostmann-office</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">platform</span>: <span style="color:#ae81ff">ESP8266</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">board</span>: <span style="color:#ae81ff">d1_mini</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">logger</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">mqtt</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">broker</span>: !<span style="color:#ae81ff">secret mqtt_iot_broker</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">ota</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">password</span>: !<span style="color:#ae81ff">secret ota_pass</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">wifi</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">ssid</span>: !<span style="color:#ae81ff">secret wifi_iot_ssid</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">password</span>: !<span style="color:#ae81ff">secret wifi_iot_pass</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">ap</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ssid</span>: <span style="color:#e6db74">&#34;Dostmann Office Fallback&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">password</span>: !<span style="color:#ae81ff">secret fallback_pass</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">power_save_mode</span>: <span style="color:#ae81ff">high</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">captive_portal</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">sensor</span>:
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">platform</span>: <span style="color:#ae81ff">zyaura</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">clock_pin</span>: <span style="color:#ae81ff">D2</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">data_pin</span>: <span style="color:#ae81ff">D1</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">co2</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">name</span>: <span style="color:#e6db74">&#34;Office Dostmann CO2&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">temperature</span>:
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">name</span>: <span style="color:#e6db74">&#34;Office Dostmann Temperature&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  - <span style="color:#f92672">platform</span>: <span style="color:#ae81ff">wifi_signal</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">name</span>: <span style="color:#e6db74">&#34;Office Dostmann WiFi Signal&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">update_interval</span>: <span style="color:#ae81ff">60s</span>
</span></span></code></pre></div><p>(If you are wondering about the <code>!secret</code> stuff, those values are contained in
a <code>secret.yaml</code> file in my esphome folder, and you can read all about that
<a href="https://esphome.io/guides/faq.html#tips-for-using-esphome">in the ESPHome docs here</a>.)</p>
<p>And with that I could now see the sensor in my Home Assistant instance and forward the data
easily to my InfluxDB &amp; Grafana monitoring stack.</p>
<p>To put everything together physically, fully contained, I used <a href="https://www.thingiverse.com/thing:4225732">this alternative backplate</a>
by Stefan Kern.</p>
<p><img alt="The alternative backplate in place, closing up the sensor and containing the Wemos D1 Mini as well" loading="lazy" src="/blog/2022-01-03-tfa-dostmann-meets-esphome/tfa-dostmann-back.jpg"></p>
<p>However, I&rsquo;ve noticed a temperature increase of around 3°C with it and the ESP
in place, and I fear this might be screwing with the CO2 sensor&rsquo;s calibration (as the measurement
is temperature sensitive). I already mitigated this a bit by setting the chip to power save and adding some strategically placed aluminium tape,
but that&rsquo;s only improved things slightly. Due to that I plan to redesign the
backplate to have the ESP outside the sensor case, in its own compartment. I
hope that will solve the &ldquo;running hot&rdquo; issue for good then, but we&rsquo;ll see.</p>
<p><em>Update from January 27th 2022</em> I redesigned the backplate and now have a solution that seems to work better, based on the reported temperature and CO2. <a href="https://www.prusaprinters.org/prints/119968-airco2ntrol-mini-backplate-with-wemos-d1-mini">I&rsquo;ve published it here</a>.</p>
<p>In any case, for now I at least got a reliable indicator of my office&rsquo;s CO2 levels that also now
are trackable long term, and I have also forwarded the current values to my <a href="https://awtrixdocs.blueforcer.de/">AWTRIX mini</a>
via some NodeRED flow that also takes care of color coding. Further possibilities include
flashing the office lights or some audio cues, should just the visual warning turn out
to be insufficient in the long term 😉</p>
<p><img alt="CO2 sensor data graphed over two days" loading="lazy" src="/blog/2022-01-03-tfa-dostmann-meets-esphome/grafana-co2.png"></p>
]]></content:encoded></item></channel></rss>