ESP32 MicroPython

La puce ESP32 est le successeur de la puce ESP8266. Le Wi-Fi est plus rapide, il y a plus de GPIOs, la puce supporte le Bluetooth 4.2 et le Bluetooth low energy. La puce possède aussi deux cœurs.

ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-Copy-768x554

Attention, PIN  de la version ESP32 S

Capture

Utilisation avec l’IDE ARDUINO :

Références :

Alexa FauxMoESP : https://randomnerdtutorials.com/alexa-echo-with-esp32-and-esp8266/

Accès au WEB : https://techtutorialsx.com/2017/05/19/esp32-http-get-requests/

Lora : https://makeradvisor.com/esp32-sx1276-lora-ssd1306-oled/

et https://randomnerdtutorials.com/ttgo-lora32-sx1276-arduino-ide/

https://randomnerdtutorials.com/esp32-ds18b20-temperature-arduino-ide/

https://randomnerdtutorials.com/esp32-multiple-ds18b20-temperature-sensors/

https://randomnerdtutorials.com/micropython-ds18b20-esp32-esp8266/

https://makeradvisor.com/esp32-vs-esp8266/

https://randomnerdtutorials.com/esp32-dual-core-arduino-ide/

https://randomnerdtutorials.com/esp32-pwm-arduino-ide/

https://randomnerdtutorials.com/micropython-gpios-esp32-esp8266/

https://randomnerdtutorials.com/esp32-web-server-spiffs-spi-flash-file-system/

https://randomnerdtutorials.com/esp32-flash-memory/

MicroPython

Currently we only support esptool.py to copy across the firmware. You can find this tool here: https://github.com/espressif/esptool/, or install it using pip:

pip install esptool

Versions starting with 1.3 support both Python 2.7 and Python 3.4 (or newer). An older version (at least 1.2.1 is needed) works fine but will require Python 2.7.

Using esptool.py you can erase the flash with the command:

esptool.py --port /dev/ttyUSB0 erase_flash

And then deploy the new firmware (à télécharger ici) using:

esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20180511-v1.9.4.bin

Notes:

  • You might need to change the “port” setting to something else relevant for your PC
  • You may need to reduce the baudrate if you get errors when flashing (eg down to 115200 by adding --baud 115200 into the command)
  • For some boards with a particular FlashROM configuration you may need to change the flash mode (eg by adding -fm dio into the command)
  • The filename of the firmware should match the file that you have

If the above commands run without error then MicroPython should be installed on your board!

Références :

https://docs.micropython.org/en/latest/esp32/tutorial/intro.html

et https://docs.micropython.org/en/latest/esp8266/tutorial/index.html#esp8266-tutorial

Pour travailler avec Python :

Soit via le terminal :

sudo apt install picocom

puis pour lancer le terminal : picocom /dev/ttyUSB0 -b115200

et tapez les commandes python :

>>> print('hello esp8266!')
hello esp8266!

Pour allumer et éteindre la led :

>>> import machine
>>> pin = machine.Pin(2, machine.Pin.OUT)
>>> pin.on()
>>> pin.off()

IDE (Thonny)

Installing Thonny IDE – Linux : sudo pip3 install thonny

Lancement : thonny

Paramétrage :

Connect the board to your computer using a USB cable. To test the installation, you need to tell Thonny that you want to run MicroPython Interpreter and select the board you are using.

1. Go to Tools > Options and select the Interpreter tab. Make sure you’ve selected the right interpreter for your board as well as the COM port.

You can also select the “Try to detect automatically” option, but only if you just have one board connected to your computer at a time. Otherwise, select the specific port for the board you’re using.

Exemple de programme :

from machine import Pin
from time import sleep

led = Pin(2, Pin.OUT)

while True:
  led.value(not led.value())
  sleep(0.5)

Exécution :

Le programme doit être nommé main.py et sauvegardé sur l’ESP32 pour qu’il s’éxécute au démarrage du device.

Donc, vous pouvez le tester et le sauvegarder sur votre PC avec n’importe quel nom mais il devra s’appeler main.py pour s’exécuter automatiquement.

Références :

https://docs.micropython.org/en/latest/esp8266/tutorial/repl.html

Projets en MicroPython :

MAJ à distance du code : https://randomnerdtutorials.com/esp32-esp8266-micropython-ota-updates/

Autres projets : https://randomnerdtutorials.com/projects-esp32-esp8266-micropython/

Articles récents
Commentaires récents
fatima dans Bienvenue !
AdminDroid dans Bienvenue !
fatima dans Bienvenue !
Archives
Catégories
%d blogueurs aiment cette page :