Friday, August 21, 2026

Finding MP3 streams for internet radio part 1

For an index to all my stories click this text

Time really flies !! I could not believe my eyes when I saw that my stories on building an internet radio dated from 2018 !!! At that time I build an internet radio with a Raspberry Pi Zero. It was a 4 part story.

You can read the stories that start with what hard and software you need and building a single station internet radio, to a headless (no display or keyboard) stand alone internet radio, with only some buttons that allow to choose the desired radio stations. I'll give you the link to the last part in which you can find links to the previous parts:
https://lucstechblog.blogspot.com/2018/10/raspberry-pi-internet-radio-part-3.html

Well this suddenly became current again.
Like a lot of people we have TV, internet and (landline) telephone from one company. My girlfriend enjoys listening to a certain classic radio station using our stereo set. However that radio station suddenly decided that it would only broadcast through the internet instead of the cable. And our stereo set does not have internet radio on board.

So time to build an internet radio for our living room.

There was only a slight problem. In part 2B in the series I described how you easily can find the URL's for the MP3 streams with VTuner. And that did not work anymore. Well things change in 7 year ..........

The new VTuner method.


First step is to point your browser to http://www.vtuner.com/

 At the top-right side of the page click on "Check out our huge station list!"


So far so good.

I was looking especially for a station with the name Classic FM, and (like said above) it is an internet only station. So I filled that name in, in the search box. Obviously you may want to look for another radio station. To get that stream just follow the steps I'll show you here.


And I got a complete list of radio stations with the name Classic FM.
There was one with the indication Internet Only and that was the one I needed.


Press the green play button in front of the station name.


A new screen opens with an audio player at the bottom.


Press the play button.
The player plays the realtime radio stream from that station.

My web browser is Firefox and I do not use Windows but my computer runs Linux (Kubuntu). So the next steps might be different on your system. But they are not difficult to follow.

Search in your browser menu for the option to look at the page source. In Firefox it is in the Hamburger menu on at the top-right side of the browser screen under the More tools option. You can also find it by pressing the right-side mouse button.


Use the search function in your browser to look for "MP3"
And there it is.

http://classicfm.ice.infomaniak.ch/classic-fm.mp3

Select only this part and you got the link you need for your internet radio !!!

This is all a bit tedious. Fortunately I found an easier method to get the link. That's for next weeks story.

Till then,
have fun

Luc Volders

Friday, August 14, 2026

Javascript Speech Recognition

For an index to all my stories click this text

Speech synthesises is having your computer speak out words and sentences to you. You can do that with Javascript like I wrote in this story: 
https://lucstechblog.blogspot.com/2025/09/javascript-speech-synthesises.html
But even microcontrollers like the ESP32 can (although in a very low quality) speak out words and sentences like you can read in these stories:
- talkie 1
https://lucstechblog.blogspot.com/2022/11/talkie-part-1-esp32-speech-synthesiser.html 

- Audio on the Raspberry Pi Pico part 4
http://lucstechblog.blogspot.com/2024/11/pico-audio-part-4-talking-thermometer.html

But next to that there is speech recognition. That's the other way round. You speak into a microphone and your computer recognizes the words and acts on them. The most famous examples are of course Google Home and Alexa.

A few years ago I wrote a story on how to build a speech recognition App for Android:
https://lucstechblog.blogspot.com/2016/01/voice-command.html

This time I am going to show you how it is done in Javascript.
There is a limitation and that is that this is Windows only and it does not work in Firefox. Firefox does not support speech recognition. So you will have to use Google Chrome or Microsoft Edge.

Javascript.

Javascript runs in a browser. So to use it you need to build a minimal web-page.

On this web-page we put a text that tells what this page is about and an empty paragraph into which the spoken and recognized words and sentences are put.

<!DOCTYPE html>
<html>
<body>
<h1 style="color:red;">Luc's speech recognition</h1>
<h2>Below comes the text that you speak.</h2>
<br>
<p id="texthere"></p>

</html>

