Help with displaying temperature

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Help with displaying temperature

Post by Jed Hodson » Thu Apr 25, 2013 2:12 am

Hello
I am trying to display the temperature from a DHT 22 onto the freetronics DMD. But when I try to display the temperature it only comes up as text. Using Arduino IDE 1.0.1. Here is my code so far.

Code: Select all

#include <SPI.h> //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h> //
#include <TimerOne.h> //
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#include "DHT.h"

#define DHTPIN 3 
#define DHTTYPE DHT11 
DHT dht(DHTPIN, DHTTYPE);
//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 2 
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
int GND = 4;
int PWR = 2;

/*--------------------------------------------------------------------------------------
 Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
 called at the period set in Timer1.initialize();
 --------------------------------------------------------------------------------------*/
void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

/*--------------------------------------------------------------------------------------
 setup
 Called by the Arduino architecture before the main loop begins
 --------------------------------------------------------------------------------------*/
void setup(void)
{
  pinMode(GND, OUTPUT);
  pinMode(PWR, OUTPUT);
  digitalWrite(GND, LOW);
  digitalWrite(PWR, HIGH);
  dht.begin();
  //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()

  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)

}

/*--------------------------------------------------------------------------------------
 loop
 Arduino architecture main loop
 --------------------------------------------------------------------------------------*/
void loop(void){
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(t) || isnan(h)) {
      byte b;
      // display some text
    dmd.clearScreen( true );
    dmd.selectFont(System5x7);
    for (byte x=0;x<DISPLAYS_ACROSS;x++) {
      for (byte y=0;y<DISPLAYS_DOWN;y++) {
        dmd.drawString( 2+(32*x), 1+(16*y), "Fail", 4, GRAPHICS_NORMAL );
        dmd.drawString( 2+(32*x), 9+(16*y), "Read", 4, GRAPHICS_NORMAL );
      }
    }
  }
  else {

    byte b;


    // display some text
    dmd.clearScreen( true );
    dmd.selectFont(System5x7);
    for (byte x=0;x<DISPLAYS_ACROSS;x++) {
      for (byte y=0;y<DISPLAYS_DOWN;y++) {
        dmd.drawString( 2+(32*x), 1+(16*y), "TEMP", 4, GRAPHICS_NORMAL );
        dmd.drawString( 2+(32*x), 9+(16*y), "(t)", 5, GRAPHICS_NORMAL );
      }
    }
    delay(2000);
  } 
}
Any help appreciated.

Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Fri Apr 26, 2013 12:27 am

Do you mean I will have to add all the numbers and have the sketch find a matching pair?

Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Fri Apr 26, 2013 12:39 am

Thanks I will look at that now and try to make it suitable for the DHT22.

Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Fri Apr 26, 2013 1:20 am

Quick question. I need to know how to round the numbers from the DHT22 to the nearest 5. Please help.

Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Fri Apr 26, 2013 2:41 am

Thanks for that. Any idea on how to embed it into the nearly finished code
Here's a copy of it so far

Code: Select all

// for Freetronics DMD
#include <SPI.h>      
#include <DMD.h>      
#include <TimerOne.h> 
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#include "DHT.h"
#define DISPLAYS_ACROSS 1 // you could have more than one DMD in a row
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
#define DHTPIN 3// what pin we're connected to
int GND = 4;
int PWR = 2;

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);
String finalString; // used to hold final sentence to display on DMD

void ScanDMD() // required for DMD
{ 
  dmd.scanDisplayBySPI();
}

void setup()
{
  // for DMD
  Timer1.initialize( 5000 );
  Timer1.attachInterrupt( ScanDMD );   
  dmd.clearScreen(true);
  // for DHT22
  pinMode(GND, OUTPUT);
  pinMode(PWR, OUTPUT);
  digitalWrite(GND, LOW);
  digitalWrite(PWR, HIGH);
  dht.begin();

}


