Skip to content

Commit 0f9e52e

Browse files
authored
Merge pull request #1 from sparkfun/v11
Add 512GB SD support, MS8607 support, Qwiic power control, I2C speed adjustment
2 parents 705851e + 96ee3a0 commit 0f9e52e

File tree

15 files changed

+589
-72
lines changed

15 files changed

+589
-72
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Change Log
2+
======================
3+
4+
v1.1
5+
---------
6+
7+
* Add support for exFat microSD cards. Tested up to 512GB. Smaller FAT16 and FAT32 formatted cards are still supported.
8+
* Add support for MS8607 PHT sensor
9+
* Add ability to turn on/off power on Qwiic bus when time between sensor readings is > 2s. By default the bus powers down to save power but there may be instances where user wants to keep sensors powered up and running between reads. This can be accessed via the Attached Devices menu.
10+
* Add ability to limit I2C bus speed. Most devices operate at 400kHz I2C. Some (MCP9600) are automatically limited by OLA to 100kHz. There may be instances, because of bus length or other, where the user may want to artifically limit the bus speed. This can be access via the Attached Devices menu.
11+
12+
13+
v1.0
14+
---------
15+
Initial release.

Firmware/OpenLog_Artemis/OpenLog_Artemis.ino

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
*/
1919

20-
const float FIRMWARE_VERSION = 1.0;
20+
const float FIRMWARE_VERSION = 1.1;
2121

2222
#include "settings.h"
2323

@@ -33,7 +33,7 @@ enum returnStatus {
3333

3434
//Setup Qwiic Port
3535
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
36-
#include "Wire.h"
36+
#include <Wire.h>
3737
TwoWire qwiic(1); //Will use pads 8/9
3838
const byte PIN_QWIIC_POWER = 18;
3939
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
@@ -54,9 +54,16 @@ const byte PIN_MICROSD_POWER = 15; //x04
5454
#define SD_CONFIG SdSpiConfig(PIN_MICROSD_CHIP_SELECT, SHARED_SPI, SD_SCK_MHZ(24)) //Max of 24MHz
5555
#define SD_CONFIG_MAX_SPEED SdSpiConfig(PIN_MICROSD_CHIP_SELECT, DEDICATED_SPI, SD_SCK_MHZ(24)) //Max of 24MHz
5656

57-
SdFat sd;
58-
File sensorDataFile; //File that all sensor data is written to
59-
File serialDataFile; //File that all incoming serial data is written to
57+
//ExFat
58+
SdFs sd;
59+
FsFile sensorDataFile; //File that all sensor data is written to
60+
FsFile serialDataFile; //File that all incoming serial data is written to
61+
62+
//Fat16/32
63+
//SdFat sd;
64+
//File sensorDataFile; //File that all sensor data is written to
65+
//File serialDataFile; //File that all incoming serial data is written to
66+
6067
char sensorDataFileName[30] = ""; //We keep a record of this file name so that we can re-open it upon wakeup from sleep
6168
char serialDataFileName[30] = ""; //We keep a record of this file name so that we can re-open it upon wakeup from sleep
6269
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
@@ -75,7 +82,7 @@ const int MAX_IDLE_TIME_MSEC = 500;
7582
bool newSerialData = false;
7683
char incomingBuffer[256 * 2]; //This size of this buffer is sensitive. Do not change without analysis using OpenLog_Serial.
7784
int incomingBufferSpot = 0;
78-
//int charsReceived = 0; //Used for verifying/debugging serial reception
85+
int charsReceived = 0; //Used for verifying/debugging serial reception
7986
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
8087

8188
//Add ICM IMU interface
@@ -131,6 +138,9 @@ SGP30 vocSensor_SGP30;
131138
#include "SparkFun_SCD30_Arduino_Library.h" //Click here to get the library: http://librarymanager/All#SparkFun_SCD30
132139
SCD30 co2Sensor_SCD30;
133140

141+
#include "MS8607_Library.h" //Click here to get the library: http://librarymanager/All#Qwiic_MS8607
142+
MS8607 pressureSensor_MS8607;
143+
134144
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
135145

136146
//Global variables
@@ -169,7 +179,7 @@ void setup() {
169179

170180
Serial.flush(); //Complete any previous prints
171181
Serial.begin(settings.serialTerminalBaudRate);
172-
Serial.printf("Artemis OpenLog v%f\n", FIRMWARE_VERSION);
182+
Serial.printf("Artemis OpenLog v%.02f\n", FIRMWARE_VERSION);
173183

174184
beginQwiic();
175185

@@ -227,7 +237,7 @@ void loop() {
227237
serialDataFile.write(incomingBuffer, sizeof(incomingBuffer)); //Record the buffer to the card
228238
incomingBufferSpot = 0;
229239
}
230-
//charsReceived++;
240+
charsReceived++;
231241
}
232242

233243
lastSeriaLogSyncTime = millis(); //Reset the last sync time to now
@@ -250,7 +260,7 @@ void loop() {
250260

251261
newSerialData = false;
252262
lastSeriaLogSyncTime = millis(); //Reset the last sync time to now
253-
//Serial.println("Total chars recevied: " + (String)charsReceived);
263+
printDebug("Total chars received: " + (String)charsReceived);
254264
}
255265
}
256266
}
@@ -342,7 +352,7 @@ void beginSD()
342352
delay(250); //Give SD more time to power up, then try again
343353
if (sd.begin(SD_CONFIG) == false) //Slightly Faster SdFat Beta (we don't have dedicated SPI)
344354
{
345-
Serial.println("SD init failed. Do you have the correct board selected in Arduino? Is card present? Formatted?");
355+
Serial.println("SD init failed. Is card present? Formatted?");
346356
digitalWrite(PIN_MICROSD_CHIP_SELECT, HIGH); //Be sure SD is deselected
347357
online.microSD = false;
348358
return;

Firmware/OpenLog_Artemis/Sensors.ino

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,26 @@ bool beginSensors()
207207
else
208208
beginSensorOutput += "SCD30 failed to respond. Check wiring.\n";
209209
}
210+
211+
if (qwiicAvailable.MS8607 && settings.sensor_MS8607.log && !qwiicOnline.MS8607)
212+
{
213+
if (pressureSensor_MS8607.begin(qwiic) == true) //Wire port. This checks both 0x40 and 0x76 sensor addresses
214+
{
215+
if(settings.sensor_MS8607.enableHeater == true)
216+
pressureSensor_MS8607.enable_heater();
217+
else
218+
pressureSensor_MS8607.disable_heater();
219+
220+
pressureSensor_MS8607.set_pressure_resolution(settings.sensor_MS8607.pressureResolution);
221+
pressureSensor_MS8607.set_humidity_resolution(settings.sensor_MS8607.humidityResolution);
222+
223+
qwiicOnline.MS8607 = true;
224+
beginSensorOutput += "MS8607 Online\n";
225+
}
226+
else
227+
beginSensorOutput += "MS8607 failed to respond. Check wiring.\n";
228+
}
229+
210230
return true;
211231
}
212232

