[137] | 1 | /***************************************************
|
---|
| 2 | This is an example for the TMP007 Barometric Pressure & Temp Sensor
|
---|
| 3 |
|
---|
| 4 | Designed specifically to work with the Adafruit TMP007 Breakout
|
---|
| 5 | ----> https://www.adafruit.com/products/2023
|
---|
| 6 |
|
---|
| 7 | These displays use I2C to communicate, 2 pins are required to
|
---|
| 8 | interface
|
---|
| 9 | Adafruit invests time and resources providing this open source code,
|
---|
| 10 | please support Adafruit and open-source hardware by purchasing
|
---|
| 11 | products from Adafruit!
|
---|
| 12 |
|
---|
| 13 | Written by Limor Fried/Ladyada for Adafruit Industries.
|
---|
| 14 | BSD license, all text above must be included in any redistribution
|
---|
| 15 | ****************************************************/
|
---|
| 16 |
|
---|
| 17 | #include <Wire.h>
|
---|
| 18 | #include "Adafruit_TMP007.h"
|
---|
| 19 |
|
---|
| 20 | // Connect VCC to +3V (its a quieter supply than the 5V supply on an Arduino
|
---|
| 21 | // Gnd -> Gnd
|
---|
| 22 | // SCL connects to the I2C clock pin. On newer boards this is labeled with SCL
|
---|
| 23 | // otherwise, on the Uno, this is A5 on the Mega it is 21 and on the Leonardo/Micro digital 3
|
---|
| 24 | // SDA connects to the I2C data pin. On newer boards this is labeled with SDA
|
---|
| 25 | // otherwise, on the Uno, this is A4 on the Mega it is 20 and on the Leonardo/Micro digital 2
|
---|
| 26 |
|
---|
| 27 | Adafruit_TMP007 tmp007;
|
---|
| 28 | //Adafruit_TMP007 tmp007(0x41); // start with a diferent i2c address!
|
---|
| 29 |
|
---|
| 30 | void setup() {
|
---|
| 31 | Serial.begin(9600);
|
---|
| 32 | Serial.println("Adafruit TMP007 example");
|
---|
| 33 |
|
---|
| 34 | // you can also use tmp007.begin(TMP007_CFG_1SAMPLE) or 2SAMPLE/4SAMPLE/8SAMPLE to have
|
---|
| 35 | // lower precision, higher rate sampling. default is TMP007_CFG_16SAMPLE which takes
|
---|
| 36 | // 4 seconds per reading (16 samples)
|
---|
| 37 | if (! tmp007.begin()) {
|
---|
| 38 | Serial.println("No sensor found");
|
---|
| 39 | while (1);
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | void loop() {
|
---|
| 44 | float objt = tmp007.readObjTempC();
|
---|
| 45 | Serial.print("Object Temperature: "); Serial.print(objt); Serial.println("*C");
|
---|
| 46 | float diet = tmp007.readDieTempC();
|
---|
| 47 | Serial.print("Die Temperature: "); Serial.print(diet); Serial.println("*C");
|
---|
| 48 |
|
---|
| 49 | delay(4000); // 4 seconds per reading for 16 samples per reading
|
---|
| 50 | }
|
---|