Skip to content

Connecting an ESP8266

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

Prerequisites

  • USB-UART Adapter (if it is not integrated into your board).
  • Access to the ESP8266's GPIO0 pin to enter flashing mode.

Creating a Project

The Cloud4RPi library is published in the PlatformIO Registry. Follow the instructions below to start a new Cloud4RPi-enabled project:

  1. Create a new PlatformIO project for your board as described in the PlatformIO documentation (Visual Studio Code, Atom)
  2. Open your platformio.ini and add the following lines to the end:

    lib_deps =
        cloud4rpi-esp-arduino
    
    build_flags=
    ; Required for PubSub library
        -D MQTT_MAX_PACKET_SIZE=1024
        -D MQTT_MAX_TRANSFER_SIZE=128
    ; Enables the verbose output to Serial
        -D CLOUD4RPI_DEBUG=1
    
  3. Save the platformio.ini file and open the src\main.cpp file.

  4. Copy-paste the sample code into it.
  5. If you know the pin number connected to an LED on your board, replace the BUILTIN_LED constant with it.

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.
  4. Replace the __SSID__ and __PASSWORD__ strings with your Wi-Fi network data.

Running

  1. Hit the Build button and wait until the compilation is completed.
  2. Connect the board in the flashing mode (power it with the GPIO0 pin connected to GND) and hit the Upload button.
  3. Once flashing is complete, open Serial Monitor and watch the sample code's output.
  4. Notice that the device went online and started sending data.
  5. Go to the Control Panels page and add a new control panel.
  6. Add a new Chart widget and bind it to the Uptime variable.
  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 STATUS variable. Configure different colors for the "IDLE", "RING" and "BOOM!" strings.

Video