Skip to content

Commit edbe014

Browse files
authored
Merge pull request #202 from sparkfun/release_candidate
v2.9 - adds support for the TMP102 - thank you @summetj
2 parents 43f6df6 + aab0c96 commit edbe014

10 files changed

+182
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Change Log
22
======================
3+
v2.9:
4+
* Adds support for the TMP102 temperature sensor
35

46
v2.8:
57
---------

COMPILE_BINARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Copy and paste the following into an empty sketch. Click on each link in turn to
5252
// http://librarymanager/All#SparkFun_SGP30
5353
// http://librarymanager/All#SparkFun_VCNL4040
5454
// http://librarymanager/All#SparkFun_MS5637
55+
// http://librarymanager/All#SparkFun_TMP102
5556
// http://librarymanager/All#SparkFun_TMP117
5657
// http://librarymanager/All#SparkFun_u-blox_GNSS
5758
// http://librarymanager/All#SparkFun_NAU7802

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
(done) Add a fix for issue #109 - check if a BME280 is connected before calling multiplexerBegin: https://github.com/sparkfun/OpenLog_Artemis/issues/109
109109
(done) Correct issue #104. enableSD was redundant. The microSD power always needs to be on if there is a card inserted, otherwise the card pulls
110110
the SPI lines low, preventing communication with the IMU: https://github.com/sparkfun/OpenLog_Artemis/issues/104
111+
(done) Add support for TMP102 temperature sensor (while differentating between it and the ADS1015 (which share the same 4 addresses starting at 0x48)
111112
112113
v2.2:
113114
Use Apollo3 v2.2.1 with changes by paulvha to fix Issue 117 (Thank you Paul!)
@@ -160,10 +161,12 @@
160161
The charsReceived debug print ("Total chars received: ") now excludes the length of the timestamps
161162
Consistent use of File32/ExFile/FsFile/File. Don't use SdFile for temporary files
162163
164+
v2.9
165+
Adds support for TMP102 low(er) cost temperature sensor
163166
*/
164167

165168
const int FIRMWARE_VERSION_MAJOR = 2;
166-
const int FIRMWARE_VERSION_MINOR = 8;
169+
const int FIRMWARE_VERSION_MINOR = 9;
167170

168171
//Define the OLA board identifier:
169172
// This is an int which is unique to this variant of the OLA and which allows us
@@ -315,6 +318,7 @@ icm_20948_DMP_data_t dmpData; // Global storage for the DMP data - extracted fro
315318
#include "SparkFun_SGP30_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_SGP30
316319
#include "SparkFun_VCNL4040_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_VCNL4040
317320
#include "SparkFun_MS5637_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_MS5637
321+
#include "SparkFunTMP102.h" //Click here to get the library: http://librarymanager/All#SparkFun_TMP102
318322
#include "SparkFun_TMP117.h" //Click here to get the library: http://librarymanager/All#SparkFun_TMP117
319323
#include "SparkFun_u-blox_GNSS_Arduino_Library.h" //http://librarymanager/All#SparkFun_u-blox_GNSS
320324
#include "SparkFun_Qwiic_Scale_NAU7802_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_NAU7802

Firmware/OpenLog_Artemis/Sensors.ino

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,20 @@ void gatherDeviceValues(char * sdOutputData, size_t lenData)
434434
}
435435
}
436436
break;
437+
case DEVICE_TEMPERATURE_TMP102:
438+
{
439+
TMP102 *nodeDevice = (TMP102 *)temp->classPtr;
440+
struct_TMP102 *nodeSetting = (struct_TMP102 *)temp->configPtr;
441+
442+
if (nodeSetting->log == true)
443+
{
444+
olaftoa(nodeDevice->readTempC(), tempData1, 4, sizeof(tempData1) / sizeof(char)); //Resolution to 0.0625°C, ACCURACY: 0.5°C (–25°C to +85°C)
445+
sprintf(tempData, "%s,", tempData1);
446+
strlcat(sdOutputData, tempData, lenData);
447+
448+
}
449+
}
450+
break;
437451
case DEVICE_TEMPERATURE_TMP117:
438452
{
439453
TMP117 *nodeDevice = (TMP117 *)temp->classPtr;
@@ -1465,6 +1479,19 @@ static void getHelperText(char* helperText, size_t lenText)
14651479
}
14661480
}
14671481
break;
1482+
case DEVICE_TEMPERATURE_TMP102:
1483+
{
1484+
1485+
struct_TMP102 *nodeSetting = (struct_TMP102 *)temp->configPtr;
1486+
if (nodeSetting->log)
1487+
{
1488+
// Include unique ID's for bus/port/address for each TMP102 temp sensor
1489+
char tempTxt[25];
1490+
sprintf(tempTxt,"TMP102 %02X-%d-%02X DegC,", temp->muxAddress, temp->portNumber, temp->address);
1491+
strlcat(helperText, tempTxt, lenText);
1492+
}
1493+
}
1494+
break;
14681495
case DEVICE_TEMPERATURE_TMP117:
14691496
{
14701497
struct_TMP117 *nodeSetting = (struct_TMP117 *)temp->configPtr;

Firmware/OpenLog_Artemis/autoDetect.ino

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ bool addDevice(deviceType_e deviceType, uint8_t address, uint8_t muxAddress, uin
147147
temp->configPtr = new struct_VCNL4040;
148148
}
149149
break;
150+
case DEVICE_TEMPERATURE_TMP102:
151+
{
152+
temp->classPtr = new TMP102;
153+
temp->configPtr = new struct_TMP102;
154+
}
155+
break;
150156
case DEVICE_TEMPERATURE_TMP117:
151157
{
152158
temp->classPtr = new TMP117;
@@ -402,6 +408,14 @@ bool beginQwiicDevices()
402408
temp->online = tempDevice->begin(qwiic); //Wire port
403409
}
404410
break;
411+
case DEVICE_TEMPERATURE_TMP102:
412+
{
413+
TMP102 *tempDevice = (TMP102 *)temp->classPtr;
414+
struct_TMP102 *nodeSetting = (struct_TMP102 *)temp->configPtr; //Create a local pointer that points to same spot as node does
415+
if (nodeSetting->powerOnDelayMillis > qwiicPowerOnDelayMillis) qwiicPowerOnDelayMillis = nodeSetting->powerOnDelayMillis; // Increase qwiicPowerOnDelayMillis if required
416+
temp->online = tempDevice->begin(temp->address, qwiic); //Address, Wire port
417+
}
418+
break;
405419
case DEVICE_TEMPERATURE_TMP117:
406420
{
407421
TMP117 *tempDevice = (TMP117 *)temp->classPtr;
@@ -819,6 +833,18 @@ void configureDevice(node * temp)
819833
sensor->setAmbientIntegrationTime(sensorSetting->ambientIntegrationTime);
820834
}
821835
break;
836+
837+
case DEVICE_TEMPERATURE_TMP102:
838+
{
839+
TMP102 *sensor = (TMP102 *)temp->classPtr;
840+
struct_TMP102 *sensorSetting = (struct_TMP102 *)temp->configPtr;
841+
842+
// JWS - I did not initalize the TMP102 sensor, as they appear to
843+
// work just fine with no special initalization code.
844+
845+
846+
}
847+
break;
822848
case DEVICE_TEMPERATURE_TMP117:
823849
{
824850
TMP117 *sensor = (TMP117 *)temp->classPtr;
@@ -1106,6 +1132,9 @@ FunctionPointer getConfigFunctionPtr(uint8_t nodeNumber)
11061132
case DEVICE_PROXIMITY_VCNL4040:
11071133
ptr = (FunctionPointer)menuConfigure_VCNL4040;
11081134
break;
1135+
case DEVICE_TEMPERATURE_TMP102:
1136+
ptr = (FunctionPointer)menuConfigure_TMP102;
1137+
break;
11091138
case DEVICE_TEMPERATURE_TMP117:
11101139
ptr = (FunctionPointer)menuConfigure_TMP117;
11111140
break;
@@ -1324,6 +1353,7 @@ void swap(struct node * a, struct node * b)
13241353
#define ADR_MS8607 0x40 //Humidity portion of the MS8607 sensor
13251354
#define ADR_UBLOX 0x42 //But can be set to any address
13261355
#define ADR_ADS122C04 0x45 //Alternates: 0x44, 0x41 and 0x40
1356+
#define ADR_TMP102 0x48 //Alternates: 0x49, 0x4A, and 0x4B
13271357
#define ADR_TMP117 0x48 //Alternates: 0x49, 0x4A, and 0x4B
13281358
#define ADR_ADS1015 0x48 //Alternates: 0x49, 0x4A, and 0x4B
13291359
#define ADR_BIO_SENSOR_HUB 0x55
@@ -1488,10 +1518,54 @@ deviceType_e testDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumb
14881518
if (sensor.begin(i2cAddress, qwiic) == true) //Address, Wire port
14891519
return (DEVICE_TEMPERATURE_TMP117);
14901520

1491-
//Confidence: Low - only does a simple isConnected
1521+
1522+
1523+
1524+
1525+
// Confidence: Medium - does a simple isConnected check, and then tests that two bits are read/write to disambiguate
1526+
// from the TMP102 sensor, where those two bits are read only 11.
14921527
ADS1015 sensor1;
1493-
if (sensor1.begin(i2cAddress, qwiic) == true) //Address, Wire port
1494-
return (DEVICE_ADS1015);
1528+
if (sensor1.begin(i2cAddress, qwiic) == true) //Address, Wire port
1529+
{
1530+
//Peek at the current config register (same 01 pointer addr as the TMP102)
1531+
uint16_t config = sensor1.readRegister(ADS1015_POINTER_CONFIG);
1532+
1533+
//Write zeros to the MUX[2:1] bits of the ADS1015 (read/write bits) which
1534+
// happen to be in the same place as the R1/R0 bits of the TMP102 (and
1535+
// are read only 11 on the TMP102
1536+
uint16_t newConfig = config & 0x9FFF; // 0x9FFF is 1001 1111 1111 1111 so it zeros out those two bits
1537+
1538+
//SerialPrintf2("ADS1015 detect, newconfig is:: %x \r\n", newConfig);
1539+
1540+
1541+
sensor1.writeRegister(ADS1015_POINTER_CONFIG, newConfig);
1542+
1543+
//Read back to see if our changes were recorded (ADS1015) or not (TMP102)
1544+
newConfig = sensor1.readRegister(ADS1015_POINTER_CONFIG);
1545+
1546+
1547+
//SerialPrintf2("ADS105 detect, after write/read cycle, config is: %x \r\n", newConfig);
1548+
1549+
1550+
// Write the original config back to restore the correct state.
1551+
sensor1.writeRegister(ADS1015_POINTER_CONFIG, config);
1552+
1553+
//Check to see if the bits we wrote zero stayed at 00 (ADS1015) or returned as
1554+
// 1's because it's actually a TMP102 or some other chip with read only bits
1555+
// in that spot...
1556+
if( (newConfig & 0x6000) == 0 ) // 0x6000 is 0110 0000 0000 0000 so it zeros out all bits except the two we are interested in.
1557+
{
1558+
// Our cannary bits correctly stayed set at zero! Write successful, assume it is a ADS1015
1559+
return (DEVICE_ADS1015);
1560+
1561+
}
1562+
// Otherwise, fall through to the TMP102 test below, which just assumes anything on the correct address is in fact a TMP102 sensor...
1563+
} // end if there is a device on this address.
1564+
1565+
//Confidence: Low - only does a simple isConnected.
1566+
TMP102 sensor2;
1567+
if (sensor2.begin(i2cAddress, qwiic) == true) //Address, Wire port
1568+
return (DEVICE_TEMPERATURE_TMP102);
14951569
}
14961570
break;
14971571
case 0x55:
@@ -1889,6 +1963,9 @@ const char* getDeviceName(deviceType_e deviceNumber)
18891963
case DEVICE_PROXIMITY_VCNL4040:
18901964
return "Proximity-VCNL4040";
18911965
break;
1966+
case DEVICE_TEMPERATURE_TMP102:
1967+
return "Temperature-TMP102";
1968+
break;
18921969
case DEVICE_TEMPERATURE_TMP117:
18931970
return "Temperature-TMP117";
18941971
break;

Firmware/OpenLog_Artemis/menuAttachedDevices.ino

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ void menuAttachedDevices()
297297
case DEVICE_PROXIMITY_VCNL4040:
298298
SerialPrintf3("%s VCNL4040 Proximity Sensor %s\r\n", strDeviceMenu, strAddress);
299299
break;
300+
case DEVICE_TEMPERATURE_TMP102:
301+
SerialPrintf3("%s TMP102 Temperature Sensor %s\r\n", strDeviceMenu, strAddress);
302+
break;
300303
case DEVICE_TEMPERATURE_TMP117:
301304
SerialPrintf3("%s TMP117 High Precision Temperature Sensor %s\r\n", strDeviceMenu, strAddress);
302305
break;
@@ -1643,6 +1646,35 @@ void menuConfigure_VCNL4040(void *configPtr)
16431646

16441647
}
16451648

