Browse Source

Moved SCL to GPIO4 because boot fails if it's connected to GPIO12

Added temperature and altitude to data logger
Added periodic log flush to avoid data loss
master
Youen Toupin 3 years ago
parent
commit
9700b9f9e1
  1. 7
      ESP32/src/DataLogger.cpp
  2. 1
      ESP32/src/DataLogger.h
  3. 4
      ESP32/src/vehicle-monitor.cpp
  4. 1589
      schema/MCU_board/MCU_board.kicad_pcb
  5. 2
      schema/MCU_board/MCU_board.kicad_prl
  6. 1976
      schema/MCU_board/MCU_board.kicad_sch
  7. 168996
      schema/MCU_board/fp-info-cache

7
ESP32/src/DataLogger.cpp

@ -72,6 +72,13 @@ void DataLogger::log(unsigned long timeMilliseconds, const Entry& entry)
sprintf(line, "%.3f,%.3f,%.3f,%.3f,%.1f,%.1f\n", currentTime, entry.speed, entry.batteryVoltage, entry.batteryOutputCurrent, entry.temperature, entry.altitude);
file.print(line);
if(currentTime >= lastFlushTime + 10.0f)
{
// we need to flush often enough, because the system is typically powered off right after arrival to destination
file.flush();
lastFlushTime = currentTime;
}
lastEntry = entry;
lastLogTime = currentTime;
}

1
ESP32/src/DataLogger.h

@ -44,6 +44,7 @@ private:
unsigned long lastTimeMilliseconds = -1;
float currentTime = 0.0f;
float lastLogTime = 0.0f;
float lastFlushTime = 0.0f;
File file; // @suppress("Abstract class cannot be instantiated")
};

4
ESP32/src/vehicle-monitor.cpp

@ -27,7 +27,7 @@ Dps310 pressureSensor = Dps310();
const int8_t speedSensorPin = 13;
const int8_t debugLedPin = 2;
const int8_t I2C_SDA = 15;
const int8_t I2C_SCL = 12;
const int8_t I2C_SCL = 4;
const float wheelDiameterInches = 20;
const int numImpulsesPerTurn = 2;
@ -383,6 +383,8 @@ void loop()
entry.batteryVoltage = (float)batteryVoltage / 1000.0f;
entry.batteryOutputCurrent = (float)batteryOutputCurrent / 1000.0f;
entry.speed = getSpeed();
entry.temperature = (float)temperature / 10.0f;
entry.altitude = (float)altitude / 1000.0f;
if(entry.speed > 0.0f)
{

1589
schema/MCU_board/MCU_board.kicad_pcb

File diff suppressed because it is too large Load Diff

2
schema/MCU_board/MCU_board.kicad_prl

@ -1,7 +1,7 @@
{
"board": {
"active_layer": 0,
"active_layer_preset": "Toutes Couches",
"active_layer_preset": "All Layers",
"auto_track_width": true,
"hidden_nets": [],
"high_contrast_mode": 0,

1976
schema/MCU_board/MCU_board.kicad_sch

File diff suppressed because it is too large Load Diff

168996
schema/MCU_board/fp-info-cache

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save