Add examples
This commit is contained in:
parent
9faf94b30e
commit
6f553ed23c
1 changed files with 31 additions and 0 deletions
|
@ -57,4 +57,35 @@ sensor:
|
|||
```
|
||||
{% endraw %}
|
||||
|
||||
## {% linkable_title Examples %}
|
||||
|
||||
### {% linkable_title Arduino %}
|
||||
|
||||
For controllers of the Arduino family a possible sketch to read the temperature and the humidity could look like the sample below.
|
||||
|
||||
```
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
StaticJsonBuffer<100> jsonBuffer;
|
||||
JsonObject& json = prepareResponse(jsonBuffer);
|
||||
json.printTo(Serial);
|
||||
Serial.println();
|
||||
delay(2000);
|
||||
}
|
||||
|
||||
JsonObject& prepareResponse(JsonBuffer& jsonBuffer) {
|
||||
JsonObject& root = jsonBuffer.createObject();
|
||||
root["temperature"] = analogRead(A0);
|
||||
root["humidity"] = analogRead(A1);
|
||||
return root;
|
||||
}
|
||||
```
|
||||
|
||||
### {% linkable_title Digispark USB Development Board %}
|
||||
|
||||
This [blog post](/blog/2017/10/23/simple-analog-sensor/) describes the setup with a Digispark USB Development Board.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue