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 2 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. 35
      schema/MCU_board/MCU_board.kicad_pcb
  5. 2
      schema/MCU_board/MCU_board.kicad_prl
  6. 22
      schema/MCU_board/MCU_board.kicad_sch

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)
{

35
schema/MCU_board/MCU_board.kicad_pcb

@ -82,9 +82,9 @@
(net 5 "Net-(J3-Pad1)")
(net 6 "Net-(J4-Pad1)")
(net 7 "Net-(J4-Pad2)")
(net 8 "Net-(U1-Pad12)")
(net 8 "Net-(J4-Pad3)")
(net 9 "Net-(J5-Pad2)")
(net 10 "Net-(U1-Pad18)")
(net 10 "Net-(J4-Pad4)")
(net 11 "unconnected-(U1-Pad1)")
(net 12 "unconnected-(U1-Pad10)")
(net 13 "unconnected-(U1-Pad4)")
@ -95,7 +95,7 @@
(net 18 "unconnected-(U1-Pad9)")
(net 19 "unconnected-(U1-Pad11)")
(net 20 "unconnected-(U1-Pad19)")
(net 21 "unconnected-(U1-Pad20)")
(net 21 "unconnected-(U1-Pad12)")
(net 22 "unconnected-(U1-Pad26)")
(net 23 "unconnected-(U1-Pad21)")
(net 24 "unconnected-(U1-Pad22)")
@ -198,9 +198,9 @@
(pad "2" thru_hole oval (at 0 2.54) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 7 "Net-(J4-Pad2)") (pinfunction "VCC") (pintype "power_in") (tstamp c8b019d7-0440-4702-b7bc-0c6e98e593c6))
(pad "3" thru_hole oval (at 0 5.08) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 10 "Net-(U1-Pad18)") (pinfunction "SDA") (pintype "bidirectional") (tstamp fa36be4e-7de9-478f-a4ef-c229ac16c103))
(net 8 "Net-(J4-Pad3)") (pinfunction "SDA") (pintype "bidirectional") (tstamp fa36be4e-7de9-478f-a4ef-c229ac16c103))
(pad "4" thru_hole oval (at 0 7.62) (size 1.7 1.7) (drill 1) (layers *.Cu *.Mask)
(net 8 "Net-(U1-Pad12)") (pinfunction "SCL") (pintype "input") (tstamp fc991e31-8b48-465c-9197-72f4fa1bee7e))
(net 10 "Net-(J4-Pad4)") (pinfunction "SCL") (pintype "input") (tstamp fc991e31-8b48-465c-9197-72f4fa1bee7e))
(model "${KICAD6_3DMODEL_DIR}/Connector_PinHeader_2.54mm.3dshapes/PinHeader_1x04_P2.54mm_Vertical.wrl"
(offset (xyz 0 0 0))
(scale (xyz 1 1 1))
@ -456,7 +456,7 @@
(pad "11" thru_hole circle (at 0 25.4) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 19 "unconnected-(U1-Pad11)") (pinfunction "GPIO14") (pintype "bidirectional+no_connect") (tstamp 03262628-1cc5-491d-862f-0eb1bd93094e))
(pad "12" thru_hole circle (at 0 27.94) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 8 "Net-(U1-Pad12)") (pinfunction "GPIO12") (pintype "bidirectional") (tstamp bd87c8ae-c0f8-478e-afa3-98b6cb999a88))
(net 21 "unconnected-(U1-Pad12)") (pinfunction "GPIO12") (pintype "bidirectional+no_connect") (tstamp bd87c8ae-c0f8-478e-afa3-98b6cb999a88))
(pad "13" thru_hole circle (at 0 30.48) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 9 "Net-(J5-Pad2)") (pinfunction "GPIO13") (pintype "bidirectional") (tstamp dd9956f2-e1a3-43eb-b682-c9200e10a75b))
(pad "14" thru_hole circle (at 0 33.02) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
@ -468,11 +468,11 @@
(pad "17" thru_hole circle (at 25.4 33.02) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 6 "Net-(J4-Pad1)") (pinfunction "GND") (pintype "power_in") (tstamp 8382be0b-64da-434d-b3bb-5bc1d436be2d))
(pad "18" thru_hole circle (at 25.4 30.48) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 10 "Net-(U1-Pad18)") (pinfunction "GPIO15") (pintype "bidirectional") (tstamp fbd23587-9e1b-4461-b511-2257604d25ff))
(net 8 "Net-(J4-Pad3)") (pinfunction "GPIO15") (pintype "bidirectional") (tstamp fbd23587-9e1b-4461-b511-2257604d25ff))
(pad "19" thru_hole circle (at 25.4 27.94) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 20 "unconnected-(U1-Pad19)") (pinfunction "GPIO2") (pintype "bidirectional+no_connect") (tstamp 73012d62-09f7-4e13-998e-800cf36a3c2b))
(pad "20" thru_hole circle (at 25.4 25.4) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 21 "unconnected-(U1-Pad20)") (pinfunction "GPIO4") (pintype "bidirectional+no_connect") (tstamp 0dee7dc7-28b8-43a0-982f-9fa20c03186e))
(net 10 "Net-(J4-Pad4)") (pinfunction "GPIO4") (pintype "bidirectional") (tstamp 0dee7dc7-28b8-43a0-982f-9fa20c03186e))
(pad "21" thru_hole circle (at 25.4 22.86) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
(net 23 "unconnected-(U1-Pad21)") (pinfunction "RX2") (pintype "bidirectional+no_connect") (tstamp 790da2d6-8e50-4f89-a27a-5123b485dd01))
(pad "22" thru_hole circle (at 25.4 20.32) (size 1.8 1.8) (drill 0.9) (layers *.Cu *.Mask)
@ -742,7 +742,7 @@
(dimension (type aligned) (layer "User.1") (tstamp a1df1579-7f98-456b-96b2-f2255e6a78f1)
(pts (xy 139.7 109.22) (xy 139.7 43.18))
(height -7.62)
(gr_text "66,0400 mm" (at 130.93 76.2 90) (layer "User.1") (tstamp a1df1579-7f98-456b-96b2-f2255e6a78f1)
(gr_text "66.0400 mm" (at 130.93 76.2 90) (layer "User.1") (tstamp a1df1579-7f98-456b-96b2-f2255e6a78f1)
(effects (font (size 1 1) (thickness 0.15)))
)
(format (units 3) (units_format 1) (precision 4))
@ -751,7 +751,7 @@
(dimension (type aligned) (layer "User.1") (tstamp b74d18b6-0a0c-4ef4-b5e7-77a6be3fc614)
(pts (xy 139.7 109.22) (xy 183 109.22))
(height 5.08)
(gr_text "43,3000 mm" (at 161.35 113.15) (layer "User.1") (tstamp b74d18b6-0a0c-4ef4-b5e7-77a6be3fc614)
(gr_text "43.3000 mm" (at 161.35 113.15) (layer "User.1") (tstamp b74d18b6-0a0c-4ef4-b5e7-77a6be3fc614)
(effects (font (size 1 1) (thickness 0.15)))
)
(format (units 3) (units_format 1) (precision 4))
@ -776,16 +776,17 @@
(segment (start 144.78 50.8) (end 144.78 53.34) (width 0.25) (layer "F.Cu") (net 5) (tstamp 5259d978-b387-4967-b81c-f641c98585a8))
(segment (start 175.1375 91.44) (end 180.34 91.44) (width 0.25) (layer "F.Cu") (net 6) (tstamp e4195b8f-3996-4a59-b6a1-76534a4e174b))
(segment (start 180.34 93.98) (end 175.1375 93.98) (width 0.25) (layer "F.Cu") (net 7) (tstamp 05a60061-f69f-4cf0-982b-3b600d194cef))
(segment (start 172.72 99.06) (end 160.02 86.36) (width 0.25) (layer "F.Cu") (net 8) (tstamp 63fcfc59-7439-416e-96ce-38a112eb4939))
(segment (start 180.34 99.06) (end 172.72 99.06) (width 0.25) (layer "F.Cu") (net 8) (tstamp b982722b-1bf7-4726-a5b9-a2b33c43ad35))
(via (at 160.02 86.36) (size 0.8) (drill 0.4) (layers "F.Cu" "B.Cu") (net 8) (tstamp 60d76cd4-7135-41b5-bb14-f84115e2b595))
(segment (start 160.02 86.36) (end 149.7375 86.36) (width 0.25) (layer "B.Cu") (net 8) (tstamp 6f13e8dd-8f95-4897-aa4a-7af39b71330f))
(segment (start 175.1375 88.9) (end 177.8 88.9) (width 0.25) (layer "F.Cu") (net 8) (tstamp 9e5b0177-ea58-4f76-8b57-ff1c6e52d9df))
(segment (start 177.8 96.52) (end 180.34 96.52) (width 0.25) (layer "F.Cu") (net 8) (tstamp dfa2c928-7d9a-4cd3-90db-112716296421))
(via (at 177.8 88.9) (size 0.8) (drill 0.4) (layers "F.Cu" "B.Cu") (net 8) (tstamp b7340f23-0eaa-48ae-aea8-b5b53a0ae99a))
(via (at 177.8 96.52) (size 0.8) (drill 0.4) (layers "F.Cu" "B.Cu") (net 8) (tstamp f630bdcd-b048-45d2-91a0-928349b89dad))
(segment (start 177.8 88.9) (end 177.8 96.52) (width 0.25) (layer "B.Cu") (net 8) (tstamp e8cb6cb3-dd2b-4328-8592-132e369ebb71))
(segment (start 160.02 88.9) (end 149.7375 88.9) (width 0.25) (layer "B.Cu") (net 9) (tstamp 527346bb-ea73-4a6b-90c5-e15d8df2e57f))
(segment (start 167.64 81.28) (end 160.02 88.9) (width 0.25) (layer "B.Cu") (net 9) (tstamp 8fd52544-866c-407e-990a-b7ff97bb39d0))
(segment (start 167.64 48.26) (end 167.64 81.28) (width 0.25) (layer "B.Cu") (net 9) (tstamp e39b0b7f-91f8-45ca-b50b-563bff3dc7f3))
(segment (start 172.72 88.9) (end 175.1375 88.9) (width 0.25) (layer "F.Cu") (net 10) (tstamp 17bfb2da-c5fc-4e07-91e1-b9c5ab3fe262))
(segment (start 180.34 96.52) (end 172.72 96.52) (width 0.25) (layer "F.Cu") (net 10) (tstamp 50e2510b-285f-450d-924c-851068760a2c))
(segment (start 172.72 96.52) (end 172.72 88.9) (width 0.25) (layer "F.Cu") (net 10) (tstamp c8b088e8-33f6-4063-86e4-a7b123b42783))
(segment (start 170.18 99.06) (end 170.18 83.82) (width 0.25) (layer "F.Cu") (net 10) (tstamp 45676199-bb82-4d58-98c1-b606deb355be))
(segment (start 180.34 99.06) (end 170.18 99.06) (width 0.25) (layer "F.Cu") (net 10) (tstamp 55ac7ee1-f461-406b-8cf5-da47a7717180))
(segment (start 170.18 83.82) (end 175.1375 83.82) (width 0.25) (layer "F.Cu") (net 10) (tstamp b14aea3f-7e9b-4416-ac0e-1c7beb3cd27c))
(segment (start 154.94 60.96) (end 149.7375 60.96) (width 0.25) (layer "F.Cu") (net 32) (tstamp 61e763ec-1c1c-4f1e-a003-f55d7ad04f9f))
(segment (start 154.94 48.26) (end 154.94 60.96) (width 0.25) (layer "F.Cu") (net 32) (tstamp e5c077a6-2e6e-4ddb-9cdd-7189d5453897))
(segment (start 144.78 63.5) (end 149.7375 63.5) (width 0.25) (layer "F.Cu") (net 33) (tstamp 30bfa64d-761b-4732-997d-bd4590e66c7b))

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,

22
schema/MCU_board/MCU_board.kicad_sch

@ -598,7 +598,6 @@
(uuid 95ffd3f8-cc4e-49e8-a469-fe0ef795ac79)
)
(no_connect (at 104.14 92.71) (uuid 42e27ade-eeba-4263-a787-39f108a3f5bf))
(no_connect (at 104.14 95.25) (uuid 675b2a1e-1d1e-4f5b-91f1-23d348015a92))
(no_connect (at 104.14 90.17) (uuid 7a036c8b-424e-4cd3-9042-9dd09fe44aa7))
(no_connect (at 104.14 87.63) (uuid 7a036c8b-424e-4cd3-9042-9dd09fe44aa8))
@ -620,6 +619,7 @@
(no_connect (at 104.14 69.85) (uuid 8df7c71e-685c-43dd-af60-6f9cdc315f85))
(no_connect (at 104.14 77.47) (uuid 8df7c71e-685c-43dd-af60-6f9cdc315f86))
(no_connect (at 39.37 62.23) (uuid a6b973bf-3c82-4206-bae7-4f835d16d359))
(no_connect (at 55.88 95.25) (uuid e8a669b7-c663-4fa5-9b1f-ce9eb01dc726))
(wire (pts (xy 52.07 48.26) (xy 52.07 72.39))
(stroke (width 0) (type default) (color 0 0 0 0))
@ -633,6 +633,10 @@
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 0b437303-3880-4c2e-936f-36b72f5e5c8c)
)
(wire (pts (xy 110.49 107.95) (xy 113.03 107.95))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 14b56486-a565-4ad2-9d4e-44e6442ea175)
)
(wire (pts (xy 49.53 100.33) (xy 55.88 100.33))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 1adb5de4-24a9-45d7-81f0-5bb173e17332)
@ -661,10 +665,6 @@
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 4269b426-1ca0-4358-b7c8-f87d360b6b77)
)
(wire (pts (xy 54.61 95.25) (xy 55.88 95.25))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 457cdafe-757b-46b6-9d3e-8d438360f308)
)
(wire (pts (xy 109.22 97.79) (xy 109.22 105.41))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 58175922-1337-43ad-ad83-f2ad48af61c5)
@ -705,13 +705,9 @@
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 9918ed3d-ef60-4f9c-bbab-d5a94c54dede)
)
(wire (pts (xy 113.03 107.95) (xy 54.61 107.95))
(wire (pts (xy 104.14 92.71) (xy 110.49 92.71))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid a89c5c87-c6cf-48f3-a098-73aaf195ccfc)
)
(wire (pts (xy 54.61 107.95) (xy 54.61 95.25))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid aea22020-99fc-43b4-984a-a7253337aa40)
(uuid a7b396e8-387b-4006-982d-ca6acb770010)
)
(wire (pts (xy 104.14 100.33) (xy 113.03 100.33))
(stroke (width 0) (type default) (color 0 0 0 0))
@ -745,6 +741,10 @@
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid db08d23b-92e3-4f99-8704-1a66ba98c4e9)
)
(wire (pts (xy 110.49 92.71) (xy 110.49 107.95))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid dfa04c8b-bd8e-46e0-b63e-f2b2ac1e224a)
)
(wire (pts (xy 49.53 48.26) (xy 52.07 48.26))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid e15ae67b-2c04-433b-9d01-93c6a63abb6c)

Loading…
Cancel
Save