You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/edge-control/tutorials/user-manual/content.md
+89-2Lines changed: 89 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -969,7 +969,7 @@ The different commands and controllable power rails will be specified in the lis
969
969
970
970
```cpp
971
971
Power.on(PWR_VBAT); // turns on the 12V power rails for the "Latching Outputs"
972
-
Power.on(PWR_3V3); // turns on the 3.3V power rail for the micro SD Card (default ON)
972
+
Power.on(PWR_3V3); // turns on the 3.3V power rail for the micro SD Card
973
973
Power.on(PWR_19V); // turns on the 19V power rail for the 4-20mA sensors reference
974
974
Power.on(PWR_MKR1); // turns on the MKR board connected to slot 1
975
975
Power.on(PWR_MKR2); // turns on the MKR board connected to slot 2
@@ -1459,4 +1459,91 @@ void loop()
1459
1459
1460
1460

1461
1461
1462
-
### Bluetooth® Low Energy
1462
+
## Micro SD Card
1463
+
1464
+
A Micro SD Card can be integrated to the Edge Control for sensor data logging, storing projects configurations or any application concerned to data storage.
1465
+
1466
+
The very known [SD library](https://www.arduino.cc/reference/en/libraries/sd/) is compatible with the Edge Control, we can test the included examples just by adding some lines of code needed by the Edge Control.
1467
+
1468
+
The example code used below is an adaptation of the "Datalogger" example included in the `SD` library. It logs the value sampled from an analog input of the Edge Control.
1469
+
1470
+
The same wiring of the [analog input section](#analog-inputs) can be used, with the addition of an micro SD card attached.
1471
+
1472
+
```cpp
1473
+
#include<Arduino_EdgeControl.h>
1474
+
#include<SPI.h>
1475
+
#include<SD.h>
1476
+
1477
+
constexprunsignedint adcResolution{ 12 };
1478
+
1479
+
const int chipSelect = PIN_SD_CS;
1480
+
1481
+
void setup() {
1482
+
// Open serial communications and wait for port to open:
1483
+
Serial.begin(115200);
1484
+
while (!Serial) {
1485
+
; // wait for serial port to connect. Needed for native USB port only
1486
+
}
1487
+
1488
+
EdgeControl.begin();
1489
+
// Power on the 3V3 rail for SD Card
1490
+
Power.on(PWR_3V3);
1491
+
Power.on(PWR_VBAT);
1492
+
1493
+
Wire.begin();
1494
+
Expander.begin();
1495
+
1496
+
Serial.print("Waiting for IO Expander Initialization...");
1497
+
while (!Expander) {
1498
+
Serial.print(".");
1499
+
delay(100);
1500
+
}
1501
+
Serial.println(" done.");
1502
+
1503
+
Input.begin();
1504
+
Input.enable();
1505
+
1506
+
analogReadResolution(adcResolution);
1507
+
1508
+
Serial.print("Initializing SD card...");
1509
+
1510
+
// see if the card is present and can be initialized:
1511
+
if (!SD.begin(chipSelect)) {
1512
+
Serial.println("Card failed, or not present");
1513
+
// don't do anything more:
1514
+
while (1)
1515
+
;
1516
+
}
1517
+
Serial.println("card initialized.");
1518
+
}
1519
+
1520
+
voidloop() {
1521
+
// make a string for assembling the data to log:
1522
+
String dataString = "";
1523
+
1524
+
int sensor = Input.analogRead(INPUT_05V_CH01); // read the Edge Control 0-5v Channel 1
1525
+
dataString += String(sensor);
1526
+
1527
+
// open the file. note that only one file can be open at a time,
1528
+
// so you have to close this one before opening another.
0 commit comments