From 2038522e0fb2c5d73a9f8a599647ec1ed6b273c4 Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Sun, 23 May 2021 19:07:00 +0200 Subject: [PATCH] Wait for 30s Before Initializuing the HM330x --- lib/HM330x/HM330x.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/HM330x/HM330x.cpp b/lib/HM330x/HM330x.cpp index af6364c..ad83f9d 100644 --- a/lib/HM330x/HM330x.cpp +++ b/lib/HM330x/HM330x.cpp @@ -35,8 +35,13 @@ HM330x::HM330x() {}; // Initialize the Sensor void HM330x::initialize(void) { uint8_t retryCount = 0; - DEBUG_PRINTLN("HM330x::initialize"); + + // Wait for Sensor to get Ready + DEBUG_PRINTLN("HM330x::initialize Waiting for Sensor Startup"); + delay(30000); + + DEBUG_PRINTLN("HM330x::initialize Trying to send Select"); // Send select command while (!sendCmd(HM330x_SELECT)) { if (retryCount++ >= 10) { @@ -58,7 +63,7 @@ uint8_t HM330x::getSensorData(char *payload, uint8_t startbyte) { // Initialize Payload with 0s for (uint8_t i=startbyte; i < startbyte+6; i++) - payload[i] = 0; + payload[i] = 0xFF; // Get Data from the Sensors Wire.requestFrom(HM330x_ADDR, HM330x_DATA_LEN); @@ -78,6 +83,9 @@ uint8_t HM330x::getSensorData(char *payload, uint8_t startbyte) { startbyte += 2; } return startbyte; + } else { + for (uint8_t i=startbyte; i < startbyte+6; i++) + payload[i] = 0xEE; } } return startbyte+6;