This is the complete web-page. However it does nothing exept setting some text on your screen. To have speech recognition to work we need a Javascript program. and here is that program line by line.

window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition;

This line selects the speech recognition that is needed for your browser.

const recognition = new window.SpeechRecognition();

We make an instance of the Speech.Recognition and call it recognition

    recognition.continuous = true;


This line is important as it sets the speech recognition to continuous.
Continuous means that you do not need a button to click on each time you want a new sentence to get analysed.

    recognition.lang = "en-US"

And with this line you can change the language you want to get recognised.

    recognition.onresult = (event) =>
    {
      var textheard = (event.results[event.results.length -1][0].transcript);
      document.getElementById("texthere").innerHTML = textheard;
    }


If the speech recognition has heard a sentence an event is raised.
The variable textheard gets the interpreted text from the speech recognition and that variable is put into the paragraph on the screen with the ID texthere.

recognition.start();


And this is the actual command that starts the speech recognition.

And that is all that is to it.

So here is the complete page with the Javascript code.

<!DOCTYPE html>
<html>
<body>
<h1 style="color:red;">Luc's speech recognition</h1>
<h2>Below comes the text that you speak.</h2>
<br>
<p id="texthere"></p>

<script>

window.SpeechRecognition = window.webkitSpeechRecognition || window.SpeechRecognition;

    const recognition = new window.SpeechRecognition();

    recognition.continuous = true;
    recognition.lang = "en-US"

    recognition.onresult = (event) =>
    {
      var textheard = (event.results[event.results.length -1][0].transcript);
      document.getElementById("texthere").innerHTML = textheard;
    }
    
    recognition.start();

</script>
</html>


Play with it.

To play with this, copy the above code and paste it into your favorite texteditor. I mostly use notepad for these small programs.
Save the file as recognition.html or any name you like in any folder of your choice. Just make sure it is plain ASCII and the file has the extension HTML.
Open the folder and you will see an HTML file. Left click on that and open it with Google Chrome or microsofts Edge.



The webpage asks now whether it is ok to use your computers microphone.
Then just speak any text to your liking.



And this is how the webpage looks after I said "put lamp number one on"
You can see where this is going.

Language selection.

The above program uses recognition.lang = "en-US" yo set the speech.recognition to recognise the English language. So here is a list of the other languages that are available.

Javascript uses the BCP 47 Language Codes and here is the complete list of languages that are available:

ar-SA Arabic Saudi Arabia
cs-CZ Czech Czech Republic
da-DK Danish Denmark
de-DE German Germany
el-GR Modern Greek Greece
en-AU English Australia
en-GB English United Kingdom
en-IE English Ireland
en-US English United States
en-ZA English South Africa
es-ES Spanish Spain
es-MX Spanish Mexico
fi-FI Finnish Finland
fr-CA French Canada
fr-FR French France
he-IL Hebrew Israel
hi-IN Hindi India
hu-HU Hungarian Hungary
id-ID Indonesian Indonesia
it-IT Italian Italy
ja-JP Japanese Japan
ko-KR Korean Republic of Korea
nl-BE Dutch Belgium
nl-NL Dutch Netherlands
no-NO Norwegian Norway
pl-PL Polish Poland
pt-BR Portuguese Brazil
pt-PT Portuguese Portugal
ro-RO Romanian Romania
ru-RU Russian Russian Federation
sk-SK Slovak Slovakia
sv-SE Swedish Sweden
th-TH Thai Thailand
tr-TR Turkish Turkey
zh-CN Chinese China
zh-HK Chinese Hong Kong
zh-TW Chinese Taiwan


So just change recognition.lang = "en-US" into recognition.lang = "nl-NL" to change from English to Dutch for example.

Some considerations.

First:
The speech recognition is continuous. However when there is a silence for more then 10 seconds the speech recognition is turned off and you will have to restart it manually.

Second:
Do not use this if you hate Google. Actually every sentence you speak is send over the internet to Google's speech recognition server in the cloud. So if you thought you could use this to get rid of your Google Home or Nest you are wrong. This is still using Google's services.

What's next

