From ed0186a2ff64962a626d2f824c634b237b5bb60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Fri, 5 Jun 2020 13:23:19 +0200 Subject: [PATCH] Arduino minor optimizations --- arduino/tempLightSensor/tempLightSensor.ino | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arduino/tempLightSensor/tempLightSensor.ino b/arduino/tempLightSensor/tempLightSensor.ino index 41f67bb..3956ccd 100644 --- a/arduino/tempLightSensor/tempLightSensor.ino +++ b/arduino/tempLightSensor/tempLightSensor.ino @@ -16,8 +16,7 @@ JsonObject payload = telemetry.createNestedObject("payload"); JsonObject temp = payload.createNestedObject("temperature"); unsigned int counter = 0; -int tempPin = A0; -int photocellPin = A1; + EthernetUDP ntpUDP; NTPClient timeClient(ntpUDP); @@ -31,7 +30,6 @@ netConfig config; const String apiURL = "/api/device/subscribe/"; const String telemetryURL = "/telemetry/"; -const int postDelay = 10 * 1000; void setup(void) { Serial.begin(9600); @@ -90,9 +88,10 @@ void setup(void) { } void loop(void) { + const int postDelay = 10 * 1000; - unsigned int photocellReading = analogRead(photocellPin); - unsigned int tempReading = analogRead(tempPin); + unsigned int tempReading = analogRead(A0); + unsigned int photocellReading = analogRead(A1); float tempVoltage = tempReading * AREF_VOLTAGE / 1024.0; float tempC = (tempVoltage - 0.5) * 100 ;