Skip to content

Connecting an ESP8266

Follow the instructions below to connect your device to the Cloud4RPi control panel.


Your ESP8266 module should have at least 1Mbyte of flash storage to install the full version of MicroPython.

  1. Flash the latest version of MicroPython using the official manual.
  2. Connect to your Wi-Fi network:

    >>> from network import WLAN
    >>> STA = WLAN(0);
    >>> STA.connect('__SSID__', '__PASSWORD__')
    >>> STA.ifconfig()  # Outputs the network configuration. If it is not valid, wait and re-execute
  3. Configure WebREPL for easier file uploading.

    >>> import webrepl_setup
  4. Connect to the ESP8266 via WebREPL.

Getting Libraries and Examples

Download the required source code files to your computer:

  • MQTT Library for MicroPython. Save this file as when downloading.
  • Cloud4RPi client library for MicroPython.
  • Sample code.

Hacking Together some Code

Open the file in a text editor (for instance, Visual Studio Code) and replace the following strings:

  • __SSID__ with your Wi-Fi network name.
  • __PWD__ with your Wi-Fi network password. If you have an open network, remove the '__PWD__' element without removing the trailing comma so that the WIFI_SSID_PASSWORD variable becomes a tuple with one element.
  • __YOUR_DEVICE_TOKEN__ with the token displayed at the top of the device page on If you have no token yet, open the Devices page, create a device using the New Device button in the top right corner, and use its token.

Save the file.

The LED & Button Example's Hardware

Connect the LED to GPIO12 and a button to GPIO16. If you need to use other pins, change the corresponding variables in


  1. Upload three files (, and to your ESP8266 via the WebREPL.
  2. Reset the ESP8266. You can use the console for this:

    >>> import machine
    >>> machine.reset()
  3. Check that the device goes online and starts sending data.

  4. Go to the Control Panels page and add a new control panel.
  5. Add a new Switch widget and bind it to the LED variable.
  6. Add a new Text widget and bind it to the Button variable. Configure different colors for the "true" and "false" strings.
  7. Press the hardware button and notice the changes on the control panel.
  8. Use the LED switch on the control panel to light the hardware LED.

Explore the code of the file and adapt it for your needs. Feel free to share your projects and ideas with us!