void drawText(String oldString) 
{


  dmd.clearScreen(true);
  dmd.selectFont(Arial_Black_16);
  char newString[256];
  int sLength = oldString.length();
  oldString.toCharArray(newString, sLength+1);
  dmd.drawMarquee(newString,sLength,(32*DISPLAYS_ACROSS)-1,0);
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while(!ret){
    if ((timer+20) < millis()) {
      ret=dmd.stepMarquee(-1,0);
      timer=millis();
    }
  }
}


void createTextTime()
// this mashes up all the ttemprature data into text 
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  finalString=" "; // wipe the sentence out for special cases (below)
  finalString=finalString+"It's ";

  // add the list
  if (t<=-10.50) { 
    finalString=finalString+"COLD "; 
  } 
  if (t==-10.00) { 
    finalString=finalString+"-10 "; 
  } 
  if (t==-9.50) { 
    finalString=finalString+"-9.5 "; 
  } 
  if (t==-9.00) { 
    finalString=finalString+"-9.0 "; 
  } 
  if (t==-8.50) { 
    finalString=finalString+"-8.5 "; 
  } 
  if (t==-8.00) { 
    finalString=finalString+"-8 "; 
  } 
  if (t==-7.50) { 
    finalString=finalString+"-7.5 "; 
  } 
  if (t==-7.00) { 
    finalString=finalString+"-7 "; 
  } 
  if (t==-6.50) { 
    finalString=finalString+"-6.5 "; 
  } 
  if (t==-6.00) { 
    finalString=finalString+"-6 "; 
  } 
  if (t==-5.50) { 
    finalString=finalString+"-5.5 "; 
  } 
  if (t==-4.50) { 
    finalString=finalString+"-4.5 "; 
  } 
  if (t==-4.00) { 
    finalString=finalString+"-4 "; 
  } 
  if (t==-3.50) { 
    finalString=finalString+"-3.5 "; 
  } 
  if (t==-3.00) { 
    finalString=finalString+"-3 "; 
  } 
  if (t==-2.50) { 
    finalString=finalString+"-2.5 "; 
  } 
  if (t==-2.00) { 
    finalString=finalString+"-2 "; 
  } 
  if (t==-1.50) { 
    finalString=finalString+"-1.5 "; 
  } 
  if (t==-1.00) { 
    finalString=finalString+"-1 "; 
  } 
  if (t==0.00) { 
    finalString=finalString+"0 "; 
  } 
  if (t==1.00) { 
    finalString=finalString+"1 "; 
  } 
  if (t==1.50) { 
    finalString=finalString+"1.5 "; 
  } 
  if (t==2.00) { 
    finalString=finalString+"2 "; 
  } 
  if (t==2.50) { 
    finalString=finalString+"2.5 "; 
  } 
  if (t==3.00) { 
    finalString=finalString+"3 "; 
  } 
  if (t==3.50) { 
    finalString=finalString+"3.5 "; 
  } 
  if (t==4.00) { 
    finalString=finalString+"4 "; 
  } 
  if (t==4.50) { 
    finalString=finalString+"4.5 "; 
  } 
  if (t==5.00) { 
    finalString=finalString+"5 "; 
  } 
  if (t==5.50) { 
    finalString=finalString+"5.5 "; 
  } 
  if (t==6.00) { 
    finalString=finalString+"6 "; 
  } 
  if (t==6.50) { 
    finalString=finalString+"6.5 "; 
  } 
  if (t==7.00) { 
    finalString=finalString+"7 "; 
  } 
  if (t==7.50) { 
    finalString=finalString+"7.5 "; 
  } 
  if (t==8.00) { 
    finalString=finalString+"8 "; 
  } 
  if (t==8.50) { 
    finalString=finalString+"8.5 "; 
  } 
  if (t==9.00) { 
    finalString=finalString+"9 "; 
  } 
  if (t==9.50) { 
    finalString=finalString+"9.5 "; 
  } 
  if (t==10.00) { 
    finalString=finalString+"10 "; 
  } 
  if (t==10.50) { 
    finalString=finalString+"10.5 "; 
  } 
  if (t==11.00) { 
    finalString=finalString+"11 "; 
  } 
  if (t==11.50) { 
    finalString=finalString+"11.5 "; 
  } 
  if (t==12.00) { 
    finalString=finalString+"12 "; 
  } 
  if (t==12.50) { 
    finalString=finalString+"12.5 "; 
  } 
  if (t==13.00) { 
    finalString=finalString+"13 "; 
  } 
  if (t==13.50) { 
    finalString=finalString+"13.5 "; 
  } 
  if (t==14.00) { 
    finalString=finalString+"14 "; 
  } 
  if (t==14.50) { 
    finalString=finalString+"14.5 "; 
  } 
  if (t==15.00) { 
    finalString=finalString+"15 "; 
  } 
  if (t==15.50) { 
    finalString=finalString+"15.5 "; 
  } 
  if (t==16.00) { 
    finalString=finalString+"16 "; 
  } 
  if (t==16.50) { 
    finalString=finalString+"16.5 "; 
  } 
  if (t==17.00) { 
    finalString=finalString+"17 "; 
  } 
  if (t==17.50) { 
    finalString=finalString+"17.5 "; 
  } 
  if (t==18.00) { 
    finalString=finalString+"18 "; 
  } 
  if (t==18.50) { 
    finalString=finalString+"18.5 "; 
  } 
  if (t==19.00) { 
    finalString=finalString+"19 "; 
  } 
  if (t==19.50) { 
    finalString=finalString+"19.5 "; 
  } 
  if (t==20.00) { 
    finalString=finalString+"20 "; 
  } 
  if (t==20.50) { 
    finalString=finalString+"20.5 "; 
  } 
  if (t==21.00) { 
    finalString=finalString+"21 "; 
  } 
  if (t==21.50) { 
    finalString=finalString+"21.5 "; 
  } 
  if (t==22.00) { 
    finalString=finalString+"22 "; 
  }

  if (t==22.50) { 
    finalString=finalString+"22.5 "; 
  } 
  if (t==23.00) { 
    finalString=finalString+"23 "; 
  } 
  if (t==23.50) { 
    finalString=finalString+"23.5 "; 
  } 
  if (t==24.00) { 
    finalString=finalString+"24 "; 
  } 
  if (t==24.50) { 
    finalString=finalString+"24.5 "; 
  } 
  if (t==25.00) { 
    finalString=finalString+"25 "; 
  } 
  if (t==25.50) { 
    finalString=finalString+"25.5 "; 
  } 
  if (t==26.00) { 
    finalString=finalString+"26 "; 
  } 
  if (t==26.50) { 
    finalString=finalString+"26.5 "; 
  } 
  if (t==27.00) { 
    finalString=finalString+"27 "; 
  } 
  if (t==27.50) { 
    finalString=finalString+"27.5 "; 
  } 
  if (t==28.00) { 
    finalString=finalString+"28 "; 
  } 
  if (t==28.50) { 
    finalString=finalString+"28.5 "; 
  } 
  if (t==29.00) { 
    finalString=finalString+"29 "; 
  } 
  if (t==29.50) { 
    finalString=finalString+"29.5 "; 
  } 
  if (t==30.00) { 
    finalString=finalString+"30 "; 
  } 
  if (t==30.50) { 
    finalString=finalString+"30.5 "; 
  } 
  if (t==31.00) { 
    finalString=finalString+"31 "; 
  } 
  if (t==31.50) { 
    finalString=finalString+"31.5 "; 
  } 
  if (t==32.00) { 
    finalString=finalString+"32 "; 
  } 
  if (t==32.50) { 
    finalString=finalString+"32.5 "; 
  } 
  if (t==33.00) { 
    finalString=finalString+"33 "; 
  } 
  if (t==33.50) { 
    finalString=finalString+"33.5 "; 
  } 
  if (t==34.00) { 
    finalString=finalString+"34 "; 
  } 
  if (t==34.50) { 
    finalString=finalString+"34.5 "; 
  } 
  if (t==35.00) { 
    finalString=finalString+"35 "; 
  } 
  if (t==35.50) { 
    finalString=finalString+"35.5 "; 
  } 
  if (t==36.00) { 
    finalString=finalString+"36 "; 
  } 
  if (t==36.50) { 
    finalString=finalString+"36.5 "; 
  } 
  if (t==37.00) { 
    finalString=finalString+"37 "; 
  } 
  if (t==37.50) { 
    finalString=finalString+"37.5 "; 
  } 
  if (t==38.00) { 
    finalString=finalString+"38 "; 
  } 
  if (t==38.50) { 
    finalString=finalString+"38.5 "; 
  } 
  if (t==39.00) { 
    finalString=finalString+"39 "; 
  } 
  if (t==39.50) { 
    finalString=finalString+"39.5 "; 
  } 
  if (t==40.00) { 
    finalString=finalString+"40 "; 
  } 
  if (t==40.50) { 
    finalString=finalString+"40.5 "; 
  } 
  if (t==41.00) { 
    finalString=finalString+"41 "; 
  } 
  if (t==41.50) { 
    finalString=finalString+"41.5 "; 
  } 
  if (t==42.00) { 
    finalString=finalString+"42 "; 
  } 
  if (t==42.50) { 
    finalString=finalString+"42.5 "; 
  } 
  if (t==43.00) { 
    finalString=finalString+"43 "; 
  } 
  if (t==43.50) { 
    finalString=finalString+"43.5 "; 
  } 
  if (t==44.00) { 
    finalString=finalString+"44 "; 
  } 
  if (t==44.50) { 
    finalString=finalString+"44.5 "; 
  } 
  if (t==45.00) { 
    finalString=finalString+"45 "; 
  } 
  if (t==45.50) { 
    finalString=finalString+"45.5 "; 
  } 
  if (t==46.00) { 
    finalString=finalString+"46 "; 
  } 
  if (t==46.50) { 
    finalString=finalString+"46.5 "; 
  } 
  if (t==47.00) { 
    finalString=finalString+"47 "; 
  } 
  if (t==47.50) { 
    finalString=finalString+"47.5 "; 
  } 
  if (t==48.00) { 
    finalString=finalString+"48 "; 
  } 
  if (t==48.50) { 
    finalString=finalString+"48.5 "; 
  } 
  if (t==49.00) { 
    finalString=finalString+"49 "; 
  } 
  if (t==49.50) { 
    finalString=finalString+"49.5 "; 
  } 
  if (t==50.00) { 
    finalString=finalString+"50 "; 
  } 
  if (t==50.50) { 
    finalString=finalString+"50.5 "; 
  } 
  if (t==51.00) { 
    finalString=finalString+"51 "; 
  } 
  if (t==51.50) { 
    finalString=finalString+"51.5 "; 
  } 
  if (t==52.00) { 
    finalString=finalString+"52 "; 
  } 
  if (t==52.50) { 
    finalString=finalString+"52.5 "; 
  } 
  if (t==53.00) { 
    finalString=finalString+"53 "; 
  } 
  if (t==53.50) { 
    finalString=finalString+"53.5 "; 
  } 
  if (t==54.00) { 
    finalString=finalString+"54 "; 
  } 
  if (t==54.50) { 
    finalString=finalString+"54.5 "; 
  } 
  if (t==55.00) { 
    finalString=finalString+"55 "; 
  } 
  if (t==55.50) { 
    finalString=finalString+"55.5 "; 
  } 
  if (t>=55.50) { 
    finalString=finalString+"HOT "; 
  } 

}

