-
I would like to log data on an SD card. |
Beta Was this translation helpful? Give feedback.
Replies: 49 comments 21 replies
-
Have you tried using one of the SD card examples available on the net? If I'm not mistaken, t here are also several SD card libraries around, so the one we use in BSB-LAN may not be the one for your adapter. And of course you have to activate |
Beta Was this translation helpful? Give feedback.
-
Yes indeed To run your software without any modification, I tried to make my hardware similar to the one of the Olimex ESP32-EVB board that your software supports out of the box.
(*): or GND as CS is supposed to be active low??? I tried both without success. Could you point me into your code to the place where you specify the pin numbers of the ESP32 SPI bus connector used for communicating with the SD Card? |
Beta Was this translation helpful? Give feedback.
-
This is all done in the respective SD card library, nothing is specifically defined in BSB-LAN. That's why I recommended you to first try to get the SD adapter working with basic examples outside BSB-LAN. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Thanks providing this solution, so it means you just connect the adapter 1:1 without any other parts to the UEXT pinholes? That would really be easy. Or do you have some extra wires on the back of the adapter? |
Beta Was this translation helpful? Give feedback.
-
And CS now also goes to 3.3V? |
Beta Was this translation helpful? Give feedback.
-
Yes ~1:1, easy, no extra wire but a drop of solder between 3.3V and CS to connect them directly. |
Beta Was this translation helpful? Give feedback.
-
Thanks, but on my adapter some of the UEXT pins are not connected to anything, so how did you make the connection from the SD adapter via the UEXT pins to GPIOs 2, 14 and 15 respectively? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Only UEXT pins 1, 2, 4 and 10 are connected to VCC, GND, RX and TX, all other pins are not connected. It wouldn't make much sense to connect them to some random pins on the Joy-It rails because these may or may not have the same function. Even within the Olimex range, the UEXT pins refer to different GPIOs on the ESP32. For things like you are doing, I have connected the outer double pin row next to the UEXT connector on a 1:1 basis. So if you solder a pin header on that one, you have access to those pins. If these are not the "right" ones, then most software/library lets you configure other GPIOs so that you should be able to make it match accordingly. And no, BSB-LAN does not fall back to writing on the EEPROM if you have no SD card connected. This would lead to messed up data log files if you insert and remove the SD card because part of it would be written to the card and other parts to the EEPROM then. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Great, thanks! How did you connect the blue cable (I assume GPIO2?) to the BSB-LAN adapter? |
Beta Was this translation helpful? Give feedback.
-
I am not sure to understand perfectly your question: I connected the blue wire the same way I soldered the other wires but on the top rail. |
Beta Was this translation helpful? Give feedback.
-
Sorry for this not being so straightforward as it maybe could be, but the "upper" double row is not connected to the Joy-It header row. That's because this double row is used also for the optional use of the adapter on a Raspberry Pi. Therefore these pins cannot be shortened. Of course you could do so yourself with just a drop of solder, but if you just connected the blue wire to the adjacent pin of D14, then this means that your setup doesn't need it ;). You can try and see for yourself that on that row, the pins are not connected, so the pin would just float. |
Beta Was this translation helpful? Give feedback.
-
As unbelievable as it sounds recording data on the SD-Card was working fine without the clock signal!!! |
Beta Was this translation helpful? Give feedback.
-
Yes it is. Yesterday I performed OTA update (v3.3.2-> v3.3.3) of my original setup. It works fine with the SD card adapter connected. |
Beta Was this translation helpful? Give feedback.
-
I got my adapter working with the SPI library, using the following pins:
*Note: My adapter did not work when connecting it to 3V3, but it worked when using VIN. Other adapters, however, may work with 3V3 as well. Try VIN first, and if everything works fine, you can try 3V3 as it is easier to connect to, as you will have all required pins on one side. |
Beta Was this translation helpful? Give feedback.
-
Using wget, the speed I get is 444KB/s (11.17M in 26s). |
Beta Was this translation helpful? Give feedback.
-
I confirm it is possible to upload the firmware by USB with the SD card adapter connected and the SD card inserted (see below photos) on my WROOM (Joy-It?) board (see pictures below).
|
Beta Was this translation helpful? Give feedback.
-
That is really strange. I have an exactly same-looking WROOM-board (although not from Joy-It), and I have the same problems that you describe with the WROVER (GPIO pin 2 has to be detached to perform an upload). If there was a way to determine which boards are "good" and/or which card readers are "good", then that would be a great help, because doubling the SD card speed is certainly an advantage. But unless we can figure that out, I won't be able to recommend that solution because it will only lead to bug reports here with people claiming that either the card and/or the upload is no longer working :(... |
Beta Was this translation helpful? Give feedback.
-
Recommending this hack or not is up to you, but disconnecting an external circuitry to upload a firmware is a well known manipulation in the Arduino community, and can be done easily if the board is plugged in your BSB-LAN board, not soldered. Sadly, I am still getting the same compilation error ('SD' was not declared in this scope) with your latest firmware version. |
Beta Was this translation helpful? Give feedback.
-
Yes the firmware works fine now with the latest commit! |
Beta Was this translation helpful? Give feedback.
-
Thanks! I'll try to get a multimeter tomorrow and check if the resistance on mine is 3k3. Just to be sure, the 10k go from MISO to VCC, right? It's not 10k from the SD card MISO pin to the corresponding pin on the ESP32? |
Beta Was this translation helpful? Give feedback.
-
I was wondering if it's possible to make use of the CD pin of the SD card, but I'm not good enough in electronics to just test this by only using my imagination: If the SD card is ejected, CD is outputting low (i.e. tied to GND?). GPIO2, on the other hand, needs to be tied low when a FW update is made. Could the low CD output be used to also pull GPIO2 low as well? Because Espressif themselve suggest a similar solution:
What I don't know is what kind of transistor or something like that would be necessary so that the low signal from CD is only connecting GPIO2 to GND if CD is low. I guess that would require a PNP transistor with CD connected to the base, GPIO2 to the collector and GND to the emitter? Or vice versa? So if CD is high, nothing would happen, and if CD goes low, GPIO2 is pulled to GND and the upload will work - at least in my theory ;)... |
Beta Was this translation helpful? Give feedback.
-
Here is the reverse engineering of my card:
|
Beta Was this translation helpful? Give feedback.
-
Regarding the pullups resistors on my board, yes they are NOT mounted in series on the line but rather in parallel with 3v3. About your board, I think the 3K3 resistors are only there to limit the current going to the 74HC125. This component acts like a repeater (1->1, 0->0) but at a different voltage. What I mean is that your board could be either 3v3 or 5v logic, whereas the SD card needs to be 3v3. I am still confused about this CS line (as I thought it was a SD card output) but I think your adapter is wired very similarly to mine, and thus could work the same way (in MMC mode). CD1 and CD2 are the two poles of a switch that is open without a card and close with a SD card in. Thus you could connect those two poles between the adapter board MISO pin and the MCU board GPIO2 pin to allow disconnecting the adapter board MISO line pullup resistor when removing the SD card. It would still be necessary for those two pins to be accessible and to mention the users to remove the SD card when uploading a new firmware (which is not far from mentioning them to disconnect the SD card adapter). |
Beta Was this translation helpful? Give feedback.
-
Aaah, I forgot about the pullup which I don't have on my adapter. Never mind, then it won't work that way, and that's ok. Thanks for all your testing and the idea in the first place! |
Beta Was this translation helpful? Give feedback.
-
@sebi5361: Sorry to bother you again, but I got a SD card reader today which kind of looks like yours, except that it's for full-size SD-cards: |
Beta Was this translation helpful? Give feedback.
-
Thanks, I got a multimeter today, but just an analogue one, so measurements are not really exact. I also changed the Dupont jumper wires to make sure they are not worn out. I measure a bit above 3V on the adapter on +3.3V and MOSI. MISO and CLK are around 1.6V, both with inserted SD card and without. |
Beta Was this translation helpful? Give feedback.
-
Hi Fred. Today is a day-off in France and I finally found the time to do the measures you asked.
Hope this helps... |
Beta Was this translation helpful? Give feedback.
I got my adapter working with the SPI library, using the following pins:
*Note: My adapter did not work when connecting it to 3V3, but it worked when using VIN. Other adapters, however, may work with 3V3 as well. Try VIN first, and if everything works fine, you can try 3V3 as it is easier to connect to, as you will have all required pins on one side.
Transfer speed with SPI is around 250kB/s. Can you give us the speed with SD_MMC, @sebi5361?