|
1 | 1 | # InfluxDB Arduino Client |
2 | 2 |
|
3 | | -Simple Arduino client for writing and reading data from [InfluxDB](https://www.influxdata.com/products/influxdb-overview/), it doesn't matter whether a local server or InfluxDB Cloud. Library supports authentication, secure communication over TLS, [batching](#writing-in-batches), [automatic retrying](#buffer-handling-and-retrying) on server backpressure and connection failure. |
| 3 | +Simple Arduino client for writing data to [InfluxDB](https://www.influxdata.com/products/influxdb-overview/), it doesn't matter whether a local server or InfluxDB Cloud. Library supports authentication, secure communication over TLS, [batching](#writing-in-batches), [automatic retrying](#buffer-handling-and-retrying) on server backpressure and connection failure. |
4 | 4 |
|
5 | 5 | It also allows setting data in various formats, automatically escapes special characters and offers specifying timestamp in various precisions. |
6 | 6 |
|
@@ -344,43 +344,6 @@ void setup() { |
344 | 344 | } |
345 | 345 | ``` |
346 | 346 |
|
347 | | -## Querying |
348 | | -InfluxDB uses [Flux](https://www.influxdata.com/products/flux/) to process and query data. InfluxDB client for Arduino offers a simple way how to query data with `query` function: |
349 | | -```cpp |
350 | | -// Construct a Flux query |
351 | | -// Query will find RSSI for last 24 hours for each connected WiFi network with this device computed by given selector function |
352 | | -String query = "from(bucket: \"" INFLUXDB_BUCKET "\") |> range(start: -24h) |> filter(fn: (r) => r._measurement == \"wifi_status\" and r._field == \"rssi\""; |
353 | | -query += "and r.device == \"" DEVICE "\")"; |
354 | | -query += "|> " + selectorFunction + "()"; |
355 | | - |
356 | | -String resultSet = client.query(query); |
357 | | -// Check empty response |
358 | | -if (resultSet == "") { |
359 | | - // It can mean empty query result |
360 | | - if (client.wasLastQuerySuccessful()) { |
361 | | - Serial.println("Empty results set"); |
362 | | - } else { |
363 | | - // or an error |
364 | | - Serial.print("InfluxDB query failed: "); |
365 | | - Serial.println(client.getLastErrorMessage()); |
366 | | - } |
367 | | -} else { |
368 | | - Serial.println(resultSet); |
369 | | -} |
370 | | -``` |
371 | | - |
372 | | -InfluxDB query result set is returned in the CSV format, where the first line contains column names: |
373 | | -```CSV |
374 | | -,result,table,_start,_stop,_time,_value,SSID,_field,_measurement,device |
375 | | -,_result,0,2019-12-11T12:39:49.632459453Z,2019-12-12T12:39:49.632459453Z,2019-12-12T12:26:25Z,-68,666G,rssi,wifi_status,ESP8266 |
376 | | -``` |
377 | | -This library also provides a couple of helper methods for parsing such a result set. |
378 | | - |
379 | | -If the query results in an empty result set, the server returns an empty response. As the empty result returned from the `query` function indicates an error, |
380 | | -use `wasLastQuerySuccessful()` method to determine final status. |
381 | | - |
382 | | -Complete source code is available in [Query example](examples/Query/Query.ino). |
383 | | - |
384 | 347 | ## Troubleshooting |
385 | 348 | All db methods return status. Value `false` means something went wrong. Call `getLastErrorMessage()` to get the error message. |
386 | 349 |
|
|
0 commit comments