#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD_MMC 4-bit Mode */
if (!SD_MMC.begin()) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD_MMC);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
}
#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD_MMC 1-bit Mode */
if (!SD_MMC.begin("/cdcard", true)) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD_MMC);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
}
#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD SPI Mode at HSPI */
SPIClass spi = SPIClass(HSPI);
spi.begin(14 /* SCK */, 12 /* MISO */, 13 /* MOSI */, 15 /* SS */);
if (!SD.begin(15 /* SS */, spi, 80000000)) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
}
采用 32GB 闪迪 TF卡出现以下问题:
#include "FS.h"
#include "SD.h"
#include "SD_MMC.h"
void WriteFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
//unsigned long start_time = millis();
Serial.printf("write [%s]...\n", path);
File file = fs.open(path, FILE_WRITE);
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (!file.write(buf, len)) {
Serial.println("Write failed");
return;
}
file.flush();
file.close();
Serial.printf("Write [%s] Complete", path);
}
void ReadFile(fs::FS &fs, const char *path, uint8_t *buf, int len)
{
Serial.printf("read [%s]...\n", path);
File file = fs.open(path);
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
if (!file.read(buf, len)) {
Serial.println("Read failed");
return;
}
file.close();
Serial.printf("Read [%s] Complete: %s", path, buf);
}
void testIO(fs::FS &fs)
{
char buf[] = "hello world";
WriteFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
ReadFile(fs, "/test.txt", (uint8_t *)buf, strlen(buf));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("请插入内存卡");
delay(8000);
/* SD SPI Mode at VSPI */
SPIClass spi = SPIClass(HSPI);
spi.begin(18 /* SCK */, 19 /* MISO */, 23 /* MOSI */, 5 /* SS */);
if (!SD.begin(5 /* SS */, spi, 80000000)) {
Serial.println("Card Mount Failed");
return;
}
testIO(SD);
SD_MMC.end(); // 取消SD挂载
}
void loop() {
}
采用 32GB 闪迪 TF卡出现 VSPI 同样问题,换成 32GB Kingston TF 卡正常。
RISC-V(发音为“risk-five”)是一个基于精简指令集(RISC)原则的开源指令集架构(ISA)。RISC-V指令集可以自由地用于任何目的,允许任何人设计、制造和销售RISC-V芯片和软件。
相信很多人都有把绿植给养死的经历,可能是浇水过多、忘记浇水、较长时间不在家不能浇水等,本文介绍一种可以灵活定制的智能浇花方案。
MicroPython 在 ESP32 上支持线程(Thread)功能,通过_thread模块实现。线程允许程序并发执行多个任务,适合处理需要同时运行的场景,例如传感器数据采集和网络通信。
掌控板3.0升级了主控,还主打AI。带有双麦克风阵列,增加了音频解码芯片,板载了一个1W喇叭,还把之前的单色屏幕换成了1.47寸的彩色屏幕,有更多的可玩性。
使用了 MicroPython 库,通过 定时器(Timer) 和 ADC(模数转换器) 功能来实时读取传感器数据。使用定时器可以实现高精度、非阻塞、低资源消耗的周期性任务,保证实时性和可靠性,特别适用于嵌入式系统中的多任务处理和低功耗场景。
ESP32的DAC函数可以实现真正的模拟输出。
ESP32 没有Arduino输出 PWM 的 analogWrite(pin, value) 方法,取而代之的 ESP32 有一个 LEDC 来实现PWM功能。
本书由少年创学院联合创始人兼院长、知名创客程晨撰写,以Arduino作为硬件平台,介绍了使用米思齐(Mixly)软件进行程序开发的方法。
本文学习如何使用ESP32开发板来进行多线程的开发。
ESP8266有三种工作模式,分别为:AP,STA,AP混合STA