Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Demo code for Grove - Temperature Sensor V1.1/1.2
- // Loovee @ 2015-8-26
- #include <Wire.h>
- #include <SeeedOLED.h>
- #include <math.h>
- const int B=4275; // B value of the thermistor
- const int R0 = 100000; // R0 = 100k
- const int pinTempSensor = A0; // Grove - Temperature Sensor connect to A5
- void setup()
- {
- Wire.begin();
- SeeedOled.init(); //initialze SEEED OLED display
- SeeedOled.clearDisplay(); //clear the screen and set start position to top left corner
- SeeedOled.setNormalDisplay(); //Set display to normal mode (i.e non-inverse mode)
- SeeedOled.setPageMode(); //Set addressing mode to Page Mode
- SeeedOled.setTextXY(0,0); //Set the cursor to Xth Page, Yth Column
- SeeedOled.putString("Temp:");
- Serial.begin(9600);
- }
- void loop()
- {
- int a = analogRead(pinTempSensor );
- float R = 1023.0/((float)a)-1.0;
- R = 100000.0*R;
- float temperature=1.0/(log(R/100000.0)/B+1/298.15)-273.15;//convert to temperature via datasheet ;
- SeeedOled.setTextXY(1,0); //Set the cursor to Xth Page, Yth Column
- SeeedOled.putNumber(temperature);
- Serial.print("temperature = ");
- Serial.println(temperature);
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement