Cloud4RRi client library for Arduino framework
Clone or download
Latest commit 0e2fb49 Mar 30, 2018

README.md

Cloud4RPi Client Library for Arduino Framework

Build Status

The package provides a client library that simplifies connecting Internet-enabled Arduino devices to the Cloud4RPi service.

Currently supported hardware:

Supported ecosystems:

The further instructions depend on your preferred ecosystem.

PlatformIO

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. Log in to your Cloud4RPi account or create a new one.
  6. 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.
  7. Replace the __YOUR_DEVICE_TOKEN__ string with your device token.
  8. Replace the __SSID__ and __PASSWORD__ strings with your Wi-Fi network data.
  9. If you know the pin number connected to an LED on your board, replace the BUILTIN_LED constant with it.
  10. Hit the Build button and wait until the compilation is done.
  11. Connect the board in the flashing mode and hit the Upload button.
  12. Once flashing is complete, open Serial Monitor and watch the sample code's output.
  13. Notice that the device went online and started sending data.
  14. Go to the Control Panels page and add a new control panel.
  15. Add a new Chart widget and bind it to the Uptime variable.
  16. Add a new Switch widget and bind it to the LED On variable.
  17. Add a new Text widget and bind it to the STATUS variable. Configure different colors for the "IDLE", "RING" and "BOOM!" strings.

Arduino

  1. Create a new Arduino sketch and select your board in the Tools | Board menu. Add ESP8266 support if required.
  2. Install the Cloud4RPi library from the Library Manager: open the Sketch | Include Library | Manage Libraries menu, enter cloud4rpi into the search field and install the cloud4rpi-esp-arduino package.
  3. Install ArduinoJson and PubSubClient libraries. You should do it manually because the Library Manager does not manage package dependencies.
  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 statements at the beginning:
      #define MQTT_MAX_PACKET_SIZE 1024
      #define MQTT_MAX_TRANSFER_SIZE 128
    3. 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 enable verbose output by adding the #define CLOUD4RPI_DEBUG 1 line at the beginning.
  5. Open the sample code using the File | Examples | cloud4rpi-esp-arduino | ESP8266 menu item. Restart Arduino IDE if this item did not appear.
  6. Log in to your Cloud4RPi account or create a new one.
  7. 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.
  8. Replace the __YOUR_DEVICE_TOKEN__ string with your device token.
  9. Replace the __SSID__ and __PASSWORD__ strings with your Wi-Fi network data.
  10. If you know the pin number connected to an LED on your board, replace the BUILTIN_LED constant with it.
  11. Hit the Verify button and wait until the compilation is done.
  12. Connect the board in the flashing mode and hit the Upload button.
  13. Once flashing is complete, open Serial Monitor and watch the sample code's output.
  14. Notice that the device went online and started sending data.
  15. Go to the Control Panels page and add a new control panel.
  16. Add a new Chart widget and bind it to the Uptime variable.
  17. Add a new Switch widget and bind it to the LED On variable.
  18. Add a new Text widget and bind it to the STATUS variable. Configure different colors for the "IDLE", "RING" and "BOOM!" strings.

See Also