void loop()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(t) || isnan(h)) {
    byte b;
    // display some text
    dmd.clearScreen( true );
    dmd.selectFont(System5x7);
    for (byte x=0;x<DISPLAYS_ACROSS;x++) {
      for (byte y=0;y<DISPLAYS_DOWN;y++) {
        dmd.drawString( 2+(32*x), 1+(16*y), "Fail", 4, GRAPHICS_NORMAL );
        dmd.drawString( 2+(32*x), 9+(16*y), "Read", 4, GRAPHICS_NORMAL );
      }
    }
  }
  // now send the text to the DMD
  drawText(finalString);
}











Thanks

Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Fri Apr 26, 2013 3:48 am

For my code I need to round numbers to nearest half. e.g. 23.10 = 23.00, 1.50 = 1.50, etc.
Help

Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Sat Apr 27, 2013 12:11 am

Thanks for that. What about numbers below zero?
Thanks


Jed

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Sat Apr 27, 2013 5:14 am

Ok, I have finished my code but when I to test it all it did was flash the DMD briefly. I don't know what I did wrong. Anyway here's the code. It was only running on USB.

Code: Select all

//DMD Temperature id the combination of a freetronics DMD + DHT22 + eleven to display a
//scrolling message with temperature. Compatible with DHT22, DHT21, DHT11.
//By Jed Hodson 2013
//for Freetronics DMD and DHT22
#include <SPI.h>      
#include <DMD.h>      
#include <TimerOne.h> 
#include "SystemFont5x7.h"
#include "Arial_black_16.h"
#include "DHT.h"
#define DISPLAYS_ACROSS 1 // you could have more than one DMD in a row
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
#define DHTPIN 3// what pin we're connected to
int GND = 4;
int PWR = 2;

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);
String finalString; // used to hold final sentence to display on DMD