The next step is to combine the speech synthezises and the ESP webserver with the speech recognition. Then we will be able to have the ESP8266 react on commands like "put the lamp on" and "tell me the room temperature" !!!

Till then.
Have fun

Luc Volders



Friday, July 17, 2026

DFRobot mini with pause for podcasts

For an index to all my stories click this text.

In a previous story I wrote how to use a DFRobot Mini MP3 player. The player is attached to a Raspberry Pi Pico with 5 keys. The key's functions are next song, previous song, volume up, volume down and reset. You can read that story here: 
https://lucstechblog.blogspot.com/2026/07/dfrobot-mini-mp3-with-micropython.html

There are however some more commands you can issue to the MP3 player. And while using it in real life I realized I do miss these commands. So I made some adjustments to the previous design.

Pause and Resume.

The previous design had a reset button. That reset the Pico and the program started fresh making the MP3 player start playing from the first song again.

I am however a frequent podcast listener.
And when listening something urgent happens: the phone rings, the doorbell rings etc.
Stop playing the podcast is annoying as you then have to start all over again. Not a problem for a song of a few minutes but annoying when listening to a podcast of an hour or so.

Luckily the DFRobot MP3 player has a pause function (music.pause()) and a resume function (music.resume()). Pause indeed pauses the player and resume neatly starts where the player was set at pause.
So I adapted the design an added a Pause and resume button.

I also rewired the reset button to another pin and altered the software so that it makes the player sop playing. Pressing any button (except the volume buttons) then restarts the player at the next song in line.

Breadboard.


You can find the description in the previous story. I just mention the 3 new buttons here.
The pause and resume button are wired to GPI14 and GPIO15.
The stop button is wired to GPIO11.

As mentioned in the previous story: watch out which pins you use. Pins GPIO12 and GPIO13 are wired to UART0. And UART0 communicates with the DFRobot Mini MP3 player. So pressing a button attached to one of these pins interferes with the Uart communication and makes the player behave strangely.

Please note that the USB power line is only connected to the DFRobot Mini player. It is not connected to the Pico. The GND lines are connected to the Pico and to the player.

The MicroPython program.

Because 1 button is rewired and 2 new buttons are added as wel extra functionality being added the software needs to be adapted. Here is the new program in full.

from dfplayermini import Player
from time import sleep
import machine

vol = 20

butstop   = machine.Pin(11, machine.Pin.IN)

butpause  = machine.Pin(15, machine.Pin.IN)
butresume = machine.Pin(14, machine.Pin.IN)

butnext   = machine.Pin(18, machine.Pin.IN)
butprev   = machine.Pin(19, machine.Pin.IN)
butvolup  = machine.Pin(20, machine.Pin.IN)
butvoldwn = machine.Pin(21, machine.Pin.IN)

busypin = machine.Pin(22, machine.Pin.IN)

txpin = machine.Pin(0)
rxpin = machine.Pin(1, machine.Pin.IN)
music = Player(pin_TX=txpin, pin_RX=rxpin)

stop = False
pause = False

sleep(.2)

music.stop()
sleep(.2)

music.volume(vol)
sleep(.2)
music.play(1)
sleep(2)

while True:
    if butpause.value() == 0:
        print("pause")
        pause = True
        music.pause()
        sleep(.5)
    if butresume.value() == 0:
        print("resume")
        pause = False
        music.resume()
        sleep(.5)
    if butstop.value() == 0:
        print("stop")
        music.stop()
        stop = not stop
        sleep(.5)
    if busypin.value() == 1 and stop == False and pause == False:
        music.play('next')
        sleep(.4)
    if (butnext.value()==0):
        music.stop()
        sleep(.5)
        print ("next number")
        music.play('next')
        sleep(.5)
    if (butprev.value()==0):
        music.stop()
        sleep(.5)
        print ("previous number")
        music.play('prev')
        sleep(.5)
    if (butvolup.value()==0):
        vol = vol + 1
        print ("Volume : ",vol)
        music.volume(vol)
        sleep(.2)
    if (butvoldwn.value()==0):
        vol = vol - 1
        print ("Volume : ",vol)
        music.volume(vol)
        sleep(.2)

