Gy-906 Code function Result

Hello,
I would like your help on the code;
it displays "Hypothermie" no matter what the temperature is;
I would like it to display "Hypothermie", "Normal", "Hyperthermie" and "Danger Corona".
depending on the temperature.

Thank you very much

#include <Wire.h>
#include <Adafruit_MLX90614.h>
Adafruit_MLX90614 mlx = Adafruit_MLX90614();



/* Constantes pour les broches */
const byte TRIGGER_PIN = 9; // Broche TRIGGER
const byte ECHO_PIN = 10;    // Broche ECHO
 
/* Constantes pour le timeout */
const unsigned long MEASURE_TIMEOUT = 25000UL; // 25ms = ~8m à 340m/s

/* Vitesse du son dans l'air en mm/us */
const float SOUND_SPEED = 340.0 / 1000;

//

//double temp = mlx.readObjectTempC();



/** Fonction setup() */
void setup() {
   
  /* Initialise le port série */
  Serial.begin(9600);

  
 Serial.println("Arduino MLX90614 Testing");  
 mlx.begin(); 

  /* Initialise les broches */
  pinMode(TRIGGER_PIN, OUTPUT);
  digitalWrite(TRIGGER_PIN, LOW); // La broche TRIGGER doit être à LOW au repos
  pinMode(ECHO_PIN, INPUT);
  
}
 
/** Fonction loop() */
void loop() {

 // Calcul de la distance :
  /* 1. Lance une mesure de distance en envoyant une impulsion HIGH de 10µs sur la broche TRIGGER */
  digitalWrite(TRIGGER_PIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGGER_PIN, LOW);
  
  /* 2. Mesure le temps entre l'envoi de l'impulsion ultrasonique et son écho (si il existe) */
  long measure = pulseIn(ECHO_PIN, HIGH, MEASURE_TIMEOUT);
   
  /* 3. Calcul la distance à partir du temps mesuré */
  float distance_mm = measure / 2.0 * SOUND_SPEED;
   
  /* Affiche les résultats en mm, cm et m */
  Serial.print(F("Distance: "));
  Serial.println(distance_mm);


  if (distance_mm==0){
  
  Serial.println("Prennez votre Temperature ICI"); 
  }
  
  else if  (distance_mm<80){

  Serial.print("Temp Corps = "); Serial.print(mlx.readObjectTempC()); Serial.println("°C");
  
  Serial.print("T°Ambient = "); Serial.print(mlx.readAmbientTempC());  Serial.println("°C "); 


//

if (mlx.readObjectTempC()<35,7){
      Serial.println("Hypothermie");  
    }
  else if(mlx.readObjectTempC()<37,9){
      Serial.println("Normal"); 
    }
  else if (mlx.readObjectTempC()<40){
      Serial.println("Hyperthermie"); 
    }
  else{
      Serial.println("Danger Corona");
    }


  <
  }
  
  else {
    Serial.println("Raprochez vous pour prendre la temperature");
    //lcd.print("Rapprochez vous");
  }

  
   
  /* Délai d'attente pour éviter d'afficher trop de résultats à la seconde */
  delay(5500);
}



Use serial monitor and, in the code, a Serial.println(mlx.readObjectTempC()); That will tell what the value is.

Schematics could help us.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.