### Docker Compose Up Output Example Source: https://github.com/thinger-io/docs/blob/main/server/deployment/on-premise.md This is an example of the output you might see when starting the Thinger.io services. It indicates the progress of pulling images and creating networks and containers. ```bash root@docker-s-1vcpu-1gb-fra1-01:~# docker-compose up -d Creating network "root_default" with the default driver Pulling thinger (thinger/server:latest)... latest: Pulling from thinger/server da6fc00e4d0b: Pull complete c3c0be9d84b3: Pull complete 9c1dda927878: Pull complete 4b8880231fa0: Pull complete ec7cf4588dfa: Pull complete f03c87626902: Pull complete 2c927b4e662e: Pull complete 0c0ed4ba2578: Pull complete db577de2586f: Pull complete Digest: sha256:156bb95f155ce9d3706c6a2f17d2a6750cf62e91777a610625910c7ebf780894 Status: Downloaded newer image for thinger/server:latest Pulling mongodb (mongo:8)... 8: Pulling from library/mongo 2746a4a261c9: Pull complete 4c1d20cdee96: Pull complete 0d3160e1d0de: Pull complete c8e37668deea: Pull complete fc3987a82b4c: Pull complete c75f139e0836: Pull complete 4acc9c8680b4: Pull complete fb02df30d947: Pull complete ae725ef3d2ce: Pull complete e30f54ed6b43: Pull complete bca9e535ddb8: Pull complete 9c3edad81b2a: Pull complete 6dbcf78fe5ae: Pull complete Digest: sha256:7a1406bfc05547b33a3b7b112eda6346f42ea93ee06b74d30c4c47dfeca0d5f2 Status: Downloaded newer image for mongo:8 Pulling ouroboros (pyouroboros/ouroboros:)... latest: Pulling from pyouroboros/ouroboros ``` -------------------------------- ### Arduino Portenta/Opta OTA Setup Source: https://github.com/thinger-io/docs/blob/main/ota.md Integrate OTA functionality for Arduino Portenta and Opta devices by including ThingerPortentaOTA.h and instantiating it. This example includes WiFi setup and basic resource handling. ```cpp #define THINGER_SERIAL_DEBUG #include #include #include "arduino_secrets.h" ThingerMbed thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerPortentaOTA ota(thing); void setup() { // configure LED_BUILTIN for output pinMode(LED_BUILTIN, OUTPUT); // open serial for debugging Serial.begin(115200); // configure wifi network thing.add_wifi(SSID, SSID_PASSWORD); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // start thinger on its own task thing.start(); // more details at http://docs.thinger.io/arduino/ } void loop() { // use loop as in normal Arduino Sketch // use thing.lock() thing.unlock() when using/modifying variables exposed on thinger resources delay(1000); } ``` ```cpp #define USERNAME "your_user_name" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define SSID "your_wifi_ssid" #define SSID_PASSWORD "your_wifi_ssid_password" ``` -------------------------------- ### Input/Output Resource Example Source: https://github.com/thinger-io/docs/blob/main/features/devices-administration.md This example demonstrates a resource that handles both input and output, allowing for complex interactions where data can be sent to the device and results can be received. ```APIDOC ## Input/Output Resource Example ### Description This example demonstrates a resource that handles both input and output, allowing for complex interactions where data can be sent to the device and results can be received. This specific resource calculates the sum and multiplication of two integer numbers provided as input. ### Method POST ### Endpoint `/v1/users/{username}/devices/{device_id}/resources/in_out` ### Parameters #### Path Parameters - **username** (string) - Required - The username of the device owner. - **device_id** (string) - Required - The unique identifier of the device. #### Request Body - **value1** (integer) - Required - The first integer value. - **value2** (integer) - Required - The second integer value. ### Request Example ```json { "value1": 10, "value2": 5 } ``` ### Response #### Success Response (200) - **sum** (integer) - The sum of value1 and value2. - **mult** (integer) - The multiplication of value1 and value2. #### Response Example ```json { "sum": 15, "mult": 50 } ``` ``` -------------------------------- ### ESP32 WiFi WebConfig Setup Source: https://github.com/thinger-io/docs/blob/main/arduino/espressif-esp32.md This sketch sets up the ESP32 with Thinger.io using WiFiManager for web-based configuration. It includes examples for controlling a digital pin and outputting a value. Ensure the WiFiManager library is installed. ```cpp #define THINGER_SERIAL_DEBUG // Requires WifiManager from Library Manager or https://github.com/tzapu/WiFiManager #include ThingerESP32WebConfig thing; void setup() { // open serial for debugging Serial.begin(115200); pinMode(27, OUTPUT); // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) thing["relay"] << digitalPin(27); // resource output example (i.e. reading a sensor value) thing["millis"] >> outputValue(millis()); } void loop() { thing.handle(); } ``` -------------------------------- ### ESP8266 OTA Setup Source: https://github.com/thinger-io/docs/blob/main/ota.md Include ThingerESP8266OTA.h and create an instance for OTA functionality on ESP8266. This example demonstrates basic setup with WiFi credentials and digital pin control. ```cpp #define THINGER_SERIAL_DEBUG #include #include #include "arduino_secrets.h" ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerESP8266OTA ota(thing); void setup() { // open serial for monitoring Serial.begin(115200); // set builtin led as output pinMode(LED_BUILTIN, OUTPUT); // add WiFi credentials thing.add_wifi(SSID, SSID_PASSWORD); // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value) thing["millis"] >> outputValue(millis()); // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` ```cpp #define USERNAME "your_user_name" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define SSID "your_wifi_ssid" #define SSID_PASSWORD "your_wifi_ssid_password" ``` -------------------------------- ### Install Thinger Monitor with Auto Provisioning Source: https://github.com/thinger-io/docs/blob/main/others/other-software/server-monitoring-client.md Execute this command to install the Thinger.io Monitoring Client and auto-provision the device using a provided token. Root privileges are required for update and reboot functionalities. ```bash ./install_thinger_monitor.sh -t '' ``` -------------------------------- ### Arduino Opta Wifi Setup with Thinger.io Source: https://github.com/thinger-io/docs/blob/main/arduino/arduino-wifi.md This sketch configures the Arduino Opta for WiFi connectivity using Thinger.io. It sets up digital pins for relay control and LEDs, exposes them as resources, and includes an example for reading the system's millisecond counter. Ensure your WiFi credentials and Thinger.io account details are correctly entered in 'arduino_secrets.h'. ```cpp #define THINGER_SERIAL_DEBUG #include #include #include "arduino_secrets.h" ThingerMbed thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerPortentaOTA ota(thing); void setup() { // open serial for debugging Serial.begin(115200); // configure leds for output pinMode(LED_D0, OUTPUT); pinMode(LED_D1, OUTPUT); pinMode(LED_D2, OUTPUT); pinMode(LED_D3, OUTPUT); pinMode(LEDR, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); // configure relays for output pinMode(D0, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); // example for controlling relays and status LED thing["relay_d0"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D0); }else{ digitalWrite(D0, in ? HIGH : LOW); digitalWrite(LED_D0, in ? HIGH : LOW); } }; thing["relay_d1"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D1); }else{ digitalWrite(D1, in ? HIGH : LOW); digitalWrite(LED_D1, in ? HIGH : LOW); } }; thing["relay_d2"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D2); }else{ digitalWrite(D2, in ? HIGH : LOW); digitalWrite(LED_D2, in ? HIGH : LOW); } }; thing["relay_d3"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D3); }else{ digitalWrite(D3, in ? HIGH : LOW); digitalWrite(LED_D3, in ? HIGH : LOW); } }; // example for controlling the LED thing["led"] << digitalPin(LED_BUILTIN); thing["led_r"] << digitalPin(LEDR); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // start thinger on its own task thing.start(); // more details at http://docs.thinger.io/arduino/ } void loop() { // use loop as in normal Arduino Sketch // use thing.lock() thing.unlock() when using/modifying variables exposed on thinger resources delay(1000); } ``` -------------------------------- ### Arduino RPI2040 Connect OTA Setup Source: https://github.com/thinger-io/docs/blob/main/ota.md Include ThingerMbedOTA.h and create an instance for OTA functionality. ```cpp #define THINGER_SERIAL_DEBUG #include #include #include "arduino_secrets.h" ThingerMbed thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerMbedOTA ota(thing); void setup() { // open serial for debugging Serial.begin(115200); // configure LED_BUILTIN for output pinMode(LED_BUILTIN, OUTPUT); // configure wifi network thing.add_wifi(SSID, SSID_PASSWORD); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // start thinger task thing.start(); // more details at http://docs.thinger.io/arduino/ } void loop() { // your code here } ``` ```cpp #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define SSID "your_wifi_ssid" #define SSID_PASSWORD "your_wifi_ssid_password" ``` -------------------------------- ### Arduino Nano 33 IOT OTA Setup Source: https://github.com/thinger-io/docs/blob/main/ota.md Enable OTA updates on Arduino Nano 33 IOT by including ThingerWiFiNINAOTA.h and creating an instance. This example covers WiFi configuration and basic resource handling. ```cpp #define THINGER_SERIAL_DEBUG #include #include #include "arduino_secrets.h" ThingerWiFiNINA thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerWiFiNINAOTA ota(thing); void setup() { // configure LED_BUILTIN for output pinMode(LED_BUILTIN, OUTPUT); // open serial for debugging Serial.begin(115200); // configure wifi network thing.add_wifi(SSID, SSID_PASSWORD); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` ```cpp #define USERNAME "your_user_name" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define SSID "your_wifi_ssid" #define SSID_PASSWORD "your_wifi_ssid_password" ``` -------------------------------- ### Input/Output Resource Example Source: https://github.com/thinger-io/docs/blob/main/console/devices-administration.md Demonstrates how to define and interact with an input/output resource that performs calculations based on provided input values. ```APIDOC ## Input/Output Resource Example ### Description This example shows a device resource that accepts two integer values, performs addition and multiplication, and returns the results. This demonstrates the flexibility of handling both input and output in a single resource. ### Method POST ### Endpoint `/v1/users/{username}/devices/{device_id}/resources/in_out` ### Parameters #### Path Parameters - **username** (string) - Required - The username of the account. - **device_id** (string) - Required - The unique identifier of the device. #### Request Body - **value1** (integer) - Required - The first integer value. - **value2** (integer) - Required - The second integer value. ### Request Example ```bash curl -X POST \ 'https://api.thinger.io/v1/users/your_username/devices/your_device_id/resources/in_out' \ -H 'Authorization: Bearer YOUR_API_TOKEN' \ -H 'Content-Type: application/json' \ -d '{\"value1\": 10, \"value2\": 5}' ``` ### Response #### Success Response (200) - **sum** (integer) - The sum of value1 and value2. - **mult** (integer) - The multiplication of value1 and value2. #### Response Example ```json { "sum": 15, "mult": 50 } ``` ``` -------------------------------- ### ESP8266 Device Connection Example Source: https://github.com/thinger-io/docs/blob/main/console/devices-administration.md This example demonstrates how to configure an ESP8266 device, such as a NodeMCU, to connect to the Thinger.io platform. Ensure you replace the placeholder values with your actual Thinger.io account username, device ID, and device credentials. ```c++ #define THINGER_USERNAME "your_username" #define THINGER_DEVICE_ID "your_device_id" #define THINGER_DEVICE_CREDENTIALS "your_device_credentials" #include ThingerESP8266 thing( கட்டமை "your_username", "your_device_id", "your_device_credentials"); // add here your custom functions void setup() { Serial.begin(115200); // connect to wifi thing.add_wifi("your_ssid", "your_password"); // connect to thinger.io server thing.start(); } ``` -------------------------------- ### Install Linux Client Dependencies Source: https://github.com/thinger-io/docs/blob/main/linux.md Installs necessary packages for compiling the Thinger.io IoTMP client, including C++ compiler, CMake, OpenSSL, and Boost libraries. ```bash sudo apt install gcc g++ cmake libssl-dev libboost-system-dev libboost-filesystem-dev libboost-thread-dev libboost-program-options-dev libboost-regex-dev ``` -------------------------------- ### Arduino MKR WiFi 1010 OTA Setup Source: https://github.com/thinger-io/docs/blob/main/ota.md Include ThingerWiFiNINAOTA.h and create an instance for OTA functionality. Ensure lib_archive = no in platformio.ini. ```cpp #include #include #include "arduino_secrets.h" ThingerWiFiNINA thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerWiFiNINAOTA ota(thing); void setup() { // configure LED_BUILTIN for output pinMode(LED_BUILTIN, OUTPUT); // open serial for debugging Serial.begin(115200); // configure wifi network thing.add_wifi(SSID, SSID_PASSWORD); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` ```cpp #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define SSID "your_wifi_ssid" #define SSID_PASSWORD "your_wifi_ssid_password" ``` -------------------------------- ### Device Firmware Update Flow Example Source: https://github.com/thinger-io/docs/blob/main/business-features/file-system.md An example demonstrating a typical IoT device firmware update process using the file system API. ```APIDOC ## Device Integration Example A typical IoT device firmware update flow: 1. **Check for new firmware version** ```bash LATEST=$(curl -s "https://iot.thinger.io/v2/users/USERNAME/storages/firmware/files/latest.txt") ``` 2. **Download firmware if newer** ```bash curl -o /tmp/firmware.bin \ "https://iot.thinger.io/v2/users/USERNAME/storages/firmware/files/releases/${LATEST}/firmware.bin" ``` 3. **Verify and apply update** ```bash # ... device-specific update logic ``` ``` -------------------------------- ### Arduino Opta Ethernet Setup with Thinger.io Source: https://github.com/thinger-io/docs/blob/main/arduino/arduino-ethernet.md This sketch configures the Arduino Opta for Ethernet connectivity using Thinger.io. It sets up digital pins for relay control and LEDs, and exposes resources for monitoring and control. Ensure you have the ThingerMbedEth and ThingerPortentaOTA libraries installed. ```cpp #define THINGER_SERIAL_DEBUG #define THINGER_SERVER "acme.aws.thinger.io" #include #include #include "arduino_secrets.h" ThingerMbedEth thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); ThingerPortentaOTA ota(thing); void setup() { // open serial for debugging Serial.begin(115200); // configure leds for output pinMode(LED_D0, OUTPUT); pinMode(LED_D1, OUTPUT); pinMode(LED_D2, OUTPUT); pinMode(LED_D3, OUTPUT); pinMode(LEDR, OUTPUT); pinMode(LED_BUILTIN, OUTPUT); // configure relays for output pinMode(D0, OUTPUT); pinMode(D1, OUTPUT); pinMode(D2, OUTPUT); pinMode(D3, OUTPUT); // example for controlling relays and status LED thing["relay_d0"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D0); }else{ digitalWrite(D0, in ? HIGH : LOW); digitalWrite(LED_D0, in ? HIGH : LOW); } }; thing["relay_d1"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D1); }else{ digitalWrite(D1, in ? HIGH : LOW); digitalWrite(LED_D1, in ? HIGH : LOW); } }; thing["relay_d2"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D2); }else{ digitalWrite(D2, in ? HIGH : LOW); digitalWrite(LED_D2, in ? HIGH : LOW); } }; thing["relay_d3"] << [](pson& in){ if(in.is_empty()){ in = (bool) digitalRead(D3); }else{ digitalWrite(D3, in ? HIGH : LOW); digitalWrite(LED_D3, in ? HIGH : LOW); } }; // example for controlling the LED thing["led"] << digitalPin(LED_BUILTIN); thing["led_r"] << digitalPin(LEDR); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // start thinger on its own task thing.start(); // more details at http://docs.thinger.io/arduino/ } void loop() { // use loop as in normal Arduino Sketch // use thing.lock() thing.unlock() when using/modifying variables exposed on thinger resources delay(1000); } ``` -------------------------------- ### Start Thinger.io Services Source: https://github.com/thinger-io/docs/blob/main/server/deployment/on-premise.md Execute this command to launch all the services defined in the docker-compose.yml file in detached mode. This will start the Thinger.io server, MongoDB, and Ouroboros. ```bash docker-compose up -d ``` -------------------------------- ### Arduino ESP8266 Device Connection Example Source: https://github.com/thinger-io/docs/blob/main/console/README.md This example demonstrates how to connect an ESP8266 device to Thinger.io. Ensure you replace placeholders with your actual username, device ID, and device credentials. ```c++ #include #include "ThingerESP8266.h" #define USERNAME "your_username" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIALS "your_device_credentials" ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIALS); void setup() { Serial.begin(115200); thing.setDebugMessageInterval(0); thing.wifiэтому.connectionTimeout = 5; thing.add_wifi(SSID, PASSWORD); thing.process(); } void loop() { thing.handle(); } ``` -------------------------------- ### Arduino Nano 33 IoT Thinger.io Connection Source: https://github.com/thinger-io/docs/blob/main/arduino/arduino-wifi.md This example demonstrates connecting the Arduino Nano 33 IoT to Thinger.io. It includes setup for WiFi, digital pin control, and reading gyroscope data. Ensure the 'Arduino WiFiNINA' and 'Arduino_LSM6DS3' libraries are installed. ```cpp #define THINGER_SERIAL_DEBUG #include #include "arduino_secrets.h" // requires library Arduino_LSM6DS3 for the imu readings #include // cannot connect? Update WiFiNiNA and add iot.thinger.io SSL Certificate // https://support.arduino.cc/hc/en-us/articles/360016119219 ThingerWiFiNINA thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); void setup() { // configure LED_BUILTIN for output pinMode(LED_BUILTIN, OUTPUT); // open serial for debugging Serial.begin(115200); // initialize IMU if (!IMU.begin()) { Serial.println("Failed to initialize IMU!"); while (1); } // configure wifi network thing.add_wifi(SSID, SSID_PASSWORD); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // example for the built-in gyroscope thing["imu"] >> [](pson& out){ float x, y, z; IMU.readGyroscope(x, y, z); out["x"] = x; out["y"] = y; out["z"] = z; }; // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` -------------------------------- ### ESP8266 Thinger.io Setup with SmartConfig Source: https://github.com/thinger-io/docs/blob/main/arduino/espressif-esp8266.md This sketch configures the ESP8266 for Thinger.io and enables WiFi provisioning via SmartConfig. It includes setup for digital pin control and resource output. Ensure you have the ThingerSmartConfig library installed. ```cpp #define THINGER_SERIAL_DEBUG #include #include "arduino_secrets.h" ThingerSmartConfig thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); void setup() { // open serial for debugging Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); // digital pin control example (i.e. turning on/off a light, a relay, configuring a parameter, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value) thing["millis"] >> outputValue(millis()); // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` -------------------------------- ### Arduino ENC28J60 Ethernet Setup Source: https://github.com/thinger-io/docs/blob/main/arduino/arduino-ethernet.md Connect an Arduino with an ENC28J60 Ethernet module to Thinger.io. This example requires the UIPEthernet library and a static IP configuration as DHCP is too large for stock Arduinos. ```cpp // Install UIPEthernet for ENC28J60 // https://github.com/UIPEthernet/UIPEthernet #define THINGER_SERIAL_DEBUG #include #include "arduino_secrets.h" ThingerENC28J60 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); void setup() { // open serial for debugging Serial.begin(115200); // ENC28J60 using fixed IP Address. DHCP is too big for the sketch. uint8_t mac[6] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05}; Ethernet.begin(mac, IPAddress(192, 168, 1, 125)); pinMode(LED_BUILTIN, OUTPUT); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value) thing["millis"] >> outputValue(millis()); // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` ```cpp #define USERNAME "your_user_name" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" ``` -------------------------------- ### Create and Enter Build Directory Source: https://github.com/thinger-io/docs/blob/main/linux.md Creates a new directory named 'build' for the compilation process and then navigates into it. ```bash mkdir build cd build ``` -------------------------------- ### Connect Arduino Compatible Device to Thinger.io Source: https://github.com/thinger-io/docs/blob/main/quick-start.md Use the Thinger.io Arduino library to connect ESP8266 or ESP32 devices. Ensure you have installed the library and updated your device credentials (USERNAME, DEVICE_ID, DEVICE_CREDENTIALS) in the example code. ```c++ #include #define USERNAME "your_username" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIALS "your_device_credentials" ThingerESP8266 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIALS); void setup() { Serial.begin(115200); thing.set_wifi("your_ssid", "your_password"); // connect to thinger.io server thing.connect(); } void loop() { thing.handle(); } ``` -------------------------------- ### Listen for Thinger.io Connection States Source: https://github.com/thinger-io/docs/blob/main/coding-guide.md Set up a listener in the setup() method to react to various connection states with Thinger.io. This is useful for notifying disconnected status or controlling application flow. ```cpp void setup(){ // the setup code here.. thing.set_state_listener([&](ThingerClient::THINGER_STATE state){ switch(state){ case ThingerClient::NETWORK_CONNECTING: break; case ThingerClient::NETWORK_CONNECTED: break; case ThingerClient::NETWORK_CONNECT_ERROR: break; case ThingerClient::SOCKET_CONNECTING: break; case ThingerClient::SOCKET_CONNECTED: break; case ThingerClient::SOCKET_CONNECTION_ERROR: break; case ThingerClient::SOCKET_DISCONNECTED: break; case ThingerClient::SOCKET_ERROR: break; case ThingerClient::SOCKET_TIMEOUT: break; case ThingerClient::THINGER_AUTHENTICATING: break; case ThingerClient::THINGER_AUTHENTICATED: break; case ThingerClient::THINGER_AUTH_FAILED: break; case ThingerClient::THINGER_STOP_REQUEST: break; } }); } ``` -------------------------------- ### Run Server Monitor Client Source: https://github.com/thinger-io/docs/blob/main/others/other-software/server-monitoring-client.md Execute the server monitor client with a specified configuration file. Ensure the device is provisioned and credentials are set in the config. ```bash ./thinger_monitor [-c ] ``` -------------------------------- ### Connect Arduino MKR NB 1500 to Thinger.io Source: https://github.com/thinger-io/docs/blob/main/arduino/arduino-gsm.md This example demonstrates how to connect the Arduino MKR NB 1500 to the Thinger.io cloud platform. It includes setup for serial debugging, setting the APN, controlling the built-in LED, and reading the current time from the NB module. Ensure `arduino_secrets.h` is configured with your credentials. ```cpp #define THINGER_SERIAL_DEBUG #include #include "arduino_secrets.h" ThingerMKRNB thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); void setup() { // enable serial for debugging Serial.begin(115200); // optional set pin number thing.set_pin(PIN_NUMBER); // set APN thing.set_apn(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD); // set builtin led to output pinMode(LED_BUILTIN, OUTPUT); // pin control example over the Iinternet (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["time"] >> [&](pson& out){ out = thing.getNB().getTime(); }; // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` ```cpp #define USERNAME "your_user_name" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define PIN_NUMBER "" #define GPRS_APN "your_apn_name" #define GPRS_LOGIN "your_gprs_login" #define GPRS_PASSWORD "your_gprs_password" ``` -------------------------------- ### Update and Upgrade apt Repository Source: https://github.com/thinger-io/docs/blob/main/linux.md Before installing new packages, it's recommended to update and upgrade your system's package lists and installed packages. ```bash sudo apt update sudo apt upgrade ``` -------------------------------- ### Include ThingerConsole.h and Create Instance Source: https://github.com/thinger-io/docs/blob/main/remote-console.md Include the ThingerConsole library and create an instance using the 'thing' reference. This is the initial setup required for using the remote console. ```cpp #include ThingerConsole console(thing); ``` -------------------------------- ### Compile the Client Binary Source: https://github.com/thinger-io/docs/blob/main/linux.md Builds the Thinger.io IoTMP Linux client executable using the 'make' utility. This process may take several minutes. ```bash make ``` -------------------------------- ### Compile and Run IOTMP Linux Client Source: https://context7.com/thinger-io/docs/llms.txt Install dependencies, clone, build, and run the IOTMP C++ client on Linux devices. Replace placeholder credentials with your actual Thinger.io account details. ```bash # Install dependencies sudo apt update && sudo apt upgrade sudo apt install gcc g++ cmake libssl-dev \ libboost-system-dev libboost-filesystem-dev \ libboost-thread-dev libboost-program-options-dev \ libboost-regex-dev # Clone, build, and run git clone https://github.com/thinger-io/IOTMP-Linux.git cd IOTMP-Linux && mkdir build && cd build cmake ../ && make # Connect to Thinger.io (replace with real credentials) ./thinger -u username -d device_id -p device_credential \ --host "backend.thinger.io" # Expected output: # [THINGER] Authenticating. user: 'username', device: 'device_id' # [THINGER] Authenticated! # [THINGER] Keep alive received ``` -------------------------------- ### cURL HTTP Request Example Source: https://github.com/thinger-io/docs/blob/main/http-devices.md An example of how to make an HTTP request using cURL. This is useful for systems that support cURL instructions and for testing integrations. ```bash curl -k -X POST https://trincado.do.thinger.io/v3/users/jt/devices/Example_Device/callback/data \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "value": 10 }' ``` -------------------------------- ### Thinger.io Instance Initialization with Wi-Fi Source: https://github.com/thinger-io/docs/blob/main/coding.md Initialize the Thinger instance with your device's Wi-Fi credentials. Replace 'username', 'deviceId', and 'deviceCredential' with your actual registered values. ```cpp ThingerWifi thing("username", "deviceId", "deviceCredential"); ``` -------------------------------- ### Execute Thinger.io Linux Client Source: https://github.com/thinger-io/docs/blob/main/linux.md Run the compiled client binary with username, device, and credential parameters. The output shows connection and authentication logs. ```bash pi@RevPi20679:~/thinger_iotmp_linux_client/build $ ./thinger -u username -d device -p credential --host "perf.aws.thinger.io" [1] 2442 pi@RevPi20679:~/thinger_iotmp_linux_client/build $ date time ( uptime ) [ thread name/id ] file:line v| 2022-09-06 19:54:46.635 ( 0.001s) [main thread ] loguru.cpp:647 INFO| arguments: ./thinger -u alvarolb -d macbook -p macbook --host perf.aws.thinger.io 2022-09-06 19:54:46.636 ( 0.001s) [main thread ] loguru.cpp:650 INFO| Current dir: /home/pi/thinger_iotmp_linux_client/build 2022-09-06 19:54:46.636 ( 0.002s) [main thread ] loguru.cpp:652 INFO| stderr verbosity: 0 2022-09-06 19:54:46.636 ( 0.002s) [main thread ] loguru.cpp:653 INFO| ----------------------------------- 2022-09-06 19:54:46.643 ( 0.009s) [main thread ] asio_client.hpp:97 INFO| [CLIENT] Starting ASIO client... 2022-09-06 19:54:46.644 ( 0.009s) [main thread ] thinger.h:242 INFO| [SOCKET] Connecting to perf.aws.thinger.io:25206 (TLS: 1) 2022-09-06 19:54:46.763 ( 0.129s) [main thread ] thinger.h:251 INFO| [SOCKET] Connected! 2022-09-06 19:54:46.763 ( 0.129s) [main thread ] thinger.h:263 INFO| [THINGER] Authenticating. user: '', device: '' 2022-09-06 19:54:46.764 ( 0.130s) [main thread ] thinger.h:719 INFO| [MSG_OUT] (CONNECT) (2:1) (3:["username","device","password"]) (1:17767) 2022-09-06 19:54:46.793 ( 0.159s) [main thread ] thinger.h:677 INFO| [MSG__IN] (OK) (1:17767) 2022-09-06 19:54:46.794 ( 0.160s) [main thread ] thinger.h:266 INFO| [THINGER] Authenticated! 2022-09-06 19:54:47.795 ( 1.161s) [main thread ] thinger.h:719 INFO| [MSG_OUT] (KEEP_ALIVE) 2022-09-06 19:54:47.818 ( 1.184s) [main thread ] thinger.h:677 INFO| [MSG__IN] (KEEP_ALIVE) 2022-09-06 19:54:47.818 ( 1.184s) [main thread ] thinger.h:278 INFO| [THINGER] Keep alive received ``` -------------------------------- ### Shelly Plug S Processed Data Input Example Source: https://github.com/thinger-io/docs/blob/main/business-features/products/examples/shelly-plug-s.md Example of the data structure received by the `processData` function after topic parsing, containing both energy and power fields. ```json { "energy": 1386640, "power": 6.55 } ``` -------------------------------- ### Sigfox Uplink Callback Data Example Source: https://github.com/thinger-io/docs/blob/main/features/plugins/sigfox.md This is an example of the raw JSON data received by the Sigfox plugin from the Sigfox network. It includes custom data fields and the raw payload. ```javascript { "temperature" : {customData#temp}, "humidity" : {customData#hum} "data" : {data} } ``` -------------------------------- ### Download Docker Compose File Source: https://github.com/thinger-io/docs/blob/main/server/deployment/on-premise.md Use this command to download the docker-compose.yml file, which is essential for setting up Thinger.io. Replace {LICENSE} with your actual license token. ```bash curl https://subscriptions.thinger.io/v1/docker-compose.yml?token={LICENSE} -o docker-compose.yml ``` -------------------------------- ### Custom Data Timestamp Example Source: https://github.com/thinger-io/docs/blob/main/features/buckets.md This example shows how to include a custom timestamp in your data payload. The timestamp must be in milliseconds since the Unix epoch. If a timestamp matches an existing entry, the data will be overwritten. ```json { "ts":1671536877360, "lat": 40.416775, "lng": -3.70379, "temperature": 23.33, "humidity": 32.44 } ``` -------------------------------- ### Thinger.io Instance Initialization Source: https://github.com/thinger-io/docs/blob/main/coding-guide.md Initialize your Thinger.io instance with your unique username, device ID, and device credential. These values are obtained from the Thinger.io console when creating a new device. ```cpp ThingerESP32 thing("username", "deviceId", "deviceCredential"); ``` -------------------------------- ### Arduino MKR1010 WiFi Connection to Thinger.io Source: https://github.com/thinger-io/docs/blob/main/arduino/arduino-wifi.md This sketch connects the MKR1010 to Thinger.io using WiFi. Ensure the 'Arduino WiFiNINA' library is installed. For secure connections, the Thinger.io server certificate may need to be installed on the board. ```cpp #define THINGER_SERIAL_DEBUG #include #include "arduino_secrets.h" // cannot connect? Update WiFiNiNA and add iot.thinger.io SSL Certificate // https://support.arduino.io/hc/en-us/articles/360016119219 ThingerWiFiNINA thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); void setup() { // configure LED_BUILTIN for output pinMode(LED_BUILTIN, OUTPUT); // open serial for debugging Serial.begin(115200); // configure wifi network thing.add_wifi(SSID, SSID_PASSWORD); // pin control example (i.e. turning on/off a light, a relay, etc) thing["led"] << digitalPin(LED_BUILTIN); // resource output example (i.e. reading a sensor value, a variable, etc) thing["millis"] >> outputValue(millis()); // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); } ``` ```cpp #define USERNAME "your_user_name" #define DEVICE_ID "your_device_id" #define DEVICE_CREDENTIAL "your_device_credential" #define SSID "your_wifi_ssid" #define SSID_PASSWORD "your_wifi_ssid_password" ``` -------------------------------- ### Basic Thinger.io Arduino Sketch Structure Source: https://github.com/thinger-io/docs/blob/main/coding-guide.md This is the fundamental structure for an Arduino sketch using Thinger.io. Ensure required headers are included and the Thinger instance is initialized with your credentials. The setup() method is for initializing devices and resources, while loop() must always call thing.handle() and avoid delays. ```cpp #include // initialize Thinger instance (type can change depending on the device) ThingerESP32 thing("username", "deviceId", "deviceCredential"); void setup() { // initialize sensors and pins // initialize wifi (see examples for the device) // add resources here, like sensors, lights, etc. } void loop() { // call always the thing handled in the loop and avoid any delay here thing.handle(); // here it is possible to call endpoints // and also it is possible to stream resources } ```