Nothing special in this program except this part in the while loop:

    if busypin.value() == 1 and stop == False and pause == False:
        music.play('next')
        sleep(.4)

When the player has played one song it normally stops. The busy pin is LOW when the player plays and gets HIGH when the player stops. This is handled in a different part of the program and already discussed in the previous story.

But we do not want the player to automatically play the next song if the stop and pause buttons have been pressed. And that is handled here.

Copy the program into Thonny's editor and save it in your Pico's memory. If you did not follow the previous story then do so now because it showed where to get the required library.

If you do not have a clue about what Thonny is, how to install MicroPython or how to install libraries please consider buying one of my books, about the Raspberry Pi Pico, listed below.

That's all for now.

Till next time
have fun

Luc Volders

Friday, July 10, 2026

DFRobot mini MP3 with MicroPython

For an index to all my stories click this text.

Portable MP3 players where once THE thing to have. Now they are getting obsolete because (almost) everyone has a handheld computer (called a smartphone) that is perfectly capable of doing the job. However, sometimes you want a simple music player that does the job. And that's exactly what we are going to build.

DFRobot DFPlayer

DFRobot is an US brand that makes some neat gadgets. And the most well-known is the DFRobot DFPlayer. It is a small MP3 player that has an amplifier on board so you can attach a loudspeker for direct results. The MP3 files are stored on a SD card and therefore there is an SD card reader on board.


The board has an original price of about 5 USD but clones (which are 100% copies) can be bought from our Chinese friends for about 1.50 USD.

In 2019 I wrote a small story on how to use this MP3 player with just two buttons. The functionality was limited. Pressing the first button took you to the next song. The other button switched to the previous song. You can find that story here:
https://lucstechblog.blogspot.com/2019/05/mp3-player-stand-alone.html

In 2022 I revisited the DFRobot MP3 player and wrote a story on how you could control it from a website. That sory attached an ESP8266 or ESP32 to the DFRobot MP3 player. It had however the same limited functionality as the story with the manual control. You can read that story here:
https://lucstechblog.blogspot.com/2019/10/web-controlled-mp3-player.html

More control.

The previous two stories used the DFRobot MP3 player's IO pins to control the player. And they only offer next song, previous song functionality. There are however a lot more possibilities.
To use these extra functions you need to send commands over a serial interface (UART). And that is a lot easier as you think.

There is a nice MicroPython library that makes it possible to control almost all functions of this player. You can find that library here:
https://github.com/lavron/micropython-dfplayermini

If you do not know how to install MicroPython libraries please consider buying one of my books describing the use of Micropython with the Raspberry Pi Pico. You can find them here:


Click here to open a link on Amazon to buy my books


This library offers the following controls:

music.play(x)                            plays track x from the SD card
music.play('next')                    play the next track. If the just played track was the last
                                                       on the SD card the player will play the first track.
music.play('prev')                    Play the previous track. If there is no previous track
                                                       then the player will play the last track on the SD card.
