<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Koen Vervloesem - Technology Writer</title><link>https://koen.vervloesem.eu/</link><description>Koen Vervloesem, freelance journalist and writer specialized in Linux and open source, computer security, privacy, programming, artificial intelligence and Internet of Things</description><atom:link href="https://koen.vervloesem.eu/rss.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Copyright © 2025 &lt;a href="mailto:koen@vervloesem.eu"&gt;Koen Vervloesem&lt;/a&gt; &lt;p xmlns:dct="http://purl.org/dc/terms/" xmlns:cc="http://creativecommons.org/ns#" class="license-text"&gt;This work by &lt;a rel="cc:attributionURL" href="mailto:koen@vervloesem.eu"&gt;&lt;span rel="cc:attributionName"&gt;Koen Vervloesem&lt;/span&gt;&lt;/a&gt; is licensed under &lt;a href="https://creativecommons.org/licenses/by-sa/4.0"&gt;CC BY-SA 4.0&lt;img style="height:22px!important;margin-left: 3px;vertical-align:text-bottom;" src="/cc.svg" /&gt;&lt;img  style="height:22px!important;margin-left: 3px;vertical-align:text-bottom;" src="/by.svg" /&gt;&lt;img  style="height:22px!important;margin-left: 3px;vertical-align:text-bottom;" src="/sa.svg" /&gt;&lt;/a&gt; | &lt;a href="/legal-notice/"&gt;Legal notice&lt;/a&gt; | &lt;a href="/privacy-policy/"&gt;Privacy policy&lt;/a&gt;&lt;/p&gt;</copyright><lastBuildDate>Sat, 15 Mar 2025 20:05:59 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>How to install alternative firmware to the SenseCAP M2 Data Only LoRaWAN Indoor Gateway</title><link>https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;When I searched for a new &lt;a class="reference external" href="https://lora-alliance.org/about-lorawan/"&gt;LoRaWAN&lt;/a&gt; indoor gateway, my primary criterion was that it should be capable of running open-source firmware. The &lt;a class="reference external" href="https://github.com/chirpstack/chirpstack-gateway-os"&gt;ChirpStack Gateway OS&lt;/a&gt; firmware caught my attention. It's based on &lt;a class="reference external" href="https://openwrt.org"&gt;OpenWrt&lt;/a&gt; and has regular &lt;a class="reference external" href="https://github.com/chirpstack/chirpstack-gateway-os/releases"&gt;releases&lt;/a&gt;. Its recent &lt;a class="reference external" href="https://github.com/chirpstack/chirpstack-gateway-os/releases"&gt;4.7.0 release&lt;/a&gt; added support for the &lt;a class="reference external" href="https://wiki.seeedstudio.com/Network/SenseCAP_Network/SenseCAP_M2_Multi_Platform/SenseCAP_M2_Multi_Platform_Overview/"&gt;Seeed SenseCAP M2 Multi-Platform Gateway&lt;/a&gt;, which seemed like an interesting and affordable option for a LoRaWAN gateway.&lt;/p&gt;
&lt;p&gt;Unfortunately, this device wasn't available through my usual suppliers. However, &lt;a class="reference external" href="https://www.tinytronics.nl"&gt;TinyTronics&lt;/a&gt; did stock the &lt;a class="reference external" href="https://wiki.seeedstudio.com/Network/SenseCAP_Network/SenseCAP_M2_Data_Only-Helium_gateway/SenseCAP_M2_Data_Only_Overview/"&gt;SenseCAP M2 Data Only&lt;/a&gt;, which looked to me like exactly the same hardware but with different firmware to support the &lt;a class="reference external" href="https://www.helium.com"&gt;Helium LongFi Network&lt;/a&gt;. Ten minutes before their closing time on a Friday evening, I called their office to confirm whether I could use it as a LoRaWAN gateway on an arbitrary network. I was helped by a guy who was surprisingly friendly for the time of my call, and after a quick search he confirmed that it was indeed the same hardware. After this, I ordered this Helium variant of the gateway.&lt;/p&gt;
&lt;p&gt;Upon its arrival, the first thing I did after connecting the antenna and powering it on was to search for the &lt;strong&gt;Backup/Flash Firmware&lt;/strong&gt; entry in Luci's &lt;strong&gt;System&lt;/strong&gt; menu, as explained in Seeed Studio's wiki page about &lt;a class="reference external" href="https://wiki.seeedstudio.com/flash_opensource_firmware_to_m2_gateway/#get-and-flash-firmware-via-luci"&gt;flashing open-source firmware to the M2 Gateway&lt;/a&gt;. Unfortunately, the M2 Data Only seemed to have a locked-down version of OpenWrt's Luci interface, without the ability to flash other firmware. There was no SSH access either. I tried to &lt;a class="reference external" href="https://wiki.seeedstudio.com/flash_opensource_firmware_to_m2_gateway/#get-and-flash-firmware-via-tftp"&gt;flash the firmware via TFTP&lt;/a&gt;, but to no avail..&lt;/p&gt;
&lt;p&gt;After these disappointing attempts, I submitted a support ticket to Seeed Studio, explaining my intention to install alternative firmware on the device, as I wasn't interested in the Helium functionality. I received a helpful response by a field application engineer with the high-level steps to do this, although I had to fill in some details myself. After getting stuck on a missing step, my follow-up query was promptly answered with the missing information and an apology for the incomplete instructions, and I finally succeeded in installing the Chirpstack Gateway OS on the SenseCAP M2 Data Only. Here are the detailed steps I followed.&lt;/p&gt;
&lt;section id="initial-serial-connection"&gt;
&lt;h2&gt;Initial serial connection&lt;/h2&gt;
&lt;p&gt;Connect the gateway via USB and start a serial connection with a baud rate of 57600. I used &lt;a class="reference external" href="https://www.gnu.org/software/screen/"&gt;GNU Screen&lt;/a&gt; for this purpose:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_87838a4539304db8a90fbfbcb075237c-1" name="rest_code_87838a4539304db8a90fbfbcb075237c-1" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_87838a4539304db8a90fbfbcb075237c-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;screen&lt;span class="w"&gt; &lt;/span&gt;/dev/ttyUSB0&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;57600&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When the &lt;a class="reference external" href="https://www.u-boot.org"&gt;U-Boot&lt;/a&gt; boot loader shows its options, press &lt;strong&gt;0&lt;/strong&gt; for &lt;strong&gt;Load system code then write to Flash via Serial&lt;/strong&gt;:&lt;/p&gt;
&lt;img alt="/images/sensecap-m2-uboot-menu.png" class="align-center" src="https://koen.vervloesem.eu/images/sensecap-m2-uboot-menu.png"&gt;
&lt;p&gt;You'll then be prompted to switch the baud rate to 230400 and press ENTER. I terminated the screen session with Ctrl+a k and reconnected with the new baud rate:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_4086764ae8c8462c83062aaa9693b84b-1" name="rest_code_4086764ae8c8462c83062aaa9693b84b-1" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_4086764ae8c8462c83062aaa9693b84b-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;screen&lt;span class="w"&gt; &lt;/span&gt;/dev/ttyUSB0&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;230400&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/section&gt;
&lt;section id="sending-the-firmware-with-kermit"&gt;
&lt;h2&gt;Sending the firmware with Kermit&lt;/h2&gt;
&lt;p&gt;Upon pressing ENTER, you'll see the message &lt;strong&gt;Ready for binary (kermit) download to 0x80100000 at 230400 bps...&lt;/strong&gt;. I never used the &lt;a class="reference external" href="https://www.kermitproject.org"&gt;Kermit&lt;/a&gt; protocol before, but I installed &lt;code class="docutils literal"&gt;ckermit&lt;/code&gt; and found the procedure in a StackOverflow response to the question &lt;a class="reference external" href="https://stackoverflow.com/questions/38279621/how-to-send-boot-files-over-uart"&gt;How to send boot files over uart&lt;/a&gt;. After some experimenting, I found that I needed to use the following commands:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-1" name="rest_code_94b595435d454e2481a6f48e5ed76c48-1" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-1"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;koan@nov:~/Downloads$&lt;span class="w"&gt; &lt;/span&gt;kermit
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-2" name="rest_code_94b595435d454e2481a6f48e5ed76c48-2" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-2"&gt;&lt;/a&gt;C-Kermit&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;.0&lt;span class="w"&gt; &lt;/span&gt;pre-Beta.11,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;06&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Feb&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2024&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;Linux+SSL&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;64&lt;/span&gt;-bit&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-3" name="rest_code_94b595435d454e2481a6f48e5ed76c48-3" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-3"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;Copyright&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;C&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1985&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2024&lt;/span&gt;,
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-4" name="rest_code_94b595435d454e2481a6f48e5ed76c48-4" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;Trustees&lt;span class="w"&gt; &lt;/span&gt;of&lt;span class="w"&gt; &lt;/span&gt;Columbia&lt;span class="w"&gt; &lt;/span&gt;University&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;City&lt;span class="w"&gt; &lt;/span&gt;of&lt;span class="w"&gt; &lt;/span&gt;New&lt;span class="w"&gt; &lt;/span&gt;York.
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-5" name="rest_code_94b595435d454e2481a6f48e5ed76c48-5" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;Open&lt;span class="w"&gt; &lt;/span&gt;Source&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;-clause&lt;span class="w"&gt; &lt;/span&gt;BSD&lt;span class="w"&gt; &lt;/span&gt;license&lt;span class="w"&gt; &lt;/span&gt;since&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2011&lt;/span&gt;.
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-6" name="rest_code_94b595435d454e2481a6f48e5ed76c48-6" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-6"&gt;&lt;/a&gt;Type&lt;span class="w"&gt; &lt;/span&gt;?&lt;span class="w"&gt; &lt;/span&gt;or&lt;span class="w"&gt; &lt;/span&gt;HELP&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;help.
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-7" name="rest_code_94b595435d454e2481a6f48e5ed76c48-7" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;set&lt;span class="w"&gt; &lt;/span&gt;port&lt;span class="w"&gt; &lt;/span&gt;/dev/ttyUSB0
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-8" name="rest_code_94b595435d454e2481a6f48e5ed76c48-8" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-8"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;set&lt;span class="w"&gt; &lt;/span&gt;speed&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;230400&lt;/span&gt;
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-9" name="rest_code_94b595435d454e2481a6f48e5ed76c48-9" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-9"&gt;&lt;/a&gt;/dev/ttyUSB0,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;230400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bps
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-10" name="rest_code_94b595435d454e2481a6f48e5ed76c48-10" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-10"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;set&lt;span class="w"&gt; &lt;/span&gt;carrier-watch&lt;span class="w"&gt; &lt;/span&gt;off
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-11" name="rest_code_94b595435d454e2481a6f48e5ed76c48-11" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-11"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;set&lt;span class="w"&gt; &lt;/span&gt;flow-control&lt;span class="w"&gt; &lt;/span&gt;none
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-12" name="rest_code_94b595435d454e2481a6f48e5ed76c48-12" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-12"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;set&lt;span class="w"&gt; &lt;/span&gt;prefixing&lt;span class="w"&gt; &lt;/span&gt;all
&lt;a id="rest_code_94b595435d454e2481a6f48e5ed76c48-13" name="rest_code_94b595435d454e2481a6f48e5ed76c48-13" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_94b595435d454e2481a6f48e5ed76c48-13"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;send&lt;span class="w"&gt; &lt;/span&gt;openwrt.bin
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class="docutils literal"&gt;openwrt.bin&lt;/code&gt; file was the firmware image from Seeed's own &lt;a class="reference external" href="https://github.com/Seeed-Solution/LoRa_Gateway_OpenWRT"&gt;LoRa_Gateway_OpenWRT&lt;/a&gt; firmware. I decided to install this instead of the ChirpStack Gateway OS because it was a smaller image and hence flashed more quickly (although still almost 8 minutes).&lt;/p&gt;
&lt;img alt="/images/sensecap-m2-kermit-send.png" class="align-center" src="https://koen.vervloesem.eu/images/sensecap-m2-kermit-send.png"&gt;
&lt;p&gt;After the file was sent successfully, I didn't see any output when reestablishing a serial connection. After responding this to Seeed's field application engineer, he replied that the gateway should display a prompt requesting to switch the baud rate again to 57600.&lt;/p&gt;
&lt;p&gt;Kermit can also function as a serial terminal, so I just stayed within the Kermit command line and entered the following commands:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-1" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-1" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-1"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;set&lt;span class="w"&gt; &lt;/span&gt;speed&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;57600&lt;/span&gt;
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-2" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-2" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-2"&gt;&lt;/a&gt;/dev/ttyUSB0,&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;57600&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bps
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-3" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-3" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-3"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;~/Downloads/&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;C-Kermit&amp;gt;connect
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-4" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-4" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-4"&gt;&lt;/a&gt;Connecting&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;/dev/ttyUSB0,&lt;span class="w"&gt; &lt;/span&gt;speed&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;57600&lt;/span&gt;
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-5" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-5" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-5"&gt;&lt;/a&gt;&lt;span class="w"&gt; &lt;/span&gt;Escapr&lt;span class="w"&gt; &lt;/span&gt;character:&lt;span class="w"&gt; &lt;/span&gt;Ctrl-&lt;span class="se"&gt;\ &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;ASCII&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;28&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;FS&lt;span class="o"&gt;)&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;enabled
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-6" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-6" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-6"&gt;&lt;/a&gt;Type&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;escape&lt;span class="w"&gt; &lt;/span&gt;character&lt;span class="w"&gt; &lt;/span&gt;followed&lt;span class="w"&gt; &lt;/span&gt;by&lt;span class="w"&gt; &lt;/span&gt;C&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;get&lt;span class="w"&gt; &lt;/span&gt;back,
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-7" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-7" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-7"&gt;&lt;/a&gt;or&lt;span class="w"&gt; &lt;/span&gt;followed&lt;span class="w"&gt; &lt;/span&gt;by&lt;span class="w"&gt; &lt;/span&gt;?&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;see&lt;span class="w"&gt; &lt;/span&gt;other&lt;span class="w"&gt; &lt;/span&gt;options.
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-8" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-8" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-8"&gt;&lt;/a&gt;----------------------------------------------------
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-9" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-9" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-9"&gt;&lt;/a&gt;&lt;span class="c1"&gt;## Total Size      = 0x00840325 = 8651557 Bytes&lt;/span&gt;
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-10" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-10" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-10"&gt;&lt;/a&gt;&lt;span class="c1"&gt;## Start Addr      = 0x80100000&lt;/span&gt;
&lt;a id="rest_code_256c42cc3fc1437294a9ef75500b71d4-11" name="rest_code_256c42cc3fc1437294a9ef75500b71d4-11" href="https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/#rest_code_256c42cc3fc1437294a9ef75500b71d4-11"&gt;&lt;/a&gt;&lt;span class="c1"&gt;## Switch baudrate to 57600 bps and press ESC ...&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And indeed, there was the prompt. After pressing ESC, the transferred image was flashed.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="reboot-into-the-new-firmware"&gt;
&lt;h2&gt;Reboot into the new firmware&lt;/h2&gt;
&lt;p&gt;Upon rebooting, the device was now running Seeed's open-source LoRaWAN gateway operating system. Luci's menu now included a &lt;strong&gt;Backup/Flash Firmware&lt;/strong&gt; entry in the &lt;strong&gt;System&lt;/strong&gt; menu, enabling me to upload the ChirpStack Gateway OS image:&lt;/p&gt;
&lt;img alt="/images/sensecap-m2-openwrt-new-firmware.png" class="align-center" src="https://koen.vervloesem.eu/images/sensecap-m2-openwrt-new-firmware.png"&gt;
&lt;p&gt;Before flashing the firmware image, I deselected the &lt;strong&gt;Keep settings and retain the current configuration&lt;/strong&gt; option, as outlined in &lt;a class="reference external" href="https://www.chirpstack.io/docs/chirpstack-gateway-os/install/seeed.html"&gt;ChirpStack's documentation for installation on the SenseCAP M2&lt;/a&gt;:&lt;/p&gt;
&lt;img alt="/images/sensecap-m2-openwrt-flash.png" class="align-center" src="https://koen.vervloesem.eu/images/sensecap-m2-openwrt-flash.png"&gt;
&lt;p&gt;Thus, I now have open-source firmware running on my new LoRaWAN gateway, with regular updates in place.&lt;/p&gt;
&lt;/section&gt;</description><category>firmware</category><category>helium</category><category>kermit</category><category>lora</category><category>lorawan</category><category>seeed-studio</category><category>sensecap</category><category>uboot</category><guid>https://koen.vervloesem.eu/blog/how-to-install-alternative-firmware-to-the-sensecap-m2-data-only-lorawan-indoor-gateway/</guid><pubDate>Sat, 15 Mar 2025 18:20:59 GMT</pubDate></item><item><title>AlsaMixer's poetic error message from Lewis Carroll's "The Hunting of the Snark"</title><link>https://koen.vervloesem.eu/blog/alsamixers-poetic-error-message-from-lewis-carrolls-the-hunting-of-the-snark/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;When I mindlessly unplugged a USB audio card from my laptop while viewing its mixer settings in AlsaMixer, I was surprised by the following poetic error message: &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/alsamixers-poetic-error-message-from-lewis-carrolls-the-hunting-of-the-snark/#footnote-copyright" id="footnote-reference-1" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;1&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;img alt="In the midst of the word he was trying to say, In the midst of his laughter and glee, He had softly and suddenly vanished away— For the Snark was a Boojum, you see." src="https://koen.vervloesem.eu/images/alsamixer-error-sound-device-unplugged-boojum.png"&gt;
&lt;p&gt;These lines are actually the final verse of Lewis Carroll's whimsical poem &lt;a class="reference external" href="https://www.poetryfoundation.org/poems/43909/the-hunting-of-the-snark"&gt;The Hunting of the Snark&lt;/a&gt;:&lt;/p&gt;
&lt;pre class="literal-block"&gt;In the midst of the word he was trying to say,
  In the midst of his laughter and glee,
He had softly and suddenly vanished away—
  For the Snark &lt;em&gt;was&lt;/em&gt; a Boojum, you see.

-- Lewis Carroll, "The Hunting of the Snark"&lt;/pre&gt;
&lt;p&gt;Initially, I didn't even notice the bright red error message &lt;strong&gt;The sound device was unplugged. Press F6 to select another sound card.&lt;/strong&gt; The poetic lines were enough to convey what had happened and they put a smile on my face.&lt;/p&gt;
&lt;p&gt;Please, developers, keep putting a smile on my face when something unexpected happens.&lt;/p&gt;
&lt;aside class="footnote-list brackets"&gt;
&lt;aside class="footnote brackets" id="footnote-copyright" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/alsamixers-poetic-error-message-from-lewis-carrolls-the-hunting-of-the-snark/#footnote-reference-1"&gt;1&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;Fun fact: the copyright header of &lt;a class="reference external" href="https://github.com/alsa-project/alsa-utils/blob/master/alsamixer/mixer_display.c"&gt;AlsaMixer's source code&lt;/a&gt; includes: &lt;code class="docutils literal"&gt;Copyright (c) 1874 Lewis Carroll&lt;/code&gt;.&lt;/p&gt;
&lt;/aside&gt;
&lt;/aside&gt;</description><category>alsamixer</category><category>open-source</category><category>poetry</category><guid>https://koen.vervloesem.eu/blog/alsamixers-poetic-error-message-from-lewis-carrolls-the-hunting-of-the-snark/</guid><pubDate>Tue, 11 Jun 2024 19:55:15 GMT</pubDate></item><item><title>Building wireless sensor networks with OpenThread, CoAP, and Zephyr</title><link>https://koen.vervloesem.eu/blog/building-wireless-sensor-networks-with-openthread-coap-and-zephyr/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;figure&gt;&lt;img src="https://koen.vervloesem.eu/images/books/building-wireless-sensor-networks-with-openthread.thumbnail.png"&gt;&lt;/figure&gt; &lt;p&gt;Last week my new book has been published, &lt;a class="reference external" href="https://koen.vervloesem.eu/books/building-wireless-sensor-networks-with-openthread/"&gt;Building Wireless Sensor Networks with OpenThread: Developing CoAP Applications for Thread Networks with Zephyr&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thread is a protocol for building efficient, secure and scalable wireless mesh networks for the Internet of Things (IoT), based on IPv6. OpenThread is an open-source implementation of the Thread protocol, originally developed by Google. It offers a comprehensive Application Programming Interface (API) that is both operating system and platform agnostic. OpenThread is the industry’s reference implementation and the go-to platform for professional Thread application developers.&lt;/p&gt;
&lt;aside class="sidebar"&gt;
&lt;p class="sidebar-title"&gt;Source code&lt;/p&gt;
&lt;p&gt;All code examples from this book are published &lt;a class="reference external" href="https://github.com/koenvervloesem/openthread-applications"&gt;on GitHub&lt;/a&gt;. The repository also lists errors that may have been found in this book since its publication, as well as information about changes that impact the examples.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;This book uses OpenThread in conjunction with Zephyr, an open-source real-time operating system designed for use with resource-constrained devices. This allows you to develop Thread applications that work on various hardware platforms, without the need to delve into low-level details or to learn another API when switching hardware platforms.&lt;/p&gt;
&lt;p&gt;With its practical approach, this book not only explains theoretical concepts, but also demonstrates Thread’s network features with the use of practical examples. It explains the code used for a variety of basic Thread applications based on Constrained Application Protocol (CoAP). This includes advanced topics such as service discovery and security. As you work through this book, you’ll build on both your knowledge and skills. By the time you finish the final chapter, you’ll have the confidence to effectively implement Thread-based wireless networks for your own IoT projects.&lt;/p&gt;
&lt;section id="what-is-thread"&gt;
&lt;h2&gt;What is Thread?&lt;/h2&gt;
&lt;p&gt;Thread is a low-power, wireless, and IPv6-based networking protocol designed specifically for IoT devices. Development of the protocol is managed by the &lt;a class="reference external" href="https://www.threadgroup.org"&gt;Thread Group&lt;/a&gt;, an alliance founded in 2015. This is a consortium of major industry players, including Google, Apple, Amazon, Qualcomm, Silicon Labs, and Nordic Semiconductor.&lt;/p&gt;
&lt;p&gt;You can download the &lt;a class="reference external" href="https://www.threadgroup.org/support#specifications"&gt;Thread specification&lt;/a&gt; for free, although registration is required. The version history is as follows:&lt;/p&gt;
&lt;table&gt;
&lt;caption&gt;Versions of the Thread specification&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th class="head"&gt;&lt;p&gt;Version&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;Release year&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;Remarks&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;Thread 1.0&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;2015&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;Never implemented in commercial products&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;Thread 1.1&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;2017&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The ability to automatically move to a clear channel on detecting interference (channel agility)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to reset a master key and drive new rotating keys in the network&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;Thread 1.2&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;2019&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Enhancements to scalability and energy efficiency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support for large-scale networking applications, including the ability to integrate multiple Thread networks into one singular Thread domain&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;Thread 1.3&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;2023&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Enhancements to scalability, reliability, and robustness of Thread networks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Standardization of Thread Border Routers, Matter support, and firmware upgrades for Thread devices&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;All versions of the Thread specification maintain backward compatibility.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="threads-architecture"&gt;
&lt;h2&gt;Thread’s architecture&lt;/h2&gt;
&lt;p&gt;Thread employs a mesh networking architecture that allows devices to communicate directly with each other, eliminating the need for a central hub or gateway. This architecture offers inherent redundancy, as devices can relay data using multiple paths, ensuring increased reliability in case of any single node failure.&lt;/p&gt;
&lt;p&gt;The Thread protocol stack is built upon the widely used IPv6 protocol, which simplifies the integration of Thread networks into existing IP infrastructures. Thread is designed to be lightweight, streamlined and efficient, making it an excellent protocol for IoT devices running in resource-constrained environments.&lt;/p&gt;
&lt;p&gt;Before discussing Thread, it’s essential to understand its place in the network protocol environment. Most modern networks are based on the &lt;strong&gt;Internet Protocol suite&lt;/strong&gt;, which uses a four-layer architecture. The layers of the Internet Protocol suite are, from bottom to top:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;Link layer&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Defines the device’s connection with a local network. Protocols like &lt;strong&gt;Ethernet&lt;/strong&gt; and &lt;strong&gt;Wi-Fi&lt;/strong&gt; operate within this layer. In the more complex Open Systems Interconnection (OSI) model, this layer includes the physical and data link layers.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Network layer&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Enables communication across network boundaries, known as routing. The &lt;strong&gt;Internet Protocol (IP)&lt;/strong&gt; operates within this layer and defines IP addresses.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Transport layer&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Enables communication between two devices, either on the same network or on different networks with routers in between. The transport layer also defines the concept of a port. &lt;strong&gt;User Datagram Protocol (UDP)&lt;/strong&gt; and &lt;strong&gt;Transmission Control Protocol (TCP)&lt;/strong&gt; operate within this layer.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Application layer&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Facilitates communication between applications on the same device or different devices. Protocols like &lt;strong&gt;HyperText Transfer Protocol (HTTP)&lt;/strong&gt;, &lt;strong&gt;Domain Name System (DNS)&lt;/strong&gt;, &lt;strong&gt;Simple Mail Transfer Protocol (SMTP)&lt;/strong&gt;, and &lt;strong&gt;Message Queuing Telemetry Transport (MQTT)&lt;/strong&gt; operate within this layer.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;When data is transmitted across the network, the data of each layer is embedded in the layer below it, as shown in this diagram:&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/internet-protocol-encapsulation.png" src="https://koen.vervloesem.eu/images/internet-protocol-encapsulation.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;Network data is encapsulated in the four layers of the Internet Protocol suite (based on: Colin Burnett, CC BY-SA 3.0)&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Thread operates in the network and transport layers. However, it’s important to know
what’s going on in all layers.&lt;/p&gt;
&lt;section id="link-layer-ieee-802-15-4"&gt;
&lt;h3&gt;Link layer: IEEE 802.15.4&lt;/h3&gt;
&lt;p&gt;For its link layer, Thread builds upon the IEEE 802.15.4 standard, a specification by the &lt;a class="reference external" href="https://www.ieee.org"&gt;Institute of Electrical and Electronics Engineers (IEEE)&lt;/a&gt;. This is the same link layer that &lt;a class="reference external" href="https://csa-iot.org/all-solutions/zigbee/"&gt;Zigbee&lt;/a&gt; uses. It focuses on low power consumption, allowing devices to communicate for months or even years on a single battery charge. The direct communication range is approximately 10 meters under normal conditions.&lt;/p&gt;
&lt;p&gt;IEEE 802.15.4 is a radio standard operating in the license-free &lt;strong&gt;2.4 GHz frequency band&lt;/strong&gt; with data rates up to 250 kbit/s. It has 16 channels (channels 11 to 26), ranging from 2405 to 2530 MHz with 5 MHz channel spacing. This is the same 2.4 GHz frequency band used by &lt;a class="reference external" href="https://koen.vervloesem.eu/books/develop-your-own-bluetooth-low-energy-applications/"&gt;Bluetooth&lt;/a&gt; and Wi-Fi.&lt;/p&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;In Europe and North America, IEEE 802.15.4 also supports channels at frequencies of 868 MHz and 920 MHz, respectively. Channel 0 (with a data rate of 20 kbit/s) is for 868.3 MHz, and channels 1 to 10 (with a data rate of 40 kbit/s) are for 906 to 924 MHz with 2 MHz channel spacing.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;An IEEE 802.15.4 network includes two types of devices:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;Full Function Device (FFD)&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A device that implements the complete feature set of the IEEE 802.15.4 standard. It can communicate with all other IEEE 802.15.4 devices within its immediate radio range.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Reduced Function Device (RFD)&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A device that implements only a subset of features of the IEEE 802.15.4 standard to conserve device resources. It can only communicate with the FFD through which it joined the network.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;An IEEE 802.15.4 network is known as a &lt;strong&gt;Personal Area Network (PAN)&lt;/strong&gt;. Each PAN is identified by a unique PAN ID that no other PAN in range is allowed to have. Within each PAN, one FFD is the PAN coordinator. This device initiates and manages the PAN, enabling other devices to join the network.&lt;/p&gt;
&lt;p&gt;IEEE 802.15.4 includes &lt;strong&gt;built-in encryption and authentication&lt;/strong&gt;, using AES-128 (128-bit Advanced Encryption Standard) in CCM* mode, a variation of CCM mode (counter with cipher block chaining message authentication code). This mode provides authenticated encryption by combining encryption in CTR (counter) mode with authentication using CBC-MAC (cipher block chaining message authentication code). The original message is transmitted alongside a MIC (Message Integrity Check) so the recipient can validate that the message has not been tampered with.&lt;/p&gt;
&lt;p&gt;Devices can only communicate with each other in an IEEE 802.15.4 network if they use the same 128-bit AES key. The IEEE 802.15.4 standard doesn’t, however, define the key exchange process. The key must therefore either be stored in each device during manufacture, entered manually by the user, or by a key exchange protocol in the layers above the link layer.&lt;/p&gt;
&lt;p&gt;IEEE 802.15.4 data packets can transmit data from 0 to 127 bytes long. Each IEEE 802.15.4 device has an &lt;strong&gt;EUI-64 (Extended Unique Identifier)&lt;/strong&gt; address set by the manufacturer, which is used as a MAC address. When a device joins a PAN, it’s also assigned a 16-bit short address. This allows the transmitted packets to be shorter because they only need to use two instead of eight bytes to define source and target addresses. Some special short addresses exist, such as &lt;code class="docutils literal"&gt;0xffff&lt;/code&gt; as a broadcast address to send packets to all devices, and &lt;code class="docutils literal"&gt;0xfffe&lt;/code&gt; as an unassigned address, used by devices while joining a network.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="network-layer-6lowpan-and-ipv6"&gt;
&lt;h3&gt;Network layer: 6LoWPAN and IPv6&lt;/h3&gt;
&lt;p&gt;Thread’s network layer consists of IPv6 over Low-Power Wireless Access Networks (6LoWPAN). This is an IETF specification described in &lt;a class="reference external" href="https://datatracker.ietf.org/doc/html/rfc4944"&gt;RFC 4944&lt;/a&gt;, "Transmission of IPv6 Packets over IEEE 802.15.4 Networks", with an update for the compression mechanism in &lt;a class="reference external" href="https://datatracker.ietf.org/doc/html/rfc6282"&gt;RFC 6282&lt;/a&gt;, "Compression Format for IPv6 Datagrams over IEEE 802.15.4-Based Networks". 6LoWPAN’s purpose is to allow even the smallest devices with limited processing power and low energy requirements to be part of the Internet of Things.&lt;/p&gt;
&lt;p&gt;6LoWPAN essentially enables you to &lt;strong&gt;run an IPv6 network over the IEEE 802.15.4 link layer&lt;/strong&gt;. It acts as an ‘adaptation layer’ between IPv6 and IEEE 802.15.4 and is therefore sometimes considered part of the link layer. This adaptation poses some challenges. For example, IPv6 mandates that all links can handle datagram sizes of at least 1280 bytes, but IEEE 802.15.4, as explained in the previous subsection, limits a frame to 127 bytes. 6LoWPAN solves this by excluding information in the 6LoWPAN header that can already be derived from IEEE 802.15.4 frames and by using local, shortened addresses. If the payload is still too large, it’s divided into fragments.&lt;/p&gt;
&lt;p&gt;The link-local IPv6 addresses of 6LoWPAN devices are derived from the IEEE 802.15.4 EUI-64 addresses and their shortened 16-bit addresses. The devices in a 6LoWPAN network can communicate directly with ‘normal’ IPv6 devices in a network if connected via an &lt;strong&gt;edge router&lt;/strong&gt;. This means there is no need for translation via a gateway, in contrast to non-IP networks such as Zigbee or &lt;a class="reference external" href="https://www.z-wave.com"&gt;Z-Wave&lt;/a&gt;. Communication with non-6LoWPAN networks purely involves forwarding data packets at the network layer.&lt;/p&gt;
&lt;p&gt;In this layer, Thread builds upon IEEE 802.15.4 to create an IPv6-based mesh network. In IEEE 802.15.4 only communication between devices that are in immediate radio range is possible, whereas routing allows devices that aren’t in immediate range to communicate.&lt;/p&gt;
&lt;p&gt;If you want to delve into more details of Thread’s network layer, consult the Thread Group’s white paper &lt;a class="reference external" href="https://www.threadgroup.org/Portals/0/documents/support/6LoWPANUsage_632_2.pdf"&gt;Thread Usage of 6LoWPAN&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="transport-layer-udp"&gt;
&lt;h3&gt;Transport layer: UDP&lt;/h3&gt;
&lt;p&gt;On top of 6LoWPAN and IPv6, Thread’s transport layer employs the User Datagram Protocol (UDP), which is the lesser known alternative to Transmission Control Protocol (TCP).&lt;/p&gt;
&lt;p&gt;UDP has the following properties:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;Connectionless&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Unlike TCP, UDP doesn’t require establishing a connection before transferring data. It sends datagrams (packets) directly without any prior setup.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;No error checking and recovery&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;UDP doesn’t provide built-in error checking, nor does it ensure the delivery of packets. If data is lost or corrupted during transmission, UDP doesn’t attempt to recover or resend it.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Speed&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;UDP is faster than TCP, as it doesn’t involve the overhead of establishing and maintaining a connection, error checking, or guaranteeing packet delivery.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;UDP is ideal for use by Thread for several reasons:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;Resource constraints&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Thread devices often have limited processing power, memory, and energy. The simplicity and low overhead of UDP make it a better fitting choice for such resource-constrained devices compared to TCP.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Lower latency&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;UDP’s connectionless and lightweight nature guarantees data transmission with low latency, making it appropriate for wireless sensors.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;/section&gt;
&lt;section id="thread-lacks-an-application-layer"&gt;
&lt;h3&gt;Thread lacks an application layer&lt;/h3&gt;
&lt;p&gt;Unlike home automation protocols such as Zigbee, Z-Wave, or &lt;a class="reference external" href="https://csa-iot.org/all-solutions/matter/"&gt;Matter&lt;/a&gt;, the Thread standard doesn’t define an application layer. A Thread network merely offers network infrastructure that applications can use to communicate. Just as your web browser and email client use TCP/IP over Ethernet or Wi-Fi, home automation devices can use Thread over IEEE 802.15.4 as their network infrastructure.&lt;/p&gt;
&lt;p&gt;Several application layers exist that can make use of Thread:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;Constrained Application Protocol (CoAP)&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A simpler version of HTTP, designed for resource-constrained devices and using UDP instead of TCP.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;MQTT for Sensor Networks (MQTT-SN)&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A variant of MQTT designed to be used over UDP.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Apple HomeKit&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;Apple’s application protocol for home automation devices.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Matter&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A new home automation standard developed by the &lt;a class="reference external" href="https://csa-iot.org"&gt;Connectivity Standards Alliance (CSA)&lt;/a&gt;.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;Matter was developed by the Zigbee Alliance, the original developers of the Zigbee standard for home automation. Following the introduction of Matter, the Zigbee Alliance rebranded to the Connectivity Standards Alliance. Matter’s application layer is heavily influenced by Zigbee. It not only runs on top of Thread, but can also be used over Wi-Fi and Ethernet.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;Like your home network which simultaneously hosts a lot of application protocols including HTTP, DNS, and SMTP, a Thread network can also run all these application protocols concurrently.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/thread-stack.png" src="https://koen.vervloesem.eu/images/thread-stack.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;The Thread network stack supports multiple application protocols simultaneously.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Throughout this book, I will be using CoAP as an application protocol in a Thread network. Once you have a Thread network set up, you can also use it for Apple HomeKit and Matter devices.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="advantages-of-thread"&gt;
&lt;h2&gt;Advantages of Thread&lt;/h2&gt;
&lt;p&gt;Some of Thread’s key benefits include:&lt;/p&gt;
&lt;section id="scalability"&gt;
&lt;h3&gt;Scalability&lt;/h3&gt;
&lt;p&gt;Thread’s mesh network architecture allows for large-scale deployment of IoT devices, supporting hundreds of devices within a single network. Thread accommodates up to 32 Routers per network and up to 511 End Devices per Router. In addition, from Thread 1.2, multiple Thread networks can be integrated into one single Thread domain, allowing thousands of devices within a mesh network.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="security"&gt;
&lt;h3&gt;Security&lt;/h3&gt;
&lt;p&gt;Devices can’t access a Thread network without authorization. Moreover, all communication on a Thread network is encrypted using IEEE 802.15.4 security mechanisms. As a result, an outsider without access to the network credentials can’t read network traffic.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="reliability"&gt;
&lt;h3&gt;Reliability&lt;/h3&gt;
&lt;p&gt;Thread networks are robust and support self-healing and self-organizing network properties at various levels, ensuring the network’s resilience against failures. This all happens transparently to the user; messages are automatically routed around any bad node via alternative paths.&lt;/p&gt;
&lt;p&gt;For example, an End Device requires a parent Router to communicate with the rest of the network. If communication with this parent Router fails for any reason and it becomes unavailable the End Device will choose another parent Router in its neighborhood, after which communication resumes.&lt;/p&gt;
&lt;p&gt;Thread Routers also relay packets from their End Devices to other Routers using the most efficient route they can find. In case of connection problems, the Router will immediately seek an alternate route. Router-Eligible End Devices can also temporarily upgrade their status to Routers if necessary. Each Thread network has a Leader who supervises the Routers and whose role is dynamically selected by the Routers. If the Leader fails, another Router automatically takes over as Leader.&lt;/p&gt;
&lt;p&gt;Border Routers have the same built-in resilience. In a Thread network with multiple Border Routers, communication between Thread devices and devices on another IP network (such as a home network) occurs along multiple routes. If one Border Router loses connectivity, communications will be rerouted via the other Border Routers. If your Thread network only has a single Border Router, this will become a single point of failure for communication with the outside network.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="low-power-consumption"&gt;
&lt;h3&gt;Low power consumption&lt;/h3&gt;
&lt;p&gt;Thread is based on the power-efficient IEEE 802.15.4 link layer. This enables devices to operate on batteries for prolonged periods. Sleepy End Devices will also switch off their radio during idle periods and only wake up periodically to communicate with their parent Router, thereby giving even longer battery life.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="interoperability"&gt;
&lt;h3&gt;Interoperability&lt;/h3&gt;
&lt;p&gt;As the protocol is built upon IPv6, Thread devices are straightforward to incorporate into existing networks, both in industrial and home infrastructure, and for both local networks and cloud connections. You don’t need a proprietary gateway; every IP-based device is able to communicate with Thread devices, as long as there’s a route between both devices facilitated by a Border Router.&lt;/p&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="disadvantages-of-thread"&gt;
&lt;h2&gt;Disadvantages of Thread&lt;/h2&gt;
&lt;p&gt;In life, they say there’s no such thing as a free lunch and Thread is no exception to this rule. Some of its limitations are:&lt;/p&gt;
&lt;section id="limited-range"&gt;
&lt;h3&gt;Limited range&lt;/h3&gt;
&lt;p&gt;Thread’s emphasis on low power consumption can lead to a restricted wireless range compared with other technologies such as Wi-Fi. Although this can be offset by its mesh architecture, where Routers relay messages, it still means that devices in general can’t be placed too far apart.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="low-data-rates"&gt;
&lt;h3&gt;Low data rates&lt;/h3&gt;
&lt;p&gt;Thread supports lower data rates than some rival IoT technologies. This makes Thread unsuitable for applications requiring high throughput.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="complexity"&gt;
&lt;h3&gt;Complexity&lt;/h3&gt;
&lt;p&gt;The Thread protocol stack may be more challenging to implement compared to other IoT networking solutions, potentially ramping up development costs and time.&lt;/p&gt;
&lt;aside class="sidebar"&gt;
&lt;p class="sidebar-title"&gt;Read more&lt;/p&gt;
&lt;p&gt;This is an abridged version of the introduction of my book &lt;a class="reference external" href="https://koen.vervloesem.eu/books/building-wireless-sensor-networks-with-openthread/"&gt;Building Wireless Sensor Networks with OpenThread: Developing CoAP Applications for Thread Networks with Zephyr&lt;/a&gt;. You can read the full introduction for free &lt;a class="reference external" href="https://www.elektor.com/products/building-wireless-sensor-networks-with-openthread-bundle"&gt;in the Elektor Store&lt;/a&gt;, where you can also find the table of contents.&lt;/p&gt;
&lt;/aside&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="platforms-used-in-this-book"&gt;
&lt;h2&gt;Platforms used in this book&lt;/h2&gt;
&lt;p&gt;In this book I focus on building wireless sensor networks using the Thread protocol together with the following hardware and software environments:&lt;/p&gt;
&lt;dl class="simple"&gt;
&lt;dt&gt;Nordic Semiconductor’s nRF52840 SoC&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;A powerful yet energy-efficient and low cost hardware solution for Thread-based IoT devices&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;OpenThread&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;An open-source implementation of the Thread protocol, originally developed by Google, making it easy to incorporate Thread into your IoT projects&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;Zephyr&lt;/dt&gt;
&lt;dd&gt;&lt;p&gt;An open-source real-time operating system designed for resource-constrained devices&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;Armed with these tools and by using practical examples I will go on to guide you step-by-step through the details of the hardware and software required to build Thread networks and OpenThread-based applications.&lt;/p&gt;
&lt;section id="nordic-semiconductors-nrf52840-soc"&gt;
&lt;h3&gt;Nordic Semiconductor’s nRF52840 SoC&lt;/h3&gt;
&lt;p&gt;Nordic Semiconductor’s nRF52840 is a SoC built around the 32-bit ARM Cortex-M4 CPU running at 64 MHz. This chip supports Bluetooth Low Energy (BLE), Bluetooth Mesh, Thread, Zigbee, IEEE 802.15.4, ANT and 2.4 GHz proprietary stacks. With its 1 MB flash storage and 256 KB RAM, it offers ample resources for advanced Thread applications.&lt;/p&gt;
&lt;p&gt;This SoC is available for developers in the form of Nordic Semiconductor’s user-friendly nRF52840 Dongle. You can power and program this small, low-cost USB dongle via a computer USB port. The documentation lists comprehensive &lt;a class="reference external" href="https://docs.nordicsemi.com/bundle/ug_nrf52840_dongle/page/UG/nrf52840_Dongle/intro.html"&gt;information about the dongle&lt;/a&gt;.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/nrf52840-dongle.png" src="https://koen.vervloesem.eu/images/nrf52840-dongle.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;Nordic Semiconductor’s nRF52840 Dongle is a low-cost USB dongle ideal for experimenting with Thread. (image source: Nordic Semiconductor)&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/section&gt;
&lt;section id="openthread"&gt;
&lt;h3&gt;OpenThread&lt;/h3&gt;
&lt;p&gt;Thread is basically a networking protocol; in order to work with it you need an implementation of the Thread networking protocol. The industry’s reference implementation, used even by professional Thread device developers, is &lt;a class="reference external" href="https://openthread.io"&gt;OpenThread&lt;/a&gt;. It’s a BSD-licensed implementation, with development ongoing via &lt;a class="reference external" href="https://github.com/openthread/openthread"&gt;its GitHub repository&lt;/a&gt;. The license for this software allows for its use in both open-source and proprietary applications.&lt;/p&gt;
&lt;p&gt;OpenThread provides an Application Programming Interface (API) that’s operating system and platform agnostic. It has a narrow platform abstraction layer to achieve this, and has a small memory footprint, making it highly portable. In this book, I will be using OpenThread in conjunction with Zephyr, but the same API can be used in other combinations, such as ESP-IDF for Espressif’s Thread SoCs.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/openthread-website.png" src="https://koen.vervloesem.eu/images/openthread-website.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;The BSD-licensed OpenThread project is the industry’s standard implementation of the Thread protocol.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/section&gt;
&lt;section id="zephyr"&gt;
&lt;h3&gt;Zephyr&lt;/h3&gt;
&lt;p&gt;&lt;a class="reference external" href="https://zephyrproject.org"&gt;Zephyr&lt;/a&gt; is an open-source real-time operating system (RTOS) designed for resource-constrained devices. It incorporates OpenThread as a module, simplifying the process of creating Thread applications based on Zephyr and OpenThread. Because of Zephyr’s hardware abstraction layer, these applications will run on all SoCs supported by Zephyr that have an IEEE 802.15.4 radio facility.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/zephyr-website.png" src="https://koen.vervloesem.eu/images/zephyr-website.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;Zephyr is an open-source real-time operating system (RTOS) with excellent support for OpenThread.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/section&gt;
&lt;/section&gt;
&lt;section id="recommended-hardware"&gt;
&lt;h2&gt;Recommended hardware&lt;/h2&gt;
&lt;p&gt;For the hardware, I recommend a &lt;a class="reference external" href="https://www.nordicsemi.com/Products/Development-hardware/nRF52840-Dongle"&gt;Nordic Semiconductor nRF52840 Dongle&lt;/a&gt;, but you can use any microcontroller board with Thread radio supported by Zephyr. There are variants of the dongle by other manufacturers, such as the &lt;a class="reference external" href="https://wiki.aprbrother.com/en/BleUsbDongle.html#april-usb-dongle-52840"&gt;April USB Dongle 52840&lt;/a&gt; (with an external antenna) or the &lt;a class="reference external" href="https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/"&gt;nRF52840 MDK USB Dongle&lt;/a&gt; from makerdiary (with a case).&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/nrf52840-dongles.jpg" src="https://koen.vervloesem.eu/images/nrf52840-dongles.jpg"&gt;
&lt;figcaption&gt;
&lt;p&gt;From left to right: April Brother’s April USB Dongle 52840, Nordic Semiconductor’s nRF52840 Dongle, and makerdiary’s nRF52840 MDK USB Dongle.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;The more devices you have in a Thread network, the better it works, because Routers can relay messages via other devices. Having more devices also aids in understanding how Thread operates: you can turn devices on and off, run commands on them through Zephyr’s shell, and observe how the network reacts. So, if possible, I recommend purchasing a handful of nRF52840 Dongles or other IEEE 802.15.4 devices supported by Zephyr. A USB hub with several Thread devices plugged in makes an excellent test setup, as shown in this example:&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/hub-with-thread-dongles.jpg" src="https://koen.vervloesem.eu/images/hub-with-thread-dongles.jpg"&gt;
&lt;figcaption&gt;
&lt;p&gt;A USB hub with some Thread dongles plugged in is a great test setup to get to know Thread networking.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;If you’re serious about Thread development with Zephyr, I also recommend Nordic Semiconductor’s nRF52840 Development Kit. This is the bigger (and slightly less affordable) brother of the nRF52840 Dongle, offering more capabilities to debug code easily. With one of these, you can carry out initial development and debugging then flash the code to the nRF52840 Dongle once all the bugs have been ironed out.&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;img alt="/images/nrf52840-dk.png" src="https://koen.vervloesem.eu/images/nrf52840-dk.png"&gt;
&lt;figcaption&gt;
&lt;p&gt;Nordic Semiconductor’s nRF52840 Development Kit has some powerful debugging capabilities. (image source: Nordic Semiconductor)&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/section&gt;</description><category>coap</category><category>coap-client</category><category>coap-server</category><category>coaps</category><category>dtls</category><category>dtls-cert</category><category>dtls-psk</category><category>nordic-semiconductor</category><category>nordicsemi</category><category>nrf5x</category><category>nrf52</category><category>nrf52840</category><category>nrf52840-dk</category><category>nrf52840-dongle</category><category>openthread</category><category>openthread-application</category><category>python</category><category>thread</category><category>zephyr</category><category>zephyr-rtos</category><guid>https://koen.vervloesem.eu/blog/building-wireless-sensor-networks-with-openthread-coap-and-zephyr/</guid><pubDate>Thu, 09 May 2024 19:26:05 GMT</pubDate></item><item><title>How to change the default I²C pins in Zephyr</title><link>https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;When working with I²C devices in the &lt;a class="reference external" href="https://zephyrproject.org"&gt;Zephyr&lt;/a&gt; real-time operating system, a lot is configured behind the scenes using a &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/build/dts/index.html"&gt;devicetree&lt;/a&gt;, a hierarchical data structure that describes available hardware. It took me some time to figure out how to change the default I²C pins (SDA and SCL). Here are my notes.&lt;/p&gt;
&lt;p&gt;I tried this with Zephyr's &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/samples/sensor/bme280/README.html"&gt;BME280 Humidity and Pressure Sensor sample&lt;/a&gt;. My goal was to flash the sample firmware to Nordic Semiconductor's nRF52840 Dongle with a BME280 breakout board.&lt;/p&gt;
&lt;section id="what-are-the-default-i2c-pins"&gt;
&lt;h2&gt;What are the default I²C pins?&lt;/h2&gt;
&lt;p&gt;First I needed to find out the default I²C pins. To check this, I looked at the devicetree source include file for the nRF52840 Dongle's &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/hardware/pinctrl/index.html"&gt;Pin Control&lt;/a&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_bdef55b3f66843d78623729036ddd16d-1" name="rest_code_bdef55b3f66843d78623729036ddd16d-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_bdef55b3f66843d78623729036ddd16d-1"&gt;&lt;/a&gt;koan@tux:~$&lt;span class="w"&gt; &lt;/span&gt;less&lt;span class="w"&gt; &lt;/span&gt;~/zephyrproject/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840-pinctrl.dtsi
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The relevant configuration for the i2c0 peripheral is as follows:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code devicetree"&gt;&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-1" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-1"&gt;&lt;/a&gt;&lt;span class="nl"&gt;i2c0_default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c0_default&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-2" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nf"&gt;group1&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-3" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-3" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;psels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SDA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-4" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-4" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SCL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-5" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-5" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-6" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-6" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-6"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-7" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-7" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-8" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-8" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-8"&gt;&lt;/a&gt;&lt;span class="nl"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-9" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-9" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nf"&gt;group1&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-10" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-10" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;psels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SDA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-11" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-11" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SCL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-12" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-12" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;low-power-enable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-13" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-13" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-14" name="rest_code_89a25b8a221b494b8c02c1b0bd7814ae-14" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_89a25b8a221b494b8c02c1b0bd7814ae-14"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This configures pin 0.26 for SDA and pin 0.27 for SCL. My first thought was to simply connect the BME280 to these pins on the nRF52840 Dongle. However, upon examining the board's pinout, I discovered that pin 0.26 is only exposed as a pad on the bottom, and pin 0.27 isn't accessible anywhere:&lt;/p&gt;
&lt;img alt="/images/nrf52840-dongle-pinout.png" class="align-center" src="https://koen.vervloesem.eu/images/nrf52840-dongle-pinout.png"&gt;
&lt;/section&gt;
&lt;section id="how-to-change-the-default-i2c-pins"&gt;
&lt;h2&gt;How to change the default I²C pins?&lt;/h2&gt;
&lt;p&gt;Since the default I²C pins weren't suitable on this board, I needed to change them. I decided to connect the BME280 sensor board as follows:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th class="head"&gt;&lt;p&gt;BME280&lt;/p&gt;&lt;/th&gt;
&lt;th class="head"&gt;&lt;p&gt;nRF52840 Dongle&lt;/p&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;SDA&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0.31&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;SCL&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;0.29&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;GND&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;GND&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;p&gt;VCC&lt;/p&gt;&lt;/td&gt;
&lt;td&gt;&lt;p&gt;VDD&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This looks like this on a breadboard:&lt;/p&gt;
&lt;img alt="/images/nrf52840-dongle-bme280.jpg" class="align-center" src="https://koen.vervloesem.eu/images/nrf52840-dongle-bme280.jpg"&gt;
&lt;p&gt;Next, I copied the sample code so I could change it:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_01c3195d4e3b4c01b32b842c3636e6b8-1" name="rest_code_01c3195d4e3b4c01b32b842c3636e6b8-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_01c3195d4e3b4c01b32b842c3636e6b8-1"&gt;&lt;/a&gt;koan@tux:~$&lt;span class="w"&gt; &lt;/span&gt;cp&lt;span class="w"&gt; &lt;/span&gt;-r&lt;span class="w"&gt; &lt;/span&gt;~/zephyrproject/zephyr/samples/sensor/bme280/&lt;span class="w"&gt; &lt;/span&gt;.
&lt;a id="rest_code_01c3195d4e3b4c01b32b842c3636e6b8-2" name="rest_code_01c3195d4e3b4c01b32b842c3636e6b8-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_01c3195d4e3b4c01b32b842c3636e6b8-2"&gt;&lt;/a&gt;koan@tux:~$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bme280/
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then, I added a devicetree overlay file called &lt;code class="docutils literal"&gt;nrf52840dongle_nrf52840.overlay&lt;/code&gt; to the project's &lt;code class="docutils literal"&gt;boards&lt;/code&gt; directory. The content of the overlay file is as follows:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code devicetree"&gt;&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-1" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-1"&gt;&lt;/a&gt;&lt;span class="cm"&gt;/*&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-2" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-2"&gt;&lt;/a&gt;&lt;span class="cm"&gt; * Configuration of a BME280 device on an I2C bus.&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-3" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-3" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-3"&gt;&lt;/a&gt;&lt;span class="cm"&gt; *&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-4" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-4" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-4"&gt;&lt;/a&gt;&lt;span class="cm"&gt; * Device address 0x76 is assumed. Your device may have a different&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-5" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-5" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-5"&gt;&lt;/a&gt;&lt;span class="cm"&gt; * address; check your device documentation if unsure.&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-6" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-6" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-6"&gt;&lt;/a&gt;&lt;span class="cm"&gt; */&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-7" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-7" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="na"&gt;pinctrl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-8" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-8" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nl"&gt;i2c0_default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c0_default&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-9" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-9" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="nf"&gt;group1&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-10" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-10" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="n"&gt;psels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SDA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-11" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-11" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SCL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-12" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-12" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-13" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-13" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-14" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-14" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-14"&gt;&lt;/a&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-15" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-15" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-15"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nl"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-16" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-16" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-16"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="nf"&gt;group1&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-17" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-17" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-17"&gt;&lt;/a&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="n"&gt;psels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SDA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-18" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-18" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-18"&gt;&lt;/a&gt;&lt;span class="w"&gt;                                &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="na"&gt;NRF_PSEL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;TWIM_SCL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-19" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-19" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-19"&gt;&lt;/a&gt;&lt;span class="w"&gt;                        &lt;/span&gt;&lt;span class="n"&gt;low-power-enable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-20" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-20" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-20"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-21" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-21" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-21"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-22" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-22" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-22"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-23" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-23" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-23"&gt;&lt;/a&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-24" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-24" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-24"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nf"&gt;i2c0&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-25" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-25" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-25"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kr"&gt;status&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"okay"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-26" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-26" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-26"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nf"&gt;bme280&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="mi"&gt;76&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-27" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-27" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-27"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;compatible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"bosch,bme280"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-28" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-28" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-28"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;reg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mh"&gt;0x76&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-29" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-29" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-29"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-30" name="rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-30" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_0f8f4a8b394943b6ab953da6ac9cedb4-30"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class="docutils literal"&gt;&amp;amp;pinctrl&lt;/code&gt; section was copied from the devicetree source include file for the nRF52840 Dongle, with pins 26 and 27 changed to 31 and 29, respectively.&lt;/p&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;Pin 31 is also assigned as the default SCL pin for the i2c1 peripheral. However, this doesn't matter if you're not using i2c1.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;The &lt;code class="docutils literal"&gt;&amp;amp;i2c0&lt;/code&gt; part defines the &lt;code class="docutils literal"&gt;bme280&lt;/code&gt; sensor with the I²C address 0x76. We need to add this sensor definition here because the nRF52840 Dongle doesn't have it built in.&lt;/p&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;If you have an Adafruit BME280 breakout board, the address should be 0x77.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;So, with this overlay, you can use the BME280 sensor connected to pins 0.31 (SDA) and 0.29 (SCL).&lt;/p&gt;
&lt;p&gt;Because the file name of the devicetree overlay is the board name &lt;code class="docutils literal"&gt;nrf52840dongle_nrf52840&lt;/code&gt; with the extension &lt;code class="docutils literal"&gt;.overlay&lt;/code&gt;, Zephyr's build system picks it up automatically if you're building the project for the nRF52840 Dongle and merges it with the default devicetree of the board. If you're building the project for another board, the overlay will be ignored.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="building-the-code"&gt;
&lt;h2&gt;Building the code&lt;/h2&gt;
&lt;p&gt;Let's build the sample code with this devicetree overlay, adding configuration options to initialize USB at boot and enable Zephyr's shell:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_646cc7f37aab4f23b19221f4e581b169-1" name="rest_code_646cc7f37aab4f23b19221f4e581b169-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_646cc7f37aab4f23b19221f4e581b169-1"&gt;&lt;/a&gt;koan@tux:~/bme280$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~/zephyrproject/zephyr/zephyr-env.sh
&lt;a id="rest_code_646cc7f37aab4f23b19221f4e581b169-2" name="rest_code_646cc7f37aab4f23b19221f4e581b169-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_646cc7f37aab4f23b19221f4e581b169-2"&gt;&lt;/a&gt;koan@tux:~/bme280$&lt;span class="w"&gt; &lt;/span&gt;west&lt;span class="w"&gt; &lt;/span&gt;build&lt;span class="w"&gt; &lt;/span&gt;-b&lt;span class="w"&gt; &lt;/span&gt;nrf52840dongle_nrf52840&lt;span class="w"&gt; &lt;/span&gt;.&lt;span class="w"&gt; &lt;/span&gt;--&lt;span class="w"&gt; &lt;/span&gt;-DCONFIG_USB_DEVICE_INITIALIZE_AT_BOOT&lt;span class="o"&gt;=&lt;/span&gt;y&lt;span class="w"&gt; &lt;/span&gt;-DCONFIG_SHELL&lt;span class="o"&gt;=&lt;/span&gt;y
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now let's examine the generated devicetree:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_b8596d50ecdd4561a2b2f4f4bd2a12fc-1" name="rest_code_b8596d50ecdd4561a2b2f4f4bd2a12fc-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_b8596d50ecdd4561a2b2f4f4bd2a12fc-1"&gt;&lt;/a&gt;koan@tux:~/bme280$&lt;span class="w"&gt; &lt;/span&gt;less&lt;span class="w"&gt; &lt;/span&gt;build/zephyr/zephyr.dts
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This includes the bme280 sensor on the i2c0 bus:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code devicetree"&gt;&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-1" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-1"&gt;&lt;/a&gt;&lt;span class="nl"&gt;i2c0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="mi"&gt;40003000&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-2" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;compatible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"nordic,nrf-twi"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-3" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-3" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;#address-cells&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-4" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-4" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;#size-cells&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-5" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-5" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;reg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x40003000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x1000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-6" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-6" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;clock-frequency&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x186a0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-7" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-7" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;interrupts&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-8" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-8" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;status&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"okay"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-9" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-9" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;pinctrl-0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="na"&gt;i2c0_default&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-10" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-10" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;pinctrl-1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="na"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-11" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-11" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;pinctrl-names&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"sleep"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-12" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-12" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nf"&gt;bme280&lt;/span&gt;&lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="mi"&gt;76&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-13" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-13" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="kr"&gt;compatible&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"bosch,bme280"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-14" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-14" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="kr"&gt;reg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x76&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-15" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-15" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-15"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_03cac25647b24a1780daf047ee2fc9c2-16" name="rest_code_03cac25647b24a1780daf047ee2fc9c2-16" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_03cac25647b24a1780daf047ee2fc9c2-16"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Pin Control section shows the I²C pin defaults:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code devicetree"&gt;&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-1" name="rest_code_1451ed693e5547079a1efd87fef86a94-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-1"&gt;&lt;/a&gt;&lt;span class="nl"&gt;i2c0_default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c0_default&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-2" name="rest_code_1451ed693e5547079a1efd87fef86a94-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;phandle&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-3" name="rest_code_1451ed693e5547079a1efd87fef86a94-3" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nf"&gt;group1&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-4" name="rest_code_1451ed693e5547079a1efd87fef86a94-4" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;psels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0xc001f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0xb001d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-5" name="rest_code_1451ed693e5547079a1efd87fef86a94-5" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-6" name="rest_code_1451ed693e5547079a1efd87fef86a94-6" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-6"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-7" name="rest_code_1451ed693e5547079a1efd87fef86a94-7" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-7"&gt;&lt;/a&gt;&lt;span class="nl"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;i2c0_sleep&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-8" name="rest_code_1451ed693e5547079a1efd87fef86a94-8" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kr"&gt;phandle&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0x5&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-9" name="rest_code_1451ed693e5547079a1efd87fef86a94-9" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="nf"&gt;group1&lt;/span&gt;&lt;span class="cm"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-10" name="rest_code_1451ed693e5547079a1efd87fef86a94-10" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;psels&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0xc001f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;0xb001d&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-11" name="rest_code_1451ed693e5547079a1efd87fef86a94-11" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="n"&gt;low-power-enable&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-12" name="rest_code_1451ed693e5547079a1efd87fef86a94-12" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;a id="rest_code_1451ed693e5547079a1efd87fef86a94-13" name="rest_code_1451ed693e5547079a1efd87fef86a94-13" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_1451ed693e5547079a1efd87fef86a94-13"&gt;&lt;/a&gt;&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, &lt;code class="docutils literal"&gt;1f&lt;/code&gt; is of course the hexadecimal representation of 31 and &lt;code class="docutils literal"&gt;1d&lt;/code&gt; corresponds to 29.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="running-the-sample"&gt;
&lt;h2&gt;Running the sample&lt;/h2&gt;
&lt;p&gt;Now that we're confident that the devicetree is correct, let's create a firmware package and flash it to the nRF52840 Dongle:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-1" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-1"&gt;&lt;/a&gt;koan@tux:~/bme280$&lt;span class="w"&gt; &lt;/span&gt;nrfutil&lt;span class="w"&gt; &lt;/span&gt;pkg&lt;span class="w"&gt; &lt;/span&gt;generate&lt;span class="w"&gt; &lt;/span&gt;--hw-version&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;52&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--sd-req&lt;span class="o"&gt;=&lt;/span&gt;0x00&lt;span class="w"&gt; &lt;/span&gt;--application&lt;span class="w"&gt; &lt;/span&gt;build/zephyr/zephyr.hex&lt;span class="w"&gt; &lt;/span&gt;--application-version&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;bme280.zip
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-2" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-3" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-3" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-3"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="o"&gt;===============================================================&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-4" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-4" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-4"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="c1"&gt;##      ##    ###    ########  ##    ## #### ##    ##  ######  |&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-5" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-5" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-5"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="c1"&gt;##  ##  ##   ## ##   ##     ## ###   ##  ##  ###   ## ##    ## |&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-6" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-6" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-6"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="c1"&gt;##  ##  ##  ##   ##  ##     ## ####  ##  ##  ####  ## ##       |&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-7" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-7" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-7"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="c1"&gt;##  ##  ## ##     ## ########  ## ## ##  ##  ## ## ## ##   ####|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-8" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-8" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-8"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="c1"&gt;##  ##  ## ######### ##   ##   ##  ####  ##  ##  #### ##    ## |&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-9" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-9" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-9"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="c1"&gt;##  ##  ## ##     ## ##    ##  ##   ###  ##  ##   ### ##    ## |&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-10" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-10" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-10"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;###  ###  ##     ## ##     ## ##    ## #### ##    ##  ######  |&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-11" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-11" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-11"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="o"&gt;===============================================================&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-12" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-12" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-12"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;You&lt;span class="w"&gt; &lt;/span&gt;are&lt;span class="w"&gt; &lt;/span&gt;not&lt;span class="w"&gt; &lt;/span&gt;providing&lt;span class="w"&gt; &lt;/span&gt;a&lt;span class="w"&gt; &lt;/span&gt;signature&lt;span class="w"&gt; &lt;/span&gt;key,&lt;span class="w"&gt; &lt;/span&gt;which&lt;span class="w"&gt; &lt;/span&gt;means&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;DFU&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-13" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-13" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-13"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;files&lt;span class="w"&gt; &lt;/span&gt;will&lt;span class="w"&gt; &lt;/span&gt;not&lt;span class="w"&gt; &lt;/span&gt;be&lt;span class="w"&gt; &lt;/span&gt;signed,&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;are&lt;span class="w"&gt; &lt;/span&gt;vulnerable&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;tampering.&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-14" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-14" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-14"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;This&lt;span class="w"&gt; &lt;/span&gt;is&lt;span class="w"&gt; &lt;/span&gt;only&lt;span class="w"&gt; &lt;/span&gt;compatible&lt;span class="w"&gt; &lt;/span&gt;with&lt;span class="w"&gt; &lt;/span&gt;a&lt;span class="w"&gt; &lt;/span&gt;signature-less&lt;span class="w"&gt; &lt;/span&gt;bootloader&lt;span class="w"&gt; &lt;/span&gt;and&lt;span class="w"&gt; &lt;/span&gt;is&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-15" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-15" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-15"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;not&lt;span class="w"&gt; &lt;/span&gt;suitable&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;production&lt;span class="w"&gt; &lt;/span&gt;environments.&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-16" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-16" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-16"&gt;&lt;/a&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="o"&gt;===============================================================&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-17" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-17" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-17"&gt;&lt;/a&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-18" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-18" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-18"&gt;&lt;/a&gt;Zip&lt;span class="w"&gt; &lt;/span&gt;created&lt;span class="w"&gt; &lt;/span&gt;at&lt;span class="w"&gt; &lt;/span&gt;bme280.zip
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-19" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-19" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-19"&gt;&lt;/a&gt;koan@tux:~/bme280$&lt;span class="w"&gt; &lt;/span&gt;nrfutil&lt;span class="w"&gt; &lt;/span&gt;dfu&lt;span class="w"&gt; &lt;/span&gt;usb-serial&lt;span class="w"&gt; &lt;/span&gt;-pkg&lt;span class="w"&gt; &lt;/span&gt;bme280.zip&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;/dev/ttyACM0
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-20" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-20" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-20"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="c1"&gt;####################################]  100%&lt;/span&gt;
&lt;a id="rest_code_c975acc081394fb997c5b8baa9dfe5ca-21" name="rest_code_c975acc081394fb997c5b8baa9dfe5ca-21" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_c975acc081394fb997c5b8baa9dfe5ca-21"&gt;&lt;/a&gt;Device&lt;span class="w"&gt; &lt;/span&gt;programmed.
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After this, connect to the UART interface over USB:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_43aea3277db042c1bdc629d1951c99a4-1" name="rest_code_43aea3277db042c1bdc629d1951c99a4-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_43aea3277db042c1bdc629d1951c99a4-1"&gt;&lt;/a&gt;koan@tux:~$&lt;span class="w"&gt; &lt;/span&gt;screen&lt;span class="w"&gt; &lt;/span&gt;/dev/ttyACM0
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You should see that the I²C device has been detected, and the sensor values are being displayed:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-1" name="rest_code_80aff91d22b346eaaf995a4eea711bce-1" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-1"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;00&lt;/span&gt;:00:00.317,932&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;dbg&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;BME280:&lt;span class="w"&gt; &lt;/span&gt;bme280_chip_init:&lt;span class="w"&gt; &lt;/span&gt;ID&lt;span class="w"&gt; &lt;/span&gt;OK
&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-2" name="rest_code_80aff91d22b346eaaf995a4eea711bce-2" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-2"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="m"&gt;00&lt;/span&gt;:00:00.328,582&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;lt;dbg&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;BME280:&lt;span class="w"&gt; &lt;/span&gt;bme280_chip_init:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bme280@76"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;OK
&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-3" name="rest_code_80aff91d22b346eaaf995a4eea711bce-3" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-3"&gt;&lt;/a&gt;***&lt;span class="w"&gt; &lt;/span&gt;Booting&lt;span class="w"&gt; &lt;/span&gt;Zephyr&lt;span class="w"&gt; &lt;/span&gt;OS&lt;span class="w"&gt; &lt;/span&gt;build&lt;span class="w"&gt; &lt;/span&gt;zephyr-v3.4.0-837-gb4ed6c4300a2&lt;span class="w"&gt; &lt;/span&gt;***
&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-4" name="rest_code_80aff91d22b346eaaf995a4eea711bce-4" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-4"&gt;&lt;/a&gt;Found&lt;span class="w"&gt; &lt;/span&gt;device&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"bme280@76"&lt;/span&gt;,&lt;span class="w"&gt; &lt;/span&gt;getting&lt;span class="w"&gt; &lt;/span&gt;sensor&lt;span class="w"&gt; &lt;/span&gt;data
&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-5" name="rest_code_80aff91d22b346eaaf995a4eea711bce-5" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-5"&gt;&lt;/a&gt;temp:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;25&lt;/span&gt;.850000&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;press:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;101&lt;/span&gt;.987800&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;humidity:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;59&lt;/span&gt;.248046
&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-6" name="rest_code_80aff91d22b346eaaf995a4eea711bce-6" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-6"&gt;&lt;/a&gt;temp:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;25&lt;/span&gt;.840000&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;press:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;101&lt;/span&gt;.986144&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;humidity:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;59&lt;/span&gt;.187500
&lt;a id="rest_code_80aff91d22b346eaaf995a4eea711bce-7" name="rest_code_80aff91d22b346eaaf995a4eea711bce-7" href="https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/#rest_code_80aff91d22b346eaaf995a4eea711bce-7"&gt;&lt;/a&gt;temp:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;25&lt;/span&gt;.850000&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;press:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;101&lt;/span&gt;.985195&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;humidity:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;59&lt;/span&gt;.176757
&lt;/pre&gt;&lt;/div&gt;
&lt;/section&gt;</description><category>bme280</category><category>embedded</category><category>i2c</category><category>iot</category><category>open-source</category><category>programming</category><category>rtos</category><category>zephyr</category><guid>https://koen.vervloesem.eu/blog/how-to-change-the-default-i2c-pins-in-zephyr/</guid><pubDate>Mon, 21 Aug 2023 19:02:39 GMT</pubDate></item><item><title>Using ESPHome on the Raspberry Pi Pico W and other RP2040 microcontroller boards</title><link>https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;&lt;a class="reference external" href="https://esphome.io"&gt;ESPHome&lt;/a&gt; is an open-source program that allows you to create your own home-automation devices using an ESP32, ESP8266, or RP2040 microcontroller board that you connect to LEDs, sensors, or switches. What sets ESPHome apart from other solutions like Arduino or MicroPython is that you don't need to program. Instead, you define your components and their respective pin connections in a &lt;a class="reference external" href="https://yaml.org"&gt;YAML&lt;/a&gt; configuration file. ESPHome then generates the necessary C++ code and compiles it into firmware that you can install on the device. &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-esphome-book" id="footnote-reference-1" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;1&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;ESPHome is often used with ESP32 development boards. Support for the &lt;a class="reference external" href="https://esphome.io/components/rp2040.html"&gt;RP2040 platform&lt;/a&gt;, the chip in the popular Raspberry Pi Pico W, is still relatively new (introduced in &lt;a class="reference external" href="https://esphome.io/changelog/2022.11.0.html"&gt;ESPHome 2022.11&lt;/a&gt;). As a result, you may encounter some issues, some things are not clearly documented, and there aren't that many ESPHome example configurations using the RP2040. In this article, I'll share my findings after exploring ESPHome's RP2040 support.&lt;/p&gt;
&lt;section id="use-the-dashboard-not-the-wizard"&gt;
&lt;h2&gt;Use the dashboard, not the wizard&lt;/h2&gt;
&lt;p&gt;A first issue you may encounter is that ESPHome's command-line wizard doesn't support the RP2040 platform. The wizard is typically used to create a new ESPHome project by guiding you through a series of steps and generating a default YAML file. However, as of ESPHome 2023.7.0, the wizard only accepts ESP32 or ESP8266 as a platform:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-1" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;esphome&lt;span class="w"&gt; &lt;/span&gt;wizard&lt;span class="w"&gt; &lt;/span&gt;test.yaml
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-2" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-2"&gt;&lt;/a&gt;Hi&lt;span class="w"&gt; &lt;/span&gt;there!
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-3" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-3"&gt;&lt;/a&gt;I&lt;span class="s1"&gt;'m the wizard of ESPHome :)&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-4" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-4"&gt;&lt;/a&gt;&lt;span class="s1"&gt;And I'&lt;/span&gt;m&lt;span class="w"&gt; &lt;/span&gt;here&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;help&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;you&lt;span class="w"&gt; &lt;/span&gt;get&lt;span class="w"&gt; &lt;/span&gt;started&lt;span class="w"&gt; &lt;/span&gt;with&lt;span class="w"&gt; &lt;/span&gt;ESPHome.
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-5" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-5"&gt;&lt;/a&gt;In&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;steps&lt;span class="w"&gt; &lt;/span&gt;I&lt;span class="s1"&gt;'m going to guide you through creating a basic configuration file for your custom ESP8266/ESP32 firmware. Yay!&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-6" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-6"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-7" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-8" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-8"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-9" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-9"&gt;&lt;/a&gt;&lt;span class="s1"&gt;============= STEP 1 =============&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-10" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-10" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-10"&gt;&lt;/a&gt;&lt;span class="s1"&gt;    _____ ____  _____  ______&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-11" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-11" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-11"&gt;&lt;/a&gt;&lt;span class="s1"&gt;   / ____/ __ \|  __ \|  ____|&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-12" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-12" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-12"&gt;&lt;/a&gt;&lt;span class="s1"&gt;  | |   | |  | | |__) | |__&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-13" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-13" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-13"&gt;&lt;/a&gt;&lt;span class="s1"&gt;  | |   | |  | |  _  /|  __|&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-14" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-14" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-14"&gt;&lt;/a&gt;&lt;span class="s1"&gt;  | |___| |__| | | \ \| |____&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-15" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-15" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-15"&gt;&lt;/a&gt;&lt;span class="s1"&gt;   \_____\____/|_|  \_\______|&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-16" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-16" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-16"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-17" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-17" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-17"&gt;&lt;/a&gt;&lt;span class="s1"&gt;===================================&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-18" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-18" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-18"&gt;&lt;/a&gt;&lt;span class="s1"&gt;First up, please choose a name for your node.&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-19" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-19" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-19"&gt;&lt;/a&gt;&lt;span class="s1"&gt;It should be a unique name that can be used to identify the device later.&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-20" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-20" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-20"&gt;&lt;/a&gt;&lt;span class="s1"&gt;For example, I like calling the node in my living room livingroom.&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-21" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-21" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-21"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-22" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-22" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-22"&gt;&lt;/a&gt;&lt;span class="s1"&gt;(name): test&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-23" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-23" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-23"&gt;&lt;/a&gt;&lt;span class="s1"&gt;Great! Your node is now called "test".&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-24" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-24" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-24"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-25" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-25" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-25"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-26" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-26" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-26"&gt;&lt;/a&gt;&lt;span class="s1"&gt;============= STEP 2 =============&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-27" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-27" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-27"&gt;&lt;/a&gt;&lt;span class="s1"&gt;      ______  _____ _____&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-28" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-28" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-28"&gt;&lt;/a&gt;&lt;span class="s1"&gt;     |  ____|/ ____|  __ \\&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-29" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-29" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-29"&gt;&lt;/a&gt;&lt;span class="s1"&gt;     | |__  | (___ | |__) |&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-30" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-30" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-30"&gt;&lt;/a&gt;&lt;span class="s1"&gt;     |  __|  \___ \|  ___/&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-31" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-31" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-31"&gt;&lt;/a&gt;&lt;span class="s1"&gt;     | |____ ____) | |&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-32" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-32" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-32"&gt;&lt;/a&gt;&lt;span class="s1"&gt;     |______|_____/|_|&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-33" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-33" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-33"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-34" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-34" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-34"&gt;&lt;/a&gt;&lt;span class="s1"&gt;===================================&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-35" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-35" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-35"&gt;&lt;/a&gt;&lt;span class="s1"&gt;Now I'&lt;/span&gt;d&lt;span class="w"&gt; &lt;/span&gt;like&lt;span class="w"&gt; &lt;/span&gt;to&lt;span class="w"&gt; &lt;/span&gt;know&lt;span class="w"&gt; &lt;/span&gt;what&lt;span class="w"&gt; &lt;/span&gt;microcontroller&lt;span class="w"&gt; &lt;/span&gt;you&lt;span class="s1"&gt;'re using so that I can compile firmwares for it.&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-36" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-36" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-36"&gt;&lt;/a&gt;&lt;span class="s1"&gt;Are you using an ESP32 or ESP8266 platform? (Choose ESP8266 for Sonoff devices)&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-37" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-37" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-37"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-38" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-38" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-38"&gt;&lt;/a&gt;&lt;span class="s1"&gt;Please enter either ESP32 or ESP8266.&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-39" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-39" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-39"&gt;&lt;/a&gt;&lt;span class="s1"&gt;(ESP32/ESP8266): RP2040&lt;/span&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-40" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-40" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-40"&gt;&lt;/a&gt;&lt;span class="s1"&gt;Unfortunately, I can'&lt;/span&gt;t&lt;span class="w"&gt; &lt;/span&gt;find&lt;span class="w"&gt; &lt;/span&gt;an&lt;span class="w"&gt; &lt;/span&gt;espressif&lt;span class="w"&gt; &lt;/span&gt;microcontroller&lt;span class="w"&gt; &lt;/span&gt;called&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"RP2040"&lt;/span&gt;.&lt;span class="w"&gt; &lt;/span&gt;Please&lt;span class="w"&gt; &lt;/span&gt;try&lt;span class="w"&gt; &lt;/span&gt;again.
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-41" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-41" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-41"&gt;&lt;/a&gt;
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-42" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-42" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-42"&gt;&lt;/a&gt;Please&lt;span class="w"&gt; &lt;/span&gt;enter&lt;span class="w"&gt; &lt;/span&gt;either&lt;span class="w"&gt; &lt;/span&gt;ESP32&lt;span class="w"&gt; &lt;/span&gt;or&lt;span class="w"&gt; &lt;/span&gt;ESP8266.
&lt;a id="rest_code_5e8547c4cb364d8c9119eabb7f86d270-43" name="rest_code_5e8547c4cb364d8c9119eabb7f86d270-43" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_5e8547c4cb364d8c9119eabb7f86d270-43"&gt;&lt;/a&gt;&lt;span class="o"&gt;(&lt;/span&gt;ESP32/ESP8266&lt;span class="o"&gt;)&lt;/span&gt;:
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Fortunately, this limitation doesn't mean that you have to configure your Raspberry Pi Pico W from scratch. Instead, you can use the ESPHome dashboard.&lt;/p&gt;
&lt;p&gt;To start the ESPHome dashboard and specify the directory where your ESPHome configuration files are located, run the following command: &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-config-dir" id="footnote-reference-2" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;2&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_f2d0bfe3c01d448cb6183a367218b49b-1" name="rest_code_f2d0bfe3c01d448cb6183a367218b49b-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_f2d0bfe3c01d448cb6183a367218b49b-1"&gt;&lt;/a&gt;$ esphome dashboard config/
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will start a web server on &lt;a class="reference external" href="http://0.0.0.0:6052"&gt;http://0.0.0.0:6052&lt;/a&gt;. You can access this URL from your web browser. If you already have ESPHome devices on your network, the dashboard will automatically discover them.&lt;/p&gt;
&lt;p&gt;Next, click on &lt;strong&gt;New device&lt;/strong&gt; at the bottom right corner, and then on &lt;strong&gt;Continue&lt;/strong&gt;. Give your device a name and enter the SSID and password for the Wi-Fi network that you want your device to connect to. Click on &lt;strong&gt;Next&lt;/strong&gt; and choose your device type. For an ESP32 or ESP8266, you first need to choose the platform and then the specific board. For the RP2040 platform, the dashboard (as of ESPHome 2023.7.0) only allows you to choose &lt;strong&gt;Raspberry Pi Pico W&lt;/strong&gt;, and also &lt;strong&gt;Raspberry Pi Pico&lt;/strong&gt; if you uncheck &lt;strong&gt;Use recommended settings&lt;/strong&gt;. You can always manually change the board later. For now, let's assume you want to install ESPHome on a Raspberry Pi Pico W. After choosing the platform, the dashboard creates a minimal configuration and shows an encryption key that you can use to allow the ESPHome device to communicate with &lt;a class="reference external" href="https://www.home-assistant.io"&gt;Home Assistant&lt;/a&gt;, the popular open-source home automation gateway developed by the same team behind ESPHome. Finally, click on &lt;strong&gt;Install&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;ESPHome offers several installation methods, but not all of them are supported by every device. Since there's no ESPHome firmware running on your device yet, the first method (over Wi-Fi) is not yet possible. &lt;strong&gt;Plug into the computer running ESPHome Dashboard&lt;/strong&gt; isn't available either, for the same reason. However, you can always choose &lt;strong&gt;Manual download&lt;/strong&gt;. This gives you instructions on how to accomplish the installation. For the Raspberry Pi Pico W, you need to disconnect the board from USB, hold down the BOOTSEL button while reconnecting the board, and then release the button. This will cause a USB drive named &lt;strong&gt;RPI-RP2&lt;/strong&gt; to appear in your file manager. In the ESPHome dashboard, click on &lt;strong&gt;Download project&lt;/strong&gt; and then drag the .uf2 file to the USB drive. Once the drive disappears, the board runs your ESPHome firmware, and you can click on &lt;strong&gt;Close&lt;/strong&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="blinking-the-built-in-led-on-the-raspberry-pi-pico-w"&gt;
&lt;h2&gt;Blinking the built-in LED on the Raspberry Pi Pico W&lt;/h2&gt;
&lt;p&gt;On the Raspberry Pi Pico, the built-in LED is connected to GPIO25. However, on the Raspberry Pi Pico W, the built-in LED is connected to the Wi-Fi chip, the Infineon CYW43439. To blink the LED on the Raspberry Pi Pico W, you need to use GPIO32. &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-gpio32" id="footnote-reference-3" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;3&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt; For example, edit your configuration file by clicking on &lt;strong&gt;Edit&lt;/strong&gt; in the box representing your device, and add this YAML configuration:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-1" name="rest_code_e720b05908d94824a124d7a6a1acc39c-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-2" name="rest_code_e720b05908d94824a124d7a6a1acc39c-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;gpio&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-3" name="rest_code_e720b05908d94824a124d7a6a1acc39c-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;32&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-4" name="rest_code_e720b05908d94824a124d7a6a1acc39c-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-5" name="rest_code_e720b05908d94824a124d7a6a1acc39c-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-6" name="rest_code_e720b05908d94824a124d7a6a1acc39c-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-6"&gt;&lt;/a&gt;&lt;span class="nt"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-7" name="rest_code_e720b05908d94824a124d7a6a1acc39c-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;1000ms&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-8" name="rest_code_e720b05908d94824a124d7a6a1acc39c-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;then&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-9" name="rest_code_e720b05908d94824a124d7a6a1acc39c-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;output.turn_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-10" name="rest_code_e720b05908d94824a124d7a6a1acc39c-10" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;500ms&lt;/span&gt;
&lt;a id="rest_code_e720b05908d94824a124d7a6a1acc39c-11" name="rest_code_e720b05908d94824a124d7a6a1acc39c-11" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_e720b05908d94824a124d7a6a1acc39c-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;output.turn_off&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This configuration adds an &lt;code class="docutils literal"&gt;output&lt;/code&gt; component with the &lt;code class="docutils literal"&gt;gpio&lt;/code&gt; platform, assigning it to GPIO pin 32, which corresponds to the built-in LED of the Raspberry Pi Pico W. Additionally, an &lt;code class="docutils literal"&gt;interval&lt;/code&gt; component is defined to trigger the LED to turn on, wait for 500 ms, and then turn off every 1000ms.&lt;/p&gt;
&lt;p&gt;After saving the file (in the web editor at the top right), click on &lt;strong&gt;Install&lt;/strong&gt;. Choose your installation method. Since your Raspberry Pi Pico W is already running ESPHome and connected to your Wi-Fi network, you can choose &lt;strong&gt;Wirelessly&lt;/strong&gt; as the installation method. The board doesn't even need to be connected to your computer's USB port anymore. Your YAML configuration is now transformed into C++ code and compiled. If you see the message &lt;strong&gt;INFO Successfully compiled program.&lt;/strong&gt;, the dashboard will upload the new firmware. Once the board reboots, the LED starts blinking.&lt;/p&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;You can also use the &lt;code class="docutils literal"&gt;LED&lt;/code&gt; pin number. ESPHome automatically translates it to pin 25 for the Raspberry Pi Pico and to pin 32 for the Raspberry Pi Pico W. &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-pin-led" id="footnote-reference-4" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;4&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/aside&gt;
&lt;/section&gt;
&lt;section id="using-pwm-output"&gt;
&lt;h2&gt;Using PWM output&lt;/h2&gt;
&lt;p&gt;If you want to send a PWM (pulse-width modulation) signal to a GPIO pin on the RP2040, you can use the &lt;code class="docutils literal"&gt;output&lt;/code&gt; component with the &lt;code class="docutils literal"&gt;rp2040_pwm&lt;/code&gt; platform (not yet documented on ESPHome's web site). Here's an example how you can make a dimmable LED connected to GPIO15: &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-builtin-led-pwn" id="footnote-reference-5" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;5&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-1" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-2" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pwm&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-3" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;15&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-4" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-5" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-6" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-6"&gt;&lt;/a&gt;&lt;span class="nt"&gt;light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-7" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;monochromatic&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-8" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Dimmable&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;LED"&lt;/span&gt;
&lt;a id="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-9" name="rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_32e6f8aa3b6d4f47b7bcb1042a5281d3-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On a breadboard, connect the anode (the longer leg) of an LED to the Pico W's GPIO15 pin. Then connect the cathode (the shorter leg), via a 220 Ω resistor, to GND. The circuit should look like this:&lt;/p&gt;
&lt;img alt="/images/picow-led-gpio15_bb.png" class="align-center" src="https://koen.vervloesem.eu/images/picow-led-gpio15_bb.png"&gt;
&lt;p&gt;After uploading this firmware to your board, you can control the LED's brightness using Home Assistant's dashboard:&lt;/p&gt;
&lt;img alt="/images/ha-dimmable-led.png" class="align-center" src="https://koen.vervloesem.eu/images/ha-dimmable-led.png"&gt;
&lt;p&gt;You can also use a PWM output to create various &lt;a class="reference external" href="https://esphome.io/components/light/index.html#light-effects"&gt;light effects&lt;/a&gt;. This is how you define a slow &lt;a class="reference external" href="https://esphome.io/components/light/#pulse-effect"&gt;pulse effect&lt;/a&gt; that continuously pulses the LED:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-1" name="rest_code_9e245126fb934f67aaf7600960dcd27d-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-2" name="rest_code_9e245126fb934f67aaf7600960dcd27d-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pwm&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-3" name="rest_code_9e245126fb934f67aaf7600960dcd27d-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;15&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-4" name="rest_code_9e245126fb934f67aaf7600960dcd27d-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-5" name="rest_code_9e245126fb934f67aaf7600960dcd27d-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-6" name="rest_code_9e245126fb934f67aaf7600960dcd27d-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-6"&gt;&lt;/a&gt;&lt;span class="nt"&gt;light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-7" name="rest_code_9e245126fb934f67aaf7600960dcd27d-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;monochromatic&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-8" name="rest_code_9e245126fb934f67aaf7600960dcd27d-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-9" name="rest_code_9e245126fb934f67aaf7600960dcd27d-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;pulsating_led&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-10" name="rest_code_9e245126fb934f67aaf7600960dcd27d-10" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;effects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-11" name="rest_code_9e245126fb934f67aaf7600960dcd27d-11" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;pulse&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-12" name="rest_code_9e245126fb934f67aaf7600960dcd27d-12" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Slow&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;pulse"&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-13" name="rest_code_9e245126fb934f67aaf7600960dcd27d-13" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;transition_length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;2s&lt;/span&gt;
&lt;a id="rest_code_9e245126fb934f67aaf7600960dcd27d-14" name="rest_code_9e245126fb934f67aaf7600960dcd27d-14" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_9e245126fb934f67aaf7600960dcd27d-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;update_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;2s&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To start this effect, add the following automation to the &lt;code class="docutils literal"&gt;on_boot&lt;/code&gt; section of the &lt;code class="docutils literal"&gt;esphome&lt;/code&gt; core configuration:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-1" name="rest_code_4f7dd25b6de54be29b1049994054147a-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;esphome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-2" name="rest_code_4f7dd25b6de54be29b1049994054147a-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;raspberry-pi-pico-w&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-3" name="rest_code_4f7dd25b6de54be29b1049994054147a-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;friendly_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;Raspberry Pi Pico W&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-4" name="rest_code_4f7dd25b6de54be29b1049994054147a-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;on_boot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-5" name="rest_code_4f7dd25b6de54be29b1049994054147a-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;then&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-6" name="rest_code_4f7dd25b6de54be29b1049994054147a-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;light.turn_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-7" name="rest_code_4f7dd25b6de54be29b1049994054147a-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;pulsating_led&lt;/span&gt;
&lt;a id="rest_code_4f7dd25b6de54be29b1049994054147a-8" name="rest_code_4f7dd25b6de54be29b1049994054147a-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_4f7dd25b6de54be29b1049994054147a-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;effect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Slow&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;pulse"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;After uploading the firmware to the board, the LED will start slowly pulsing.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="only-use-i2c0"&gt;
&lt;h2&gt;Only use I2C0&lt;/h2&gt;
&lt;p&gt;When using I²C devices with the RP2040, it's important to note that ESPHome's I²C component for the RP2040 &lt;a class="reference external" href="https://github.com/esphome/issues/issues/3838"&gt;only works for the i2c0 bus&lt;/a&gt;. To determine which pins to use for I²C, always refer to the Raspberry Pi Pico W's pinout:&lt;/p&gt;
&lt;img alt="/images/picow-pinout.svg" class="align-center" src="https://koen.vervloesem.eu/images/picow-pinout.svg"&gt;
&lt;p&gt;Only the pins defined as I2C0 SDA and I2C0 SCL can be used for I²C communication. This means you can use the following pin combinations for SDA/SCL: GP0/GP1, GP4/GP5, GP8/GP9, GP12/GP13, GP16/GP17, or GP20/GP21.&lt;/p&gt;
&lt;aside class="admonition warning"&gt;
&lt;p class="admonition-title"&gt;Warning&lt;/p&gt;
&lt;p&gt;If you accidentally use the I2C1 bus, the board won't boot. However, you can recover from this by disconnecting the board from USB, holding down the BOOTSEL button while reconnecting the board, and then releasing the button. Then move the .uf2 file with the correct I²C configuration to the RPI-RP2 drive that appears in your file manager.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;Since the GP20/GP21 pins on the Raspberry Pi Pico W are dedicated to I2C0 SDA/I2C0 SCL and do not have any alternative functions, I like to use these pins for the I²C bus. Here's an example configuration to read the temperature, pressure, and humidity from a &lt;a class="reference external" href="https://esphome.io/components/sensor/bme280.html"&gt;BME280 sensor&lt;/a&gt; board:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-1" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;i2c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-2" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;sda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;20&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-3" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;scl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;21&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-4" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-4"&gt;&lt;/a&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-5" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-5"&gt;&lt;/a&gt;&lt;span class="nt"&gt;sensor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-6" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;bme280&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-7" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-8" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"BME280&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Temperature"&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-9" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pressure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-10" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-10" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"BME280&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Pressure"&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-11" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-11" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;humidity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-12" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-12" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"BME280&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;Humidity"&lt;/span&gt;
&lt;a id="rest_code_0d28f2d5397741999881fbe9c8fe02fd-13" name="rest_code_0d28f2d5397741999881fbe9c8fe02fd-13" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_0d28f2d5397741999881fbe9c8fe02fd-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;address&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;0x77&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For some BME280 boards, you need to specify an alternative address, &lt;code class="docutils literal"&gt;0x76&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Connect the pins as shown in the following circuit diagram for the BME280:&lt;/p&gt;
&lt;img alt="/images/picow-bme280_bb.png" class="align-center" src="https://koen.vervloesem.eu/images/picow-bme280_bb.png"&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;On Adafruit's version of the sensor board, SDA is called SDI and SCL is referred to as SCK.&lt;/p&gt;
&lt;/aside&gt;
&lt;/section&gt;
&lt;section id="driving-addressable-led-strips"&gt;
&lt;h2&gt;Driving addressable LED strips&lt;/h2&gt;
&lt;p&gt;Traditionally, ESPHome supported adressable LED strips using the &lt;a class="reference external" href="https://esphome.io/components/light/neopixelbus.html"&gt;NeoPixelBus&lt;/a&gt; and &lt;a class="reference external" href="https://esphome.io/components/light/fastled.html"&gt;FastLED&lt;/a&gt; platforms for the &lt;a class="reference external" href="https://esphome.io/components/light/index.html"&gt;Light&lt;/a&gt; component. However, these platforms &lt;a class="reference external" href="https://github.com/esphome/issues/issues/4559"&gt;don't work with the RP2040&lt;/a&gt;. Instead, you can use the &lt;a class="reference external" href="https://esphome.io/components/light/rp2040_pio_led_strip.html"&gt;RP2040 PIO LED Strip&lt;/a&gt; platform, which uses the RP2040 PIO (Programmable Input Output) peripheral to control various addressable LED strips.&lt;/p&gt;
&lt;p&gt;For example, an ESPHome configuration to drive a LED strip of eight WS2812B LEDs looks like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-1" name="rest_code_3c8ad50bf068489f96043407f5d09744-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-2" name="rest_code_3c8ad50bf068489f96043407f5d09744-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pio_led_strip&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-3" name="rest_code_3c8ad50bf068489f96043407f5d09744-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_strip&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-4" name="rest_code_3c8ad50bf068489f96043407f5d09744-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_strip&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-5" name="rest_code_3c8ad50bf068489f96043407f5d09744-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;13&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-6" name="rest_code_3c8ad50bf068489f96043407f5d09744-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;num_leds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;8&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-7" name="rest_code_3c8ad50bf068489f96043407f5d09744-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;0&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-8" name="rest_code_3c8ad50bf068489f96043407f5d09744-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;rgb_order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;GRB&lt;/span&gt;
&lt;a id="rest_code_3c8ad50bf068489f96043407f5d09744-9" name="rest_code_3c8ad50bf068489f96043407f5d09744-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_3c8ad50bf068489f96043407f5d09744-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;chipset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WS2812B&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Connect the LED strip's DIN to the Pico W's GPIO13, GND to GND, and the LED strip's power pin to VBUS (3V3 isn't enough voltage, while on VBUS there's 5V from the USB connector).&lt;/p&gt;
&lt;p&gt;You can now add various light effects to your configuration.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="other-rp2040-microcontroller-boards"&gt;
&lt;h2&gt;Other RP2040 microcontroller boards&lt;/h2&gt;
&lt;p&gt;If you look at the configuration file generated by the ESPHome dashboard, by clicking on &lt;strong&gt;Edit&lt;/strong&gt; in the box representing your device, you'll notice the following section for the platform configuration:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_46772bd88b7f40b789b55db5dca91333-1" name="rest_code_46772bd88b7f40b789b55db5dca91333-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_46772bd88b7f40b789b55db5dca91333-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;rp2040&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_46772bd88b7f40b789b55db5dca91333-2" name="rest_code_46772bd88b7f40b789b55db5dca91333-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_46772bd88b7f40b789b55db5dca91333-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;board&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rpipicow&lt;/span&gt;
&lt;a id="rest_code_46772bd88b7f40b789b55db5dca91333-3" name="rest_code_46772bd88b7f40b789b55db5dca91333-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_46772bd88b7f40b789b55db5dca91333-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;framework&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_46772bd88b7f40b789b55db5dca91333-4" name="rest_code_46772bd88b7f40b789b55db5dca91333-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_46772bd88b7f40b789b55db5dca91333-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged&lt;/span&gt;
&lt;a id="rest_code_46772bd88b7f40b789b55db5dca91333-5" name="rest_code_46772bd88b7f40b789b55db5dca91333-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_46772bd88b7f40b789b55db5dca91333-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;platform_version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;https://github.com/maxgerhardt/platform-raspberrypi.git&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Since ESPHome uses &lt;a class="reference external" href="https://platformio.org"&gt;PlatformIO&lt;/a&gt; under the hood, it depends on PlatformIO's support for microcontroller platforms. However, this doesn't support the Raspberry Pi Pico W yet. Max Gerhardt forked PlatformIO's repository and added support for the Raspberry Pi Pico W, as well as other RP2040-based boards.&lt;/p&gt;
&lt;p&gt;Initially, I thought that I could just run ESPHome on RP2040 microcontroller boards other than the Raspberry Pi Pico W by specifying a different board name. To test this, I created a new device in the ESPHome dashboard, chose &lt;strong&gt;Raspberry Pi Pico W&lt;/strong&gt; as the device type, and then pressed &lt;strong&gt;Skip&lt;/strong&gt; to not install the firmware immediately to the board. I clicked on &lt;strong&gt;Edit&lt;/strong&gt; in the box representing my device, and changed the board definition &lt;code class="docutils literal"&gt;rpipicow&lt;/code&gt; to another &lt;a class="reference external" href="https://github.com/maxgerhardt/platform-raspberrypi/tree/develop/boards"&gt;supported board&lt;/a&gt; in Max Gerhardt's fork of the RP2040 development platform for PlatformIO, the &lt;a class="reference external" href="https://store.arduino.cc/products/arduino-nano-rp2040-connect"&gt;Arduino Nano RP2040 Connect&lt;/a&gt; (&lt;code class="docutils literal"&gt;arduino_nano_connect&lt;/code&gt;). After saving the configuration, I clicked on &lt;strong&gt;Install&lt;/strong&gt; at the top right corner.&lt;/p&gt;
&lt;p&gt;However, when I chose &lt;strong&gt;Manual download&lt;/strong&gt; to download the .uf2 file, the image preparation failed, and I encountered several "undefined reference" errors related to the Wi-Fi chip. I should've expected this actually, as the Arduino Nano RP2040 Connect uses the u-blox NINA-W102 instead of the Raspberry Pi Pico W's Infineon CYW43439 for Wi-Fi. The same holds for the &lt;a class="reference external" href="https://www.tindie.com/products/invector/challenger-rp2040-wifi/"&gt;Challenger RP2040 WiFi&lt;/a&gt; (&lt;code class="docutils literal"&gt;challenger_2040_wifi&lt;/code&gt;), which uses the ESP8285 for Wi-Fi. It seems that additional work on the ESPHome side is required to support these other boards. I don't know any RP2040 boards from other manufacturers than Raspberry Pi using the CYW43439. If they exist, I suspect they should work with ESPHome.&lt;/p&gt;
&lt;p&gt;You can still use non-Wi-Fi RP2040 boards this way. For example, here's a configuration for the &lt;a class="reference external" href="https://www.seeedstudio.com/XIAO-RP2040-v1-0-p-5026.html"&gt;Seeed Studio XIAO RP2040&lt;/a&gt; (&lt;code class="docutils literal"&gt;seeed_xiao_rp2040&lt;/code&gt;):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-1" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;esphome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-2" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;xiao-rp2040&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-3" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;friendly_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;Xiao RP2040&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-4" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;on_boot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-5" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;then&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-6" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;output.turn_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-7" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_rgb_enable&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-8" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;light.turn_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-9" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_rgb&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-10" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-10" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;effect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Random&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;colors"&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-11" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-11" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-11"&gt;&lt;/a&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-12" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-12" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-12"&gt;&lt;/a&gt;&lt;span class="nt"&gt;rp2040&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-13" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-13" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;board&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;seeed_xiao_rp2040&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-14" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-14" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;framework&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-15" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-15" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-15"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-16" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-16" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-16"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;platform_version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;https://github.com/maxgerhardt/platform-raspberrypi.git&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-17" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-17" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-17"&gt;&lt;/a&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-18" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-18" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-18"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Enable logging&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-19" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-19" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-19"&gt;&lt;/a&gt;&lt;span class="nt"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-20" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-20" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-20"&gt;&lt;/a&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-21" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-21" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-21"&gt;&lt;/a&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-22" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-22" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-22"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;gpio&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-23" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-23" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-23"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;11&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-24" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-24" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-24"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_rgb_enable&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-25" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-25" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-25"&gt;&lt;/a&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-26" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-26" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-26"&gt;&lt;/a&gt;&lt;span class="nt"&gt;light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-27" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-27" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-27"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pio_led_strip&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-28" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-28" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-28"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_rgb&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-29" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-29" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-29"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;12&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-30" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-30" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-30"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;num_leds&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;1&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-31" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-31" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-31"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pio&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;0&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-32" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-32" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-32"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;rgb_order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;GRB&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-33" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-33" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-33"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;chipset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WS2812&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-34" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-34" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-34"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;effects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-35" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-35" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-35"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;random&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-36" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-36" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-36"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Random&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;colors"&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-37" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-37" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-37"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;transition_length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;1s&lt;/span&gt;
&lt;a id="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-38" name="rest_code_68a3ddb7ee3b411ba13fd0615b767d63-38" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_68a3ddb7ee3b411ba13fd0615b767d63-38"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;update_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;1s&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The board has a WS2812 RGB LED connected to GPIO12, so you can address it using the &lt;code class="docutils literal"&gt;rp2040_pio_led_strip&lt;/code&gt; platform with &lt;code class="docutils literal"&gt;num_leds&lt;/code&gt; set to &lt;code class="docutils literal"&gt;1&lt;/code&gt;. The &lt;code class="docutils literal"&gt;light&lt;/code&gt; component also defines a light effect with random colors. But before you can use the RGB LED on this board, you need to set GPIO11 high, so that's what the &lt;code class="docutils literal"&gt;output&lt;/code&gt; component is for. On boot, we first enable the LED, and then start the light effect.&lt;/p&gt;
&lt;p&gt;Even if a board isn't supported yet by Max Gerhardt's repository, you can still use it with ESPHome by specifying the board as &lt;code class="docutils literal"&gt;rpipico&lt;/code&gt; (or &lt;code class="docutils literal"&gt;rpipicow&lt;/code&gt; if you find a board with the CYW43439 Wi-Fi chip). This will probably work if you're not doing anything exotic. As an example, this is a configuration for &lt;a class="reference external" href="https://shop.pimoroni.com/products/tiny-2040"&gt;Pimoroni's Tiny 2040&lt;/a&gt; board:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code yaml"&gt;&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-1" name="rest_code_c1ed904190b04456ae35eb14c8423871-1" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;esphome&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-2" name="rest_code_c1ed904190b04456ae35eb14c8423871-2" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-2"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;tiny-2040&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-3" name="rest_code_c1ed904190b04456ae35eb14c8423871-3" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;friendly_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;Tiny 2040&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-4" name="rest_code_c1ed904190b04456ae35eb14c8423871-4" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;on_boot&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-5" name="rest_code_c1ed904190b04456ae35eb14c8423871-5" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;then&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-6" name="rest_code_c1ed904190b04456ae35eb14c8423871-6" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;light.turn_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-7" name="rest_code_c1ed904190b04456ae35eb14c8423871-7" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_rgb&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-8" name="rest_code_c1ed904190b04456ae35eb14c8423871-8" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;effect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Random&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;colors"&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-9" name="rest_code_c1ed904190b04456ae35eb14c8423871-9" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-10" name="rest_code_c1ed904190b04456ae35eb14c8423871-10" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-10"&gt;&lt;/a&gt;&lt;span class="nt"&gt;rp2040&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-11" name="rest_code_c1ed904190b04456ae35eb14c8423871-11" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;board&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rpipico&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-12" name="rest_code_c1ed904190b04456ae35eb14c8423871-12" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;framework&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-13" name="rest_code_c1ed904190b04456ae35eb14c8423871-13" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# Required until https://github.com/platformio/platform-raspberrypi/pull/36 is merged&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-14" name="rest_code_c1ed904190b04456ae35eb14c8423871-14" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;platform_version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;https://github.com/maxgerhardt/platform-raspberrypi.git&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-15" name="rest_code_c1ed904190b04456ae35eb14c8423871-15" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-15"&gt;&lt;/a&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-16" name="rest_code_c1ed904190b04456ae35eb14c8423871-16" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-16"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# Enable logging&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-17" name="rest_code_c1ed904190b04456ae35eb14c8423871-17" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-17"&gt;&lt;/a&gt;&lt;span class="nt"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-18" name="rest_code_c1ed904190b04456ae35eb14c8423871-18" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-18"&gt;&lt;/a&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-19" name="rest_code_c1ed904190b04456ae35eb14c8423871-19" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-19"&gt;&lt;/a&gt;&lt;span class="nt"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-20" name="rest_code_c1ed904190b04456ae35eb14c8423871-20" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-20"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pwm&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-21" name="rest_code_c1ed904190b04456ae35eb14c8423871-21" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-21"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_red&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-22" name="rest_code_c1ed904190b04456ae35eb14c8423871-22" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-22"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;18&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-23" name="rest_code_c1ed904190b04456ae35eb14c8423871-23" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-23"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;inverted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;True&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-24" name="rest_code_c1ed904190b04456ae35eb14c8423871-24" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-24"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pwm&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-25" name="rest_code_c1ed904190b04456ae35eb14c8423871-25" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-25"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_green&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-26" name="rest_code_c1ed904190b04456ae35eb14c8423871-26" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-26"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;19&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-27" name="rest_code_c1ed904190b04456ae35eb14c8423871-27" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-27"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;inverted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;True&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-28" name="rest_code_c1ed904190b04456ae35eb14c8423871-28" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-28"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rp2040_pwm&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-29" name="rest_code_c1ed904190b04456ae35eb14c8423871-29" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-29"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_blue&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-30" name="rest_code_c1ed904190b04456ae35eb14c8423871-30" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-30"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;pin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;20&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-31" name="rest_code_c1ed904190b04456ae35eb14c8423871-31" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-31"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;inverted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;True&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-32" name="rest_code_c1ed904190b04456ae35eb14c8423871-32" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-32"&gt;&lt;/a&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-33" name="rest_code_c1ed904190b04456ae35eb14c8423871-33" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-33"&gt;&lt;/a&gt;&lt;span class="nt"&gt;light&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-34" name="rest_code_c1ed904190b04456ae35eb14c8423871-34" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-34"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;platform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;rgb&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-35" name="rest_code_c1ed904190b04456ae35eb14c8423871-35" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-35"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_rgb&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-36" name="rest_code_c1ed904190b04456ae35eb14c8423871-36" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-36"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;red&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_red&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-37" name="rest_code_c1ed904190b04456ae35eb14c8423871-37" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-37"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;green&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_green&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-38" name="rest_code_c1ed904190b04456ae35eb14c8423871-38" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-38"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;led_blue&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-39" name="rest_code_c1ed904190b04456ae35eb14c8423871-39" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-39"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;effects&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-40" name="rest_code_c1ed904190b04456ae35eb14c8423871-40" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-40"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;random&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-41" name="rest_code_c1ed904190b04456ae35eb14c8423871-41" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-41"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"Random&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;colors"&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-42" name="rest_code_c1ed904190b04456ae35eb14c8423871-42" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-42"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;transition_length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;1s&lt;/span&gt;
&lt;a id="rest_code_c1ed904190b04456ae35eb14c8423871-43" name="rest_code_c1ed904190b04456ae35eb14c8423871-43" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#rest_code_c1ed904190b04456ae35eb14c8423871-43"&gt;&lt;/a&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nt"&gt;update_interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;1s&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The board has an RGB LED, which the R, G, and B components connected active low (that's why each output definition has &lt;code class="docutils literal"&gt;inverted: True&lt;/code&gt;) to GPIO18, GPIO19, and GPIO20, respectively. This configuration creates a PWM output for each color component, combines them into one RGB light, and starts a light effect with random colors on boot.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In conclusion, the support for the RP2040 platform in ESPHome is not as mature as the support for ESP32 or ESP8266. It lacks the same level of testing and comprehensive documentation. There are several &lt;a class="reference external" href="https://github.com/esphome/issues/issues?q=rp2040"&gt;issues&lt;/a&gt; reported, and certain functionalities such as &lt;a class="reference external" href="https://github.com/esphome/issues/issues/4055"&gt;MQTT&lt;/a&gt; and &lt;a class="reference external" href="https://github.com/esphome/issues/issues/3828"&gt;Bluetooth Low Energy&lt;/a&gt; are not yet supported on the RP2040.&lt;/p&gt;
&lt;p&gt;However, for a lot of tasks, ESPHome on the Raspberry Pi Pico W is still quite usable. If you have a spare Raspberry Pi Pico W lying around, give it a try! I'm also hopeful that support for additional RP2040 boards with Wi-Fi will be added in the near future.&lt;/p&gt;
&lt;aside class="footnote-list brackets"&gt;
&lt;aside class="footnote brackets" id="footnote-esphome-book" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-reference-1"&gt;1&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;If you're interested in exploring more ESPHome projects with various sensors and electronic components, you may find my book &lt;a class="reference external" href="https://koen.vervloesem.eu/books/getting-started-with-esphome/"&gt;Getting Started with ESPHome: Develop your own custom home automation devices&lt;/a&gt; helpful.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class="footnote brackets" id="footnote-config-dir" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-reference-2"&gt;2&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;It is recommended to create a directory where you store all your ESPHome projects.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class="footnote brackets" id="footnote-gpio32" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-reference-3"&gt;3&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;This doesn't seem to be documented, but you can find this in the &lt;a class="reference external" href="https://github.com/esphome/esphome/blob/dev/esphome/components/rp2040/gpio.py"&gt;esphome/components/rp2040/gpio.py&lt;/a&gt; file of ESPHome's source code.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class="footnote brackets" id="footnote-pin-led" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-reference-4"&gt;4&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;This also doesn't seem to be documented, but the LED pin is defined in &lt;a class="reference external" href="https://github.com/esphome/esphome/blob/dev/esphome/components/rp2040/boards.py"&gt;esphome/components/rp2040/boards.py&lt;/a&gt; for the Raspberry Pi Pico and Pico W.&lt;/p&gt;
&lt;/aside&gt;
&lt;aside class="footnote brackets" id="footnote-builtin-led-pwn" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/#footnote-reference-5"&gt;5&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;The built-in LED doesn't seem to support PWM.&lt;/p&gt;
&lt;/aside&gt;
&lt;/aside&gt;
&lt;/section&gt;</description><category>electronics</category><category>esp32</category><category>esp8266</category><category>esphome</category><category>home-automation</category><category>open-source</category><category>raspberry-pi-pico</category><category>raspberry-pi-pico-w</category><category>rp2040</category><guid>https://koen.vervloesem.eu/blog/using-esphome-on-the-raspberry-pi-pico-w-and-other-rp2040-microcontroller-boards/</guid><pubDate>Sun, 06 Aug 2023 18:32:19 GMT</pubDate></item><item><title>When BlueZ has connected once to a BLE device, it uses the Device Name characteristic for the device name</title><link>https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;The title of this article may seem trivial, but it represents the conclusion I reached after being astonished for a long time while debugging some issues related to decoding Bluetooth Low Energy (BLE) advertisements that rely on the device name. Like many solutions, the actual solution seemed simple in hindsight.&lt;/p&gt;
&lt;p&gt;For &lt;a class="reference external" href="https://decoder.theengs.io"&gt;Theengs Decoder&lt;/a&gt; I wrote decoders for two of Shelly's devices: the &lt;a class="reference external" href="https://www.shelly.cloud/en/products/shop/shelly-blu-button1"&gt;ShellyBLU Button1&lt;/a&gt; and the &lt;a class="reference external" href="https://www.shelly.cloud/en-be/products/shop/shelly-blu-door-window"&gt;ShellyBLU Door/Window&lt;/a&gt; sensor. Both devices broadcast BLE advertisements using the &lt;a class="reference external" href="https://bthome.io/format/"&gt;BTHome v2 format&lt;/a&gt;. Before we can decode these advertisements, we first need to identify the device that is sending a specific advertisement.&lt;/p&gt;
&lt;p&gt;In Theengs Decoder, device detection is achieved using a &lt;a class="reference external" href="https://decoder.theengs.io/participate/adding-decoders.html#condition"&gt;model condition&lt;/a&gt;. The &lt;a class="reference external" href="https://github.com/theengs/decoder/blob/development/src/devices/SBBT_002C_json.h"&gt;Button1 model condition&lt;/a&gt; is as follows:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code json"&gt;&lt;a id="rest_code_a9daa487526a4cadad72430e1c5a0212-1" name="rest_code_a9daa487526a4cadad72430e1c5a0212-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_a9daa487526a4cadad72430e1c5a0212-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;"condition"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;"servicedata"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"="&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"40"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"|"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"servicedata"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"="&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"44"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;amp;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"uuid"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"fcd2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;amp;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"SBBT-002C"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This means: the service data (an array of bytes) consists of 14 hexadecimal characters and begins with the byte &lt;code class="docutils literal"&gt;0x40&lt;/code&gt; (the first firmware versions) or &lt;code class="docutils literal"&gt;0x44&lt;/code&gt; (the latest firmware). Additionally, the service data UUID is &lt;code class="docutils literal"&gt;fcd2&lt;/code&gt; and the name starts with &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;SBBT-002C&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;a class="reference external" href="https://github.com/theengs/decoder/blob/development/src/devices/SBDW_002C_json.h"&gt;Door/Window model condition&lt;/a&gt; is similar:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code json"&gt;&lt;a id="rest_code_e4c440cc78b14a55ab1db85c28541d8e-1" name="rest_code_e4c440cc78b14a55ab1db85c28541d8e-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_e4c440cc78b14a55ab1db85c28541d8e-1"&gt;&lt;/a&gt;&lt;span class="nt"&gt;"condition"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;"servicedata"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"="&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"44"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;amp;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"uuid"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"fcd2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;amp;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"SBDW-002C"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here, the service data consists of 28 hexadecimal characters and starts with the byte &lt;code class="docutils literal"&gt;0x44&lt;/code&gt;. The service data UUID is &lt;code class="docutils literal"&gt;fcd2&lt;/code&gt; and the name starts with  &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;SBDW-002C&lt;/span&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Therefore, when decoding BLE advertisements, Theengs Decoder tries all model conditions for the &lt;a class="reference external" href="https://decoder.theengs.io/devices/devices.html"&gt;supported devices&lt;/a&gt;. If any of the conditions is true, the properties defined in the associated decoder are extracted from the advertised data.&lt;/p&gt;
&lt;p&gt;After writing these decoders, I tested them with &lt;a class="reference external" href="https://gateway.theengs.io/"&gt;Theengs Gateway&lt;/a&gt; on my Linux laptop. Theengs Gateway uses the cross-platform Python library &lt;a class="reference external" href="https://bleak.readthedocs.io"&gt;Bleak&lt;/a&gt;, which on Linux uses &lt;a class="reference external" href="http://www.bluez.org/"&gt;BlueZ&lt;/a&gt;, for receiving BLE advertisements. It then decodes them using Theengs Decoder and publishes the decoded properties (in this case a button push or the state of the contact sensor) to an MQTT broker. The decoders worked.&lt;/p&gt;
&lt;p&gt;It's important to know that Theengs Decoder purely works on BLE advertisements, which are broadcasted. This is the most basic way to communicate between BLE devices. All information is extracted from these advertisements: manufacturer-specific data, service data, and the local name. &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#footnote-ble-book" id="footnote-reference-1" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;1&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, when I later experimented with additional functionality of both devices, I connected to them. A couple of days later, I noticed that the decoders no longer worked. When I looked into it, I saw that Theengs Gateway had detected the devices with different names: &lt;code class="docutils literal"&gt;Shelly Blue Button 1&lt;/code&gt; and &lt;code class="docutils literal"&gt;Shelly BLE DW&lt;/code&gt;. Naturally, the previous model conditions no longer applied, because they were checking for the names &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;SBBT-002C&lt;/span&gt;&lt;/code&gt; and &lt;code class="docutils literal"&gt;&lt;span class="pre"&gt;SBDW-002C&lt;/span&gt;&lt;/code&gt;, respectively. Interestingly, the same version of Theengs Gateway running on a Raspberry Pi still managed to detect and decode both devices correctly, because it recognized them by their original names. I didn't understand this difference.&lt;/p&gt;
&lt;p&gt;It took me a while before I remembered that I had previously connected to both devices on my laptop. So then I started exploring their GATT characteristics. Each BLE device that allows connections has a Generic Access Profile (GAP) service with mandatory Device Name and Appearance characteristics. I read the Device Name characteristic from both devices, and to my surprise they were identified as &lt;code class="docutils literal"&gt;Shelly Blue Button 1&lt;/code&gt; and &lt;code class="docutils literal"&gt;Shelly BLE DW&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So that's when I started to connect the dots. Once I had connected to both devices from my laptop, BlueZ seemed to remember their names based on the Device Name characteristic, even after disconnecting. Apparently, when BlueZ later encounters advertisements from the same Bluetooth address, it doesn't use the advertised name (Complete Local Name or Shortened Local Name data type) to identify this device. Instead, it relies on the name it had previously stored from the Device Name characteristic. As a result, when Bleak requests the local name from BlueZ, it receives the device's Device Name characteristic instead of the advertised local name. Consequently, Theengs Gateway sent the 'wrong' name to Theengs Decoder, which caused the devices to remain undetected.&lt;/p&gt;
&lt;p&gt;You can check this with &lt;code class="docutils literal"&gt;bluetoothctl&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-1" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;bluetoothctl
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-2" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-2" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-2"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;bluetooth&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="c1"&gt;# info 5C:C7:C1:XX:XX:XX&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-3" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-3" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-3"&gt;&lt;/a&gt;Device&lt;span class="w"&gt; &lt;/span&gt;5C:C7:C1:XX:XX:XX&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;public&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-4" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-4" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Name:&lt;span class="w"&gt; &lt;/span&gt;Shelly&lt;span class="w"&gt; &lt;/span&gt;Blue&lt;span class="w"&gt; &lt;/span&gt;Button&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-5" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-5" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Alias:&lt;span class="w"&gt; &lt;/span&gt;Shelly&lt;span class="w"&gt; &lt;/span&gt;Blue&lt;span class="w"&gt; &lt;/span&gt;Button&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-6" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-6" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Appearance:&lt;span class="w"&gt; &lt;/span&gt;0x8001
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-7" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-7" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-7"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Paired:&lt;span class="w"&gt; &lt;/span&gt;no
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-8" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-8" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-8"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Trusted:&lt;span class="w"&gt; &lt;/span&gt;yes
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-9" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-9" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-9"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Blocked:&lt;span class="w"&gt; &lt;/span&gt;no
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-10" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-10" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-10"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;Connected:&lt;span class="w"&gt; &lt;/span&gt;no
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-11" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-11" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-11"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;LegacyPairing:&lt;span class="w"&gt; &lt;/span&gt;no
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-12" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-12" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-12"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;UUID:&lt;span class="w"&gt; &lt;/span&gt;Generic&lt;span class="w"&gt; &lt;/span&gt;Access&lt;span class="w"&gt; &lt;/span&gt;Profile&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;00001800&lt;/span&gt;-0000-1000-8000-00805f9b34fb&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-13" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-13" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-13"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;UUID:&lt;span class="w"&gt; &lt;/span&gt;Generic&lt;span class="w"&gt; &lt;/span&gt;Attribute&lt;span class="w"&gt; &lt;/span&gt;Profile&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;00001801&lt;/span&gt;-0000-1000-8000-00805f9b34fb&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-14" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-14" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-14"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;UUID:&lt;span class="w"&gt; &lt;/span&gt;Device&lt;span class="w"&gt; &lt;/span&gt;Information&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;0000180a-0000-1000-8000-00805f9b34fb&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-15" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-15" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-15"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;UUID:&lt;span class="w"&gt; &lt;/span&gt;Vendor&lt;span class="w"&gt; &lt;/span&gt;specific&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-16" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-16" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-16"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;UUID:&lt;span class="w"&gt; &lt;/span&gt;Vendor&lt;span class="w"&gt; &lt;/span&gt;specific&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;de8a5aac-a99b-c315-0c80-60d4cbb51225&lt;span class="o"&gt;)&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-17" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-17" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-17"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;ManufacturerData&lt;span class="w"&gt; &lt;/span&gt;Key:&lt;span class="w"&gt; &lt;/span&gt;0x0ba9
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-18" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-18" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-18"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;ManufacturerData&lt;span class="w"&gt; &lt;/span&gt;Value:
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-19" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-19" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-19"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;09&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;0b&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;0a&lt;span class="w"&gt; &lt;/span&gt;aa&lt;span class="w"&gt; &lt;/span&gt;bb&lt;span class="w"&gt; &lt;/span&gt;cc&lt;span class="w"&gt; &lt;/span&gt;c1&lt;span class="w"&gt; &lt;/span&gt;c7&lt;span class="w"&gt; &lt;/span&gt;5c&lt;span class="w"&gt;           &lt;/span&gt;............&lt;span class="se"&gt;\&lt;/span&gt;
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-20" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-20" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-20"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;ServiceData&lt;span class="w"&gt; &lt;/span&gt;Key:&lt;span class="w"&gt; &lt;/span&gt;0000fcd2-0000-1000-8000-00805f9b34fb
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-21" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-21" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-21"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;ServiceData&lt;span class="w"&gt; &lt;/span&gt;Value:
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-22" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-22" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-22"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;40&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;00&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;19&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;5a&lt;span class="w"&gt; &lt;/span&gt;3a&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;01&lt;/span&gt;&lt;span class="w"&gt;                             &lt;/span&gt;@...Z:.
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-23" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-23" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-23"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;RSSI:&lt;span class="w"&gt; &lt;/span&gt;-68
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-24" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-24" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-24"&gt;&lt;/a&gt;&lt;span class="w"&gt;        &lt;/span&gt;AdvertisingFlags:
&lt;a id="rest_code_83e3ec35e65a40d8bdd5156114394b19-25" name="rest_code_83e3ec35e65a40d8bdd5156114394b19-25" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_83e3ec35e65a40d8bdd5156114394b19-25"&gt;&lt;/a&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="m"&gt;06&lt;/span&gt;&lt;span class="w"&gt;                                               &lt;/span&gt;.
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Fortunately, once I had figured this out, the solution was quite simple: BlueZ needed to forget the devices. You can remove a device from BlueZ's cache with the following command:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_3ddf16b35fe744f8a5d4e98d3756784f-1" name="rest_code_3ddf16b35fe744f8a5d4e98d3756784f-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_3ddf16b35fe744f8a5d4e98d3756784f-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;bluetoothctl&lt;span class="w"&gt; &lt;/span&gt;remove&lt;span class="w"&gt; &lt;/span&gt;3C:2E:F5:XX:XX:XX
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Alternatively, you can manually delete the directory where BlueZ stores device information. First, find your Bluetooth adapter's address:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-1" name="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_d0bca73d108e4511996df3a8c7d4a7eb-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;hciconfig
&lt;a id="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-2" name="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-2" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_d0bca73d108e4511996df3a8c7d4a7eb-2"&gt;&lt;/a&gt;hci0:&lt;span class="w"&gt; &lt;/span&gt;Type:&lt;span class="w"&gt; &lt;/span&gt;Primary&lt;span class="w"&gt;  &lt;/span&gt;Bus:&lt;span class="w"&gt; &lt;/span&gt;USB
&lt;a id="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-3" name="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-3" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_d0bca73d108e4511996df3a8c7d4a7eb-3"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;BD&lt;span class="w"&gt; &lt;/span&gt;Address:&lt;span class="w"&gt; &lt;/span&gt;9C:FC:E8:XX:XX:XX&lt;span class="w"&gt;  &lt;/span&gt;ACL&lt;span class="w"&gt; &lt;/span&gt;MTU:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1021&lt;/span&gt;:4&lt;span class="w"&gt;  &lt;/span&gt;SCO&lt;span class="w"&gt; &lt;/span&gt;MTU:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;96&lt;/span&gt;:6
&lt;a id="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-4" name="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-4" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_d0bca73d108e4511996df3a8c7d4a7eb-4"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;UP&lt;span class="w"&gt; &lt;/span&gt;RUNNING
&lt;a id="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-5" name="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-5" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_d0bca73d108e4511996df3a8c7d4a7eb-5"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;RX&lt;span class="w"&gt; &lt;/span&gt;bytes:1203288&lt;span class="w"&gt; &lt;/span&gt;acl:31&lt;span class="w"&gt; &lt;/span&gt;sco:0&lt;span class="w"&gt; &lt;/span&gt;events:34298&lt;span class="w"&gt; &lt;/span&gt;errors:0
&lt;a id="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-6" name="rest_code_d0bca73d108e4511996df3a8c7d4a7eb-6" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_d0bca73d108e4511996df3a8c7d4a7eb-6"&gt;&lt;/a&gt;&lt;span class="w"&gt;      &lt;/span&gt;TX&lt;span class="w"&gt; &lt;/span&gt;bytes:898242&lt;span class="w"&gt; &lt;/span&gt;acl:29&lt;span class="w"&gt; &lt;/span&gt;sco:0&lt;span class="w"&gt; &lt;/span&gt;commands:11700&lt;span class="w"&gt; &lt;/span&gt;errors:0
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then delete the following directory, based on the adapter address and the device address:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_2af84d585d7f4e60877d4391a1686484-1" name="rest_code_2af84d585d7f4e60877d4391a1686484-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_2af84d585d7f4e60877d4391a1686484-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;rm&lt;span class="w"&gt; &lt;/span&gt;-rf&lt;span class="w"&gt; &lt;/span&gt;/var/lib/bluetooth/9C&lt;span class="se"&gt;\:&lt;/span&gt;FC&lt;span class="se"&gt;\:&lt;/span&gt;E8&lt;span class="se"&gt;\:&lt;/span&gt;XX&lt;span class="se"&gt;\:&lt;/span&gt;XX&lt;span class="se"&gt;\:&lt;/span&gt;XX/3C:2E:F5:XX:XX:XX
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you're curious about the cached information, first have a look at the culprit before removing the directory:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-1" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-1" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-1"&gt;&lt;/a&gt;$&lt;span class="w"&gt; &lt;/span&gt;sudo&lt;span class="w"&gt; &lt;/span&gt;cat&lt;span class="w"&gt; &lt;/span&gt;/var/lib/bluetooth/9C&lt;span class="se"&gt;\:&lt;/span&gt;FC&lt;span class="se"&gt;\:&lt;/span&gt;E8&lt;span class="se"&gt;\:&lt;/span&gt;XX&lt;span class="se"&gt;\:&lt;/span&gt;XX&lt;span class="se"&gt;\:&lt;/span&gt;XX/3C:2E:F5:XX:XX:XX/info
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-2" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-2" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-2"&gt;&lt;/a&gt;&lt;span class="o"&gt;[&lt;/span&gt;General&lt;span class="o"&gt;]&lt;/span&gt;
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-3" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-3" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-3"&gt;&lt;/a&gt;&lt;span class="nv"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Shelly&lt;span class="w"&gt; &lt;/span&gt;BLE&lt;span class="w"&gt; &lt;/span&gt;DW
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-4" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-4" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-4"&gt;&lt;/a&gt;&lt;span class="nv"&gt;AddressType&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;public
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-5" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-5" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-5"&gt;&lt;/a&gt;&lt;span class="nv"&gt;SupportedTechnologies&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;LE&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-6" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-6" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-6"&gt;&lt;/a&gt;&lt;span class="nv"&gt;Trusted&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-7" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-7" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-7"&gt;&lt;/a&gt;&lt;span class="nv"&gt;Blocked&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-8" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-8" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-8"&gt;&lt;/a&gt;&lt;span class="nv"&gt;Services&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;00001800&lt;/span&gt;-0000-1000-8000-00805f9b34fb&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="m"&gt;00001801&lt;/span&gt;-0000-1000-8000-00805f9b34fb&lt;span class="p"&gt;;&lt;/span&gt;0000180a-0000-1000-8000-00805f9b34fb&lt;span class="p"&gt;;&lt;/span&gt;1d14d6ee-fd63-4fa1-bfa4-8f47b42119f0&lt;span class="p"&gt;;&lt;/span&gt;de8a5aac-a99b-c315-0c80-60d4cbb51225&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a id="rest_code_841de23b79db42a1b25dbb4a403fb34e-9" name="rest_code_841de23b79db42a1b25dbb4a403fb34e-9" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#rest_code_841de23b79db42a1b25dbb4a403fb34e-9"&gt;&lt;/a&gt;&lt;span class="nv"&gt;Appearance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0x8001
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It's this value of the &lt;code class="docutils literal"&gt;Name&lt;/code&gt; field that BlueZ returns to Bleak, and subsequently to Theengs Gateway and Theengs Decoder, leading to the wrong detection. After removing the device from BlueZ's cache, the advertised local name was detected correctly, and the decoders worked again.&lt;/p&gt;
&lt;p&gt;So now I'm wondering: is it possible to get the real local name advertised by a device? Bleak uses the &lt;a class="reference external" href="https://github.com/hbldh/bleak/blob/b60f793cf14861686c5beae94822d7c0686b91ba/bleak/backends/bluezdbus/scanner.py#L248"&gt;Name property&lt;/a&gt; of a device in its BlueZ backend for scanning. Does BlueZ expose the local name, and could Bleak be adapted to use this instead? I couldn't find the answer to this question.&lt;/p&gt;
&lt;aside class="footnote-list brackets"&gt;
&lt;aside class="footnote brackets" id="footnote-ble-book" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/#footnote-reference-1"&gt;1&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;If you want to know more about BLE advertisements and connections, read the &lt;a class="reference external" href="https://koen.vervloesem.eu/blog/develop-your-own-bluetooth-low-energy-applications/"&gt;introductory chapter&lt;/a&gt; of my book about &lt;a class="reference external" href="https://koen.vervloesem.eu/books/develop-your-own-bluetooth-low-energy-applications/"&gt;developing Bluetooth Low Energy applications&lt;/a&gt;.&lt;/p&gt;
&lt;/aside&gt;
&lt;/aside&gt;</description><category>ble</category><category>bleak</category><category>bluetooth</category><category>bluetooth-low-energy</category><category>bluez</category><category>linux</category><category>theengs</category><category>theengs-decoder</category><category>theengs-gateway</category><guid>https://koen.vervloesem.eu/blog/when-bluez-has-connected-once-to-a-ble-device-it-uses-the-device-name-characteristic-for-the-device-name/</guid><pubDate>Wed, 26 Jul 2023 15:09:45 GMT</pubDate></item><item><title>Zephyr's growing hardware support includes popular microcontroller boards for makers</title><link>https://koen.vervloesem.eu/blog/zephyrs-growing-hardware-support-includes-popular-microcontroller-boards-for-makers/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;&lt;a class="reference external" href="https://zephyrproject.org"&gt;Zephyr&lt;/a&gt;, an open-source real-time operating system (RTOS) launched by the Linux Foundation in 2016, has made lots of progress seven years after its announcement, and it now has an active ecosystem surrounding it. It's used in Internet of Things (IoT) sensors, Bluetooth trackers, heart rate monitors, smartwatches, and embedded controllers. A few months ago I wrote an overview article for LWN.net about the project, &lt;a class="reference external" href="https://lwn.net/Articles/925924/"&gt;Zephyr: a modular OS for resource-constrained devices&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The Zephyr RTOS is used in a lot of &lt;a class="reference external" href="https://www.zephyrproject.org/products-running-zephyr/"&gt;commercial products&lt;/a&gt; as well as some &lt;a class="reference external" href="https://github.com/zephyrproject-rtos/zephyr/wiki/Projects-Based-on-Zephyr#open-source-projects"&gt;open-source projects&lt;/a&gt;. Developers are also continuously adding support for new development boards. Currently, Zephyr supports &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/index.html"&gt;more than 450 boards&lt;/a&gt; from various architectures.&lt;/p&gt;
&lt;p&gt;While most of these boards are the typical developer boards used by professional developers, recent years have seen an uptick in support for more boards popular with hobbyists. Here's a list of some supported boards that will surely ring a bell if you're active in the maker community:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/adafruit_trinket_m0/doc/index.html"&gt;Adafruit Trinket M0&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/arduino_nano_33_ble/doc/index.html"&gt;Arduino Nano 33 BLE (Sense)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/arduino_nano_33_iot/doc/index.html"&gt;Arduino Nano 33 IoT&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/bbc_microbit/doc/index.html"&gt;BBC micro:bit&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/bbc_microbit_v2/doc/index.html"&gt;BBC micro:bit v2&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/xtensa/esp32s3_devkitm/doc/index.html"&gt;Espressif ESP32-S3-DevKitM&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/xtensa/m5stickc_plus/doc/index.html"&gt;M5Stack M5StickC Plus&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/riscv/stamp_c3/doc/index.html"&gt;M5Stack STAMP-C3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/nrf52840_mdk_usb_dongle/doc/index.html"&gt;makerdiary nRF52840 MDK USB Dongle&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/pinetime_devkit0/doc/index.html"&gt;PINE64 PineTime DevKit0&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/rpi_pico/doc/index.html"&gt;Raspberry Pi Pico and Pico W&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/ruuvi_ruuvitag/doc/index.html"&gt;Ruuvi RuuviTag&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/seeeduino_xiao/doc/index.html"&gt;Seeeduino XIAO&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/wio_terminal/doc/index.html"&gt;Seeed Studio Wio Terminal&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/xiao_ble/doc/index.html"&gt;Seeed Studio XIAO BLE (Sense)&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/riscv/xiao_esp32c3/doc/index.html"&gt;Seeed Studio XIAO ESP32C3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/xtensa/xiao_esp32s3/doc/index.html"&gt;Seeed Studio XIAO ESP32S3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/riscv/sparkfun_red_v_things_plus/doc/index.html"&gt;SparkFun RED-V Things Plus&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;aside class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;Zephyr support for a particular board doesn't mean that all of the board's features are supported. Always consult the device page in Zephyr's documentation for detailed information about the support status.&lt;/p&gt;
&lt;/aside&gt;
&lt;p&gt;So what can you do with Zephyr? An interesting use case for the operating system is developing Bluetooth Low Energy applications running on one of the above boards. A previous blog article explaining &lt;a class="reference external" href="https://koen.vervloesem.eu/blog/developing-bluetooth-low-energy-applications-with-zephyr-rtos-dissecting-an-ibeacon-example/"&gt;Zephyr's iBeacon example code&lt;/a&gt; gives you an idea about how such code looks like. If this piques your curiosity, consider delving deeper into the subject by reading my book &lt;a class="reference external" href="https://koen.vervloesem.eu/books/develop-your-own-bluetooth-low-energy-applications/"&gt;Develop your own Bluetooth Low Energy Applications for Raspberry Pi, ESP32 and nRF52 with Python, Arduino and Zephyr&lt;/a&gt;, which uses Nordic Semiconductor's &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/nrf52840dongle_nrf52840/doc/index.html"&gt;nRF52840 Dongle&lt;/a&gt; and &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/boards/arm/nrf52840dk_nrf52840/doc/index.html"&gt;nRF52840 Development Kit&lt;/a&gt;. But Zephyr supports a plethora of communication protocols, including &lt;a class="reference external" href="https://docs.zephyrproject.org/latest/connectivity/networking/api/thread.html"&gt;Thread&lt;/a&gt;, a low-power IPv6-based wireless mesh-networking technology for home-automation applications, and other protocols listed in the aforementioned LWN.net article.&lt;/p&gt;
&lt;p&gt;Even if you're not up to the task of developing applications in the C programming language, Zephyr can be interesting for you. If you prefer Python, you've surely heard about &lt;a class="reference external" href="https://micropython.org"&gt;MicroPython&lt;/a&gt;, a programming language that implements a sizable subset of Python that can run on microcontrollers. You can read more about it in my recent LWN.net article &lt;a class="reference external" href="https://lwn.net/Articles/931051/"&gt;MicroPython 1.20: Python for microcontrollers&lt;/a&gt;. MicroPython offers firmware downloads for &lt;a class="reference external" href="https://micropython.org/download/"&gt;more than 150 microcontroller boards&lt;/a&gt;, but it also has been ported to Zephyr.&lt;/p&gt;
&lt;p&gt;In &lt;a class="reference external" href="https://github.com/micropython/micropython/releases/tag/v1.20.0"&gt;MicroPython 1.20&lt;/a&gt;, this port is based on &lt;a class="reference external" href="https://docs.zephyrproject.org/3.1.0/releases/release-notes-3.1.html"&gt;Zephyr 3.1.0&lt;/a&gt;, which was released in June 2022; the current Zephyr release is 3.4.0. A Zephyr development environment can be used to build MicroPython for every target board supported by Zephyr, although not all have been tested. It also gives MicroPython code access to Zephyr's &lt;a class="reference external" href="https://docs.zephyrproject.org/3.1.0/hardware/peripherals/sensor.html"&gt;uniform sensor API&lt;/a&gt; using the &lt;a class="reference external" href="https://docs.micropython.org/en/latest/library/zephyr.zsensor.html"&gt;zsensor&lt;/a&gt; module. More information can be found in MicroPython's &lt;a class="reference external" href="https://docs.micropython.org/en/latest/zephyr/quickref.html#"&gt;documentation about the Zephyr port&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Thanks to Zephyr's broad hardware support, the Zephyr port allows MicroPython to run on the BBC micro:bit v2, whereas only a direct MicroPython port for the &lt;a class="reference external" href="https://micropython.org/download/microbit/"&gt;BBC micro:bit v1&lt;/a&gt; exists. Other interesting boards from the above list that don't have a MicroPython firmware download but that are supported thanks to the Zephyr port are the Arduino Nano 33 IoT, the PineTime, and the RuuviTag. The process of setting up the development environment, building the Zephyr port for the target board, and then flashing the firmware to the board is explained in the &lt;a class="reference external" href="https://github.com/micropython/micropython/tree/master/ports/zephyr#micropython-port-to-zephyr-rtos"&gt;port's README file&lt;/a&gt;.&lt;/p&gt;</description><category>ble</category><category>bluetooth</category><category>bluetooth-low-energy</category><category>embedded</category><category>iot</category><category>micropython</category><category>open-source</category><category>programming</category><category>rtos</category><category>thread</category><category>zephyr</category><guid>https://koen.vervloesem.eu/blog/zephyrs-growing-hardware-support-includes-popular-microcontroller-boards-for-makers/</guid><pubDate>Fri, 14 Jul 2023 17:10:12 GMT</pubDate></item><item><title>How to use the await keyword in the Python REPL without asyncio.run()</title><link>https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;The Python REPL (read-eval-print loop), which is Python's interactive interpreter, is a great way for quickly testing simple Python commands. I use it quite often as a powerful command-line calculator, but also for exploring new Python libraries.&lt;/p&gt;
&lt;p&gt;Many interesting Python libraries use asynchronous I/O with &lt;a class="reference external" href="https://docs.python.org/3/library/asyncio.html"&gt;asyncio&lt;/a&gt;. This means that, instead of just calling a function directly, you have to &lt;code class="docutils literal"&gt;await&lt;/code&gt; a coroutine. However, if you try this in the REPL, you encounter the following error message:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-1" name="rest_code_511ec362baa548e5b80ce13e977dcd47-1" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-1"&gt;&lt;/a&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-2" name="rest_code_511ec362baa548e5b80ce13e977dcd47-2" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;Python&lt;/span&gt; &lt;span class="mf"&gt;3.10.6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;May&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;38&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.3.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-3" name="rest_code_511ec362baa548e5b80ce13e977dcd47-3" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-3"&gt;&lt;/a&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="s2"&gt;"help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"copyright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credits"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-4" name="rest_code_511ec362baa548e5b80ce13e977dcd47-4" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-4"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-5" name="rest_code_511ec362baa548e5b80ce13e977dcd47-5" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-6" name="rest_code_511ec362baa548e5b80ce13e977dcd47-6" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-6"&gt;&lt;/a&gt;  &lt;span class="n"&gt;File&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;stdin&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-7" name="rest_code_511ec362baa548e5b80ce13e977dcd47-7" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-7"&gt;&lt;/a&gt;&lt;span class="ne"&gt;SyntaxError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'await'&lt;/span&gt; &lt;span class="n"&gt;outside&lt;/span&gt; &lt;span class="n"&gt;function&lt;/span&gt;
&lt;a id="rest_code_511ec362baa548e5b80ce13e977dcd47-8" name="rest_code_511ec362baa548e5b80ce13e977dcd47-8" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_511ec362baa548e5b80ce13e977dcd47-8"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is expected, because this line of code would never run in a Python script either. You would need to define a top-level coroutine with &lt;code class="docutils literal"&gt;async def&lt;/code&gt; that calls one or more coroutines with &lt;code class="docutils literal"&gt;await&lt;/code&gt;, and run the top-level coroutine with &lt;code class="docutils literal"&gt;asyncio.run()&lt;/code&gt;. The canonical "Hello world" example from the &lt;a class="reference external" href="https://docs.python.org/3/library/asyncio-task.html#coroutines"&gt;Python documentation of coroutines&lt;/a&gt; looks something like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-1" name="rest_code_fcc5d853f675438caf07776b4c641c7f-1" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-1"&gt;&lt;/a&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-2" name="rest_code_fcc5d853f675438caf07776b4c641c7f-2" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;Python&lt;/span&gt; &lt;span class="mf"&gt;3.10.6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;May&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;38&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.3.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-3" name="rest_code_fcc5d853f675438caf07776b4c641c7f-3" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-3"&gt;&lt;/a&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="s2"&gt;"help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"copyright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credits"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-4" name="rest_code_fcc5d853f675438caf07776b4c641c7f-4" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-4"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-5" name="rest_code_fcc5d853f675438caf07776b4c641c7f-5" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-6" name="rest_code_fcc5d853f675438caf07776b4c641c7f-6" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-6"&gt;&lt;/a&gt;&lt;span class="o"&gt;...&lt;/span&gt;     &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-7" name="rest_code_fcc5d853f675438caf07776b4c641c7f-7" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;...&lt;/span&gt;     &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-8" name="rest_code_fcc5d853f675438caf07776b4c641c7f-8" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-8"&gt;&lt;/a&gt;&lt;span class="o"&gt;...&lt;/span&gt;     &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"world"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-9" name="rest_code_fcc5d853f675438caf07776b4c641c7f-9" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-9"&gt;&lt;/a&gt;&lt;span class="o"&gt;...&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-10" name="rest_code_fcc5d853f675438caf07776b4c641c7f-10" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-10"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-11" name="rest_code_fcc5d853f675438caf07776b4c641c7f-11" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-11"&gt;&lt;/a&gt;&lt;span class="n"&gt;Hello&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-12" name="rest_code_fcc5d853f675438caf07776b4c641c7f-12" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-12"&gt;&lt;/a&gt;&lt;span class="n"&gt;world&lt;/span&gt;
&lt;a id="rest_code_fcc5d853f675438caf07776b4c641c7f-13" name="rest_code_fcc5d853f675438caf07776b4c641c7f-13" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_fcc5d853f675438caf07776b4c641c7f-13"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There's a five-second delay between the output of "Hello" and "world".&lt;/p&gt;
&lt;p&gt;This seems a bit cumbersome. If you just want to call the &lt;code class="docutils literal"&gt;asyncio.sleep()&lt;/code&gt; coroutine, you can simplify this to:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_0c36167abdd54154aa6d340aaa6310bf-1" name="rest_code_0c36167abdd54154aa6d340aaa6310bf-1" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0c36167abdd54154aa6d340aaa6310bf-1"&gt;&lt;/a&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt;
&lt;a id="rest_code_0c36167abdd54154aa6d340aaa6310bf-2" name="rest_code_0c36167abdd54154aa6d340aaa6310bf-2" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0c36167abdd54154aa6d340aaa6310bf-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;Python&lt;/span&gt; &lt;span class="mf"&gt;3.10.6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;May&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;38&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.3.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;a id="rest_code_0c36167abdd54154aa6d340aaa6310bf-3" name="rest_code_0c36167abdd54154aa6d340aaa6310bf-3" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0c36167abdd54154aa6d340aaa6310bf-3"&gt;&lt;/a&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="s2"&gt;"help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"copyright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credits"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_0c36167abdd54154aa6d340aaa6310bf-4" name="rest_code_0c36167abdd54154aa6d340aaa6310bf-4" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0c36167abdd54154aa6d340aaa6310bf-4"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_0c36167abdd54154aa6d340aaa6310bf-5" name="rest_code_0c36167abdd54154aa6d340aaa6310bf-5" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0c36167abdd54154aa6d340aaa6310bf-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;a id="rest_code_0c36167abdd54154aa6d340aaa6310bf-6" name="rest_code_0c36167abdd54154aa6d340aaa6310bf-6" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0c36167abdd54154aa6d340aaa6310bf-6"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is already better! However, it still means that every time you want to call a coroutine, you need to remember to wrap it inside an &lt;code class="docutils literal"&gt;asyncio.run()&lt;/code&gt; call.&lt;/p&gt;
&lt;p&gt;Fortunately, Python 3.8 introduced a &lt;a class="reference external" href="https://bugs.python.org/issue37028"&gt;top-level await&lt;/a&gt; if you run the &lt;code class="docutils literal"&gt;asyncio&lt;/code&gt; module as a script:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-1" name="rest_code_d435b77ce35b4aadb65698677856ee1b-1" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-1"&gt;&lt;/a&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-2" name="rest_code_d435b77ce35b4aadb65698677856ee1b-2" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;asyncio&lt;/span&gt; &lt;span class="n"&gt;REPL&lt;/span&gt; &lt;span class="mf"&gt;3.10.6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;May&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;38&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.3.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-3" name="rest_code_d435b77ce35b4aadb65698677856ee1b-3" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-3"&gt;&lt;/a&gt;&lt;span class="n"&gt;Use&lt;/span&gt; &lt;span class="s2"&gt;"await"&lt;/span&gt; &lt;span class="n"&gt;directly&lt;/span&gt; &lt;span class="n"&gt;instead&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="s2"&gt;"asyncio.run()"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-4" name="rest_code_d435b77ce35b4aadb65698677856ee1b-4" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-4"&gt;&lt;/a&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="s2"&gt;"help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"copyright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credits"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-5" name="rest_code_d435b77ce35b4aadb65698677856ee1b-5" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-6" name="rest_code_d435b77ce35b4aadb65698677856ee1b-6" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-6"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_d435b77ce35b4aadb65698677856ee1b-7" name="rest_code_d435b77ce35b4aadb65698677856ee1b-7" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_d435b77ce35b4aadb65698677856ee1b-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The REPL helpfully mentions &lt;code class="docutils literal"&gt;Use "await" directly instead of &lt;span class="pre"&gt;"asyncio.run()".&lt;/span&gt;&lt;/code&gt; before importing the &lt;code class="docutils literal"&gt;asyncio&lt;/code&gt; module. &lt;a class="brackets" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#footnote-asyncio-repl" id="footnote-reference-1" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;1&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt; Then you can simply type &lt;code class="docutils literal"&gt;await asyncio.sleep(5)&lt;/code&gt; without having to call &lt;code class="docutils literal"&gt;asyncio.run()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Although this might not seem like much of an improvement in this particular case, when using asynchronous libraries in a Python REPL, having to add &lt;code class="docutils literal"&gt;asyncio.run()&lt;/code&gt; for every coroutine call quickly becomes tedious.&lt;/p&gt;
&lt;p&gt;For example, I can now easily request the Bluetooth adapters on my system (using Home Assistant's &lt;a class="reference external" href="https://pypi.org/project/bluetooth-adapters/"&gt;bluetooth-adapters&lt;/a&gt; package):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-1" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-1" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-1"&gt;&lt;/a&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-2" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-2" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;asyncio&lt;/span&gt; &lt;span class="n"&gt;REPL&lt;/span&gt; &lt;span class="mf"&gt;3.10.6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;May&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;38&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.3.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-3" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-3" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-3"&gt;&lt;/a&gt;&lt;span class="n"&gt;Use&lt;/span&gt; &lt;span class="s2"&gt;"await"&lt;/span&gt; &lt;span class="n"&gt;directly&lt;/span&gt; &lt;span class="n"&gt;instead&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="s2"&gt;"asyncio.run()"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-4" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-4" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-4"&gt;&lt;/a&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="s2"&gt;"help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"copyright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credits"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-5" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-5" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-6" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-6" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-6"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bluetooth_adapters&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;get_adapters&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-7" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-7" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;adapters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_adapters&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-8" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-8" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-8"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;adapters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-9" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-9" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-9"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;adapters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapters&lt;/span&gt;
&lt;a id="rest_code_0a6691309b1a4936b953e2bdb86671d8-10" name="rest_code_0a6691309b1a4936b953e2bdb86671d8-10" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_0a6691309b1a4936b953e2bdb86671d8-10"&gt;&lt;/a&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'hci0'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'address'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'9C:FC:E8:XX:XX:XX'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sw_version'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'tux'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'hw_version'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'usb:v1D6Bp0246d0540'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'passive_scan'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'manufacturer'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Intel Corporate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'product'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0029'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'vendor_id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'8087'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'product_id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0029'&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or, I can conduct a quick scan for Bluetooth Low Energy (BLE) devices in the vicinity (using the &lt;a class="reference external" href="https://bleak.readthedocs.io/en/latest/api/scanner.html"&gt;Bleak&lt;/a&gt; package):&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-1" name="rest_code_28f7168dea474984997b7f106eff8267-1" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-1"&gt;&lt;/a&gt;&lt;span class="err"&gt;$&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-2" name="rest_code_28f7168dea474984997b7f106eff8267-2" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-2"&gt;&lt;/a&gt;&lt;span class="n"&gt;asyncio&lt;/span&gt; &lt;span class="n"&gt;REPL&lt;/span&gt; &lt;span class="mf"&gt;3.10.6&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;May&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt; &lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;38&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;GCC&lt;/span&gt; &lt;span class="mf"&gt;11.3.0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;linux&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-3" name="rest_code_28f7168dea474984997b7f106eff8267-3" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-3"&gt;&lt;/a&gt;&lt;span class="n"&gt;Use&lt;/span&gt; &lt;span class="s2"&gt;"await"&lt;/span&gt; &lt;span class="n"&gt;directly&lt;/span&gt; &lt;span class="n"&gt;instead&lt;/span&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="s2"&gt;"asyncio.run()"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-4" name="rest_code_28f7168dea474984997b7f106eff8267-4" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-4"&gt;&lt;/a&gt;&lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="s2"&gt;"help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"copyright"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"credits"&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"license"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;more&lt;/span&gt; &lt;span class="n"&gt;information&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-5" name="rest_code_28f7168dea474984997b7f106eff8267-5" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-5"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-6" name="rest_code_28f7168dea474984997b7f106eff8267-6" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-6"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bleak&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BleakScanner&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-7" name="rest_code_28f7168dea474984997b7f106eff8267-7" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-7"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;devices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;BleakScanner&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;discover&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-8" name="rest_code_28f7168dea474984997b7f106eff8267-8" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-8"&gt;&lt;/a&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;devices&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_28f7168dea474984997b7f106eff8267-9" name="rest_code_28f7168dea474984997b7f106eff8267-9" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#rest_code_28f7168dea474984997b7f106eff8267-9"&gt;&lt;/a&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Qingping Alarm Clock'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'abeacon_AC7D'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'TP358 (52C6)'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'1B-0F-09-4F-89-F3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ThermoBeacon'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'F9-DA-D2-0D-62-24'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'6A-C8-79-F4-E1-E5'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Qingping BT Clock Lite'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'LYWSD02'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Ruuvi 7E0E'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'TY'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'TP393 (2A3D)'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Flower care'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'52-9E-F1-64-DB-DF'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Give this top-level await approach a try with some of your favorite asynchronous Python libraries. You'll definitely become more productive in the REPL.&lt;/p&gt;
&lt;aside class="footnote-list brackets"&gt;
&lt;aside class="footnote brackets" id="footnote-asyncio-repl" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/#footnote-reference-1"&gt;1&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;Note that the REPL is now calling itself "asyncio REPL 3.10.6" instead of "Python 3.10.6".&lt;/p&gt;
&lt;/aside&gt;
&lt;/aside&gt;</description><category>asyncio</category><category>programming</category><category>python</category><category>repl</category><guid>https://koen.vervloesem.eu/blog/how-to-use-the-await-keyword-in-the-python-repl-without-asynciorun/</guid><pubDate>Sat, 17 Jun 2023 16:02:25 GMT</pubDate></item><item><title>Creating terminal user interfaces in Python with Textual</title><link>https://koen.vervloesem.eu/blog/creating-terminal-user-interfaces-in-python-with-textual/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;Last year, I began using &lt;a class="reference external" href="https://textual.textualize.io"&gt;Textual&lt;/a&gt; to develop &lt;a class="reference external" href="https://humble-explorer.readthedocs.io"&gt;HumBLE Explorer&lt;/a&gt;, a cross-platform, command-line and human-friendly Bluetooth Low Energy scanner. Textual caught my attention because it promised to be a rapid application development framework for Python terminal user interface (TUI) applications. Thanks to Textual, I was able to create an application like this, including scroll bars, switches and tables:&lt;/p&gt;
&lt;img alt="/images/humble-explorer-light.png" src="https://koen.vervloesem.eu/images/humble-explorer-light.png"&gt;
&lt;p&gt;One of Textual's key features is that it's inspired by web development practices. This allows for a clear separation of design and code using CSS files (in the &lt;a class="reference external" href="https://textual.textualize.io/guide/CSS/"&gt;Textual CSS dialect&lt;/a&gt;), making the framework both developer-friendly and highly customizable. It also has &lt;a class="reference external" href="https://textual.textualize.io/guide/reactivity/"&gt;reactive attributes&lt;/a&gt;, as well as a growing library of &lt;a class="reference external" href="https://textual.textualize.io/widget_gallery/"&gt;widgets&lt;/a&gt;. Additionally, the framework provides useful tools for &lt;a class="reference external" href="https://textual.textualize.io/guide/devtools/"&gt;debugging and live editing of CSS files&lt;/a&gt; during development.&lt;/p&gt;
&lt;p&gt;If you want to have an idea about Textual's capabilities, install it from PyPI and run the demo:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code shell"&gt;&lt;a id="rest_code_0f2fc58e9a734f3baa823cfe96c10212-1" name="rest_code_0f2fc58e9a734f3baa823cfe96c10212-1" href="https://koen.vervloesem.eu/blog/creating-terminal-user-interfaces-in-python-with-textual/#rest_code_0f2fc58e9a734f3baa823cfe96c10212-1"&gt;&lt;/a&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;textual
&lt;a id="rest_code_0f2fc58e9a734f3baa823cfe96c10212-2" name="rest_code_0f2fc58e9a734f3baa823cfe96c10212-2" href="https://koen.vervloesem.eu/blog/creating-terminal-user-interfaces-in-python-with-textual/#rest_code_0f2fc58e9a734f3baa823cfe96c10212-2"&gt;&lt;/a&gt;python&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;textual
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In addition, one of Textual's developers maintains a list of &lt;a class="reference external" href="https://github.com/davep/transcendent-textual"&gt;Textual-based applications&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As a relatively new project (started in 2021), Textual still experiences occasional breaking changes in new releases. However, the developers are easily accessible for support on their Discord server and provide regular &lt;a class="reference external" href="https://textual.textualize.io/blog/"&gt;blog&lt;/a&gt; updates. Moreover, Textual has excellent documentation. I plan to use Textual again for new terminal user interfaces in Python.&lt;/p&gt;
&lt;p&gt;For some more background, read my article &lt;a class="reference external" href="https://lwn.net/Articles/929123/"&gt;Textual: a framework for terminal user interfaces&lt;/a&gt; on LWN.&lt;/p&gt;</description><category>humble-explorer</category><category>programming</category><category>python</category><category>terminal-user-interface</category><category>textual</category><category>tui</category><guid>https://koen.vervloesem.eu/blog/creating-terminal-user-interfaces-in-python-with-textual/</guid><pubDate>Thu, 04 May 2023 16:58:29 GMT</pubDate></item><item><title>Creating a diagnostics module for Python software</title><link>https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/</link><dc:creator>Koen Vervloesem</dc:creator><description>&lt;p&gt;For &lt;a class="reference external" href="https://github.com/theengs/gateway"&gt;Theengs Gateway&lt;/a&gt; we regularly got bug reports that were difficult to debug, as they depend on the operating system, Python version, application configuration, and Bluetooth adapter. After some back and forth we got an idea of the user's environment and started to identify the issue (or not). Then I discovered that &lt;a class="reference external" href="https://github.com/Textualize/textual"&gt;Textual&lt;/a&gt; has a convenient solution for this: a &lt;a class="reference external" href="https://github.com/Textualize/textual/blob/main/src/textual/cli/tools/diagnose.py"&gt;diagnose&lt;/a&gt; command that prints information about the Textual library and its environment to help diagnose problems.&lt;/p&gt;
&lt;p&gt;I borrowed this code from Textual and adapted it for Theengs Gateway's usage. So now we simply ask the user to run this command and include its output in the issue description on GitHub. &lt;a class="reference external" href="https://github.com/theengs/gateway/blob/development/TheengsGateway/diagnose.py"&gt;Theengs Gateway's diagnose module&lt;/a&gt; looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://koen.vervloesem.eu/listings/theengs_gateway/diagnose.py.html"&gt;theengs_gateway/diagnose.py&lt;/a&gt;  &lt;a class="reference external" href="https://koen.vervloesem.eu/listings/theengs_gateway/diagnose.py"&gt;(Source)&lt;/a&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-1" name="rest_code_939746ea76e44df4a3a089329823c4f9-1" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-1"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;asyncio&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-2" name="rest_code_939746ea76e44df4a3a089329823c4f9-2" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-2"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;json&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-3" name="rest_code_939746ea76e44df4a3a089329823c4f9-3" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-3"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;os&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-4" name="rest_code_939746ea76e44df4a3a089329823c4f9-4" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-4"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;platform&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-5" name="rest_code_939746ea76e44df4a3a089329823c4f9-5" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-5"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;re&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-6" name="rest_code_939746ea76e44df4a3a089329823c4f9-6" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-6"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-7" name="rest_code_939746ea76e44df4a3a089329823c4f9-7" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-8" name="rest_code_939746ea76e44df4a3a089329823c4f9-8" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-8"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;importlib_metadata&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;PackageNotFoundError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-9" name="rest_code_939746ea76e44df4a3a089329823c4f9-9" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-10" name="rest_code_939746ea76e44df4a3a089329823c4f9-10" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-10"&gt;&lt;/a&gt;&lt;span class="n"&gt;_conf_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expanduser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"~"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/theengsgw.conf"&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-11" name="rest_code_939746ea76e44df4a3a089329823c4f9-11" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-11"&gt;&lt;/a&gt;&lt;span class="n"&gt;_ADDR_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"^(([0-9A-F]&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;:)&lt;/span&gt;&lt;span class="si"&gt;{3}&lt;/span&gt;&lt;span class="s2"&gt;)([0-9A-F]&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;:)&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;[0-9A-F]&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;$"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-12" name="rest_code_939746ea76e44df4a3a089329823c4f9-12" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-12"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-13" name="rest_code_939746ea76e44df4a3a089329823c4f9-13" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-14" name="rest_code_939746ea76e44df4a3a089329823c4f9-14" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-14"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_anonymize_strings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-15" name="rest_code_939746ea76e44df4a3a089329823c4f9-15" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-15"&gt;&lt;/a&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-16" name="rest_code_939746ea76e44df4a3a089329823c4f9-16" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-16"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-17" name="rest_code_939746ea76e44df4a3a089329823c4f9-17" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-17"&gt;&lt;/a&gt;            &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"***"&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-18" name="rest_code_939746ea76e44df4a3a089329823c4f9-18" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-18"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-19" name="rest_code_939746ea76e44df4a3a089329823c4f9-19" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-19"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-20" name="rest_code_939746ea76e44df4a3a089329823c4f9-20" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-20"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_anonymize_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-21" name="rest_code_939746ea76e44df4a3a089329823c4f9-21" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-21"&gt;&lt;/a&gt;    &lt;span class="n"&gt;addr_parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_ADDR_RE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-22" name="rest_code_939746ea76e44df4a3a089329823c4f9-22" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-22"&gt;&lt;/a&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;addr_parts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-23" name="rest_code_939746ea76e44df4a3a089329823c4f9-23" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-23"&gt;&lt;/a&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;addr_parts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;XX:XX:XX"&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-24" name="rest_code_939746ea76e44df4a3a089329823c4f9-24" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-24"&gt;&lt;/a&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-25" name="rest_code_939746ea76e44df4a3a089329823c4f9-25" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-25"&gt;&lt;/a&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"INVALID ADDRESS"&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-26" name="rest_code_939746ea76e44df4a3a089329823c4f9-26" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-26"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-27" name="rest_code_939746ea76e44df4a3a089329823c4f9-27" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-27"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-28" name="rest_code_939746ea76e44df4a3a089329823c4f9-28" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-28"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_anonymize_addresses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-29" name="rest_code_939746ea76e44df4a3a089329823c4f9-29" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-29"&gt;&lt;/a&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-30" name="rest_code_939746ea76e44df4a3a089329823c4f9-30" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-30"&gt;&lt;/a&gt;        &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-31" name="rest_code_939746ea76e44df4a3a089329823c4f9-31" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-31"&gt;&lt;/a&gt;            &lt;span class="n"&gt;_anonymize_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-32" name="rest_code_939746ea76e44df4a3a089329823c4f9-32" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-32"&gt;&lt;/a&gt;        &lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-33" name="rest_code_939746ea76e44df4a3a089329823c4f9-33" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-33"&gt;&lt;/a&gt;    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;KeyError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-34" name="rest_code_939746ea76e44df4a3a089329823c4f9-34" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-34"&gt;&lt;/a&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-35" name="rest_code_939746ea76e44df4a3a089329823c4f9-35" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-35"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-36" name="rest_code_939746ea76e44df4a3a089329823c4f9-36" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-36"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-37" name="rest_code_939746ea76e44df4a3a089329823c4f9-37" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-37"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# This function is taken from Textual&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-38" name="rest_code_939746ea76e44df4a3a089329823c4f9-38" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-38"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-39" name="rest_code_939746ea76e44df4a3a089329823c4f9-39" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-39"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""Print a collection of named values within a titled section.&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-40" name="rest_code_939746ea76e44df4a3a089329823c4f9-40" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-40"&gt;&lt;/a&gt;&lt;span class="sd"&gt;    Args:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-41" name="rest_code_939746ea76e44df4a3a089329823c4f9-41" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-41"&gt;&lt;/a&gt;&lt;span class="sd"&gt;        title: The title for the section.&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-42" name="rest_code_939746ea76e44df4a3a089329823c4f9-42" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-42"&gt;&lt;/a&gt;&lt;span class="sd"&gt;        values: The values to print out.&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-43" name="rest_code_939746ea76e44df4a3a089329823c4f9-43" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-43"&gt;&lt;/a&gt;&lt;span class="sd"&gt;    """&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-44" name="rest_code_939746ea76e44df4a3a089329823c4f9-44" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-44"&gt;&lt;/a&gt;    &lt;span class="n"&gt;max_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-45" name="rest_code_939746ea76e44df4a3a089329823c4f9-45" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-45"&gt;&lt;/a&gt;    &lt;span class="n"&gt;max_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;()]))&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-46" name="rest_code_939746ea76e44df4a3a089329823c4f9-46" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-46"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"## &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-47" name="rest_code_939746ea76e44df4a3a089329823c4f9-47" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-47"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-48" name="rest_code_939746ea76e44df4a3a089329823c4f9-48" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-48"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"| &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'Name'&lt;/span&gt;&lt;span class="si"&gt;:{&lt;/span&gt;&lt;span class="n"&gt;max_name&lt;/span&gt;&lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="s2"&gt; | &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'Value'&lt;/span&gt;&lt;span class="si"&gt;:{&lt;/span&gt;&lt;span class="n"&gt;max_value&lt;/span&gt;&lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="s2"&gt; |"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-49" name="rest_code_939746ea76e44df4a3a089329823c4f9-49" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-49"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"|-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'-'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;max_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-|-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'-'&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;max_value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-|"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-50" name="rest_code_939746ea76e44df4a3a089329823c4f9-50" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-50"&gt;&lt;/a&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-51" name="rest_code_939746ea76e44df4a3a089329823c4f9-51" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-51"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"| &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;:{&lt;/span&gt;&lt;span class="n"&gt;max_name&lt;/span&gt;&lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="s2"&gt; | &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:{&lt;/span&gt;&lt;span class="n"&gt;max_value&lt;/span&gt;&lt;span class="si"&gt;}}&lt;/span&gt;&lt;span class="s2"&gt; |"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-52" name="rest_code_939746ea76e44df4a3a089329823c4f9-52" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-52"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-53" name="rest_code_939746ea76e44df4a3a089329823c4f9-53" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-53"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-54" name="rest_code_939746ea76e44df4a3a089329823c4f9-54" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-54"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-55" name="rest_code_939746ea76e44df4a3a089329823c4f9-55" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-55"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_versions&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-56" name="rest_code_939746ea76e44df4a3a089329823c4f9-56" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-56"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""Print useful version numbers."""&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-57" name="rest_code_939746ea76e44df4a3a089329823c4f9-57" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-57"&gt;&lt;/a&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-58" name="rest_code_939746ea76e44df4a3a089329823c4f9-58" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-58"&gt;&lt;/a&gt;        &lt;span class="n"&gt;packages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-59" name="rest_code_939746ea76e44df4a3a089329823c4f9-59" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-59"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Theengs Gateway"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"TheengsGateway"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-60" name="rest_code_939746ea76e44df4a3a089329823c4f9-60" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-60"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Theengs Decoder"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"TheengsDecoder"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-61" name="rest_code_939746ea76e44df4a3a089329823c4f9-61" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-61"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Bleak"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"bleak"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-62" name="rest_code_939746ea76e44df4a3a089329823c4f9-62" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-62"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Bluetooth Clocks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"bluetooth-clocks"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-63" name="rest_code_939746ea76e44df4a3a089329823c4f9-63" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-63"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Bluetooth Numbers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"bluetooth-numbers"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-64" name="rest_code_939746ea76e44df4a3a089329823c4f9-64" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-64"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Paho MQTT"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"paho-mqtt"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-65" name="rest_code_939746ea76e44df4a3a089329823c4f9-65" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-65"&gt;&lt;/a&gt;        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-66" name="rest_code_939746ea76e44df4a3a089329823c4f9-66" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-66"&gt;&lt;/a&gt;    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;PackageNotFoundError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-67" name="rest_code_939746ea76e44df4a3a089329823c4f9-67" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-67"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Package &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; not found. Please install it with:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-68" name="rest_code_939746ea76e44df4a3a089329823c4f9-68" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-68"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-69" name="rest_code_939746ea76e44df4a3a089329823c4f9-69" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-69"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"    pip install &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-70" name="rest_code_939746ea76e44df4a3a089329823c4f9-70" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-70"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-71" name="rest_code_939746ea76e44df4a3a089329823c4f9-71" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-71"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-72" name="rest_code_939746ea76e44df4a3a089329823c4f9-72" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-72"&gt;&lt;/a&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version_info&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-73" name="rest_code_939746ea76e44df4a3a089329823c4f9-73" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-73"&gt;&lt;/a&gt;        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-74" name="rest_code_939746ea76e44df4a3a089329823c4f9-74" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-74"&gt;&lt;/a&gt;            &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Bluetooth Adapters"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"bluetooth-adapters"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-75" name="rest_code_939746ea76e44df4a3a089329823c4f9-75" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-75"&gt;&lt;/a&gt;        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;PackageNotFoundError&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-76" name="rest_code_939746ea76e44df4a3a089329823c4f9-76" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-76"&gt;&lt;/a&gt;            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Package &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; not found. Please install it with:"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-77" name="rest_code_939746ea76e44df4a3a089329823c4f9-77" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-77"&gt;&lt;/a&gt;            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-78" name="rest_code_939746ea76e44df4a3a089329823c4f9-78" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-78"&gt;&lt;/a&gt;            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"    pip install &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-79" name="rest_code_939746ea76e44df4a3a089329823c4f9-79" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-79"&gt;&lt;/a&gt;            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-80" name="rest_code_939746ea76e44df4a3a089329823c4f9-80" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-80"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-81" name="rest_code_939746ea76e44df4a3a089329823c4f9-81" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-81"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Package Versions"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-82" name="rest_code_939746ea76e44df4a3a089329823c4f9-82" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-82"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-83" name="rest_code_939746ea76e44df4a3a089329823c4f9-83" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-83"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-84" name="rest_code_939746ea76e44df4a3a089329823c4f9-84" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-84"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_python&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-85" name="rest_code_939746ea76e44df4a3a089329823c4f9-85" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-85"&gt;&lt;/a&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""Print information about Python."""&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-86" name="rest_code_939746ea76e44df4a3a089329823c4f9-86" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-86"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-87" name="rest_code_939746ea76e44df4a3a089329823c4f9-87" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-87"&gt;&lt;/a&gt;        &lt;span class="s2"&gt;"Python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-88" name="rest_code_939746ea76e44df4a3a089329823c4f9-88" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-88"&gt;&lt;/a&gt;        &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-89" name="rest_code_939746ea76e44df4a3a089329823c4f9-89" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-89"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;python_version&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-90" name="rest_code_939746ea76e44df4a3a089329823c4f9-90" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-90"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Implementation"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;python_implementation&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-91" name="rest_code_939746ea76e44df4a3a089329823c4f9-91" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-91"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Compiler"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;python_compiler&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-92" name="rest_code_939746ea76e44df4a3a089329823c4f9-92" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-92"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"Executable"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;executable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-93" name="rest_code_939746ea76e44df4a3a089329823c4f9-93" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-93"&gt;&lt;/a&gt;        &lt;span class="p"&gt;},&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-94" name="rest_code_939746ea76e44df4a3a089329823c4f9-94" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-94"&gt;&lt;/a&gt;    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-95" name="rest_code_939746ea76e44df4a3a089329823c4f9-95" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-95"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-96" name="rest_code_939746ea76e44df4a3a089329823c4f9-96" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-96"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-97" name="rest_code_939746ea76e44df4a3a089329823c4f9-97" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-97"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_os&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-98" name="rest_code_939746ea76e44df4a3a089329823c4f9-98" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-98"&gt;&lt;/a&gt;    &lt;span class="n"&gt;os_parameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-99" name="rest_code_939746ea76e44df4a3a089329823c4f9-99" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-99"&gt;&lt;/a&gt;        &lt;span class="s2"&gt;"System"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-100" name="rest_code_939746ea76e44df4a3a089329823c4f9-100" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-100"&gt;&lt;/a&gt;        &lt;span class="s2"&gt;"Release"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;release&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-101" name="rest_code_939746ea76e44df4a3a089329823c4f9-101" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-101"&gt;&lt;/a&gt;        &lt;span class="s2"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-102" name="rest_code_939746ea76e44df4a3a089329823c4f9-102" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-102"&gt;&lt;/a&gt;        &lt;span class="s2"&gt;"Machine type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;machine&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-103" name="rest_code_939746ea76e44df4a3a089329823c4f9-103" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-103"&gt;&lt;/a&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-104" name="rest_code_939746ea76e44df4a3a089329823c4f9-104" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-104"&gt;&lt;/a&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"Linux"&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version_info&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-105" name="rest_code_939746ea76e44df4a3a089329823c4f9-105" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-105"&gt;&lt;/a&gt;        &lt;span class="n"&gt;os_parameters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Distribution"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;freedesktop_os_release&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-106" name="rest_code_939746ea76e44df4a3a089329823c4f9-106" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-106"&gt;&lt;/a&gt;            &lt;span class="s2"&gt;"PRETTY_NAME"&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-107" name="rest_code_939746ea76e44df4a3a089329823c4f9-107" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-107"&gt;&lt;/a&gt;        &lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-108" name="rest_code_939746ea76e44df4a3a089329823c4f9-108" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-108"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-109" name="rest_code_939746ea76e44df4a3a089329823c4f9-109" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-109"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Operating System"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os_parameters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-110" name="rest_code_939746ea76e44df4a3a089329823c4f9-110" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-110"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-111" name="rest_code_939746ea76e44df4a3a089329823c4f9-111" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-111"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-112" name="rest_code_939746ea76e44df4a3a089329823c4f9-112" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-112"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-113" name="rest_code_939746ea76e44df4a3a089329823c4f9-113" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-113"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"## Configuration"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-114" name="rest_code_939746ea76e44df4a3a089329823c4f9-114" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-114"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-115" name="rest_code_939746ea76e44df4a3a089329823c4f9-115" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-115"&gt;&lt;/a&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-116" name="rest_code_939746ea76e44df4a3a089329823c4f9-116" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-116"&gt;&lt;/a&gt;        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_conf_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;config_file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-117" name="rest_code_939746ea76e44df4a3a089329823c4f9-117" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-117"&gt;&lt;/a&gt;            &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-118" name="rest_code_939746ea76e44df4a3a089329823c4f9-118" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-118"&gt;&lt;/a&gt;            &lt;span class="n"&gt;_anonymize_strings&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pass"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-119" name="rest_code_939746ea76e44df4a3a089329823c4f9-119" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-119"&gt;&lt;/a&gt;            &lt;span class="n"&gt;_anonymize_addresses&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"time_sync"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-120" name="rest_code_939746ea76e44df4a3a089329823c4f9-120" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-120"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"```"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-121" name="rest_code_939746ea76e44df4a3a089329823c4f9-121" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-121"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sort_keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-122" name="rest_code_939746ea76e44df4a3a089329823c4f9-122" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-122"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"```"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-123" name="rest_code_939746ea76e44df4a3a089329823c4f9-123" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-123"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-124" name="rest_code_939746ea76e44df4a3a089329823c4f9-124" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-124"&gt;&lt;/a&gt;    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;FileNotFoundError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-125" name="rest_code_939746ea76e44df4a3a089329823c4f9-125" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-125"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Configuration file not found: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;_conf_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-126" name="rest_code_939746ea76e44df4a3a089329823c4f9-126" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-126"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-127" name="rest_code_939746ea76e44df4a3a089329823c4f9-127" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-127"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-128" name="rest_code_939746ea76e44df4a3a089329823c4f9-128" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-128"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-129" name="rest_code_939746ea76e44df4a3a089329823c4f9-129" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-129"&gt;&lt;/a&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_adapters&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-130" name="rest_code_939746ea76e44df4a3a089329823c4f9-130" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-130"&gt;&lt;/a&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;version_info&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-131" name="rest_code_939746ea76e44df4a3a089329823c4f9-131" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-131"&gt;&lt;/a&gt;        &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;bluetooth_adapters&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;get_adapters&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-132" name="rest_code_939746ea76e44df4a3a089329823c4f9-132" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-132"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-133" name="rest_code_939746ea76e44df4a3a089329823c4f9-133" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-133"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"## Bluetooth adapters"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-134" name="rest_code_939746ea76e44df4a3a089329823c4f9-134" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-134"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-135" name="rest_code_939746ea76e44df4a3a089329823c4f9-135" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-135"&gt;&lt;/a&gt;        &lt;span class="n"&gt;bluetooth_adapters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_adapters&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-136" name="rest_code_939746ea76e44df4a3a089329823c4f9-136" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-136"&gt;&lt;/a&gt;        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;bluetooth_adapters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refresh&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-137" name="rest_code_939746ea76e44df4a3a089329823c4f9-137" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-137"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Default adapter: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bluetooth_adapters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;default_adapter&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-138" name="rest_code_939746ea76e44df4a3a089329823c4f9-138" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-138"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-139" name="rest_code_939746ea76e44df4a3a089329823c4f9-139" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-139"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-140" name="rest_code_939746ea76e44df4a3a089329823c4f9-140" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-140"&gt;&lt;/a&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;properties&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bluetooth_adapters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;adapters&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-141" name="rest_code_939746ea76e44df4a3a089329823c4f9-141" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-141"&gt;&lt;/a&gt;            &lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_anonymize_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-142" name="rest_code_939746ea76e44df4a3a089329823c4f9-142" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-142"&gt;&lt;/a&gt;            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-143" name="rest_code_939746ea76e44df4a3a089329823c4f9-143" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-143"&gt;&lt;/a&gt;            &lt;span class="n"&gt;_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;adapter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-144" name="rest_code_939746ea76e44df4a3a089329823c4f9-144" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-144"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-145" name="rest_code_939746ea76e44df4a3a089329823c4f9-145" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-145"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-146" name="rest_code_939746ea76e44df4a3a089329823c4f9-146" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-146"&gt;&lt;/a&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;diagnostics&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-147" name="rest_code_939746ea76e44df4a3a089329823c4f9-147" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-147"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"# Theengs Gateway Diagnostics"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-148" name="rest_code_939746ea76e44df4a3a089329823c4f9-148" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-148"&gt;&lt;/a&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-149" name="rest_code_939746ea76e44df4a3a089329823c4f9-149" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-149"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_versions&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-150" name="rest_code_939746ea76e44df4a3a089329823c4f9-150" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-150"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_python&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-151" name="rest_code_939746ea76e44df4a3a089329823c4f9-151" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-151"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_os&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-152" name="rest_code_939746ea76e44df4a3a089329823c4f9-152" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-152"&gt;&lt;/a&gt;    &lt;span class="n"&gt;_config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-153" name="rest_code_939746ea76e44df4a3a089329823c4f9-153" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-153"&gt;&lt;/a&gt;    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;_adapters&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-154" name="rest_code_939746ea76e44df4a3a089329823c4f9-154" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-154"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-155" name="rest_code_939746ea76e44df4a3a089329823c4f9-155" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-155"&gt;&lt;/a&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-156" name="rest_code_939746ea76e44df4a3a089329823c4f9-156" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-156"&gt;&lt;/a&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_939746ea76e44df4a3a089329823c4f9-157" name="rest_code_939746ea76e44df4a3a089329823c4f9-157" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_939746ea76e44df4a3a089329823c4f9-157"&gt;&lt;/a&gt;    &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diagnostics&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When you run this module, it prints a level one Markdown title (&lt;code class="docutils literal"&gt;# Theengs Gateway Diagnostics&lt;/code&gt;) and then calls several functions. Each of these functions prints a level two Markdown title and some diagnostic information.&lt;/p&gt;
&lt;p&gt;First, it displays the version numbers of the Python package for Theengs Gateway and some of its dependencies. This helps us immediately identify outdated versions, and we can suggest an update. Next, it shows information about the Python platform and the operating system. These functions are all borrowed from Textual's &lt;code class="docutils literal"&gt;diagnose&lt;/code&gt; module, including the &lt;code class="docutils literal"&gt;_section&lt;/code&gt; helper function to print a collection of named values within a titled section.&lt;/p&gt;
&lt;p&gt;Since many Theengs Gateway issues depend on the exact configuration used, I also added a section that displays the contents of the configuration file (a JSON file). However, this configuration file contains some information that shouldn't be shared publicly, such as a username and password for an MQTT broker, or Bluetooth addresses. I could remove these fields in the code, but then we wouldn't know if the bug might be a result of a configuration file lacking one of these fields. So I created a simple function to anonymize specific fields:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_768f503d08c84d61b2ca529349602c0a-1" name="rest_code_768f503d08c84d61b2ca529349602c0a-1" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_768f503d08c84d61b2ca529349602c0a-1"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_anonymize_strings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_768f503d08c84d61b2ca529349602c0a-2" name="rest_code_768f503d08c84d61b2ca529349602c0a-2" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_768f503d08c84d61b2ca529349602c0a-2"&gt;&lt;/a&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_768f503d08c84d61b2ca529349602c0a-3" name="rest_code_768f503d08c84d61b2ca529349602c0a-3" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_768f503d08c84d61b2ca529349602c0a-3"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_768f503d08c84d61b2ca529349602c0a-4" name="rest_code_768f503d08c84d61b2ca529349602c0a-4" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_768f503d08c84d61b2ca529349602c0a-4"&gt;&lt;/a&gt;            &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;field&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"***"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then I can call this function on the configuration to anonymize the &lt;code class="docutils literal"&gt;user&lt;/code&gt; and &lt;code class="docutils literal"&gt;pass&lt;/code&gt; fields:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_fc39df74214e432697d0e13178fd80a0-1" name="rest_code_fc39df74214e432697d0e13178fd80a0-1" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_fc39df74214e432697d0e13178fd80a0-1"&gt;&lt;/a&gt;&lt;span class="n"&gt;_anonymize_strings&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pass"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For Bluetooth addresses, I created a similar function. I want to keep the first three bytes of an address, which can point to the device manufacturer and be helpful for debugging purposes. Using a regular expression, I extract these bytes and add &lt;code class="docutils literal"&gt;XX:XX:XX&lt;/code&gt;. This function looks like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-1" name="rest_code_6b90d28a60604007bedb7257b8df5475-1" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-1"&gt;&lt;/a&gt;&lt;span class="n"&gt;_ADDR_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"^(([0-9A-F]&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;:)&lt;/span&gt;&lt;span class="si"&gt;{3}&lt;/span&gt;&lt;span class="s2"&gt;)([0-9A-F]&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;:)&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;[0-9A-F]&lt;/span&gt;&lt;span class="si"&gt;{2}&lt;/span&gt;&lt;span class="s2"&gt;$"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-2" name="rest_code_6b90d28a60604007bedb7257b8df5475-2" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-3" name="rest_code_6b90d28a60604007bedb7257b8df5475-3" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-4" name="rest_code_6b90d28a60604007bedb7257b8df5475-4" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-4"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_anonymize_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-5" name="rest_code_6b90d28a60604007bedb7257b8df5475-5" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-5"&gt;&lt;/a&gt;    &lt;span class="n"&gt;addr_parts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_ADDR_RE&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-6" name="rest_code_6b90d28a60604007bedb7257b8df5475-6" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-6"&gt;&lt;/a&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;addr_parts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-7" name="rest_code_6b90d28a60604007bedb7257b8df5475-7" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-7"&gt;&lt;/a&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;addr_parts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;XX:XX:XX"&lt;/span&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-8" name="rest_code_6b90d28a60604007bedb7257b8df5475-8" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-8"&gt;&lt;/a&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_6b90d28a60604007bedb7257b8df5475-9" name="rest_code_6b90d28a60604007bedb7257b8df5475-9" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_6b90d28a60604007bedb7257b8df5475-9"&gt;&lt;/a&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"INVALID ADDRESS"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the last part of the diagnostic information, where I display the information of the computer's Bluetooth adapters, I can call this function to anonymize the adapter's Bluetooth address:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_42b47124251e4f6f9b1e5db306549d80-1" name="rest_code_42b47124251e4f6f9b1e5db306549d80-1" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_42b47124251e4f6f9b1e5db306549d80-1"&gt;&lt;/a&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_anonymize_address&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"address"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Running the &lt;code class="docutils literal"&gt;python &lt;span class="pre"&gt;-m&lt;/span&gt; TheengsGateway.diagnose&lt;/code&gt; command shows output like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code markdown"&gt;&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-1" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-1" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-1"&gt;&lt;/a&gt;&lt;span class="gh"&gt;# Theengs Gateway Diagnostics&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-2" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-2" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-2"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-3" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-3" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-3"&gt;&lt;/a&gt;&lt;span class="gu"&gt;## Package Versions&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-4" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-4" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-4"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-5" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-5" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-5"&gt;&lt;/a&gt;| Name               | Value  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-6" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-6" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-6"&gt;&lt;/a&gt;|--------------------|--------|
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-7" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-7" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-7"&gt;&lt;/a&gt;| Theengs Gateway    | 3.0    |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-8" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-8" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-8"&gt;&lt;/a&gt;| Theengs Decoder    | 1.4.0  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-9" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-9" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-9"&gt;&lt;/a&gt;| Bleak              | 0.20.0 |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-10" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-10" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-10"&gt;&lt;/a&gt;| Bluetooth Clocks   | 0.1.0  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-11" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-11" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-11"&gt;&lt;/a&gt;| Bluetooth Numbers  | 1.1.0  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-12" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-12" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-12"&gt;&lt;/a&gt;| Paho MQTT          | 1.6.1  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-13" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-13" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-13"&gt;&lt;/a&gt;| Bluetooth Adapters | 0.15.3 |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-14" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-14" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-14"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-15" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-15" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-15"&gt;&lt;/a&gt;&lt;span class="gu"&gt;## Python&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-16" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-16" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-16"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-17" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-17" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-17"&gt;&lt;/a&gt;| Name           | Value           |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-18" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-18" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-18"&gt;&lt;/a&gt;|----------------|-----------------|
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-19" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-19" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-19"&gt;&lt;/a&gt;| Version        | 3.10.6          |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-20" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-20" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-20"&gt;&lt;/a&gt;| Implementation | CPython         |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-21" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-21" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-21"&gt;&lt;/a&gt;| Compiler       | GCC 11.3.0      |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-22" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-22" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-22"&gt;&lt;/a&gt;| Executable     | /usr/bin/python |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-23" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-23" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-23"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-24" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-24" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-24"&gt;&lt;/a&gt;&lt;span class="gu"&gt;## Operating System&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-25" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-25" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-25"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-26" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-26" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-26"&gt;&lt;/a&gt;| Name         | Value                                               |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-27" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-27" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-27"&gt;&lt;/a&gt;|--------------|-----------------------------------------------------|
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-28" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-28" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-28"&gt;&lt;/a&gt;| System       | Linux                                               |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-29" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-29" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-29"&gt;&lt;/a&gt;| Release      | 6.2.0-10005-tuxedo                                  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-30" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-30" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-30"&gt;&lt;/a&gt;| Version      | &lt;span class="ni"&gt;#5&lt;/span&gt; SMP PREEMPT_DYNAMIC Wed Mar 22 12:42:40 UTC 2023 |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-31" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-31" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-31"&gt;&lt;/a&gt;| Machine type | x86_64                                              |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-32" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-32" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-32"&gt;&lt;/a&gt;| Distribution | Ubuntu 22.04.1 LTS                                  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-33" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-33" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-33"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-34" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-34" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-34"&gt;&lt;/a&gt;&lt;span class="gu"&gt;## Configuration&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-35" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-35" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-35"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-36" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-36" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-36"&gt;&lt;/a&gt;&lt;span class="sb"&gt;```&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-37" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-37" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-37"&gt;&lt;/a&gt;&lt;span class="sb"&gt;{&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-38" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-38" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-38"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "adapter": "hci0",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-39" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-39" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-39"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "ble_scan_time": 1000,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-40" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-40" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-40"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "ble_time_between_scans": 5,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-41" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-41" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-41"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "discovery": 1,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-42" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-42" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-42"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "discovery_device_name": "TheengsGateway",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-43" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-43" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-43"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "discovery_filter": [&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-44" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-44" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-44"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "IBEACON",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-45" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-45" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-45"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "GAEN",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-46" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-46" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-46"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "MS-CDP"&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-47" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-47" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-47"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    ],&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-48" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-48" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-48"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "discovery_topic": "homeassistant/sensor",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-49" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-49" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-49"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "hass_discovery": 1,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-50" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-50" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-50"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "host": "rhasspy",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-51" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-51" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-51"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "log_level": "DEBUG",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-52" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-52" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-52"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "lwt_topic": "home/TheengsGateway/LWT",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-53" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-53" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-53"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "pass": "***",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-54" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-54" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-54"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "port": 1883,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-55" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-55" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-55"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "presence": 0,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-56" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-56" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-56"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "presence_topic": "home/TheengsGateway/presence",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-57" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-57" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-57"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "publish_advdata": 1,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-58" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-58" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-58"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "publish_all": 1,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-59" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-59" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-59"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "publish_topic": "home/TheengsGateway/BTtoMQTT",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-60" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-60" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-60"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "scanning_mode": "active",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-61" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-61" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-61"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "subscribe_topic": "home/+/BTtoMQTT/undecoded",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-62" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-62" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-62"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "time_format": 1,&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-63" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-63" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-63"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "time_sync": [&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-64" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-64" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-64"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "58:2D:34:XX:XX:XX",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-65" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-65" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-65"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "E7:2E:00:XX:XX:XX",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-66" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-66" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-66"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "BC:C7:DA:XX:XX:XX",&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-67" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-67" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-67"&gt;&lt;/a&gt;&lt;span class="sb"&gt;        "10:76:36:XX:XX:XX"&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-68" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-68" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-68"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    ],&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-69" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-69" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-69"&gt;&lt;/a&gt;&lt;span class="sb"&gt;    "user": "***"&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-70" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-70" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-70"&gt;&lt;/a&gt;&lt;span class="sb"&gt;}&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-71" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-71" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-71"&gt;&lt;/a&gt;&lt;span class="sb"&gt;```&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-72" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-72" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-72"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-73" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-73" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-73"&gt;&lt;/a&gt;&lt;span class="gu"&gt;## Bluetooth adapters&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-74" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-74" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-74"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-75" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-75" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-75"&gt;&lt;/a&gt;Default adapter: hci0
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-76" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-76" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-76"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-77" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-77" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-77"&gt;&lt;/a&gt;&lt;span class="gu"&gt;### hci0&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-78" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-78" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-78"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-79" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-79" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-79"&gt;&lt;/a&gt;| Name         | Value               |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-80" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-80" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-80"&gt;&lt;/a&gt;|--------------|---------------------|
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-81" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-81" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-81"&gt;&lt;/a&gt;| address      | 9C:FC:E8:XX:XX:XX   |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-82" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-82" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-82"&gt;&lt;/a&gt;| sw_version   | tux                 |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-83" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-83" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-83"&gt;&lt;/a&gt;| hw_version   | usb:v1D6Bp0246d0540 |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-84" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-84" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-84"&gt;&lt;/a&gt;| passive_scan | True                |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-85" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-85" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-85"&gt;&lt;/a&gt;| manufacturer | Intel Corporate     |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-86" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-86" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-86"&gt;&lt;/a&gt;| product      | 0029                |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-87" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-87" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-87"&gt;&lt;/a&gt;| vendor_id    | 8087                |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-88" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-88" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-88"&gt;&lt;/a&gt;| product_id   | 0029                |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-89" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-89" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-89"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-90" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-90" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-90"&gt;&lt;/a&gt;&lt;span class="gu"&gt;### hci1&lt;/span&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-91" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-91" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-91"&gt;&lt;/a&gt;
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-92" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-92" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-92"&gt;&lt;/a&gt;| Name         | Value                   |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-93" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-93" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-93"&gt;&lt;/a&gt;|--------------|-------------------------|
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-94" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-94" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-94"&gt;&lt;/a&gt;| address      | 00:01:95:XX:XX:XX       |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-95" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-95" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-95"&gt;&lt;/a&gt;| sw_version   | tux &lt;span class="ni"&gt;#2&lt;/span&gt;                  |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-96" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-96" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-96"&gt;&lt;/a&gt;| hw_version   | usb:v1D6Bp0246d0540     |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-97" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-97" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-97"&gt;&lt;/a&gt;| passive_scan | True                    |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-98" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-98" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-98"&gt;&lt;/a&gt;| manufacturer | Sena Technologies, Inc. |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-99" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-99" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-99"&gt;&lt;/a&gt;| product      | 0001                    |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-100" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-100" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-100"&gt;&lt;/a&gt;| vendor_id    | 0a12                    |
&lt;a id="rest_code_18da1f7f45ae44ce8b297e9e010def94-101" name="rest_code_18da1f7f45ae44ce8b297e9e010def94-101" href="https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/#rest_code_18da1f7f45ae44ce8b297e9e010def94-101"&gt;&lt;/a&gt;| product_id   | 0001                    |
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the repository's &lt;a class="reference external" href="https://github.com/theengs/gateway/blob/development/.github/ISSUE_TEMPLATE/bug_report.md"&gt;issue template for bug reports&lt;/a&gt;, we ask for the output of this command. The user simply has to copy the output, which is already formatted in Markdown syntax. This displays titles, subtitles, and even tables cleanly, providing us the necessary information:&lt;/p&gt;
&lt;img alt="/images/theengs-gateway-diagnose.png" src="https://koen.vervloesem.eu/images/theengs-gateway-diagnose.png"&gt;</description><category>anonymization</category><category>ble</category><category>bluetooth</category><category>bluetooth-low-energy</category><category>json</category><category>programming</category><category>python</category><category>theengs-gateway</category><guid>https://koen.vervloesem.eu/blog/creating-a-diagnostics-module-for-python-software/</guid><pubDate>Mon, 24 Apr 2023 18:04:11 GMT</pubDate></item></channel></rss>