Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
jucyara_silva
Published © GPL3+

Gerenciador de Temperatura de ambientes críticos com alarme

IntermediateFull instructions provided30
Gerenciador de Temperatura de ambientes críticos com alarme

Things used in this project

Hardware components

I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
Buzzer, Piezo
Buzzer, Piezo
×1
RGB Diffused Common Anode
RGB Diffused Common Anode
×1
Industrial Pushbutton Switch, Push-Pull
Industrial Pushbutton Switch, Push-Pull
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×3
Through Hole Resistor, 25.5 kohm
Through Hole Resistor, 25.5 kohm
×5
DS18B20 Temperature Sensor 1m
HARDWARIO DS18B20 Temperature Sensor 1m
×1

Story

Read more

Schematics

Gerenciador de temperatura de ambientes críticos

Code

Gerenciamento de temperatura de ambientes críticos

C/C++
#include <LiquidCrystal_I2C.h>
#include <OneWire.h>
#include <DallasTemperature.h>

OneWire pino(3);
DallasTemperature barramento(&pino);
DeviceAddress sensor;

const int RED = 10; 
const int GREEN = 9;
const int BLUE = 7; 
const int POTENC = A5;
const int BUZZER = 8;

const int pinoBotao = 11;

LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);

void rgb();

void setup() {
  lcd.begin(16,2);
  Serial.begin(9600);  
  pinMode(pinoBotao, INPUT_PULLUP);
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  pinMode(POTENC, INPUT);
  pinMode(BUZZER, OUTPUT);
  
  barramento.begin();
  barramento.getAddress(sensor, 0); 
}

  int val; 
  int val2;
  int Sen;

void loop() {
  val = map(analogRead(0), 0, 1023, 5, 15); 
  val2 = map(analogRead(2),0,1023,16,24); 
  Sen = map(analogRead(1), 0, 1023, 0, 29);

  delay(100);
  
  Serial.println(pinoBotao);
  rgb();
    
  delay(100);
  
}

int contador=0;


void rgb() {
  if(digitalRead(pinoBotao) != 0){

    contador ++;
    if(contador == 1){
      
    
    lcd.setCursor(0,0);
    lcd.print("Temp: ");
    lcd.print(Sen); 
    lcd.print(" C    ");
    lcd.print(val);
    lcd.println("  ");
  
    if((Sen < val && Sen > 4) || (Sen>val2 && Sen<24)) {
    
      digitalWrite(BLUE, HIGH);
      digitalWrite(RED, LOW);
      digitalWrite(GREEN, LOW);

      lcd.setCursor(0,1);
      lcd.print("WARNING       "); 
      lcd.print(val2);
      lcd.print("    ");
  
      digitalWrite(BUZZER, HIGH);
      delay(800);
      digitalWrite(BUZZER, LOW);
      delay(3000);
  
    }
  
    else if(Sen>= val && Sen < val2){
      digitalWrite(BLUE, LOW);
      digitalWrite(RED, LOW);
      digitalWrite(GREEN, HIGH);

      lcd.setCursor(0,1);
      lcd.print("ACEITAVEL     ");
      lcd.print(val2);
      lcd.print("   ");
      delay(1500);
    }
  
    else if(Sen <= 4 || Sen >= 25) {
    
      digitalWrite(BLUE, LOW);
      digitalWrite(RED, HIGH);
      digitalWrite(GREEN, LOW);

      lcd.setCursor(0,1);
      lcd.print("CRITICO       "); 
      lcd.print("  ");
      lcd.print(val2);
      lcd.print("  ");
    
      digitalWrite(BUZZER, HIGH);
      delay(800);
      digitalWrite(BUZZER, LOW);
      delay(800);
        }
      }
        if(digitalRead(pinoBotao) ==0){                                     

          while(1){
          barramento.requestTemperatures(); 
          float temperatura = barramento.getTempC(sensor);
          Serial.println(temperatura);
          delay(500);
          
          lcd.setCursor(0,0);
          lcd.print("Temp: ");
          lcd.print(temperatura); 
          lcd.print(" C    ");
          lcd.print(val);
          lcd.println("  ");
          
          if((temperatura < val && Sen > 4) || (temperatura>val2 && temperatura<24)) {
    
      digitalWrite(BLUE, HIGH);
      digitalWrite(RED, LOW);
      digitalWrite(GREEN, LOW);

      lcd.setCursor(0,1);
      lcd.print("WARNING       ");
      lcd.print(val2);
      lcd.print("    ");
  
      digitalWrite(BUZZER, HIGH);
      delay(800);
      digitalWrite(BUZZER, LOW);
      delay(3000);
  
    }
  
    else if(temperatura>= val && temperatura < val2){
      digitalWrite(BLUE, LOW);
      digitalWrite(RED, LOW);
      digitalWrite(GREEN, HIGH);
    

      lcd.setCursor(0,1);
      lcd.print("ACEITAVEL     ");
      lcd.print(val2);
      lcd.print("   ");
      delay(1500);
    }
  
    else if(temperatura <= 4 || temperatura >= 25) {
    
      digitalWrite(BLUE, LOW);
      digitalWrite(RED, HIGH);
      digitalWrite(GREEN, LOW);
    
    
      lcd.setCursor(0,1);
      lcd.print("CRITICO       "); 
      
      lcd.print(val2);
      lcd.print("  ");
    
      digitalWrite(BUZZER, HIGH);
      delay(800);
      digitalWrite(BUZZER, LOW);
      delay(800);
            }
          if(digitalRead(11) != 0){
            break;
          }
          }
        }
      contador = 0;
    }
  }
 

Credits

jucyara_silva

jucyara_silva

1 project • 0 followers

Comments