<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>esp32 Archives - Creatronix</title>
	<atom:link href="https://creatronix.de/tag/esp32/feed/" rel="self" type="application/rss+xml" />
	<link>https://creatronix.de/tag/esp32/</link>
	<description>My adventures in code &#38; business</description>
	<lastBuildDate>Thu, 09 Oct 2025 14:50:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>How to connect to your ESP32 on macos</title>
		<link>https://creatronix.de/esp32-serial-connection/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Thu, 06 Jan 2022 09:02:04 +0000</pubDate>
				<category><![CDATA[Electronics & IOT]]></category>
		<category><![CDATA[esp32]]></category>
		<category><![CDATA[esp8266]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[tty]]></category>
		<guid isPermaLink="false">https://creatronix.de/?p=4443</guid>

					<description><![CDATA[<p>To find out as what USB device the ESP32 is connected, open Terminal and enter: ls /dev/tty* &#124; grep usb in my case I got /dev/tty.usbserial-14120 Now we can connect via screen: screen /dev/tty.usbserial-14120 115200 When you reset the board you should see something like this configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:5656 load:0x40078000,len:12696&#8230;</p>
<p>The post <a href="https://creatronix.de/esp32-serial-connection/">How to connect to your ESP32 on macos</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To find out as what USB device the ESP32 is connected, open Terminal and enter:</p>
<pre><code class="language-bash">ls /dev/tty* | grep usb</code></pre>
<p>in my case I got</p>
<pre><code class="language-bash">/dev/tty.usbserial-14120</code></pre>
<p>Now we can connect via screen:</p>
<pre><code class="language-bash">screen /dev/tty.usbserial-14120 115200</code></pre>
<p>When you reset the board you should see something like this</p>
<pre><code class="language-bash">configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:5656
load:0x40078000,len:12696
load:0x40080400,len:4292
entry 0x400806b0</code></pre>
<p>To end the session in screen, press Ctrl+a, and type <strong>:quit</strong> and press Enter.</p>
<h2>Further Reading</h2>
<p><a href="https://creatronix.de/install-esp32-in-arduinoide/">Install ESP32 in ArduinoIDE</a></p>
<p><a href="https://creatronix.de/using-micropython-on-firebeetle-esp32/">Using MicroPython on FireBeetle ESP32</a></p>
<p><a href="https://creatronix.de/firebeetle-project/">Mailbox IoT ESP 32 Project</a></p>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/esp32-serial-connection/">How to connect to your ESP32 on macos</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Using MicroPython on FireBeetle ESP32</title>
		<link>https://creatronix.de/using-micropython-on-firebeetle-esp32/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Sat, 04 Apr 2020 14:16:24 +0000</pubDate>
				<category><![CDATA[Electronics & IOT]]></category>
		<category><![CDATA[ampy]]></category>
		<category><![CDATA[blink]]></category>
		<category><![CDATA[esp32]]></category>
		<category><![CDATA[esptool]]></category>
		<category><![CDATA[firebeetle]]></category>
		<category><![CDATA[micropython]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=3175</guid>

					<description><![CDATA[<p>Motivation In Fire Beetle ESP 32 Project I wrote about connecting the FireBeetle ESP32 with the Arduino IDE and writing a little C-style program. Another interesting approach is to use MicroPython. Installing MicroPython Install esptool To get MicroPython onto the board we use the esptool command line. Because we are in the Python ecosystem we&#8230;</p>
<p>The post <a href="https://creatronix.de/using-micropython-on-firebeetle-esp32/">Using MicroPython on FireBeetle ESP32</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Motivation</h2>
<p>In <a href="https://creatronix.de/install-esp32-in-arduinoide/">Fire Beetle ESP 32 Project</a> I wrote about connecting the FireBeetle ESP32 with the Arduino IDE and writing a little C-style program. Another interesting approach is to use MicroPython.</p>
<h2>Installing MicroPython</h2>
<h3>Install esptool</h3>
<p>To get MicroPython onto the board we use the esptool command line. Because we are in the Python ecosystem we use pip to install esptool:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>pip install esptool</code></pre>
</div>
<h3>Download firmware</h3>
<p>Go to https://micropython.org/download/esp32/</p>
<p>and download the latest release as of today is <strong>v1.19.1 (2022-06-18) .bin</strong></p>
<h3>Erase flash</h3>
<p>Before we can install the firmware it is recommended to erase the flash</p>
<p>On my machine the port is /dev/tty.usbserial-14130. This can vary depending on your OS and setup.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>esptool.py --port /dev/tty.usbserial-14130 erase_flash</code></pre>
</div>
<h3>Flash Firmware</h3>
<p>Flashing the firmware looks like the following:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>esptool.py --chip esp32 --baud 115200 --port /dev/tty.usbserial-14130 write_flash -z 0x1000 ./esp32-idf3-20191220-v1.12.bin</code></pre>
</div>
<p>To prevent flash errors we set the transmission speed to 115200 baud</p>
<h2>Connect via Serial</h2>
<p>When you work with an unixoid system like linux or macos you can use screen to connect via serial port. On Windows you can download the program putty</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>screen /dev/tty.usbserial-14130 115200</code></pre>
</div>
<p>After connecting you will get the prompt from the python command line aka REPL</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-3181" src="https://creatronix.de/wp-content/uploads/2020/04/conect_via_screen.png" alt="" width="868" height="157" srcset="https://creatronix.de/wp-content/uploads/2020/04/conect_via_screen.png 868w, https://creatronix.de/wp-content/uploads/2020/04/conect_via_screen-300x54.png 300w, https://creatronix.de/wp-content/uploads/2020/04/conect_via_screen-768x139.png 768w" sizes="(max-width: 868px) 100vw, 868px" /></p>
<h2>Working with scripts</h2>
<p>After fiddling around with the REPL we want to write our first program. We write a program like the Arduino blink sketch but just in Python:</p>
<h3>Blink Program</h3>
<p>The onboard blue led is connected to pin 2</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>from machine import Pin 
import time 
p2 = Pin(2, Pin.OUT) 
def blink(): 
    while True: 
        p2.value(0) 
        time.sleep(1) 
        p2.value(1) 
        time.sleep(1) 
blink()</code></pre>
</div>
<h3>Save this script in a file with the name blink.py</h3>
<h3>Uploading scripts</h3>
<p>To upload scripts to the FireBeetle board we use another nice library called ampy from AdaFruit. We install it via pip as well</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>pip install adafruit-ampy</code></pre>
</div>
<p>With ampy we can upload the file to our board.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>ampy --port /dev/tty.usbserial-14130 put blink.py</code></pre>
</div>
<p>If it doesn&#8217;t work right away, please close your terminal connection.</p>
<h3>Starting scripts</h3>
<p>When the upload is finished you can reconnect via serial console and import your script and the led should start to blink</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>&gt;&gt;&gt;import blink</code></pre>
</div>
<h3>Running scripts on startup</h3>
<p>When your script should start directly at power on, you upload it as main.py</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>ampy --port /dev/tty.usbserial-14130 put blink.py /main.py</code></pre>
</div>
<p>If you had fun so far feel free to read my <a href="https://creatronix.de/firebeetle-project/">Mailbox IoT ESP 32 Project</a> article as well</p>
<h3>Further Reading</h3>
<p><a href="https://docs.micropython.org/en/latest/esp32/quickref.html#">https://docs.micropython.org/en/latest/esp32/quickref.html#</a></p>
<p><a href="https://blog.miguelgrinberg.com/post/micropython-and-the-internet-of-things-part-i-welcome">https://blog.miguelgrinberg.com/post/micropython-and-the-internet-of-things-part-i-welcome</a></p>
<p>The post <a href="https://creatronix.de/using-micropython-on-firebeetle-esp32/">Using MicroPython on FireBeetle ESP32</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Mailbox IoT ESP 32 Project</title>
		<link>https://creatronix.de/firebeetle-project/</link>
		
		<dc:creator><![CDATA[Jörn]]></dc:creator>
		<pubDate>Thu, 02 Apr 2020 14:52:49 +0000</pubDate>
				<category><![CDATA[Electronics & IOT]]></category>
		<category><![CDATA[deep sleep]]></category>
		<category><![CDATA[esp32]]></category>
		<category><![CDATA[IoT]]></category>
		<category><![CDATA[micropython]]></category>
		<category><![CDATA[wifi]]></category>
		<guid isPermaLink="false">http://creatronix.de/?p=3147</guid>

					<description><![CDATA[<p>Motivation Out of curiosity I bought a ESP32 board to tinker with, but for almost half a year hadn&#8217;t got an idea what to do with it&#8230; But then! Project Idea The idea: Every time I get mail into my physical snail mail mailbox, the mailbox shall send a message via Telegram to my smartphone:&#8230;</p>
<p>The post <a href="https://creatronix.de/firebeetle-project/">Mailbox IoT ESP 32 Project</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Motivation</h2>
<p>Out of curiosity I bought a ESP32 board to tinker with, but for almost half a year hadn&#8217;t got an idea what to do with it&#8230; But then!</p>
<h2>Project Idea</h2>
<p><img decoding="async" class="alignnone size-large wp-image-3243" src="https://creatronix.de/wp-content/uploads/2020/04/IMG_8859-1024x922.jpg" alt="" width="525" height="473" srcset="https://creatronix.de/wp-content/uploads/2020/04/IMG_8859-1024x922.jpg 1024w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8859-300x270.jpg 300w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8859-768x692.jpg 768w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8859-1536x1383.jpg 1536w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8859-2048x1844.jpg 2048w" sizes="(max-width: 525px) 100vw, 525px" /></p>
<p>The idea: Every time I get mail into my physical snail mail mailbox, the mailbox shall send a message via Telegram to my smartphone:</p>
<p><img decoding="async" class="alignnone size-full wp-image-3241" src="https://creatronix.de/wp-content/uploads/2020/04/telegram_mailbox_bot_esp32.png" alt="" width="600" height="311" srcset="https://creatronix.de/wp-content/uploads/2020/04/telegram_mailbox_bot_esp32.png 600w, https://creatronix.de/wp-content/uploads/2020/04/telegram_mailbox_bot_esp32-300x156.png 300w" sizes="(max-width: 600px) 100vw, 600px" /></p>
<p>But with many ideas the execution can become time consuming. Well, let&#8217;s see 🙂</p>
<h2>MicroPython</h2>
<p>As a Python afficionado I was relieved as I found out, that you can use MicroPython on the ESP32 board. I wrote a separate article as a prerequisite:</p>
<p><a href="https://creatronix.de/using-micropython-on-firebeetle-esp32/">Using MicroPython on FireBeetle ESP32</a></p>
<p>From now on I assume, that You have a MicroPython version running on the ESP32.</p>
<h2>Buttons</h2>
<p>When the lid of the mailbox is opened, a button shall trigger the action, so we need to configure a GPIO as an input.</p>
<p>This is done via the machine package.</p>
<p>When we don&#8217;t want to have external pullups we can enable the internal pullup resistor. Beware: the logic becomes inverted, because the pin is high in idle we pull it down with the button to 0 volts, hence button pressed equals value zero</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import machine 
button = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP) 
while True: 
    if not button.value(): 
        print('Button pressed!')</code></pre>
</div>
<h2>Deep Sleep</h2>
<p>Due to the fact that the device will be battery powered and will just need to send a message once or twice a day, we will need the deepsleep capability.</p>
<p>The machine package gives you access to the deepsleep function as well.</p>
<p>A bit counterintuitive but you also need the esp32 package for defining a wake up cause. One caveat: not every GPIO is able to wake up the ESP32 from deepsleep but GPIO 4 will do it.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import machine 
import esp32 
from time import sleep 

wake1 = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP) 
esp32.wake_on_ext0(pin=wake1, level=esp32.WAKEUP_ALL_LOW) 
print('Im awake. Going to sleep in 10 seconds') 
sleep(10) 
print('Going to sleep now') 

machine.deepsleep()</code></pre>
</div>
<h2>Setting up Wifi in MicroPython</h2>
<p>To be able to send messages we need a WiFi connection. In MicroPython this is handled by the network package.</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python">import network
</pre>
</div>
<p>The ESP32 can either work as a station or as an access point. We need the first option so we use the STA_IF configuration.<br />
sta_if = network.WLAN(network.STA_IF)<br />
the interface has to be activated via</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>sta_if.active(True)</code></pre>
</div>
<p>Now we can connect to our Wi-Fi</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>sta_if.connect(ssid,  password)</code></pre>
</div>
<p>You can check the status of the connection via:</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>sta_if.isconnected()</code></pre>
</div>
<h2>Writing a Telegram Bot</h2>
<h3>Create TG bot</h3>
<ol>
<li>Open Telegram app on your phone</li>
<li>Search for @botfather</li>
<li>Start chat</li>
<li>Send /newbot</li>
<li>Pick a name</li>
<li>Pick a username (must be unique)</li>
<li>Receive credentials</li>
</ol>
<h3>Chat with your bot</h3>
<p>Now you can search for your bot&#8217;s name and send a message</p>
<h3>Python test Program</h3>
<p>Telegram has a nice python package which you can pip install</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-bash" data-lang="Bash"><code>pip install python-telegram-bot --upgrade</code></pre>
</div>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import telegram 

bot = telegram.Bot(token='&lt;your_token&gt;') 

if __name__ == '__main__': 
    print(bot.get_me()) 
    bot.send_message(chat_id="&lt;your_chat_id&gt;", text="Post ist da")</code></pre>
</div>
<p>This program is just used to test the connectivity of your bot.</p>
<h3>urequests</h3>
<p>Because we don&#8217;t have access to the telegram package inside the ESP / MicroPython environment we use <a href="https://pypi.org/project/urequests/">urequests</a>.</p>
<p>urequests is similar to the requests package and lets you send http messages.</p>
<p>Sending messages looks like the following</p>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python"><code>import urequests 

requests.get("https://api.telegram.org/bot&lt;your_token&gt;/sendMessage?text=hallo&amp;chat_id=&lt;your_chat_id&gt;")</code></pre>
</div>
<h2>The complete Code</h2>
<div class="hcb_wrap">
<pre class="prism line-numbers lang-python" data-lang="Python">import network
import urequests
import machine
import esp32
from time import sleep

SSID = &lt;your_ssid&gt;
WIFI_PW = &lt;your_wifi_pw&gt;
TOKEN = &lt;your_tg_token&gt;
URL = "https://api.telegram.org/bot{}/".format(TOKEN)
CHAT_ID = &lt;your_chat_id&gt;


def connect_to_wifi(ssid, password):
    print("MBB: connect_to_wifi")
    sta_if = network.WLAN(network.STA_IF)

    if sta_if.isconnected():
        print("MBB: already connected")
        return

    if not sta_if.active():
        print("MBB: activate network adapter")
        sta_if.active(True)
        print("MBB: network adapter activated")

    if not sta_if.isconnected():
        print("MBB: trying to connect")
        sta_if.connect('%s' % ssid, '%s' % password)

        while not sta_if.isconnected():
            pass
        print("MBB: connected successfully")
    print(sta_if.ifconfig())


def get_url(url):
    response = urequests.get(url)
    content = response.text
    return content


def send_message(text, chat_id):
    url = URL + "sendMessage?text={}&amp;chat_id={}".format(text, chat_id)
    get_url(url)


if __name__ == '__main__':
    print("MBB: start")
    #disable LED on firebeetle board
    p2 = machine.Pin(2, machine.Pin.OUT)
    p2.value(0)
    wake1 = machine.Pin(4, machine.Pin.IN, machine.Pin.PULL_UP) # pin 4 is able to wake
    esp32.wake_on_ext0(pin=wake1, level=esp32.WAKEUP_ALL_LOW)
    print('MBB: Im awake. Going to sleep in 10 seconds')
    connect_to_wifi(SSID, WIFI_PW)
    print("MBB: sending message")
    send_message("Post ist endlich da", CHAT_ID)
    print("MBB: finished")
    sleep(10)
    print('MBB: Going to sleep now')
    machine.deepsleep()

</pre>
</div>
<h2>Testing</h2>
<p><img decoding="async" class="alignnone size-large wp-image-3250" src="https://creatronix.de/wp-content/uploads/2020/04/IMG_8888-1024x768.jpg" alt="" width="525" height="394" srcset="https://creatronix.de/wp-content/uploads/2020/04/IMG_8888-1024x768.jpg 1024w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8888-300x225.jpg 300w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8888-768x576.jpg 768w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8888-1536x1152.jpg 1536w, https://creatronix.de/wp-content/uploads/2020/04/IMG_8888-2048x1536.jpg 2048w" sizes="(max-width: 525px) 100vw, 525px" /></p>
<p>After charging the battery we can use the board independently from the computer</p>
<h2>Sources</h2>
<p>https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf</p>
<p>&nbsp;</p>
<p>The post <a href="https://creatronix.de/firebeetle-project/">Mailbox IoT ESP 32 Project</a> appeared first on <a href="https://creatronix.de">Creatronix</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
