Advertisement
Erfinator

2.39 C*, only reading i get

Jan 4th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. // An example to get started with the TMP006 temperature sensor
  2. //Modified by SparkFun Electronics.
  3. //We release this code under ([Beerware license](http://en.wikipedia.org/wiki/Beerware)).
  4.  
  5. /*Original Code license:
  6. > /***************************************************
  7. > This is a library for the TMP006 Temp Sensor
  8. >
  9. > Designed specifically to work with the Adafruit TMP006 Breakout
  10. > ----> https://www.adafruit.com/products/1296
  11. >
  12. > These displays use I2C to communicate, 2 pins are required to
  13. > interface
  14. > Adafruit invests time and resources providing this open source code,
  15. > please support Adafruit and open-source hardware by purchasing
  16. > products from Adafruit!
  17. >
  18. > Written by Limor Fried/Ladyada for Adafruit Industries.
  19. > BSD license, all text above must be included in any redistribution
  20. > ****************************************************/
  21.  
  22. // Only things needed to configure are the sensor address and
  23. // samples per reading, however the defaults work fine if using
  24. // just one TMP006 sensor. Check out the hook up guide tutorial
  25. // if you want a better explanation of the hardware and code.
  26.  
  27. #include <stdint.h>
  28. #include <math.h>
  29. #include <Wire.h>
  30. #include "I2C_16.h"
  31. #include "TMP006.h"
  32.  
  33. uint8_t sensor1 = 0x40; // I2C address of TMP006, can be 0x40-0x47
  34. uint16_t samples = TMP006_CFG_8SAMPLE; // # of samples per reading, can be 1/2/4/8/16
  35.  
  36. void setup()
  37. {
  38. Serial.begin(9600);
  39. Serial.println("TMP006 Example");
  40.  
  41. config_TMP006(sensor1, samples);
  42. }
  43.  
  44. void loop()
  45. {
  46. float object_temp = readObjTempC(sensor1);
  47. Serial.print("Object Temperature: ");
  48. Serial.print(object_temp); Serial.println("*C");
  49.  
  50. float sensor_temp = readDieTempC(sensor1);
  51. Serial.print("Sensor Temperature: ");
  52. Serial.print(sensor_temp); Serial.println("*C");
  53.  
  54. delay(2000); // delay 1 second for every 4 samples per reading
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement