Skip to content
Merged
99 changes: 99 additions & 0 deletions ADDING_SENSORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# OpenLog Artemis : How To Add A New Sensor

These are _abbreviated_ instructions on how to add a new sensor to the OLA firmware. It's more of an aide-memoire really... Sorry about that.

Caveat: this is _currently_ how a new sensor is added, for version v1.n of the OLA firmware using v1.2.n of the Apollo3 boards (the OLA code is compiled using the SparkFun RedBoard Artemis ATP (All The Pins) board). This will change, dramatically, when we upgrade to v2 of Apollo3 and integrate BLE support.

## Use The Release Candidate Branch

First up, please target any commits at the _**release_candidate**_ branch, so they can be tested before being merged into the _master_ branch.

- https://github.com/sparkfun/OpenLog_Artemis/tree/release_candidate

## OpenLog_Artemis.ino

- [Add the new sensor to the comments at the start of the file](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-7d096a133c17fd6db382abb9a3c6ea7b42ec505961876cecf404a55be5945347R71)

- [#include the library .h file remembering to include the library manager helper link](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-7d096a133c17fd6db382abb9a3c6ea7b42ec505961876cecf404a55be5945347R203)

## Sensors.ino

### gatherDeviceValues

- This is where the sensor readings are actually read. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-fba25af49a58a7a24fb75cb34321e25dd4a94a9d3515ac051fcaa4502e444f7fR725-R798)

### printHelperText

- [Add helper text for the sensor readings](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-fba25af49a58a7a24fb75cb34321e25dd4a94a9d3515ac051fcaa4502e444f7fR1132-R1165)

## autoDetect.ino

### addDevice

- This code is called to add the discovered device to the linked list of active devices. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR234-R239). The class name comes from the library. The config struct is defined in settings.h.

### beginQwiicDevices

- This is the code that is called to start (begin) the device. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR453-R461). Update _qwiicPowerOnDelayMillis_ if this device needs extra time to get its act together on power-up.

### configureDevice

- If the sensor needs to be configured before use, that gets done here. [Add a case for the new sensor, even if it doesn't need to be configured.](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR705-R707)

### getConfigFunctionPtr

- [Add a pointer to the sensor menu function (defined in menuAttachedDevices.ino)](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR795-R797)

### swap

- [Add the device's I2C address(es) here - just for reference (we don't use these #defines any longer)](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR929)

### testDevice

- This is the code used to detect the sensor. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR987-R994). Provide some indication of how robust the detection is. Confidence would be high if the .begin writes and reads unique data to/from the sensor. Confidence is low if .begin only uses the standard _isConnected_ I2C address test.

### getDeviceName

- This is where the sensor name is defined as text. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-68cc245ab0d3c1bed2bfc22b403edc3ed73d347a35a21179b3a6ec27a458803bR1423-R1425). Keep it brief and follow the same format as the other sensors: usually _TYPE_ (PRESSURE, TEMPERATURE etc.) followed by the abbreviated manufacturer's part number

## menuAttachedDevices.ino

### menuAttachedDevices

- This is the code which lists all the attached devices as a menu. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-6174875faf8039f2627c16aaf48e4db57f5a2c8c883061ac97202d74e9a46ef8R309-R311)

### menuConfigure_

- [Add a new menuConfigure_ for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-6174875faf8039f2627c16aaf48e4db57f5a2c8c883061ac97202d74e9a46ef8R2026-R2141)
- Boolean settings are simple to toggle. [Make them exclusive if you need to](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-6174875faf8039f2627c16aaf48e4db57f5a2c8c883061ac97202d74e9a46ef8R1942-R1948)
- _int64_t_ values are requested using _getNumber_ (defined in support.ino)
- _double_ values are requested using _getDouble_ (defined in support.ino)

## nvm.ino

### recordDeviceSettingsToFile

- This function gets called to write the device settings to file. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-629ae89c3c660583493d544d3a7902728f4a8eefb65800c3acb64aea37d5d88dR611-R629). Include all of the sensor settings.

### parseDeviceLine

- This function gets called when the device settings are read back from file. [Add a case for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-629ae89c3c660583493d544d3a7902728f4a8eefb65800c3acb64aea37d5d88dR1116-R1150)

## settings.h

### enum

- [Add the device to the enumerated sensors](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-c853eddd04f78093fed5ec20b822c3c224bfa5f268738ce4c479b45667f86fe9R25). Insert the new one above _DEVICE_TOTAL_DEVICES_

### settings struct