@@ -642,6 +662,25 @@ void getData()
642662
}
643663
}
644664

665+
if (qwiicOnline.MS8607 && settings.sensor_MS8607.log)
666+
{
667+
if (settings.sensor_MS8607.logPressure)
668+
{
669+
outputData += (String)pressureSensor_MS8607.getPressure() + ",";
670+
helperText += "hPa,";
671+
}
672+
if (settings.sensor_MS8607.logHumidity)
673+
{
674+
outputData += (String)pressureSensor_MS8607.getHumidity() + ",";
675+
helperText += "humidity_%,";
676+
}
677+
if (settings.sensor_MS8607.logPressure)
678+
{
679+
outputData += (String)pressureSensor_MS8607.getTemperature() + ",";
680+
helperText += "degC,";
681+
}
682+
}
683+
645684
if (settings.logHertz)
646685
{
647686
//Calculate the actual update rate based on the sketch start time and the
@@ -677,5 +716,9 @@ void determineMaxI2CSpeed()
677716
else if (settings.sensor_uBlox.i2cSpeed == 100000)
678717
maxSpeed = 100000;
679718

719+
//If user wants to limit the I2C bus speed, do it here
720+
if(maxSpeed > settings.qwiicBusMaxSpeed)
721+
maxSpeed = settings.qwiicBusMaxSpeed;
722+
680723
qwiic.setClock(maxSpeed);
681724
}

Firmware/OpenLog_Artemis/logging.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ char* findNextAvailableLog(int &newFileNumber, const char *fileLeader)
2525
if (sd.exists(newFileName) == false) break; //File name not found so we will use it.
2626

2727
//File exists so open and see if it is empty. If so, use it.
28-
newFile = sd.open(newFileName, O_READ);
28+
newFile.open(newFileName, O_READ);
2929
if (newFile.size() == 0) break; // File is empty so we will use it.
3030

3131
newFile.close(); // Close this existing file we just opened.

Firmware/OpenLog_Artemis/lowerPower.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,15 @@ void goToSleep()
114114
am_hal_gpio_pinconfig(x, g_AM_HAL_GPIO_DISABLE);
115115

116116
//We can't leave these power control pins floating
117-
qwiicPowerOff();
118117
imuPowerOff();
119118
microSDPowerOff();
120119

120+
//Keep Qwiic bus powered on if user desires it
121+
if (settings.powerDownQwiicBusBetweenReads == true)
122+
qwiicPowerOff();
123+
else
124+
qwiicPowerOn(); //Make sure pins stays as output
125+
121126
//Power down Flash, SRAM, cache
122127
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_CACHE); //Turn off CACHE
123128
am_hal_pwrctrl_memory_deepsleep_powerdown(AM_HAL_PWRCTRL_MEM_FLASH_512K); //Turn off everything but lower 512k

0 commit comments

Comments
 (0)