diff --git a/src/main.cpp b/src/main.cpp index e857f23..e4c21dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,15 +3,19 @@ Adafruit_SHT4x sht4 = Adafruit_SHT4x(); -void setup() { - Serial.begin(9600); // zacni seriovou komunikaci s baudrate 9600 +void setup() +{ + Serial.begin(115200); // zacni seriovou komunikaci s baudrate 115200 Serial.println("UART OK"); + pinMode(LED_BUILTIN, OUTPUT); // nastav ledku na desce jako vystup + Serial.println("Adafruit SHT4x test"); // zadni komunikaci s SHT40 po I2C - if (! sht4.begin()) + if (!sht4.begin()) { Serial.println("Couldn't find SHT4x"); // pokud neni sensor nalezen, program skonci v nekonecne smycce - while (1) delay(1); + while (1) + delay(1); } Serial.println("Found SHT4x sensor"); Serial.print("Serial number 0x"); @@ -20,11 +24,12 @@ void setup() { sht4.setHeater(SHT4X_NO_HEATER); } -void loop() { - sensors_event_t humidity, temp; - +void loop() +{ + sensors_event_t humidity, temp; + uint32_t timestamp = millis(); - sht4.getEvent(&humidity, &temp); // cteni ze senzoru + sht4.getEvent(&humidity, &temp); // cteni ze senzoru timestamp = millis() - timestamp; // ziskani delky cteni ze senzoru Serial.print("temp= "); @@ -32,6 +37,8 @@ void loop() { Serial.print(" humidity="); Serial.println(humidity.relative_humidity); - delay(1000); + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(250); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(250); // wait for a second } -