How can we get data of temperature sensor with centigrade unite

`#include <DHT.h>
#include <DHT_U.h>

#include "SevSeg.h"
#include "DHT.h"
#define DHTPIN 2 
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
char chars = 'C';
SevSeg sevseg; //Instantiate a seven segment controller object

void setup() {
  byte numDigits = 4;
  byte digitPins[] = {50, 51, 52 ,53};
  byte segmentPins[] = {1, 3, 5, 6, 7, 8, 9, 11}; //6, 7, 8, 9, 10, 11, 12, 13
  
  bool resistorsOnSegments = true; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_CATHODE; // See README.md for options
  bool updateWithDelays = false; // Default 'false' is Recommended
  bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
  bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected
  
  dht.begin();
 
  
  sevseg.begin(hardwareConfig, numDigits, digitPins,segmentPins, resistorsOnSegments,
  updateWithDelays, disableDecPoint, leadingZeros );
  
  sevseg.setBrightness(200);
}

void loop() { 
    
  static unsigned long timer = millis();
  static int deciSeconds = 0;
  

  //float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
 
  // Read temperature as Fahrenheit (isFahrenheit = true)
//  float f = dht.readTemperature(true);
  
  if (millis() - timer >= 100)
  {
    timer += 100;
    sevseg.setNumber(t*100,1);
     sevseg.setChars(chars);
  }
 
  sevseg.refreshDisplay();
  
  //Serial.println(t);
}`

and is there possibility to shift a character on particular digit of 7 segment.

According to the DHT library, passing true or false as a parameter to the readTemperature function returns a temperature in F or C respectively. Your code comments appear to indicate this.

I'm not sure I understand this. Can you explain in a different way?

Hi, @piyoosh
Welcome to the forum.

What model Arduino are you using?
What is the problem?

Have you tried the example code with the DHT library to prove your input circuit is working.
If not, then , for the moment just use some code to read the DHT.

Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Actually i want to print temperature on 4 digit 7 segment display and I have been found temperature but i want centigrade unit on 4th number digit of 7 segment.

I am using ATmega 2560 pro.
problem is that i want to use centigrade unit with temperature but i failed and i am using sevseg library.

Check your display hardware and the library you are using. They may support hexadecimal digits so you can set it to C or F.

1 Like

Hi,

There may be example code giving you the command to read Celsius.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

I've not used the sevseg library. Looking at the github page for it, when you call sevseg.setNumber with a 3 digit number such as 341 - which I'm guessing is a function call like sevseg.setNumber(341,0), is the 3 digit number left justified or right justified?

If it's left justified, then you may be able to call sevseg.setSegmentsDigit(3, XXXX), where XXXX is the bit pattern to create an F or a C (or c). See the actual library you are using as the github page suggests that the bit patterns for several characters are already pre-defined for you.

i have already tried.

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