|
1 | 1 | # Supabase-ESP32 |
2 | | -A library to connect to Supabase's Realtime Database from an ESP32 in realtime with API Key authentication. |
| 2 | +### A library to connect to Supabase's Realtime Database from an ESP32 in realtime with API Key authentication. |
| 3 | + |
| 4 | +The Arduino Nano ESP32 library provides a simple and efficient way to integrate Supabase.io's Realtime Database into your ESP32 projects. By leveraging API Key authentication, this library enables real-time communication between your ESP32 microcontroller and Supabase.io's powerful database infrastructure. |
| 5 | + |
| 6 | +To get started, simply include the library in your Arduino IDE and follow the provided documentation to establish a connection with Supabase.io. Once connected, you can easily retrieve, update, and synchronize data between your ESP32 and the Supabase.io Realtime Database. |
| 7 | + |
| 8 | +With the Arduino Nano ESP32 library, you can unlock the full potential of Supabase.io's Realtime Database and build IoT applications that seamlessly interact with cloud-based data. Start building your next project today! |
| 9 | +--- |
| 10 | +#### Installation |
| 11 | +At the moment installation has to be done manually either on a global level (*libraries* folder in the main Arduino Sketch folder) or locally placed in the *libraries* folder inside your Sketch directory. |
| 12 | +The library will be soon available also from the Arduino IDE. |
| 13 | + |
| 14 | +For the time being when including it you'll have to go with |
| 15 | +```#include "SupabaseESP32.h"``` |
| 16 | + |
| 17 | +#### Usage |
| 18 | +In order to setup the library you need to pass the following data. |
| 19 | +Please note that those data are available from you supabase database settings under the API tab (https://supabase.com/dashboard/project/PROJECT-CODE/settings/api). |
| 20 | +``` |
| 21 | +#define supabaseUrl "INSERT YOUR URL HERE" |
| 22 | +#define tableRealtime "INSERT YOUR TABLE NAME HERE" |
| 23 | +#define supabaseApiKey "INSERT YOUR API KEY HERE" |
| 24 | +``` |
| 25 | +in order to let the client begin with the right information you need to call the following function: |
| 26 | +```SUPABASE supabaseClient(supabaseUrl, supabaseApiKey, tableRealtime);``` |
| 27 | + |
| 28 | +Before start reading, updating or inserting any data in the database, you need to begin the connection by calling: |
| 29 | +```supabaseClient.begin();``` |
| 30 | + |
| 31 | +After that line of code, you can use three different method in order to interact with the database: |
| 32 | +``` |
| 33 | +//Read the data from the table |
| 34 | + supabaseClient.read(); |
| 35 | +
|
| 36 | +//Update a specific row with a new value |
| 37 | + int rowId = 1; |
| 38 | + String column = "column_name"; |
| 39 | + double value = 100.0; |
| 40 | + supabaseClient.update(rowId, column, value); |
| 41 | +
|
| 42 | +
|
| 43 | +//Insert a new row with a new value |
| 44 | + column = "column_name"; |
| 45 | + value = 100.0; |
| 46 | + supabaseClient.insert(column, value); |
| 47 | +``` |
| 48 | + |
| 49 | +Under the examples you can find a .ino file that includes all the mentioned functions working. |
0 commit comments