top of page

7. 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.

First download the following zip file:

http://www.seeedstudio.com/wiki/File:LCD_Display9696_Library.zip

Unzip it into the libraries file in the Arduino folder that is found in my documents after the application is installed:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Required components:

SODAQ Moja

0.5W Solar Panel

1aH battery pack

Grove - Temperature Sensor

Grove - OLED 0.96"x0.96" Display

2x Grove w/o Buckle Cable (any length)

 

Plug the displayinto the SDA SCL pin in the always on (not switched) row.

Next, place the grove temperature sensor into the A0 A1 in the always on row. Plug the 0.5W solar panel and the 1A LiPo battery into the respective sockets (see http://www.sodaq.net/#!getting-started/c21ma for a board diagram)

 

Turn on the SODAQ board, compile and upload the following sketch from the arduino IDE onto the SODAQ Board, and then unplug the USB cable from the computer when it is working:

#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);

 

}

© 2013 SODAQ. All rights reserved.

  • Facebook Classic
  • Twitter Classic
bottom of page