music.stop()                               stops playing music
music.volume(x)                       sets the volume to x where x is a value fom 0 to 40
music.pause()                            stops playing
music.resume()                         starts playing where pause left
music.loop_track(                    store a track number
music.loop()                               keeps repeating the stored track
music.loop_disable()               stops repeating the track
music.fadeout(fadeout_ms)  slowly turns the volume down and stops playing

All these commands must be given over the UART lines.

The DFRobot MP3 player's pins.

The DFRobot MP3 player is a small module with 16 pins. It is breadboard friendly. Let us have a look at the pins we are going to use in this project.

VCC
Obviously this is the power line. The module needs 3.2 till 5V. I supply the power through a separate 5V USB wall plug. The 5V is connected to the module but NOT to the Raspberry Pi Pico.

GND
This is the GND line and is connected to the wall plug and the Pico.

RX
This is the UART receive line and will get connected to the Pico's TX line

TX
This is the UART transmit line and will get connected to the Pico's RX line

SPK_1 and SPK_2
Attach a speaker to these lines for playing the audio. The lines give a mono signal.
The DFRobot Mp3 player has a build-in amplifier and can run a speaker up to 3 Watt.

DAC_R and DAC_L
The DFRobot MP3 player has a build in DAC. We can attach these lines to the left and right entrances of an amplifier.

BUSY
The DFRobot mini MP3 player has a build-in led. That led is on while a sound track is playing. At the same time the BUSY pin gives a low signal. When the sound track finishes the player stops and the line gets high.

The importance of the BUSY line.

If you give the command to play a song (track) then the DFRobot puts the BUSY pin in a LOW state. Then the song finishes and the player stops. The BUSY line will get HIGH. And nothing happens further.

This is often not what we would like to happen. Most of the time we want the player to automatic play the next song.
So what we have to do is to test if the BUSY line gets HIGH and if so send the command music.play('next')

But beware !!!
If you add a stop button and give the command music.stop() the player will stop playing but the BUSY line will get HIGH. So if you do not take care of that the software will immediately send the command music.play("next') and the next track will start playing.
If you intentionally will skip to the next song (track) just press the music.play('next") button.

The same goes for a button that pauses the player. When at pause the Busy line will get HIGH and the software will automatically go on to play the next song. So take care of that in the software if you have a pause and resume button.

The breadboard setup.

I have used two half breadboards but things could easily be build on a full breadboard.


At the top there is a USB plug. In earlier projects I used a breadboard USB adapter to connect a USB power plug to my breadboard. Nowadays I use my own printed USB connector for this. That is not because they are a lot cheaper but because I always seem to miss the breadboard connectors when I need them. The VCC is connected to the DFRobot VCC line but NOT to the Pico. The GND line is connected to the DFRobot GND line and to the Pico's GND line. Here is the link to the story about this and the STL files if you want to print some yourself:
https://lucstechblog.blogspot.com/2025/03/print-your-own-usb-connector.html

Please make sure you do NOT connect the VSS line of the Pico to the VCC of the USB connector. If you do and you power your Pico from your computer you might damage the Pico and your computer beyond repair.

To the left at the top there is a speaker. It is just a speaker so not a computer speaker which has an amplifier in it. You can use earplugs or an headphone if you do not have a speaker at hand.
The speaker is connected to the SPK_1 and SPK_2 pins. So it is a mono signal.

The TX line of the DFRobot mini player is connected to pin GP1 of the Pico which is UART0 pin RX. The RX line of the DFRobot mini player is connected to pin GP0 of the Pico which is UART0 TX. So TX and RX are crossed.

The VCC line of the DFRobot is connected to the USB connector VCC and the GND.

Next there are 5 buttons at the bottom breadboard. Each button has a pull-up resistor of 10K and the first 4 buttons are connected to the Pico's pins 18,19,20 and 21. These are the buttons that choose next song, previous song, volume up and volume down.
The fifth button is connected to the Pico's pin 30 which is the reset button.

Beware of the pins

When I started testing I tought my Pico was broken. I had connected the next song and previous song buttons to the Pico pins 16 and 17. And the most strange things happened. The player would play random songs.

Then it occured to me that those pins are also used as UART0 pins.
So whenever I pushed a button I also gave a pulse on the UART pin of the DFRobot player !!

So when using UART0 you can not use pins GP16, GP17 but also not GP12 and GP13.

You can attach the DFRobot player to UART1 (GP4 and GP5) but then you can not use GP8 and GP9. To do so however you would need to alter the library which I do not recommend.

The MicroPython program

from dfplayermini import Player
from time import sleep
import machine

vol = 20

butnext   = machine.Pin(18, machine.Pin.IN)
butprev   = machine.Pin(19, machine.Pin.IN)
butvolup  = machine.Pin(20, machine.Pin.IN)
butvoldwn = machine.Pin(21, machine.Pin.IN)

busypin = machine.Pin(22, machine.Pin.IN)

txpin = machine.Pin(0)
rxpin = machine.Pin(1, machine.Pin.IN)
music = Player(pin_TX=txpin, pin_RX=rxpin)

sleep(.2)

music.stop()
sleep(.2)

music.volume(vol)
sleep(.2)
music.play(1)
sleep(2)

while True:
    if busypin.value() == 1:
        music.play('next')
        sleep(.2)
    if (butnext.value()==0):
        music.stop()
        sleep(.2)
        print ("next number")
        music.play('next')
        sleep(.2)
    if (butprev.value()==0):
        music.stop()
        sleep(.2)
        print ("previous number")
        music.play('prev')
        sleep(.2)
    if (butvolup.value()==0):
        vol = vol + 1
        print ("Volume : ",vol)
        music.volume(vol)
        sleep(.2)
    if (butvoldwn.value()==0):
        vol = vol - 1
        print ("Volume : ",vol)
        music.volume(vol)
        sleep(.2)

After all the explanation above I do not think this program needs any more explanation.

Not all commands are available. You can add buttons and alter the program to your whishes with the commands described above.

Just one thing:
At the beginning of the program the volume is set to 20. This is a moderate setting. It is set at such a volume that you will not damage your ears when using earphones or a headphone. You can always adjust the volume later with the volume buttons.

Till next time
Have fun

Luc Volders


Friday, July 3, 2026

Automatically mount USB sticks and drives on Raspberry Pi

For an index to all my stories click this text.

I am building several systems for self hosting all kinds of services. That is because I am fed up with a lot of cloud services that just suddenly stop or move away from being a free service and start charging fees. Read my rant about this here : https://lucstechblog.blogspot.com/2026/04/my-rant-against-some-cloud-services.html

The solution is to self-host services. And I am using multiple Raspberry Pi's for that.
And I must say that that feels really satisfying.

USB devices

I use usb memory sticks for storage of some of the files. There is a reason for that: It is easy and quick to remove the usb drive for updating the files on a different machine.

Now if you are running your Pi's with a Desktop mounting USB sticks and drives is painless. 
I am running these Raspberry Pi's headless. Mounting and unmounting USB sticks or drives is a tedious task and I forget it sometimes. When that happens my server obviously doesn't work.

So I was looking for an easy way to mount and unmount USB sticks/drives. And of course there is a great solution available.

pi-usb-automount

pi-usb-automount is simple to use.
Just plug the USB stick or drive in the USB port of your computer and it is automatically mounted as USB0. Add another stick or drive and that will automatically become USB1 etc. The maximum amount of usb devices you can use is 8 (USB0 - USB7).

Installing pi-usb-automount

Before using it we have to install it.

pi-usb-automount is hosted on Github and can be found (inclusive the documentation) here:
https://github.com/fasteddy516/pi-usb-automount

We can download the repositry when GIT is installed on the Raspberry PI. And that is unfortunately standard not the case. So we have to install that first:


sudo apt install git

It does not take long and takes only about 53 MB. So that is no threat for your storage capacity.

When GIT is installed we can download the repositry.


wget https://github.com/fasteddy516/pi-usb-automount/releases/latest/download/pi-usb-automount.deb

And then we can install it with:


sudo dpkg -i pi-usb-automount.deb

That is all.

The USB drives will be mounted on /media/usb0/  /media/usb1/  etc.

Success ????

Let's see if it works.

First let's see what happens if no USB drive is plugged in.


First we point to the USB0 directory with cd /media/USB0/
And then we list the content with LS

AS you can see there is nothing there.

Now plug in a USB stick or drive.


And there it is !!!!!
I used an empty USB stick with just one file on it with the name testfile.txt.

Reboot

Now what happens if we leave the USB stick in the Pi and reboot the system.


And there it already is !!!

This is really the easiest way to mount USB sticks and drives.

Till next time
have fun

Luc Volders

Friday, May 22, 2026

Installing ESPtool with Linux

For an index to all my stories click this text.

As you might know by now I am a fan of MicroPython. The language is mature,loads of libraries are available, and it is easy to use. Installing MicroPython on a Raspberry Pi Pico is a piece of cake and well-documented. However installing MicroPython on an ESP32 while your computer runs Linux is in a different ballpark.

You will need to download the right version of MicroPython for your ESP32 and to install it you need to use a tool called ESPtool.

I am going to show you how it is done.

Get MicroPython

First step is of course to download the language.


With your web-browser visit the MicroPython website at: micropython.org


At the top of the page click the download button which brings you to a webpage where you can choose your microcontroller from a list of vendors or by type.
The ESP32 is made by Espressif so click on that name in the vendor list.


On this page you can choose your model. My most frequent used model is the ESP32 Doit Devkit. This version has the ESP32-Wroom processor on it.



This is the board I am talking about.


This is the actual microcontroller and on the top you can clearly see the type ESP-WROOM-32

So click on this model.

This brings you to the download page.
Unless you need a previous version for a special reason, always choose the latest release.
At the time of this writing that's version V1.25.0
Clicking on this line starts the download which you can (after a very short time) find in your download folder on your harddisk.

When the file is downloaded I transfer it to a new folder on my computer.
For demonstration purposes I made an ESP32 folder in my home directory. You may of course use any folder you like as long as you adjust the path names in this tutorial.

 
So now I have a folder that contains a file with the name ESP32_GENERIC-20250415-v1.25.0.bin. Well that is not really workable. So I altered the name of the file in ESP32-V125.bin.
The path to this file is therefore : ~/ESP32/ESP32-V125.bin

Wrong installation instructions.

To install MicroPython on an ESP32 you need something that is called ESPtool. And you need to install that first on your computer.

Installation instructions I found for Linux were:

sudo apt install esptool

Well that did not work. Oh it installed allright but when I tried to use it sputtered that the file stub_flasher_32.json was missing. I did a lot of searching but to no avail.

Next option is to use pip

pip3 install esptool

Again to no avail. Another error message appeared. This one told me that esptool was not a non-Debian-packaged Python package. And it would not install. Now what ??

The right way.

To install esptool start we need a virtual environment.
Please send me an email if you have no clue on what a virtual environment is and what it is about.

First build your virtual environment.


Open the console and point to your newly created directory. Mine is home/luc/ESP32.
As my new folder is in my home folder I only have to do : cd ESP32

Now in this folder we are going to create a virtual environment. And we are going to give it the name esptoolenv.


The command we use is: python3 -m venv esptoolenv

Make sure to type python3 because the older versions of Python (Python 2) is not installed on recent versions of Linux.


If you open your file explorer you can see that in your ESP32 folder a new folder is created with the name esptoolenv.


The virtual environment is there. Now we need to activate it with :
source esptoolenv/bin/activate


Now we can install esptool with: pip install esptool
This takes just a few seconds.


If you want to deactivate the virtual environment just use: deactivate.
But do not do that now as we need the virtual environment to run esptool.

Install MicroPython.

Now we can install MicroPython.

Before we can install MicroPython we need to know to which USB port the ESP32 is connected. Start with the ESP32 unplugged.


With the ESP32 not plugged in type :
ls /dev/ttyUSB* /dev/ttyACM* 2>/dev/null

As you can see nothing happens. That is because I have no devices attached to my USB ports. Now plug in the ESP32.


And there it is. The ESP32 is plugged in on ttyUSB0

Now we have everything in place.


Let's start with an empty flash.
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash
This command erases the ESP's flash memory totally.


And now we can flash MicroPython with the command:
esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 ~/ESP32/ESP32-V125.bin

A quick look at the details:

esptool.py              calls the program
--chip esp32            tells which chip we are flashing
--port /dev/ttyUSB0     the usb port we are using
--baud 460800           The speed we are writing with
write_flash -z 0x1000   the starting memory location
~/ESP32/ESP32-V125.bin  the file we are flashing

Looks quite complicated, but don't worry you will soon get the hang of it.


And there we are.
MicroPython up and running in Thonny.

Till next time
have fun


Luc Volders