Ollie Smeenk
Published

Using the OLED Screen to display a temperature

In this tutorial you will learn how to print data onto an OLED Screen, and how to read values from a digital thermometer.

Full instructions provided2,242
Using the OLED Screen to display a temperature

Things used in this project

Hardware components

0.5W Solar Panel
×1
SODAQ Moja
×1
1aH battery pack
×1
Grove - Temperature Sensor
×1
Grove - OLED 0.96"x0.96" Display
×1
Grove w/o Buckle Cable (any length)
×2

Story

Read more

Code

code.c

C/C++
code.c
#include <wire.h>
#include  <SeeedGrayOLED.h>
#include  <avr/pgmspace.h>
#include  <math.h>
int a;
float temperature;
int B=3975; //B value of the thermistor
float resistance;
 
void setup()
{
 Wire.begin();
 SeeedGrayOled.init(); //initialize SEEED OLED display
 SeeedGrayOled.clearDisplay(); //Clear Display.
 SeeedGrayOled.setNormalDisplay();
   //Set Normal Display Mode
 SeeedGrayOled.setVerticalMode();
   //Set addressing mode to Page Mode
 
 for(char i=0; i < 12 ; i++);
}
 
void loop()
 
{
 
 SeeedGrayOled.setTextXY(0,0);
   //Set the cursor to Xth Page, Yth Column
 SeeedGrayOled.putString("Temp (oC):");
   //Print the String
 SeeedGrayOled.putNumber(temperature);
 a=analogRead(0);
 resistance=(float)(1023-a)*10000/a;
   //get the resistance of the sensor
 temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
   //convert to temperature via datasheet
 
 delay(1000);
 
}

Credits

Ollie Smeenk

Ollie Smeenk

8 projects • 6 followers
Business-oriented Tinkerer! Ready to engage in any project for- and not for profit!

Comments