Skip to content

Commit c5c2947

Browse files
authored
Merge pull request #110 from sparkfun/release_candidate
v2.1
2 parents 5c10915 + e4d410f commit c5c2947

11 files changed

+145
-92
lines changed

Binaries/OpenLog_Artemis-V10-v21.bin

353 KB
Binary file not shown.

Binaries/OpenLog_Artemis-X04-v21.bin

352 KB
Binary file not shown.

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Change Log
22
======================
33

4+
v2.1
5+
---------
6+
7+
v2.1 is a 'mini' release:
8+
9+
* The compiled binaries for v2.1 are based on v2.2.0 of the Apollo3 core
10+
* Corrects issue [109](https://github.com/sparkfun/OpenLog_Artemis/issues/109)
11+
* Corrects issue [104](https://github.com/sparkfun/OpenLog_Artemis/issues/104)
12+
413
v2.0
514
---------
615

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 74 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,15 @@
107107
The work-around is to use Serial1 in place of serialLog and then to manually force UART1 to use pins 12 and 13
108108
We need a work-around anyway because if pins 12 or 13 have been used as analog inputs, Serial1.begin does not re-configure them for UART TX and RX
109109
(in progress) Reduce sleep current as much as possible. v1.2.1 achieved ~110uA. With v2.1.0 the draw is more like 260uA...
110+
111+
(in progress) Update to Apollo3 v2.2.0 - FIRMWARE_VERSION_MAJOR = 2; FIRMWARE_VERSION_MINOR = 1.
112+
(done) Add a fix for issue #109 - check if a BME280 is connected before calling multiplexerBegin: https://github.com/sparkfun/OpenLog_Artemis/issues/109
113+
(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
114+
the SPI lines low, preventing communication with the IMU: https://github.com/sparkfun/OpenLog_Artemis/issues/104
110115
*/
111116

112117
const int FIRMWARE_VERSION_MAJOR = 2;
113-
const int FIRMWARE_VERSION_MINOR = 0;
118+
const int FIRMWARE_VERSION_MINOR = 1;
114119

115120
//Define the OLA board identifier:
116121
// This is an int which is unique to this variant of the OLA and which allows us
@@ -120,7 +125,7 @@ const int FIRMWARE_VERSION_MINOR = 0;
120125
// the variant * 0x100 (OLA = 1; GNSS_LOGGER = 2; GEOPHONE_LOGGER = 3)
121126
// the major firmware version * 0x10
122127
// the minor firmware version
123-
#define OLA_IDENTIFIER 0x120 // Stored as 288 decimal in OLA_settings.txt
128+
#define OLA_IDENTIFIER 0x121 // Stored as 289 decimal in OLA_settings.txt
124129

125130
#include "settings.h"
126131

@@ -642,58 +647,55 @@ void loop() {
642647
Serial1.print(outputData); //Print to TX pin
643648

644649
//Record to SD
645-
if (settings.logData == true)
650+
if ((settings.logData == true) && (online.microSD))
646651
{
647-
if (settings.enableSD && online.microSD)
652+
digitalWrite(PIN_STAT_LED, HIGH);
653+
uint32_t recordLength = sensorDataFile.write(outputData, strlen(outputData));
654+
if (recordLength != strlen(outputData)) //Record the buffer to the card
648655
{
649-
digitalWrite(PIN_STAT_LED, HIGH);
650-
uint32_t recordLength = sensorDataFile.write(outputData, strlen(outputData));
651-
if (recordLength != strlen(outputData)) //Record the buffer to the card
656+
if (settings.printDebugMessages == true)
652657
{
653-
if (settings.printDebugMessages == true)
654-
{
655-
SerialPrintf3("*** sensorDataFile.write data length mismatch! *** recordLength: %d, outputDataLength: %d\r\n", recordLength, strlen(outputData));
656-
}
658+
SerialPrintf3("*** sensorDataFile.write data length mismatch! *** recordLength: %d, outputDataLength: %d\r\n", recordLength, strlen(outputData));
657659
}
660+
}
661+
662+
//Force sync every 500ms
663+
if (bestMillis() - lastDataLogSyncTime > 500)
664+
{
665+
lastDataLogSyncTime = bestMillis();
666+
sensorDataFile.sync();
667+
if (settings.frequentFileAccessTimestamps == true)
668+
updateDataFileAccess(&sensorDataFile); // Update the file access time & date
669+
}
658670

659-
//Force sync every 500ms
660-
if (bestMillis() - lastDataLogSyncTime > 500)
671+
//Check if it is time to open a new log file
672+
uint64_t secsSinceLastFileNameChange = rtcMillis() - lastSDFileNameChangeTime; // Calculate how long we have been logging for
673+
secsSinceLastFileNameChange /= 1000ULL; // Convert to secs
674+
if ((settings.openNewLogFilesAfter > 0) && (((unsigned long)secsSinceLastFileNameChange) >= settings.openNewLogFilesAfter))
675+
{
676+
//Close existings files
677+
if (online.dataLogging == true)
661678
{
662-
lastDataLogSyncTime = bestMillis();
663679
sensorDataFile.sync();
664-
if (settings.frequentFileAccessTimestamps == true)
665-
updateDataFileAccess(&sensorDataFile); // Update the file access time & date
680+
updateDataFileAccess(&sensorDataFile); // Update the file access time & date
681+
sensorDataFile.close();
682+
strcpy(sensorDataFileName, findNextAvailableLog(settings.nextDataLogNumber, "dataLog"));
683+
beginDataLogging(); //180ms
684+
if (settings.showHelperText == true) printHelperText(false); //printHelperText to terminal and sensor file
666685
}
667-
668-
//Check if it is time to open a new log file
669-
uint64_t secsSinceLastFileNameChange = rtcMillis() - lastSDFileNameChangeTime; // Calculate how long we have been logging for
670-
secsSinceLastFileNameChange /= 1000ULL; // Convert to secs
671-
if ((settings.openNewLogFilesAfter > 0) && (((unsigned long)secsSinceLastFileNameChange) >= settings.openNewLogFilesAfter))
686+
if (online.serialLogging == true)
672687
{
673-
//Close existings files
674-
if (online.dataLogging == true)
675-
{
676-
sensorDataFile.sync();
677-
updateDataFileAccess(&sensorDataFile); // Update the file access time & date
678-
sensorDataFile.close();
679-
strcpy(sensorDataFileName, findNextAvailableLog(settings.nextDataLogNumber, "dataLog"));
680-
beginDataLogging(); //180ms
681-
if (settings.showHelperText == true) printHelperText(false); //printHelperText to terminal and sensor file
682-
}
683-
if (online.serialLogging == true)
684-
{
685-
serialDataFile.sync();
686-
updateDataFileAccess(&serialDataFile); // Update the file access time & date
687-
serialDataFile.close();
688-
strcpy(serialDataFileName, findNextAvailableLog(settings.nextSerialLogNumber, "serialLog"));
689-
beginSerialLogging();
690-
}
691-
692-
lastSDFileNameChangeTime = rtcMillis(); // Record the time of the file name change
688+
serialDataFile.sync();
689+
updateDataFileAccess(&serialDataFile); // Update the file access time & date
690+
serialDataFile.close();
691+
strcpy(serialDataFileName, findNextAvailableLog(settings.nextSerialLogNumber, "serialLog"));
692+
beginSerialLogging();
693693
}
694694

695-
digitalWrite(PIN_STAT_LED, LOW);
695+
lastSDFileNameChangeTime = rtcMillis(); // Record the time of the file name change
696696
}
697+
698+
digitalWrite(PIN_STAT_LED, LOW);
697699
}
698700

699701
if ((settings.useGPIO32ForStopLogging == true) && (stopLoggingSeen == true)) // Has the user pressed the stop logging button?
@@ -889,56 +891,51 @@ void beginSD()
889891
pin_config(PinName(PIN_MICROSD_CHIP_SELECT), g_AM_HAL_GPIO_OUTPUT); // Make sure the pin does actually get re-configured
890892
digitalWrite(PIN_MICROSD_CHIP_SELECT, HIGH); //Be sure SD is deselected
891893

892-
if (settings.enableSD == true)
893-
{
894-
// For reasons I don't understand, we seem to have to wait for at least 1ms after SPI.begin before we call microSDPowerOn.
895-
// If you comment the next line, the Artemis resets at microSDPowerOn when beginSD is called from wakeFromSleep...
896-
// But only on one of my V10 red boards. The second one I have doesn't seem to need the delay!?
897-
delay(5);
894+
// If the microSD card is present, it needs to be powered on otherwise the IMU will fail to start
895+
// (The microSD card will pull the SPI pins low, preventing communication with the IMU)
896+
897+
// For reasons I don't understand, we seem to have to wait for at least 1ms after SPI.begin before we call microSDPowerOn.
898+
// If you comment the next line, the Artemis resets at microSDPowerOn when beginSD is called from wakeFromSleep...
899+
// But only on one of my V10 red boards. The second one I have doesn't seem to need the delay!?
900+
delay(5);
898901

899-
microSDPowerOn();
902+
microSDPowerOn();
900903

901-
//Max power up time is 250ms: https://www.kingston.com/datasheets/SDCIT-specsheet-64gb_en.pdf
902-
//Max current is 200mA average across 1s, peak 300mA
903-
for (int i = 0; i < 10; i++) //Wait
904+
//Max power up time is 250ms: https://www.kingston.com/datasheets/SDCIT-specsheet-64gb_en.pdf
905+
//Max current is 200mA average across 1s, peak 300mA
906+
for (int i = 0; i < 10; i++) //Wait
907+
{
908+
checkBattery();
909+
delay(1);
910+
}
911+
912+
if (sd.begin(SD_CONFIG) == false) // Try to begin the SD card using the correct chip select
913+
{
914+
printDebug(F("SD init failed (first attempt). Trying again...\r\n"));
915+
for (int i = 0; i < 250; i++) //Give SD more time to power up, then try again
904916
{
905917
checkBattery();
906918
delay(1);
907919
}
908-
909920
if (sd.begin(SD_CONFIG) == false) // Try to begin the SD card using the correct chip select
910921
{
911-
printDebug(F("SD init failed (first attempt). Trying again...\r\n"));
912-
for (int i = 0; i < 250; i++) //Give SD more time to power up, then try again
913-
{
914-
checkBattery();
915-
delay(1);
916-
}
917-
if (sd.begin(SD_CONFIG) == false) // Try to begin the SD card using the correct chip select
918-
{
919-
SerialPrintln(F("SD init failed (second attempt). Is card present? Formatted?"));
920-
SerialPrintln(F("Please ensure the SD card is formatted correctly using https://www.sdcard.org/downloads/formatter/"));
921-
digitalWrite(PIN_MICROSD_CHIP_SELECT, HIGH); //Be sure SD is deselected
922-
online.microSD = false;
923-
return;
924-
}
925-
}
926-
927-
//Change to root directory. All new file creation will be in root.
928-
if (sd.chdir() == false)
929-
{
930-
SerialPrintln(F("SD change directory failed"));
922+
SerialPrintln(F("SD init failed (second attempt). Is card present? Formatted?"));
923+
SerialPrintln(F("Please ensure the SD card is formatted correctly using https://www.sdcard.org/downloads/formatter/"));
924+
digitalWrite(PIN_MICROSD_CHIP_SELECT, HIGH); //Be sure SD is deselected
931925
online.microSD = false;
932926
return;
933927
}
934-
935-
online.microSD = true;
936928
}
937-
else
929+
930+
//Change to root directory. All new file creation will be in root.
931+
if (sd.chdir() == false)
938932
{
939-
microSDPowerOff();
933+
SerialPrintln(F("SD change directory failed"));
940934
online.microSD = false;
935+
return;
941936
}
937+
938+
online.microSD = true;
942939
}
943940

944941
void enableCIPOpullUp() // updated for v2.1.0 of the Apollo3 core

Firmware/OpenLog_Artemis/Sensors.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ void printHelperText(bool terminalOnly)
15411541
strcat(helperText, "\r\n");
15421542

15431543
SerialPrint(helperText);
1544-
if ((terminalOnly == false) && (settings.logData == true) && (online.microSD) && (settings.enableSD && online.microSD))
1544+
if ((terminalOnly == false) && (settings.logData == true) && (online.microSD))
15451545
sensorDataFile.print(helperText);
15461546
}
15471547

Firmware/OpenLog_Artemis/autoDetect.ino

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,11 +1502,27 @@ deviceType_e testDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumb
15021502
//Given an address, returns the device type if it responds as we would expect
15031503
//This version is dedicated to testing muxes and uses a custom .begin to avoid the slippery mux problem
15041504
//However, we also need to check if an MS8607 is attached (address 0x76) as it can cause the I2C bus to lock up if not detected correctly
1505+
//Also check for a BME280 - to prevent multiplexerBegin from confusing it
15051506
deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portNumber)
15061507
{
15071508
switch (i2cAddress)
15081509
{
15091510
case 0x70:
1511+
{
1512+
//Ignore devices we've already recorded. This was causing the mux to get tested, a begin() would happen, and the mux would be reset.
1513+
if (deviceExists(DEVICE_MULTIPLEXER, i2cAddress, muxAddress, portNumber) == true) return (DEVICE_MULTIPLEXER);
1514+
1515+
//I don't think multiplexerBegin will cause any badness for the SHTC3 as its commands are all 16-bit
1516+
//But, just in case, let's see if one is connected
1517+
SHTC3 sensor;
1518+
if (sensor.begin(qwiic) == 0) //Wire port. Device returns 0 upon success.
1519+
return (DEVICE_HUMIDITY_SHTC3);
1520+
1521+
//Confidence: Medium - Write/Read/Clear to 0x00
1522+
if (multiplexerBegin(i2cAddress, qwiic) == true) //Address, Wire port
1523+
return (DEVICE_MULTIPLEXER);
1524+
}
1525+
break;
15101526
case 0x71:
15111527
case 0x72:
15121528
case 0x73:
@@ -1532,9 +1548,7 @@ deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portN
15321548
// So, we can't use .begin as the test for a MS5637 / MS5837 / MS8607. We need to be more creative!
15331549
// If we write 0xA0 to i2cAddress and then read two bytes:
15341550
// A mux will return 0xA0A0
1535-
// An MS5637 / MS5837 / MS8607 will return the value stored in its eeprom which _hopefully_ is not 0xA0A0!
1536-
1537-
// Let's hope this doesn't cause problems for the BME280...! We should be OK as the default address for the BME280 is 0x77.
1551+
// An MS5637 / MS5837 / MS8607 / BME280 will return an eeprom or register value which _hopefully_ is not 0xA0A0!
15381552

15391553
qwiic.beginTransmission((uint8_t)i2cAddress);
15401554
qwiic.write((uint8_t)0xA0);
@@ -1543,12 +1557,12 @@ deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portN
15431557
if (i2c_status == 0) // If the I2C write was successful
15441558
{
15451559
qwiic.requestFrom((uint8_t)i2cAddress, 2U); // Read two bytes
1546-
uint8_t buffer[2];
1560+
uint8_t buffer[2] = { 0, 0 };
15471561
for (uint8_t i = 0; i < 2; i++)
15481562
{
15491563
buffer[i] = qwiic.read();
15501564
}
1551-
if ((buffer[0] != 0xA0) || (buffer[1] != 0xA0)) // If we read back something other than 0xA0A0 then we are probably talking to an MS5637 / MS5837 / MS8607, not a mux
1565+
if ((buffer[0] != 0xA0) || (buffer[1] != 0xA0)) // If we read back something other than 0xA0A0 then we are probably talking to an MS5637 / MS5837 / MS8607 / BME280, not a mux
15521566
{
15531567
return (DEVICE_PRESSURE_MS5637);
15541568
}
@@ -1564,6 +1578,29 @@ deviceType_e testMuxDevice(uint8_t i2cAddress, uint8_t muxAddress, uint8_t portN
15641578
//Ignore devices we've already recorded. This was causing the mux to get tested, a begin() would happen, and the mux would be reset.
15651579
if (deviceExists(DEVICE_MULTIPLEXER, i2cAddress, muxAddress, portNumber) == true) return (DEVICE_MULTIPLEXER);
15661580

1581+
//multiplexerBegin confuses the BME280, so let's check if one is connected first
1582+
// If we write 0xA0 to i2cAddress and then read two bytes:
1583+
// A mux will return 0xA0A0
1584+
// A BME280 will return a register value which _hopefully_ is not 0xA0A0!
1585+
1586+
qwiic.beginTransmission((uint8_t)i2cAddress);
1587+
qwiic.write((uint8_t)0xA0);
1588+
uint8_t i2c_status = qwiic.endTransmission();
1589+
1590+
if (i2c_status == 0) // If the I2C write was successful
1591+
{
1592+
qwiic.requestFrom((uint8_t)i2cAddress, 2U); // Read two bytes
1593+
uint8_t buffer[2] = { 0, 0 };
1594+
for (uint8_t i = 0; i < 2; i++)
1595+
{
1596+
buffer[i] = qwiic.read();
1597+
}
1598+
if ((buffer[0] != 0xA0) || (buffer[1] != 0xA0)) // If we read back something other than 0xA0A0 then we are probably talking to a BME280, not a mux
1599+
{
1600+
return (DEVICE_PHT_BME280);
1601+
}
1602+
}
1603+
15671604
//Confidence: Medium - Write/Read/Clear to 0x00
15681605
if (multiplexerBegin(i2cAddress, qwiic) == true) //Address, Wire port
15691606
return (DEVICE_MULTIPLEXER);

Firmware/OpenLog_Artemis/menuAttachedDevices.ino

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,21 @@ bool detectQwiicDevices()
8282
{
8383
if (settings.printDebugMessages == true)
8484
{
85-
SerialPrintf2("detectQwiicDevices: MS8607/MS5637/MS5837 found at address 0x%02X. Ignoring it for now...\r\n", address);
85+
SerialPrintf2("detectQwiicDevices: MS8607/MS5637/MS5837/BME280 found at address 0x%02X. Ignoring it for now...\r\n", address);
86+
}
87+
}
88+
else if (foundType == DEVICE_PHT_BME280)
89+
{
90+
if (settings.printDebugMessages == true)
91+
{
92+
SerialPrintf2("detectQwiicDevices: BME280 found at address 0x%02X. Ignoring it for now...\r\n", address);
93+
}
94+
}
95+
else if (foundType == DEVICE_HUMIDITY_SHTC3)
96+
{
97+
if (settings.printDebugMessages == true)
98+
{
99+
SerialPrintf2("detectQwiicDevices: SHTC3 found at address 0x%02X. Ignoring it for now...\r\n", address);
86100
}
87101
}
88102
}

Firmware/OpenLog_Artemis/menuMain.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void menuMain()
2525

2626
SerialPrintln(F("h) Print Sensor Helper Text (and return to logging)"));
2727

28-
if (settings.enableSD && online.microSD)
28+
if (online.microSD)
2929
SerialPrintln(F("s) SD Card File Transfer"));
3030

3131
SerialPrintln(F("r) Reset all settings to default"));
@@ -61,7 +61,7 @@ void menuMain()
6161
menuDebug();
6262
else if (incoming == 's')
6363
{
64-
if (settings.enableSD && online.microSD)
64+
if (online.microSD)
6565
{
6666
//Close log files before showing sdCardMenu
6767
if (online.dataLogging == true)

Firmware/OpenLog_Artemis/nvm.ino

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ void recordSystemSettingsToFile()
113113
settingsFile.println("logMaxRate=" + (String)settings.logMaxRate);
114114
settingsFile.println("enableRTC=" + (String)settings.enableRTC);
115115
settingsFile.println("enableIMU=" + (String)settings.enableIMU);
116-
settingsFile.println("enableSD=" + (String)settings.enableSD);
117116
settingsFile.println("enableTerminalOutput=" + (String)settings.enableTerminalOutput);
118117
settingsFile.println("logDate=" + (String)settings.logDate);
119118
settingsFile.println("logTime=" + (String)settings.logTime);
@@ -325,8 +324,6 @@ bool parseLine(char* str) {
325324
settings.enableRTC = d;
326325
else if (strcmp(settingName, "enableIMU") == 0)
327326
settings.enableIMU = d;
328-
else if (strcmp(settingName, "enableSD") == 0)
329-
settings.enableSD = d;
330327
else if (strcmp(settingName, "enableTerminalOutput") == 0)
331328
settings.enableTerminalOutput = d;
332329
else if (strcmp(settingName, "logDate") == 0)

Firmware/OpenLog_Artemis/settings.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ struct struct_settings {
352352
bool logMaxRate = false;
353353
bool enableRTC = true;
354354
bool enableIMU = true;
355-
bool enableSD = true;
356355
bool enableTerminalOutput = true;
357356
bool logDate = true;
358357
bool logTime = true;

UPGRADE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Which is handy if you want to quickly update the firmware in the field, or are n
77

88
The firmware is customized for the different versions of the OLA hardware. You will find versions for the **X04 SparkX (Black) OLA** and **V10 SparkFun (Red) OLA** plus any subsequent revisions. The filename tells you which hardware the firmware is for and what version it is:
99

10-
* **OpenLog_Artemis-V10-v20.bin** - is the _stable_ version for the **V10 SparkFun (Red) OLA**
11-
* **OpenLog_Artemis-X04-v20.bin** - is the _stable_ version for the **X04 SparkX (Black) OLA**
10+
* **OpenLog_Artemis-V10-v21.bin** - is the _stable_ version for the **V10 SparkFun (Red) OLA**
11+
* **OpenLog_Artemis-X04-v21.bin** - is the _stable_ version for the **X04 SparkX (Black) OLA**
1212

1313
<table class="table table-hover table-striped table-bordered">
1414
<tr align="center">

0 commit comments

Comments
 (0)