I am trying to use an Arducam OV5642 with a SD Card reader module ( https://www.simcoe-diy.ca/product-page/micro-sd-tf-card-memory-shield-module) and an RTC (DS3231).
I have the MISO, MOSI, SCK, VCC and GND wired from the ICSP header to a breadboard and from those columns on the breadboard to the appropriate lines on those 3 devices.
When I run the code with everything connected I get SPI Error and it doesn't execute myCAM.write_reg(ARDUCHIP_TEST1, 0x55); and the output of that value remains 255 (FF), so it's clearly not writing to it.
But when I unplug the sd card reader that's plugged into the same mosi, miso, sck from the breadboard it works immediately (with everything remaining powered on), changing the value appropriately and demonstrating that the SPI to the camera works.
I've tried my best to learn how to use SPI correctly with more then one device but only found articles/tutorials that glance on the topic and don't really explain things well.
I just want to take a picture, save it to the SD card, and ultimately to do this on a fixed time basis (aka time-lapse) with the RTC that's connected to I2C.
If I connect the MISO, MOSI, SCK to pin 50, 51, 52 of my arduino mega nothing works at all, it only works if I connect it directly to the ICSP header on the arduino.
TESTING2.ino (1.39 KB)
I think the problem is that your SD card module does not release the MISO line when it is not selected by its CS line. All of the lines go through the level translator, and all of its gates are enabled all the time, which is wrong for MISO. This it pretty typical of these modules. You'll find several discussions about this in the Storage subforum. If you are up to making changes on the module, here's a fix that ought to work (if that's really the problem). Another fix that I haven't tried is just inserting a 3.3K resistor in series in the MISO line going only to the SD module. It will still interfere with other devices driving MISO, but they will prevail because of the resistor.
But I'm confused about the DS3231. I thought that communicated by I2C, not SPI.
I've partly fixed it because I didn't realize that the SD card reader is 3.3v.
When I changed its vcc to the 3.3v source the error I described didn't happen, but I still can't get the camera to take a picture atm, and now it will detect the camera and say SPI is fine but not detect the SD card reader. It sounds like the problem is what you say, I just am unsure on how to implement a solution, I'm really about as noob as they come when it comes to electronics cuz the diagram you linked is chinese to me. Are you saying to just run a wire between MISO and what is DAT0? my SD card reader has 6 pins for CS SCK MOSI, MISO VCC and GND respectively.
The DS3231 is I2C and it wasn't causing any problems in so far as I can tell, it was when I put the SD card reader in the loop that this problem occured.
I will look into your suggestion, from my meager understanding I was under the impression that when its CS pin is HIGH the master will 'ignore' the slave, until the slave's signal is LOW but clearly this isn't solving the problem for me.
I also wasn't sure if I needed to put a pull-up resistor on the SDA/SCL lines, I read something about open drain, but it seems that their not needed.
It's basically this camera module, which uses both I2C and SPI that is giving me so many troubles. I've managed to write files to the SD card based on the RTC time (serves no purpose lol but it was to see if I had connected them together correctly).
Well, the SD card itself is 3.3V, but the card module has a 3.3V regulator and voltage translator built in, so you need to provide 5V at the module's Vcc pin for it to work properly.
CS is active low. It is an output from the master that enables a specific slave. Slaves are not supposed to drive their MISO outputs back to the master unless their CS is low. The translator chip on your module ignores that rule, so it's transmitting on MISO when the other SPI slave is supposed to be doing that, which messes things up.
What I posted is called a schematic. I really don't know how to help you if you can't read it. DAT0 is a pin on the SD card holder - the metal box the card fits into. You would have to connect a wire from that pin to the MISO header pin. But you also would need to cut the existing trace on the module that connects the header pin to the translator chip.
It's expensive, but it looks like this microSD module is wired correctly:
I know what a schematic is, I just don't know how to interpret the one you linked because I have never seen a DATx pin on my SD card reader shield, as I said my shield has 6 pins CS SCK MOSI MISO VCC and GND.
It is this module: https://www.simcoe-diy.ca/product-page/micro-sd-tf-card-memory-shield-module
I have been unable to find a datasheet on this module that gives the chips pinout so I just don't know which pin to solder a wire to or more importantly which diodes trace to cut.
It's a shame I can't seem to find data logging shield anywhere in Canada cuz that would simplify this whole mess, I figured I would be capable of connecting 3 devices on a breadboard though but apparently not.
Does anyone know of a Canadian vendor who has arduino data logging shields (so has RTC and sd card reader in one package like this one: Adafruit Assembled Data Logging shield for Arduino : ID 1141 : $13.95 : Adafruit Industries, Unique & fun DIY electronics and kits )?
Note: I won't buy from Adadfruit, they want $20+ shipping for a tiny shield and the last time I ordered which was before COVID it took 3-4 weeks for the part to arrive, I dont have that time, patience, or money and just wish I knew of more then one Canadian vendor
I have a module exactly like yours, assuming yours actually looks like the pictures on that link. I'll trace it out later today and post a picture of what needs to be done. By the way, the description on your link says specifically that the MISO line is run through the translator chip, so that's definitely the problem. The DAT pins are the pins on the metal SD holder. It's supposedly pin 7, but I'll have to trace out what that means.
Yeah it's that exact module. I appreciate your help, I don't even have a multimeter, or a continuity meter to do it myself if I wanted to so your help means a lot, cuz this is frustrating the hell out of me and it shouldn't be!.
I'm posting pictures of the top and bottom of my module, and you should be sure your traces look the same before making any changes. The third picture shows the modification. Basically, you cut one trace, then solder a wire from pin 7 of the holder over to the MISO pin of the header. The hard part is soldering the wire to pin 7. It's easier if you melt a bit of solder to the end of the wire first (pre-tin) so you can hold the wire in place with one hand and just apply heat with the other.
I've tested this modification using the Read/Write example from the SD library, and it works fine after you set the CS pin correctly (CS = pin 10 on my Nano). And the resulting wiring is the same as used on the Adafruit module, so I'm pretty sure this works generally.
Yeah mine looks identical, just a more generic label on the back.
My soldering tip is unusable, went to 3 stores today and nobody seems to have soldering iron tips in stock, maybe COVID lol. Oh well put on hold for a few days until amazon order arrives. Will let you know if it fixes it.
Well if you have a 3.3K resistor, you could try the other fix, which is to insert the resistor in the line going from the MISO header pin of the SD module to the MISO pin of your Arduino.
None in the kit I bought, I'll have to wait, oh well hopefully only a few days.
That trace on the chip is going to be a ... challenge, will be interesting to see if I can even do it. Good thing this module isn't expensive.
I don't think 3.3K is critical. You might try it with whatever you have that's close to 3.3K. Maybe two 10Ks in parallel, or two 1Ks in series.
Is your soldering iron not working at all, or is the tip just bad? If it heats up properly, you could wrap about 10 turns of bare solid wire around the tip, and use the wire end as a temporary tip.
Cutting the existing trace can be done with any knife. If soldering to pin 7 of the holder is too difficult, there's an alternate point you could solder the wire to, and that's the right side of R4, which is the middle part on the upper right. You could just solder the wire to the right side of the resistor.