From fb92cd3198c31c6b4993fd8677a844033619733e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Sun, 21 Jun 2020 16:07:02 +0200 Subject: [PATCH] Minor README.md change [skip ci] --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index 6865c34..77e61f9 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,38 @@ DOCKER_HOST='127.0.0.1:22375' docker-compose -f docker-compose.modules.yml up -d A simple Arduino UNO sketch is provided in the `arduino/tempLightSensor` folder. The sketch reads temperature and light from sensors. +```c +/* ... */ + +void loop(void) { + const int postDelay = 10 * 1000; + + unsigned int tempReading = analogRead(A0); + unsigned int photocellReading = analogRead(A1); + + float tempVoltage = tempReading * AREF_VOLTAGE / 1024.0; + float tempC = (tempVoltage - 0.5) * 100 ; + + if (NTPValid) { + telemetry["clock"] = timeClient.getEpochTime(); + } else { + telemetry["clock"] = NULL; // converted into 0 + } + payload["light"] = photocellReading; + + temp["celsius"] = tempC; + temp["raw"] = tempReading; + temp["volts"] = tempVoltage; + +#if USE_MQTT + publishData(config, telemetry); +#else + postData(config, telemetryURL, telemetry); +#endif + +/* ... */ +``` + [Read more ...](./arduino/README.md) ## Testing