mercredi 24 mars 2021

Store the float value in array, and analyzing last 20 values to check in C++

I'm working with DS18B20 Temperature sensor with Arduino. I need to store the last 20 read values in array, and notify or interrupt to switch on the LED particular threshold. How to process the above scenario? You can add the rest of the codes with my initial code.

#include <OneWire.h> 
#include <DallasTemperature.h>
 
#define ONE_WIRE_BUS 10 
 
OneWire oneWire(ONE_WIRE_BUS); 
 
DallasTemperature sensors(&oneWire);
/********************************************************************/ 
void setup(void) 
{ 
 // start serial port 
 Serial.begin(9600); 
 sensors.begin(); 
} 
void loop(void) 
{ 
  readTempSensor();
       delay(100); 
} 

float readTempSensor(){
 float Temp = 0;
 float TmpArray[20]; 
 
 sensors.requestTemperatures();
 Temp = sensors.getTempCByIndex(0);
 
 Serial.print("T: "); 
 Serial.println(Temp); 
}

Aucun commentaire:

Enregistrer un commentaire