Skip to content

Commit f34d96b

Browse files
committed
Added support for the TMP102 sensor. Unfortunately, this will almost
certainly cause the ADS1015 chip to be incorrectly detected and treated as a TMP102 sensor. Ideally I'll find a way to distinguish between the two based upon their behavior in a future commit.
1 parent 54a6a99 commit f34d96b

File tree

9 files changed

+140
-4
lines changed

9 files changed

+140
-4
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
---------

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
10Hz logging IMU, no Qwiic, SD, no USB, no Power LED: 9-27mA
1919
2020
TODO:
21+
Add support for TMP102 temperature sensor (preferably while still working with the ADS1015 (also at address 0x48)
2122
(done) Create settings file for sensor. Load after qwiic bus is scanned.
2223
(done on larger Strings) Remove String dependencies.
2324
(done) Bubble sort list of devices.
@@ -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: 23 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,15 @@ static void getHelperText(char* helperText, size_t lenText)
14651479
}
14661480
}
14671481
break;
1482+
case DEVICE_TEMPERATURE_TMP102:
1483+
{
1484+
struct_TMP102 *nodeSetting = (struct_TMP102 *)temp->configPtr;
1485+
if (nodeSetting->log)
1486+
{
1487+
strlcat(helperText, "TMP102 degC,", lenText);
1488+
}
1489+
}
1490+
break;
14681491
case DEVICE_TEMPERATURE_TMP117:
14691492
{
14701493
struct_TMP117 *nodeSetting = (struct_TMP117 *)temp->configPtr;

Firmware/OpenLog_Artemis/autoDetect.ino

Lines changed: 44 additions & 0 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 TODO replace with initalization code for TMP102 if needed?
843+
//sensor->setConversionAverageMode(sensorSetting->conversionAverageMode);
844+
//sensor->setConversionCycleBit(sensorSetting->conversionCycle);
845+
//sensor->setContinuousConversionMode();
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,6 +1518,17 @@ 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

1521+
//Confidence: Low - only does a simple isConnected. Not a problem with TMP117, but it
1522+
// will probably detect a ADS1015 as a TMP102. We need to figure out a way to discriminate between
1523+
// those two devices (when a TMP102 is misdetected as a ADS1015, all 4 values are always equal, maybe this will help?)
1524+
// For development purposes, listing before the ADS1015 so that I can develop/test and make my TMP102's work.
1525+
TMP102 sensor2;
1526+
if (sensor2.begin(i2cAddress, qwiic) == true) //Address, Wire port
1527+
return (DEVICE_TEMPERATURE_TMP102);
1528+
1529+
// JWS WARNING - shadowed by above TMP102 test, need to find out a way to discriminate between the two chips via their behavior, OR
1530+
// allow user to select which it is via menu.
1531+
//
14911532
//Confidence: Low - only does a simple isConnected
14921533
ADS1015 sensor1;
14931534
if (sensor1.begin(i2cAddress, qwiic) == true) //Address, Wire port
@@ -1889,6 +1930,9 @@ const char* getDeviceName(deviceType_e deviceNumber)
18891930
case DEVICE_PROXIMITY_VCNL4040:
18901931
return "Proximity-VCNL4040";
18911932
break;
1933+
case DEVICE_TEMPERATURE_TMP102:
1934+
return "Temperature-TMP102";
1935+
break;
18921936
case DEVICE_TEMPERATURE_TMP117:
18931937
return "Temperature-TMP117";
18941938
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ typedef enum
88
DEVICE_DISTANCE_VL53L1X,
99
DEVICE_GPS_UBLOX,
1010
DEVICE_PROXIMITY_VCNL4040,
11+
DEVICE_TEMPERATURE_TMP102,
1112
DEVICE_TEMPERATURE_TMP117,
1213
DEVICE_PRESSURE_MS5637,
1314
DEVICE_PRESSURE_LPS25HB,
@@ -170,12 +171,18 @@ struct struct_VL53L1X {
170171
unsigned long powerOnDelayMillis = minimumQwiicPowerOnDelay; // Wait for at least this many millis before communicating with this device. Increase if required!
171172
};
172173

174+
struct struct_TMP102 {
175+
bool log = true;
176+
unsigned long powerOnDelayMillis = minimumQwiicPowerOnDelay; // Wait for at least this many millis before communicating with this device. Increase if required!
177+
};
178+
179+
173180
#define TMP117_MODE_CONTINUOUS 0
174181
#define TMP117_MODE_SHUTDOWN 1
175182
#define TMP117_MODE_ONESHOT 2
176183
struct struct_TMP117 {
177184
bool log = true;
178-
bool logTemperature= true;
185+
bool logTemperature= true; // JWS : This value is set to true here, and then ever changed ever again???
179186
int conversionMode = TMP117_MODE_CONTINUOUS;
180187
int conversionAverageMode = 0; //Setup for 15.5ms reads
181188
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)