void ScanDMD() // required for DMD
{ 
  dmd.scanDisplayBySPI();
}

void setup()
{
  // for DMD
  Timer1.initialize( 5000 );
  Timer1.attachInterrupt( ScanDMD );   
  dmd.clearScreen(true);
  // for DHT22
  pinMode(GND, OUTPUT);
  pinMode(PWR, OUTPUT);
  digitalWrite(GND, LOW);
  digitalWrite(PWR, HIGH);
  dht.begin();

}

int round5(float n)
{
  float a;
  int b;
  a = ((n/0.50)+0.5);
  b = int (a);
  b = b * 0.50;
  return b;
}

float a=dht.readTemperature(); //23.00
int t;


void drawText(String oldString) 
{
  //Clear the panel
  dmd.clearScreen(true);
  //Select font
  //dmd.selectFont(System5x7);
  dmd.selectFont(Arial_Black_16);
  char newString[256];
  int sLength = oldString.length();
  oldString.toCharArray(newString, sLength+1);
  dmd.drawMarquee(newString,sLength,(32*DISPLAYS_ACROSS)-1,0);
  long start=millis();
  long timer=start;
  long timer2=start;
  boolean ret=false;
  while(!ret){
    if ((timer+40) < millis()) {  //Select speed
      ret=dmd.stepMarquee(-1,0);
      timer=millis();
    }
  }
}


