thinx-firmware-esp32-ino
Arduino firmware for THiNX providing device management and automatic (webhook-based) OTA (over-the-air) firmware builds and updates.
Provides example implementations for ESP32 with Arduino IDE.
- This is a work in progress.
- 100% functionality is not guaranteed for all the time.
Requirements
IDE
- Arduino IDE (currently tested with 1.8.5 but works even with older versions)
Arduino C development
WARNING! Adding Arduino Library Manager dependencies is supported through the thinx.yml file, however this library already contains all required dependencies, because your local Arduino Libraries are not located on the CI server.
Copy dependencies from the
lib
folder to your Arduino libraries to compile locally.
Use the thinx.yml to add more dependencies for THiNX CI, but be aware that those will be merged with libraries from lib folder next to .ino file.
- Arduino IDE or Platform.io
- Arduino libraries: THiNX32Lib; ArduinoJSON, WiFiManager, ESP32httpUpdate
- Open this folder using Atom with installed Platform.io or thinx-esp32-example/thinx-esp32-example.ino using Arduino IDE with Espressif32 platform installed.
- Run prerelease.sh to bake your commit ID into the Thinx.h file.
Installation
Arduino IDE
Search for THiNX32
in Arduino Library Manager and install all other dependencies... or you can just copy then from the lib
folder if you prefer tested versions before the latest.
Board support
For properly configuring the .board
file (preset to ESP32DEV) see the Arduino CLI Docs docs for the -board package:arch:board[:parameters]
option.
Usage
- Create account on the http://rtm.thinx.cloud/ site
- Create an API Key
- Clone vanilla NodeMCU app repository
- Run the bash ./prerelease.sh to create Thinx.h file; you can edit this with your custom information but the file will be overwritten when building on the server
- You can store Owner ID and API Key in Thinx.h file in case your project is not stored in public repository. Otherwise make sure WiFiManager is enabled in THiNXLib.h to copy-paste those values to Captive Portal later.
- Build and upload the code to your device.
- After restart, connect with some device to WiFi AP 'AP-THiNX' and enter the API Key / Owner ID if you haven't hardcoded those in step 4.
- Device will connect to WiFi and register itself. Check your thinx.cloud dashboard for new device.
... Then you can add own git source, add ssh-keys to access those sources if not public, attach the source to device to dashboard and click the last icon in row to build/update the device.
Note: In case you'll build/upload your project (e.g. the library) using thinx.cloud, API key will be injected automatically and you should not need to set it up anymore.
Environment Variable Support
You provide callback receiving String using setPushConfigCallback()
method. Whenever device receives MQTT update with configuration
key, it will provide all environment variables to you.
This may be also used for the WiFi Migration procedure.
Security
HTTPS with certificate validation is supported, but not tested.
Because all the traffic from was originally HTTP-only and not all devices could handle SSL, you can install our side-kick project THiNX-Connect. Install this proxy to your home environment and it will encrypt HTTP traffic to HTTPS and will tunnel your device communication directly to thinx.cloud.
Library queries the thinx
MDNS service on _tcp
protocol on local network upon connection. When such service is available, library will forward all HTTP requests through this service.