InfluxDB-Client-for-Arduino
InfluxDB-Client-for-Arduino copied to clipboard
ony NS timestamp works with influxdb cloud
First of all big Thank you for this great lib, helps me a lot.
I had some problems with the timestamp. So I switched it of in the first try. Later I tested several variants and ended up in only setTime(WritePrecision::NS); works for me with influxdb cloud might be it is a limitation of the cloud edition of infuxdb
@antonmeyer,
- What problems did you have with other types of precisions?
- Do you set a timestamp manually? How?
- What is your write frequency?
I just do not see the data in the bucket, but I see it as soon I change it to NS. Point MP1("ePower"); MP1.addTag("eMeter", dataset.alias); MP1.addField("actW", dataset.actW); MP1.addField("sumWh", dataset.sumWh); MP1.setTime(WritePrecision::NS); //set the time
write frequency is about 1 per second using batch client.setWriteOptions(WriteOptions().batchSize(10)); client.setWriteOptions(WriteOptions().bufferSize(20));
Client does not report any error
if (!client.writePoint(MP1)) { Serial.print("InfluxDB write failed: "); Serial.println(client.getLastErrorMessage()); };
And as it works with NS I think in general my code is working.
I might check with an influxDB OS version, and might be it reports some errors or does not show it at all. But this might take a few days.
You have to set the same WritePrecision you use for timestamp also to client:
client.setWriteOptions(WriteOptions().batchSize(10).bufferSize(20).writePrecision(WritePrecision::S));
Then:
MP1.setTime(WritePrecision::S);
NS precision works for you because it is the default precision on the server.
Other note: If you want to set several options, use either one-line fluent setting, as shown above, or set options on a single instance:
WriteOptions wo;
wo.batchSize(10);
wo.bufferSize(20);
client.setWriteOptions(wo);
I just wonder that I make the error here, just one WriteOption Object instead of overwriting it several time?
client.setWriteOptions(WriteOptions().batchSize(10)); client.setWriteOptions(WriteOptions().bufferSize(20)); client.setWriteOptions(WriteOptions().writePrecision(WritePrecision::S)); client.setWriteOptions(WriteOptions().flushInterval(300));
that fixed it.
WriteOptions wo; wo.batchSize(10); wo.bufferSize(20); wo.flushInterval(300); wo.writePrecision(WritePrecision::S); client.setWriteOptions(wo);
I misunderstood the API for setting the WriteOptions. Proposal: setting precision in Point overrules the client settings, if this is possible) Or an error message in case of mismatch would also help. But Thanks a lot for the support.
I just wonder that I make the error here, just one WriteOption Object instead of overwriting it several time?
client.setWriteOptions(WriteOptions().batchSize(10)); client.setWriteOptions(WriteOptions().bufferSize(20)); client.setWriteOptions(WriteOptions().writePrecision(WritePrecision::S)); client.setWriteOptions(WriteOptions().flushInterval(300));
Because WriteOptions() creates new object with the default values and calling some setter, e.g. bufferSize(20) sets just this option. Therefore only the last call of client.setWriteOptions wins.