chipKIT® Development Platform

Inspired by Arduino™

Temp on OLED display

Created Fri, 06 Jul 2012 15:12:34 +0000 by Gromak123


Gromak123

Fri, 06 Jul 2012 15:12:34 +0000

Hi i have bought a new chipkit and i have try to show temperature on the oled display ;) my configuration is A chipkit max 32 in the midlle a network shield and on the top basic i/o shield ,i have just send this code

/* Note: For chipKit Max users you must manually
** connect SDA and SCL pins(20 and 21) to pins A4 and A5 of
** IO Shield
**
** Note: For chipKit Uno Users you must have Jumpers JP6 and JP8
** set in the RG3 and RG2 positions
**
** This example also checks the status of the Alert pin. Normally this
** could be used to send some information to an external device, but
** for this example it's just checked when we check the tempereture.
** to use this part of the example connect the A pin on header JP4
** to pin 2 on your ChipKit board.
**
*/

#include <IOShieldTemp.h>
#include <IOShieldOled.h>
#include <Wire.h>

#define ALERT_PIN 2

void setup()
{
  Serial.begin(9600);
  pinMode(ALERT_PIN, INPUT); 
  //Initialize Configuration register for oneshot with 11 bit
  //resolution
  IOShieldTemp.config(IOSHIELDTEMP_ONESHOT | IOSHIELDTEMP_RES11 | IOSHIELDTEMP_ALERTHIGH);
 
  //Set the range to bring the alert pin high if it's above 78F (25.5C), alert will stay
  //high until the temp drops below 75.2F (24C).
  IOShieldTemp.setTempLimit(IOShieldTemp.convFtoC(78)); // 78.0F ~ 25.5C
  IOShieldTemp.setTempHyst(24); // 75.2F ~ 24.0C
 
  //Setup Display
  IOShieldOled.begin();
  IOShieldOled.setCharUpdate(0); //Turn automatic updating off (removes flickering)
}

void loop()
{
  float tempF, tempC;
 
  //Get Temperature in Celsius.
  tempC = IOShieldTemp.getTemp();
 
  // Convert the result to Fahrenheit.
  tempF = IOShieldTemp.convCtoF(tempC);

  //Print Temperature to serial port
  Serial.print(tempC);
  Serial.print(" C, ");
  Serial.print(tempF);
  Serial.print(" F");
  if(digitalRead(ALERT_PIN) == HIGH)
    Serial.print(" ALERT!");
  Serial.println();
 
 
  //Print Temperature on Display
  IOShieldOled.clearBuffer();
 
  //Celsius 
  String temperature_str = "TempC:";
  temperature_str += tempC;
  char temperature_chr[temperature_str.length()+1]; //create char buffer
  temperature_str.toCharArray(temperature_chr, temperature_str.length()+1); //convert to char
  IOShieldOled.setCursor(0, 0);
  IOShieldOled.putString(temperature_chr);
 
  //Fahrenheit
  String temperature2_str = "TempF:";
  temperature2_str += tempF;
  char temperature2_chr[temperature2_str.length()+1]; //create char buffer
  temperature2_str.toCharArray(temperature2_chr, temperature2_str.length()+1); //convert to char
  IOShieldOled.setCursor(0, 1);
  IOShieldOled.putString(temperature2_chr);

  IOShieldOled.updateDisplay();

  delay(1000); 
}

But on my oled temperature in C are always 0 and TempF : 32

Can you help me ?

Thank you :ugeek:


JordanR

Fri, 06 Jul 2012 16:57:13 +0000

Hello Gromak123,

Have you connected pins 20 and 21 on the Network Shield to pins A4 and A5, respectively, on the Basic IO Shield?

getTemp() will return 0 degrees celsius if the shields are not connected properly.

JordanR, Digilent


Gromak123

Fri, 06 Jul 2012 17:23:32 +0000

Ohh Thank you :D i think its the probleme but how i can do that :roll: ( i think its a noob question >.<)

Thank you !


Gromak123

Sat, 07 Jul 2012 13:32:18 +0000

Anybody have a picture or a video for showing me HOW i can connecte pins 20 and 21 on the Network Shield to pins A4 and A5, respectively, on Please :D

Thank You !