issues with code for the display of a environmental control temperature sensor

Hello everyone!!

I am trying to design a temperature sensor for environment control. the sensor shifts the LED when cooling occurs below 25C and vice versa for heating turning the LED to red, given below I have the code. But I am having issues as there is no display appearing, it is blank shining. Can anyone please suggest me ??

#include <Wire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define RELAY1  4  // Relay heating
#define RELAY2  6  // Relay cooling


int red = 8 ; // red light heating
int blue = 2; // blue LED cooling


#define BACKLIGHT_PIN 13
#define ONE_WIRE_BUS 7

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
 float reading;


void setup() {
  Serial.begin(9600);
  sensors.begin();
  

  pinMode(red, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);

}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("TEMP CONTROL");


  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);
  float temp;
  temp= temperature * 999999;
  lcd.setCursor(0, 2);
  lcd.print("      ");
  lcd.print(temp);
  lcd.print("\337C");
  reading = (5.0 * analogRead(A0) * 100.0) / 102;
Serial.print((float)reading); 

  if (temp < 25)

  {
    
    digitalWrite(red, HIGH);
  digitalWrite(blue, LOW);

  lcd.setCursor(0, 3);
  lcd.print("heating ");

  digitalWrite(RELAY1, 1);
  digitalWrite(RELAY2, 0);
  digitalWrite(red, HIGH);
  digitalWrite(blue, LOW);

  
  }
  
  else if (temp > 25)
{
    digitalWrite(RELAY1, 0);
  digitalWrite(RELAY2, 1);
  digitalWrite(red, LOW);
  digitalWrite(blue, HIGH);

  lcd.setCursor(0, 4);
  lcd.print("Cooling ");
  lcd.setCursor(0, 3);
  lcd.display();
}
}

Assuming you used the brightness potentiometer to adjust the display, if you run this code, do you see something on the LCD?

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
  Serial.begin(9600);
  lcd.setCursor(0, 0);
  lcd.print("TEMP CONTROL");
}

void loop() {}

Also which LiquidCrystal_I2C library are you using? some require a lcd.init();orlcd.begin();==> check the examples provided with the library you picked

So, the Red LCD starts as I run the code, but then when I am putting the sensor in the cold medium for blue LED, the LED is not switching to blue also there is nth appearing on the display about the temperature reading.

Thank you

run the code above and report on what you see was my first question... what's the answer?

It is not displaying anything!!
I have verified the connections, seems correct to me
given below is an image for your understanding and the latest code which I have used.

I believe the sensor will provide us a digital signal which has to be converted to voltage and then temperature for the display. Please do correct me if I am wrong

#include <Wire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define RELAY1  4  // Relay heating
#define RELAY2  6  // Relay cooling


int red = 8 ; // red light heating
int blue = 2; // blue LED cooling
int ledPin = 13;  // LED connected to digital pin 13
int inPin = 7;    // pushbutton connected to digital pin 7
int val = 0;
int voltage = 0;
int temp = 0;


#define BACKLIGHT_PIN 13
#define ONE_WIRE_BUS 7

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float reading;


void setup() {
  Serial.begin(9600);
  sensors.begin();


  pinMode(red, OUTPUT);
  pinMode(blue, OUTPUT);
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);

}

void loop() {
  lcd.setCursor(0, 0);
  lcd.print("TEMP CONTROL");




  val = digitalRead(inPin);   // read the input pin
  digitalWrite(ledPin, val);  // sets the LED to the button's value
  voltage = val * (5000 / 1024);
  temp = ([voltage - 500] / 10);


  lcd.print("temp is", temp);

  lcd.print("\337C");


  if (temp < 25)

  {

    digitalWrite(red, HIGH);
    digitalWrite(blue, LOW);

    lcd.setCursor(0, 3);
    lcd.print("heating ");

    digitalWrite(RELAY1, 1);
    digitalWrite(RELAY2, 0);
    digitalWrite(red, HIGH);
    digitalWrite(blue, LOW);


  }

  else if (temp > 25)
  {
    digitalWrite(RELAY1, 0);
    digitalWrite(RELAY2, 1);
    digitalWrite(red, LOW);
    digitalWrite(blue, HIGH);

    lcd.setCursor(0, 4);
    lcd.print("Cooling ");
    lcd.setCursor(0, 3);
    lcd.display();
  }
}

Here is the image for help!!

Thank you !!

2 (1).jpg

2 (1).jpg

It is not displaying anything!!

then start by getting your LCD to work. there is no point adding stuff until you get this right.

where did you get all the values in

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

it seems you have just an I2C display based on your picture.

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