oled.init()  #initialze SEEED OLED display

oled.clearDisplay()          #clear the screen and set start position to top left corner
oled.setNormalDisplay()      #Set display to normal mode (i.e non-inverse mode)
oled.setPageMode()           #Set addressing mode to Page Mode

oldTemp = -1
oled.setTextXY(0,0)
oled.putString("Temperature") #Print the String

jetduino.setAnalogReadResolution(10)

while True:
    try:
        celsius = jetduino.temp(sensor,'1.2')

        #if the temp changes write it out to the screen.
        if celsius > 0 and math.fabs(oldTemp - celsius) > 0.01: 
            print ("temp =", celsius)
            fahrenheit = (celsius * 1.8) + 32
            oled.setTextXY(0,1)
            oled.putString("%3.3f C" % celsius) #Print the String
            oled.setTextXY(0,2)
            oled.putString("%3.3f F" % fahrenheit) #Print the String
            oldTemp = celsius
            time.sleep(.5)

    except KeyboardInterrupt:
        break
    except IOError:
# 	The sensor uses a thermistor to detect ambient temperature.
# 	The resistance of a thermistor will increase when the ambient temperature decreases.
#	
# 	There are 3 revisions 1.0, 1.1 and 1.2, each using a different model thermistor.
# 	Each thermistor datasheet specifies a unique Nominal B-Constant which is used in the calculation forumla.
#	
# 	The second argument in the jetduino.temp() method defines which board version you have connected.
# 	Defaults to '1.0'. eg.
# 		temp = jetduino.temp(sensor)        # B value = 3975
# 		temp = jetduino.temp(sensor,'1.1')  # B value = 4250
# 		temp = jetduino.temp(sensor,'1.2')  # B value = 4250

import time
import jetduino
from jetduino_pins import *

# Connect the Grove Temperature Sensor to analog port A0
# SIG,NC,VCC,GND
sensor = ARD_A0

while True:
    try:
        temp = jetduino.temp(sensor,'1.2')
        print ("temp =", temp)
        time.sleep(.5)

    except KeyboardInterrupt:
        break
    except IOError:
        print ("Error")