Skip to content

Connecting an ESP8266 or ESP32

Follow the instructions below to connect your ESP8266 board (like NodeMCU Dev Kit) or ESP32 board (like ESP32-DevKitC) to the Cloud4RPi control panel.

Getting Libraries and Examples

  1. Open Arduino and select your board in the Tools | Board menu. Add ESP8266 or ESP32 support if it is not added yet.
  2. Install the Cloud4RPi library from the Library Manager. To do this, open the Sketch | Include Library | Manage Libraries menu, enter cloud4rpi into the search field and install the cloud4rpi-esp-arduino package.
  3. Install the dependencies: ArduinoJson and PubSubClient libraries.
  4. Configure the installed libraries:

    1. Open the %HOMEPATH%\Documents\Arduino\libraries\PubSubClient\src\PubSubClient.h (~/Documents/Arduino/libraries/PubSubClient/src/PubSubClient.h on Mac) file with any text editor (for instance, VS Code).
    2. Add the following define directives at the beginning:

      #define MQTT_MAX_PACKET_SIZE 1024
      #define MQTT_MAX_TRANSFER_SIZE 128
    3. [Optional] Open the %HOMEPATH%\Documents\Arduino\libraries\cloud4rpi-esp-arduino\src\Cloud4RPi.h (~/Documents/Arduino/libraries/cloud4rpi-esp-arduino/src/Cloud4RPi.h on Mac) file and add the #define CLOUD4RPI_DEBUG 1 line at the beginning to enable verbose output.

Opening Sample Code

  1. Use the File | Examples | cloud4rpi-esp-arduino menu item to open the sample code. Restart Arduino IDE if this item does not appear.
  2. Select the ESP32 Dev Module board in Tools menu.
  3. If the LED_BUILTIN constant is not defined in your board's library, change this constant to the LED's pin number (for example, 2).
  4. Replace the __SSID__ and __PASSWORD__ strings with your Wi-Fi network data.

Connecting to Your Cloud4RPi Account

  1. Log in to your Cloud4RPi account or create a new one.
  2. Copy your device's Device Token. You can create a device on the Devices page and copy its Device Token if you do not have one.
  3. Replace the __YOUR_DEVICE_TOKEN__ string with your device token.


  1. Hit the Build button and wait until the compilation is completed.
  2. Hit the Upload button.
  3. If the upload fails, try to start the board in the flashing mode (connect the power supply with the GPIO0 pin connected to GND) and try uploading again.
  4. Once flashing is complete, open Serial Monitor to monitor the device's status.
  5. Notice that the device on the Devices page went online and started sending data.
  6. Go to the Control Panels page and add a new control panel.
  7. Add a new Switch widget and bind it to the LED On variable.
  8. Add a new Text widget and bind it to the State variable. Configure different colors for the "IDLE", "RING" and "BOOM!" strings.
  9. Add a new Slider widget and bind it to the DesiredTemp variable, set its minimum value to 10 and maximum value to 30.
  10. Add a new Gauge widget and bind it to the DesiredTemp variable, set its minimum value to 10 and maximum value to 30.