【ESP32】SDカードの読み書き CATALEX MicroSD Card Module 複数SPIで使う時の改造とか【SPI】

シェアする

スポンサーリンク
広告

CATALEX MicroSD Card Module

小さいのもあるけど、何が違うんだろう?

上がバッファ回路と5V→3.3Vレギュレータ付きで、下が直結バージョンですね。直結といっても。。信号線には10kΩが入ってるようですね。

こういうのってDatasheet落ちてるから。。って安易に、ちょっと前に買ったんだけど。。ArduinoのForumで見てみると。。

Catalex MicroSD Card Reader Issues
I found the solution for this probem. The MISO pin (7) of card need a pul-up resistor (10k~100k) when there is no pull-up in the microcontroller. However, in ...
I cannot find the datasheet for Catalex MicroSD Card Adapter
Hi, guys. I'm using the Catalex MicroSD Card Adapter in my final paper and I'd like to put some more consistent information about it, with reference and schema...
SOLVED. Nrf24 (Mirf lib) + Micro SD-card works OK together
knut_ny: Mod will fix it . I tried the mod, how unlucky i am that the whole pin 13 of the level shifter is pulled out, meaning that i dont have space to sold...

いろいろなことが乗ってて参考になります。回路はこれが正しいのかな?

Catalex microSDモジュールは常にMISOを駆動し、他のSPIデバイスに干渉する可能性があることに注意してください。 チップセレクトがハイになると、SDモジュールはMISOでハイZになるはずです。 チップセレクトがハイの場合、CatalexシールドはMISOのバッファを無効にします。

らしいので、このままだと1個だけしかSPIバスに付けられないみたいですね。

チップセレクトが聞くようにするには、下記の改造が必要とのこと。。13Pinを切って8ピンとつなげるようです。

catalex.jpg

13Pinを上げて。。

pulled_up_pin.JPG

8Pinとつなげるってこういうことなんですね(笑)

mod__.JPG

チップセレクトしない場合には、下記の使っている人がいたので。。普通にも使えるようです。

Arduinoで使う場合

http://everyday-science-society.blogspot.com/2014/10/arduinosd.html

ESP32でPinを変更して使う場合

ESP32開発ボードにMicroSDカードモジュールをつける | 東京お気楽カメラ

ESP32 でのSDを使うSketchの注意

ライブラリの ArduinoのSD.h と ESP32のSD.h が違うので注意が必要みたいですね。

ESP32(ESP32-DevKitC)でmicroSDカードを使う | SOAR130650
ESP32(ESP32-DevKitC)で取得したデータをmicroSDカードに保存する方法を調べ、温湿度ロガーを作成しました。

SDのフォーマットについても。。

esp32でSDcardに書き込んでみる
esp32(esp-wroom-32)を使ってsdカードに書き込みをしてみました。当初、SDカードを認識してくれず、認識しても書き込んでくれず、arduinoとして使えるesp32ですが、ちょっと違ったところもあるようです。ということで、e

2GBまではFAT16
4GB~32GBまではFAT32

あと、ディレクトリというか、ファイル名などの指定でも、

Arduino : filename.txt
ESP32 : /filename.txt

のような指定も違うようですね。

スケッチ例→SD(esp32)→ SD_test.ino

とりあえず、このPin配置を見ながら。。

https://tom2rd.sakura.ne.jp/wp/wp-content/uploads/2019/07/esp32_pinmap.png

ブレッドボード上では。。こんな感じ。。

で。。ちゃんと動きます。

実行してみると。。こんなのが出てきます。

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:10944
load:0x40080400,len:6388
entry 0x400806b4
SD Card Type: SDHC
SD Card Size: 29844MB
Listing directory: /
DIR : /System Volume Information
FILE: /foo.txt SIZE: 13
FILE: /test.txt SIZE: 1048576
Creating Dir: /mydir
Dir created
Listing directory: /
DIR : /mydir
DIR : /System Volume Information
FILE: /foo.txt SIZE: 13
FILE: /test.txt SIZE: 1048576
Removing Dir: /mydir
Dir removed
Listing directory: /
DIR : /System Volume Information
Listing directory: /System Volume Information
FILE: /System Volume Information/IndexerVolumeGuid SIZE: 76
FILE: /System Volume Information/WPSettings.dat SIZE: 12
FILE: /foo.txt SIZE: 13
FILE: /test.txt SIZE: 1048576
Writing file: /hello.txt
File written
Appending to file: /hello.txt
Message appended
Reading file: /hello.txt
Read from file: Hello World!
Deleting file: /foo.txt
File deleted
Renaming file /hello.txt to /foo.txt
File renamed
Reading file: /foo.txt
Read from file: Hello World!
1048576 bytes read for 3311 ms
1048576 bytes written for 5446 ms
Total space: 29832MB
Used space: 1MB

さて。。Pinを変える場合は、以下が味噌のようです。

enum { sd_sck = 18, sd_miso = 19, sd_mosi = 23, sd_ss = 5 };

SPI.end();
SPI.begin(sd_sck, sd_miso, sd_mosi, sd_ss); SD.begin(sd_ss,SPI)

SD.begin(sd_ss,SPI)

スポンサーリンク
広告

コメントを残していただけるとありがたいです

Loading Facebook Comments ...
%d人のブロガーが「いいね」をつけました。