Micro Controller unter macOS - Teil 3

Setting up the Arduino IDE and integrating the ESPs and setting up Thonny under macOS

An Apple a day keeps Windows away:-)

Configure Part 3-Thonny

1. A brief preliminary remark

    The programming language Python has become very popular recently, since it is the language used to program the Raspberry Pi. Python is an interpreted language whose programs are translated and executed at runtime by a program adapted to the hardware, the interpreter, line by line. Unlike C++, where the source code is completely translated and then the machine code is executed. For the ESP8266 and ESP32, a special version of Python, MicroPython, was created, a special version that was specially adapted to these microcontrollers. Those who are interested in the background of Python will find here: https://de.wikipedia.org/wiki/Python_(Programmiersprache). If you want to take the first steps in MicroPython, please refer to the blog series with six parts of Jurgen Grzesina.

    The Institute of Computer Science of the University of Tartu in Estonia provides a free IDE for the Python language. We want to install and start this IDE as follows.

    2. Installation of Thonny

      We go to the site: http://www.google.com/sea....tin-round+rock+texas



      and load the macOS version. The good piece ends up in the download folder, where the installation starts with a double click.


      We give the installer the necessary access rights and after a short time Thonny is installed. Of course we have to start Thonny immediately, asking for the language settings:


      We set "German", click "Let's go! "and Thonny shows herself in full beauty.



      The entry "Python 3.7.9 (bundled)" indicates that we are working with the built-in Python. This is exactly what we want to start with.

      Three. The first program with Python

        As usual, we will be the first program to create the "Hello World" program. To do this, we write in the upper part of the window the line: print ("Hello Python World")
        with a final .


        Of course we want to see if the program works, so we click on the triangle in the green circle. The program is not yet secured, we are asked for location and name (file extension is ".py") and after saving we see in the "Commandline" field that the program was executed.



        Four. The first MicroPython program with an ESP32

          To program a board with MicroPython, the interpreter first has to be flashed onto the board.

          We go to the website of MicroPython: https://micropython.org



          And there on "Downloads".



          Slide down to the Generic ESP32 module and click on the image.


          Now we choose the file "esp32-idf4-20210202-v1.14.bin" as download.

          After the board "ESP32 D1 R32 development board with CH340G and WiFi + Bluetooth (Arduino compatible Internet Development Board) from AZ-Delivery or another ESP32 board has started on our Mac or PC;-) we restart Thonny.

          We need these steps to flash the MicroPython onto the board:

          (a) Start Thonny
          (b) Call of'Preferences', where the rider'Interpreter'

            c) Here we click "Install or update the firmware".

            (d) In the following dialogue we set up:



              • The port to which the board is connected
              • With the "Browse..." button we search for the previously loaded file.
              • Erase flash before installing
              • Micropythone is written on the board with "Install".
              (e) After the end of the flash process, we can start:
              Call of the "Preferences", where the rider "Interpreter":

                f) Set the interpreter "MicroPython (ESP32)" and the port connected to the board, then close the window with "OK".

                The built-in LED of the board is to be flashed again.

                To do this, we need the following program code:

                from time import sleep
                from machine import Pin
                led = Pin(2, Pin.OUT)
                while True:

                This code must now be brought to the board with Thonny's help. The Thonny window is still empty at first. Clicking on the sheet icon (or menu »File ' New (z-N)) creates a new file "".



                Here we enter the program code:


                The source code must now be written to the board. To do this, we click on the blue floppy icon at the top, third character from the left (or menu »File -> Save as...).

                We are asked where we want to save the file, of course on the board!



                After clicking on the button "MicroPython device" we are asked for the name of the file to be saved:


                Now comes the big moment: the program is to be run:


                To do this, we click on the white triangle in the green circle. If everything has been done correctly, the LED on the board should now flash.




                5. Additional notes

                  • The pin to which the internal LED is connected depends on the board. For my HELTEC board, this is e.B. number 25.
                  • The program is stopped by clicking on the red STOP button.
                  • Thonny swallows more often. Then the STOP click often helps. If then at the bottom of the window »Command line » the message » MicroPython v1.14 on 2021-02-02; ESP32 module with ESP32
                    Type "help()" for more information.", the board is ready for use again.
                  • I once had the case that the "Blink" program could no longer be stopped, even after plugging in and plugging in, the program continued and the board was no longer responsive. It only helped to send the manual into flash mode:
                    Using a cable, connect pin 00 to the GND pin, then press the reset button and remove the cable. Now with Thonny flash the board again as described above.
                  • If you want to see which files are on the ESP32, click on the "Open" icon (second from top left). In the dialog that opens, you can also delete files: right-click on an entry and select the desired option.


                  Download pdf

                  Esp-32Esp-8266For arduinoBasics softwareProjects for beginners

                  1 comment

                  Rainer T

                  Rainer T

                  Sehr schöne Zusammenfassung!
                  V.a. die Möglichkeit, Files direkt aufs device zu schreiben und sie anzuzeigen, ist ein Feature, das gerne ausgelassen wird.

                  Leave a comment

                  All comments are moderated before being published

                  Recommended blog posts

                  1. Install ESP32 now from the board manager
                  2. Lüftersteuerung Raspberry Pi
                  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
                  4. ESP32 - das Multitalent
                  5. OTA - Over the Air - ESP programming via WLAN