Skip to content

Commit a01b68c

Browse files
committed
Ads comment about error codes to Influxdb::write.
1 parent 178d8b8 commit a01b68c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

InfluxDb.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ boolean Influxdb::write(InfluxData data) { return write(data.toString()); }
5555

5656
/**
5757
* Send raw data to InfluxDb.
58+
*
59+
* @see
60+
* https://github.com/esp8266/Arduino/blob/cc0bfa04d401810ed3f5d7d01be6e88b9011997f/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h#L44-L55
61+
* for a list of error codes.
5862
*/
5963
boolean Influxdb::write(String data) {
6064
Serial.print(" -> writing to " + _db + ":\n");

html/class_influxdb.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ <h2 class="memtitle"><span class="permalink"><a href="#aabc81883ba05cea585531931
220220
</tr>
221221
</table>
222222
</div><div class="memdoc">
223-
<p>Send raw data to InfluxDb. </p>
223+
<p>Send raw data to InfluxDb.</p>
224+
<dl class="section see"><dt>See also</dt><dd><a href="https://github.com/esp8266/Arduino/blob/cc0bfa04d401810ed3f5d7d01be6e88b9011997f/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h#L44-L55">https://github.com/esp8266/Arduino/blob/cc0bfa04d401810ed3f5d7d01be6e88b9011997f/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h#L44-L55</a> for a list of error codes. </dd></dl>
224225

225226
</div>
226227
</div>

html/md__r_e_a_d_m_e.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,14 @@
6565
<div class="title">ESP8266_Influx_DB </div> </div>
6666
</div><!--header-->
6767
<div class="contents">
68-
<div class="textblock"></div></div><!-- contents -->
68+
<div class="textblock"><p>Library for NodeMcu / ESP8266 (and Arduino?) for sending measurements to an Influx database.</p>
69+
<p>## Initialization </p><div class="fragment"><div class="line"><span class="preprocessor">#define INFLUXDB_HOST &quot;192.168.0.32&quot;</span></div><div class="line"><span class="preprocessor">#define INFLUXDB_PORT &quot;1337&quot;</span></div><div class="line"><span class="preprocessor">#define INFLUXDB_DATABASE &quot;test&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// TODO: connect to WiFi</span></div><div class="line"></div><div class="line"><a class="code" href="class_influxdb.html">Influxdb</a> influx(INFLUXDB_HOST); <span class="comment">// port defaults to 8086</span></div><div class="line"><span class="comment">// or</span></div><div class="line"><a class="code" href="class_influxdb.html">Influxdb</a> influx(INFLUXDB_HOST, INFLUXDB_PORT);</div><div class="line"></div><div class="line"><span class="comment">// set the target database</span></div><div class="line">influx.setDb(INFLUXDB_DATABASE);</div></div><!-- fragment --><h2>Sending a single measurement</h2>
70+
<p><b>Using an <a class="el" href="class_influx_data.html">InfluxData</a> object:</b> </p><div class="fragment"><div class="line"><span class="comment">// create a measurement object</span></div><div class="line"><a class="code" href="class_influx_data.html">InfluxData</a> measurement (<span class="stringliteral">&quot;temperature&quot;</span>);</div><div class="line">measurement.addTag(<span class="stringliteral">&quot;device&quot;</span>, d2);</div><div class="line">measurement.addTag(<span class="stringliteral">&quot;sensor&quot;</span>, <span class="stringliteral">&quot;dht11&quot;</span>);</div><div class="line">measurement.addValue(<span class="stringliteral">&quot;value&quot;</span>, 24.0);</div><div class="line"></div><div class="line"><span class="comment">// write it into db</span></div><div class="line">influx.write(measurement);</div></div><!-- fragment --><p><b>Using raw-data</b> </p><div class="fragment"><div class="line">influx.write(<span class="stringliteral">&quot;temperature,device=d2,sensor=dht11 value=24.0&quot;</span>)</div></div><!-- fragment --><h2>Write multiple data points at once</h2>
71+
<p>Batching measurements and send them with a single request will result in a much higher performance. </p><div class="fragment"><div class="line"><a class="code" href="class_influx_data.html">InfluxData</a> measurement1 = readTemperature()</div><div class="line">influx.prepare(measurement1)</div><div class="line"></div><div class="line"><a class="code" href="class_influx_data.html">InfluxData</a> measurement2 = readLight()</div><div class="line">influx.prepare(measurement2)</div><div class="line"></div><div class="line"><a class="code" href="class_influx_data.html">InfluxData</a> measurement3 = readVoltage()</div><div class="line">influx.prepare(measurement3)</div><div class="line"></div><div class="line"><span class="comment">// writes all prepared measurements with a single request into db.</span></div><div class="line"><span class="keywordtype">boolean</span> success = influx.write();</div></div><!-- fragment --><h2>Http client error codes</h2>
72+
<p>Internally <code>ESP8266HTTPClient</code> is used. </p><div class="fragment"><div class="line"><span class="preprocessor">#define HTTPC_ERROR_CONNECTION_REFUSED (-1)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_SEND_HEADER_FAILED (-2)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_SEND_PAYLOAD_FAILED (-3)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_NOT_CONNECTED (-4)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_CONNECTION_LOST (-5)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_NO_STREAM (-6)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_NO_HTTP_SERVER (-7)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_TOO_LESS_RAM (-8)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_ENCODING (-9)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_STREAM_WRITE (-10)</span></div><div class="line"><span class="preprocessor">#define HTTPC_ERROR_READ_TIMEOUT (-11)</span></div><div class="line"><span class="preprocessor">...</span></div></div><!-- fragment --><p> See <a href="https://github.com/esp8266/Arduino/blob/cc0bfa04d401810ed3f5d7d01be6e88b9011997f/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h#L44-L55">list of error codes</a> and <a href="https://github.com/esp8266/Arduino/blob/cc0bfa04d401810ed3f5d7d01be6e88b9011997f/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h#L60-L120">list of http status codes</a>.</p>
73+
<h2>Documentation</h2>
74+
<p>For the documentation see <a href="html/class_influxdb.html">html/class_influxdb.html</a> (only works locally). </p>
75+
</div></div><!-- contents -->
6976
<!-- start footer part -->
7077
<hr class="footer"/><address class="footer"><small>
7178
Generated by &#160;<a href="http://www.doxygen.org/index.html">

0 commit comments

Comments
 (0)