- [Add a settings struct for the new sensor](https://github.com/sparkfun/OpenLog_Artemis/commit/2a26acd279fa93cfe84f1bc518c0e7a041b3bc44#diff-c853eddd04f78093fed5ec20b822c3c224bfa5f268738ce4c479b45667f86fe9R265-R281). Include both _log_ and _powerOnDelayMillis_

## README.md

- Add the new sensor to the list in [README.md](./README.md). Include a link to the product page
- Update the OLA product page on Sparkle - add the new sensor to the list

## CHANGELOG.md

- Update [CHANGELOG.md](./CHANGELOG.md). Start a new version if you need to. Add the new sensor to the change notes
Binary file added Binaries/OpenLog_Artemis-V10-v17.bin
Binary file not shown.
Binary file added Binaries/OpenLog_Artemis-X04-v17.bin
Binary file not shown.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change Log
======================

v1.7
---------

* Corrected the readVin after sleep bug [39](https://github.com/sparkfun/OpenLog_Artemis/issues/39)
* Corrected detection of the MCP9600 (Qwiic Thermocouple) [41](https://github.com/sparkfun/OpenLog_Artemis/issues/41)
* Added support for the MPR MicroPressure Sensor [35](https://github.com/sparkfun/OpenLog_Artemis/issues/35)
* Added support for the SN-GCJA5 Particle Sensor
* IMU full scale and Digital Low Pass Filter settings can now be configured via Menu 3 [42](https://github.com/sparkfun/OpenLog_Artemis/issues/42)

v1.6
---------

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### How to Contribute
# OpenLog Artemis : How to Contribute

Thank you so *much* for offering to help out. We truly appreciate it.

Expand Down
50 changes: 42 additions & 8 deletions Firmware/OpenLog_Artemis/OpenLog_Artemis.ino
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
Find way to store device configs into EEPROM
Log four pressure sensors and graph them on plotter
(checked) Test GPS - not sure about %d with int32s. Does lat, long, and alt look correct?
Test NAU7802s
Test SCD30s
Add a 'does not like to be powered cycled' setting for each device type.
(done) Test NAU7802s
(done) Test SCD30s (Add an extended delay for the SCD30. (Issue #5))
(won't do?) Add a 'does not like to be powered cycled' setting for each device type. I think this has been superceded by "Add individual power-on delays for each sensor type?.
(done) Add support for logging VIN
(done) Investigate error in time between logs (https://github.com/sparkfun/OpenLog_Artemis/issues/13)
(done) Invesigate RTC reset issue (https://github.com/sparkfun/OpenLog_Artemis/issues/13 + https://forum.sparkfun.com/viewtopic.php?f=123&t=53157)
Expand All @@ -44,8 +44,7 @@
(done) Add a fix so that the MS8607 does not also appear as an MS5637
(done) Add "set RTC from GPS" functionality
(done) Add UTCoffset functionality (including support for negative numbers)
Figure out how to give the u-blox time to establish a fix if it has been powered down between log intervals.
Maybe add a waitForValidFix feature? Or maybe we can work around using a big value for "Set Qwiic bus power up delay"?
(done) Figure out how to give the u-blox time to establish a fix if it has been powered down between log intervals. The user can specify up to 60s for the Qwiic power-on delay.
Add support for VREG_ENABLE
(done) Add support for PWR_LED
(done) Use the WDT to reset the Artemis when power is reconnected (previously the Artemis would have stayed in deep sleep)
Expand All @@ -65,10 +64,15 @@
(done) Correct the measurement count misbehaviour (Issue #31)
(done) Use the corrected IMU temperature calculation (Issue #28)
(done) Add individual power-on delays for each sensor type. Add an extended delay for the SCD30. (Issue #5)
(done) v1.7: Fix readVin after sleep bug: https://github.com/sparkfun/OpenLog_Artemis/issues/39
(done) Change detectQwiicDevices so that the MCP9600 (Qwiic Thermocouple) is detected correctly
(done) Add support for the MPRLS0025PA micro pressure sensor
(done) Add support for the SN-GCJA5 particle sensor
(done) Add IMU accelerometer and gyro full scale and digital low pass filter settings to menuIMU
*/

const int FIRMWARE_VERSION_MAJOR = 1;
const int FIRMWARE_VERSION_MINOR = 6;
const int FIRMWARE_VERSION_MINOR = 7;

//Define the OLA board identifier:
// This is an int which is unique to this variant of the OLA and which allows us
Expand All @@ -78,7 +82,7 @@ const int FIRMWARE_VERSION_MINOR = 6;
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
// the major firmware version * 0x10
// the minor firmware version
#define OLA_IDENTIFIER 0x116
#define OLA_IDENTIFIER 0x117 // Stored as 279 decimal in OLA_settings.txt

#include "settings.h"

Expand Down Expand Up @@ -195,6 +199,8 @@ ICM_20948_SPI myICM;
#include "SparkFun_Qwiic_Humidity_AHT20.h" //Click here to get the library: http://librarymanager/All#Qwiic_Humidity_AHT20 by SparkFun
#include "SparkFun_SHTC3.h" // Click here to get the library: http://librarymanager/All#SparkFun_SHTC3
#include "SparkFun_ADS122C04_ADC_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_ADS122C04
#include "SparkFun_MicroPressure.h" // Click here to get the library: http://librarymanager/All#SparkFun_MicroPressure
#include "SparkFun_Particle_Sensor_SN-GCJA5_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_Particle_Sensor_SN-GCJA5

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Expand Down Expand Up @@ -675,7 +681,35 @@ void beginIMU()
checkBattery();
delay(1);
}


//Update the full scale and DLPF settings
ICM_20948_Status_e retval = myICM.enableDLPF(ICM_20948_Internal_Acc, settings.imuAccDLPF);
if (retval != ICM_20948_Stat_Ok)
{
Serial.println(F("Error: Could not configure the IMU Accelerometer DLPF!"));
}
retval = myICM.enableDLPF(ICM_20948_Internal_Gyr, settings.imuGyroDLPF);
if (retval != ICM_20948_Stat_Ok)
{
Serial.println(F("Error: Could not configure the IMU Gyro DLPF!"));
}
ICM_20948_dlpcfg_t dlpcfg;
dlpcfg.a = settings.imuAccDLPFBW;
dlpcfg.g = settings.imuGyroDLPFBW;
retval = myICM.setDLPFcfg((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), dlpcfg);
if (retval != ICM_20948_Stat_Ok)
{
Serial.println(F("Error: Could not configure the IMU DLPF BW!"));
}
ICM_20948_fss_t FSS;
FSS.a = settings.imuAccFSS;
FSS.g = settings.imuGyroFSS;
retval = myICM.setFullScale((ICM_20948_Internal_Acc | ICM_20948_Internal_Gyr), FSS);
if (retval != ICM_20948_Stat_Ok)
{
Serial.println(F("Error: Could not configure the IMU Full Scale!"));
}

online.IMU = true;
}
else
Expand Down
Loading