void createTextTime()
// this mashes up all the temprature data into text 
{
  float h = dht.readHumidity();
  float e = dht.readTemperature();
  t=round5(a); //round numbers
  finalString=" "; // wipe the sentence out for special cases (below)
  finalString=finalString+"It's ";

  // add the list of numbers from -10.50 to 55.50
  if (t<=-10.50) { 
    finalString=finalString+"COLD "; 
  } 
  if (t==-10.00) { 
    finalString=finalString+"-10 "; 
  } 
  if (t==-9.50) { 
    finalString=finalString+"-9.5 "; 
  } 
  if (t==-9.00) { 
    finalString=finalString+"-9.0 "; 
  } 
  if (t==-8.50) { 
    finalString=finalString+"-8.5 "; 
  } 
  if (t==-8.00) { 
    finalString=finalString+"-8 "; 
  } 
  if (t==-7.50) { 
    finalString=finalString+"-7.5 "; 
  } 
  if (t==-7.00) { 
    finalString=finalString+"-7 "; 
  } 
  if (t==-6.50) { 
    finalString=finalString+"-6.5 "; 
  } 
  if (t==-6.00) { 
    finalString=finalString+"-6 "; 
  } 
  if (t==-5.50) { 
    finalString=finalString+"-5.5 "; 
  } 
  if (t==-4.50) { 
    finalString=finalString+"-4.5 "; 
  } 
  if (t==-4.00) { 
    finalString=finalString+"-4 "; 
  } 
  if (t==-3.50) { 
    finalString=finalString+"-3.5 "; 
  } 
  if (t==-3.00) { 
    finalString=finalString+"-3 "; 
  } 
  if (t==-2.50) { 
    finalString=finalString+"-2.5 "; 
  } 
  if (t==-2.00) { 
    finalString=finalString+"-2 "; 
  } 
  if (t==-1.50) { 
    finalString=finalString+"-1.5 "; 
  } 
  if (t==-1.00) { 
    finalString=finalString+"-1 "; 
  } 
  if (t==0.00) { 
    finalString=finalString+"0 "; 
  } 
  if (t==0.50) { 
    finalString=finalString+"0.5 "; 
  } 
  if (t==1.00) { 
    finalString=finalString+"1 "; 
  } 
  if (t==1.50) { 
    finalString=finalString+"1.5 "; 
  } 
  if (t==2.00) { 
    finalString=finalString+"2 "; 
  } 
  if (t==2.50) { 
    finalString=finalString+"2.5 "; 
  } 
  if (t==3.00) { 
    finalString=finalString+"3 "; 
  } 
  if (t==3.50) { 
    finalString=finalString+"3.5 "; 
  } 
  if (t==4.00) { 
    finalString=finalString+"4 "; 
  } 
  if (t==4.50) { 
    finalString=finalString+"4.5 "; 
  } 
  if (t==5.00) { 
    finalString=finalString+"5 "; 
  } 
  if (t==5.50) { 
    finalString=finalString+"5.5 "; 
  } 
  if (t==6.00) { 
    finalString=finalString+"6 "; 
  } 
  if (t==6.50) { 
    finalString=finalString+"6.5 "; 
  } 
  if (t==7.00) { 
    finalString=finalString+"7 "; 
  } 
  if (t==7.50) { 
    finalString=finalString+"7.5 "; 
  } 
  if (t==8.00) { 
    finalString=finalString+"8 "; 
  } 
  if (t==8.50) { 
    finalString=finalString+"8.5 "; 
  } 
  if (t==9.00) { 
    finalString=finalString+"9 "; 
  } 
  if (t==9.50) { 
    finalString=finalString+"9.5 "; 
  } 
  if (t==10.00) { 
    finalString=finalString+"10 "; 
  } 
  if (t==10.50) { 
    finalString=finalString+"10.5 "; 
  } 
  if (t==11.00) { 
    finalString=finalString+"11 "; 
  } 
  if (t==11.50) { 
    finalString=finalString+"11.5 "; 
  } 
  if (t==12.00) { 
    finalString=finalString+"12 "; 
  } 
  if (t==12.50) { 
    finalString=finalString+"12.5 "; 
  } 
  if (t==13.00) { 
    finalString=finalString+"13 "; 
  } 
  if (t==13.50) { 
    finalString=finalString+"13.5 "; 
  } 
  if (t==14.00) { 
    finalString=finalString+"14 "; 
  } 
  if (t==14.50) { 
    finalString=finalString+"14.5 "; 
  } 
  if (t==15.00) { 
    finalString=finalString+"15 "; 
  } 
  if (t==15.50) { 
    finalString=finalString+"15.5 "; 
  } 
  if (t==16.00) { 
    finalString=finalString+"16 "; 
  } 
  if (t==16.50) { 
    finalString=finalString+"16.5 "; 
  } 
  if (t==17.00) { 
    finalString=finalString+"17 "; 
  } 
  if (t==17.50) { 
    finalString=finalString+"17.5 "; 
  } 
  if (t==18.00) { 
    finalString=finalString+"18 "; 
  } 
  if (t==18.50) { 
    finalString=finalString+"18.5 "; 
  } 
  if (t==19.00) { 
    finalString=finalString+"19 "; 
  } 
  if (t==19.50) { 
    finalString=finalString+"19.5 "; 
  } 
  if (t==20.00) { 
    finalString=finalString+"20 "; 
  } 
  if (t==20.50) { 
    finalString=finalString+"20.5 "; 
  } 
  if (t==21.00) { 
    finalString=finalString+"21 "; 
  } 
  if (t==21.50) { 
    finalString=finalString+"21.5 "; 
  } 
  if (t==22.00) { 
    finalString=finalString+"22 "; 
  }

  if (t==22.50) { 
    finalString=finalString+"22.5 "; 
  } 
  if (t==23.00) { 
    finalString=finalString+"23 "; 
  } 
  if (t==23.50) { 
    finalString=finalString+"23.5 "; 
  } 
  if (t==24.00) { 
    finalString=finalString+"24 "; 
  } 
  if (t==24.50) { 
    finalString=finalString+"24.5 "; 
  } 
  if (t==25.00) { 
    finalString=finalString+"25 "; 
  } 
  if (t==25.50) { 
    finalString=finalString+"25.5 "; 
  } 
  if (t==26.00) { 
    finalString=finalString+"26 "; 
  } 
  if (t==26.50) { 
    finalString=finalString+"26.5 "; 
  } 
  if (t==27.00) { 
    finalString=finalString+"27 "; 
  } 
  if (t==27.50) { 
    finalString=finalString+"27.5 "; 
  } 
  if (t==28.00) { 
    finalString=finalString+"28 "; 
  } 
  if (t==28.50) { 
    finalString=finalString+"28.5 "; 
  } 
  if (t==29.00) { 
    finalString=finalString+"29 "; 
  } 
  if (t==29.50) { 
    finalString=finalString+"29.5 "; 
  } 
  if (t==30.00) { 
    finalString=finalString+"30 "; 
  } 
  if (t==30.50) { 
    finalString=finalString+"30.5 "; 
  } 
  if (t==31.00) { 
    finalString=finalString+"31 "; 
  } 
  if (t==31.50) { 
    finalString=finalString+"31.5 "; 
  } 
  if (t==32.00) { 
    finalString=finalString+"32 "; 
  } 
  if (t==32.50) { 
    finalString=finalString+"32.5 "; 
  } 
  if (t==33.00) { 
    finalString=finalString+"33 "; 
  } 
  if (t==33.50) { 
    finalString=finalString+"33.5 "; 
  } 
  if (t==34.00) { 
    finalString=finalString+"34 "; 
  } 
  if (t==34.50) { 
    finalString=finalString+"34.5 "; 
  } 
  if (t==35.00) { 
    finalString=finalString+"35 "; 
  } 
  if (t==35.50) { 
    finalString=finalString+"35.5 "; 
  } 
  if (t==36.00) { 
    finalString=finalString+"36 "; 
  } 
  if (t==36.50) { 
    finalString=finalString+"36.5 "; 
  } 
  if (t==37.00) { 
    finalString=finalString+"37 "; 
  } 
  if (t==37.50) { 
    finalString=finalString+"37.5 "; 
  } 
  if (t==38.00) { 
    finalString=finalString+"38 "; 
  } 
  if (t==38.50) { 
    finalString=finalString+"38.5 "; 
  } 
  if (t==39.00) { 
    finalString=finalString+"39 "; 
  } 
  if (t==39.50) { 
    finalString=finalString+"39.5 "; 
  } 
  if (t==40.00) { 
    finalString=finalString+"40 "; 
  } 
  if (t==40.50) { 
    finalString=finalString+"40.5 "; 
  } 
  if (t==41.00) { 
    finalString=finalString+"41 "; 
  } 
  if (t==41.50) { 
    finalString=finalString+"41.5 "; 
  } 
  if (t==42.00) { 
    finalString=finalString+"42 "; 
  } 
  if (t==42.50) { 
    finalString=finalString+"42.5 "; 
  } 
  if (t==43.00) { 
    finalString=finalString+"43 "; 
  } 
  if (t==43.50) { 
    finalString=finalString+"43.5 "; 
  } 
  if (t==44.00) { 
    finalString=finalString+"44 "; 
  } 
  if (t==44.50) { 
    finalString=finalString+"44.5 "; 
  } 
  if (t==45.00) { 
    finalString=finalString+"45 "; 
  } 
  if (t==45.50) { 
    finalString=finalString+"45.5 "; 
  } 
  if (t==46.00) { 
    finalString=finalString+"46 "; 
  } 
  if (t==46.50) { 
    finalString=finalString+"46.5 "; 
  } 
  if (t==47.00) { 
    finalString=finalString+"47 "; 
  } 
  if (t==47.50) { 
    finalString=finalString+"47.5 "; 
  } 
  if (t==48.00) { 
    finalString=finalString+"48 "; 
  } 
  if (t==48.50) { 
    finalString=finalString+"48.5 "; 
  } 
  if (t==49.00) { 
    finalString=finalString+"49 "; 
  } 
  if (t==49.50) { 
    finalString=finalString+"49.5 "; 
  } 
  if (t==50.00) { 
    finalString=finalString+"50 "; 
  } 
  if (t==50.50) { 
    finalString=finalString+"50.5 "; 
  } 
  if (t==51.00) { 
    finalString=finalString+"51 "; 
  } 
  if (t==51.50) { 
    finalString=finalString+"51.5 "; 
  } 
  if (t==52.00) { 
    finalString=finalString+"52 "; 
  } 
  if (t==52.50) { 
    finalString=finalString+"52.5 "; 
  } 
  if (t==53.00) { 
    finalString=finalString+"53 "; 
  } 
  if (t==53.50) { 
    finalString=finalString+"53.5 "; 
  } 
  if (t==54.00) { 
    finalString=finalString+"54 "; 
  } 
  if (t==54.50) { 
    finalString=finalString+"54.5 "; 
  } 
  if (t==55.00) { 
    finalString=finalString+"55 "; 
  } 
  if (t==55.50) { 
    finalString=finalString+"55.5 "; 
  } 
  if (t>=55.50) { 
    finalString=finalString+"HOT "; 
  } 
  finalString=finalString+"*C ";

}

void loop()
{
  float h = dht.readHumidity();
  float e = dht.readTemperature();
  if (isnan(e) || isnan(h)) {
    byte b;
    // display some text
    dmd.clearScreen( true );
    dmd.selectFont(System5x7);
    for (byte x=0;x<DISPLAYS_ACROSS;x++) {
      for (byte y=0;y<DISPLAYS_DOWN;y++) {
        dmd.drawString( 2+(32*x), 1+(16*y), "Fail", 4, GRAPHICS_NORMAL );
        dmd.drawString( 2+(32*x), 9+(16*y), "Read", 4, GRAPHICS_NORMAL );
      }
    }
  }
  else {
    createTextTime(); 
    // now send the text to the DMD
    drawText(finalString);
    delay(2000);
  }
}
















Anyone know what I am doing wrong, if so can you please help :( :(

Jed Hodson
Posts: 71
Joined: Wed Apr 24, 2013 5:14 am
Location: New South Wales, Australia

Re: Help with displaying temprature

Post by Jed Hodson » Sun Apr 28, 2013 4:01 am

Thanks for that, It works like a charm. ;)


Jed

Post Reply