1649+
1650+
void menuConfigure_TMP102(void *configPtr)
1651+
{
1652+
struct_TMP102 *sensorSetting = (struct_TMP102*)configPtr;
1653+
while (1)
1654+
{
1655+
SerialPrintln(F(""));
1656+
SerialPrintln(F("Menu: Configure TMP102 Temperature Sensor"));
1657+
1658+
SerialPrint(F("1) Sensor Logging: "));
1659+
if (sensorSetting->log == true) SerialPrintln(F("Enabled"));
1660+
else SerialPrintln(F("Disabled"));
1661+
1662+
SerialPrintln(F("x) Exit"));
1663+
1664+
byte incoming = getByteChoice(menuTimeout); //Timeout after x seconds
1665+
1666+
if (incoming == '1')
1667+
sensorSetting->log ^= 1;
1668+
else if (incoming == 'x')
1669+
break;
1670+
else if (incoming == STATUS_GETBYTE_TIMEOUT)
1671+
break;
1672+
else
1673+
printUnknown(incoming);
1674+
}
1675+
1676+
}
1677+
16461678
void menuConfigure_TMP117(void *configPtr)
16471679
{
16481680
struct_TMP117 *sensorSetting = (struct_TMP117*)configPtr;

Firmware/OpenLog_Artemis/nvm.ino

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,17 @@ void recordDeviceSettingsToFile()
587587
settingsFile.println((String)base + "resolution=" + nodeSetting->resolution);
588588
}
589589
break;
590+
case DEVICE_TEMPERATURE_TMP102:
591+
{
592+
struct_TMP102 *nodeSetting = (struct_TMP102 *)temp->configPtr;
593+
settingsFile.println((String)base + "log=" + nodeSetting->log);
594+
}
595+
break;
590596
case DEVICE_TEMPERATURE_TMP117:
591597
{
592598
struct_TMP117 *nodeSetting = (struct_TMP117 *)temp->configPtr;
593599
settingsFile.println((String)base + "log=" + nodeSetting->log);
594-
settingsFile.println((String)base + "logTemperature=" + nodeSetting->logTemperature);
600+
settingsFile.println((String)base + "logTemperature=" + nodeSetting->logTemperature); // JWS: I don't think this value is ever changed?
595601
}
596602
break;
597603
case DEVICE_PRESSURE_MS5637:
@@ -1145,13 +1151,22 @@ bool parseDeviceLine(char* str) {
11451151
SerialPrintf2("Unknown device setting: %s\r\n", deviceSettingName);
11461152
}
11471153
break;
1154+
case DEVICE_TEMPERATURE_TMP102:
1155+
{
1156+
struct_TMP102 *nodeSetting = (struct_TMP102 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does
1157+
if (strcmp(deviceSettingName, "log") == 0)
1158+
nodeSetting->log = d;
1159+
else
1160+
SerialPrintf2("Unknown device setting: %s\r\n", deviceSettingName);
1161+
}
1162+
break;
11481163
case DEVICE_TEMPERATURE_TMP117:
11491164
{
11501165
struct_TMP117 *nodeSetting = (struct_TMP117 *)deviceConfigPtr; //Create a local pointer that points to same spot as node does
11511166
if (strcmp(deviceSettingName, "log") == 0)
11521167
nodeSetting->log = d;
11531168
else if (strcmp(deviceSettingName, "logTemperature") == 0)
1154-
nodeSetting->logTemperature = d;
1169+
nodeSetting->logTemperature = d; // JWS: I don't think this value is ever used??
11551170
else
11561171
SerialPrintf2("Unknown device setting: %s\r\n", deviceSettingName);
11571172
}

Firmware/OpenLog_Artemis/settings.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ typedef enum
3434
DEVICE_ADS1015,
3535
DEVICE_PRESSURE_LPS28DFW,
3636
DEVICE_LIGHT_VEML7700,
37+
DEVICE_TEMPERATURE_TMP102,
38+
3739

3840
DEVICE_TOTAL_DEVICES, //Marks the end, used to iterate loops
3941
DEVICE_UNKNOWN_DEVICE,
@@ -170,12 +172,18 @@ struct struct_VL53L1X {
170172
unsigned long powerOnDelayMillis = minimumQwiicPowerOnDelay; // Wait for at least this many millis before communicating with this device. Increase if required!
171173
};
172174

175+
struct struct_TMP102 {
176+
bool log = true;
177+
unsigned long powerOnDelayMillis = minimumQwiicPowerOnDelay; // Wait for at least this many millis before communicating with this device. Increase if required!
178+
};
179+
180+
173181
#define TMP117_MODE_CONTINUOUS 0
174182
#define TMP117_MODE_SHUTDOWN 1
175183
#define TMP117_MODE_ONESHOT 2
176184
struct struct_TMP117 {
177185
bool log = true;
178-
bool logTemperature= true;
186+
bool logTemperature= true; // JWS : This value is set to true here, and then never changed ever again???
179187
int conversionMode = TMP117_MODE_CONTINUOUS;
180188
int conversionAverageMode = 0; //Setup for 15.5ms reads
181189
int conversionCycle = 0;

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ The OpenLog Artemis automatically scans, detects, configures, and logs various Q
3636
* [SDP3X Differential Pressure Sensor](https://www.sparkfun.com/products/17874)
3737
* [MS8607 Pressure Humidity Temperature Sensor](https://www.sparkfun.com/products/16298)
3838
* [MPR0025PA MicroPressure Sensor](https://www.sparkfun.com/products/16476)
39+
* [TMP102 Temperature Sensor] (https://www.sparkfun.com/products/13314)
3940
* [TMP117 High Precision Temperature Sensor](https://www.sparkfun.com/products/15805)
4041
* [AHT20 Humidity and Temperature Sensor](https://www.sparkfun.com/products/16618)
4142
* [SHTC3 Humidity and Temperature Sensor](https://www.sparkfun.com/products/16467)

SENSOR_UNITS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This document summarizes the units used for each sensor measurement.
4949
- [MCP9600 thermocouple amplifier](#MCP9600-thermocouple-amplifier)
5050
- [Qwiic PT100 ADS122C04 platinum resistance sensor](#Qwiic-PT100-ADS122C04-platinum-resistance-sensor)
5151
- [TMP117 precision temperature sensor](#TMP117-precision-temperature-sensor)
52+
- [TMP102 temperature sensor](#TMP102-temperature-sensor)
5253

5354
### Weight:
5455

@@ -350,6 +351,13 @@ Fan operational status:
350351
| Temperature Internal | degC | Degrees Centigrade |
351352
| Raw Voltage | V*2.048/2^23 | Volts * 2.048 / 2<sup>23</sup> |
352353

354+
---
355+
## TMP102 temperature sensor
356+
357+
| []() | | |
358+
|---|---|---|
359+
| Temperature | degC | Degrees Centigrade |
360+
353361
---
354362
## TMP117 precision temperature sensor
355363

0 commit comments

Comments
 (0)