For Windows:
1. Install Python, Esptool and AmpyIf you have no Python 3 installation on your computer please download the installer from https://www.python.org/downloads/ and execute it. Then install Esptool and Ampy with
> pip3 install esptool
> pip3 install adafruit-ampy
on the command line.
2. Download and Install FirmwareDownload https://micropython.org/resources/firmware/esp8266-20220618-v1.19.1.bin. Connect your ESP8266 device to your computer via USB. Open the Windows Device Manager and look into "COM & LPT" to find the correct COM port, e.g. COM6. Then install the firmware with
> esptool.py --port COM6 erase_flash
> esptool.py --port COM6 --baud 460800 write_flash --flash_size=detect 0 esp8266-20220618-v1.19.1.bin
Disconnect and reconnect your device after the installation is finished.
3. Download and Install LibrariesCreate a folder named lib
on your computer. Download the files cooperative_multitasking.mpy
, kolony.mpy
, mqtt.mpy
, mqtt_client.mpy
and scroller.mpy
from https://bitbucket.org/amotzek/micro-python/downloads/ into that lib
folder. In the command line navigate to the folder above lib
and then execute
> ampy.exe --port COM6 put lib
to upload the folder to your device.
4. Edit and Upload main.pyFrom the Code section of this project copy the file main.py
to your computer and fill in your WLAN credentials in line 32, a user name in line 30 and a MQTT topic name in line 33. Execute
> ampy.exe --port COM6 put main.py
to upload the file to your device.
5. TestIn your browser go to http://www.hivemq.com/demos/websocket-client/. Click the Connect button. Enter the topic name from line 32 into the Topic field. Enter
{ ":message": "Hello!" }
into the Message field. Click the Publish button. Your device should display Hello!
now.
Comments