0

Hi I have a Beetle BLE (https://www.dfrobot.com/wiki/index.php/Bluno_Beetle_SKU:DFR0339) and I am trying to connect an Adafruit MicroSD card breakout board+ (https://www.adafruit.com/product/254) via SPI connections. I am trying the following code, but I am having trouble selecting the CS pin using D4 since the Beetle has no D10. Does anyone know if I am selecting D4 correctly, while keeping pin 10 as an output. I keep getting initialization failed! My setup is on the ICSP 6 pin configuration:

5V --> 5V

MISO --> DO

SCK -->CLK

GND --> GND

MOSI --> DI

D4 --> CS

RST is left out

Here is my code:

#include <SPI.h>

#include <SD.h>

File myFile;

void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
//   pinMode(4, OUTPUT);
   pinMode(10, OUTPUT);
//   digitalWrite(4, HIGH); // Add this line

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.

  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
  // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
  // nothing happens after setup
}
  • Schematic of the Bluno beetle can be found here: dfrobot.com/product-1259.html The atmega is connected with rx and tx via 4k7 resistor to the bluetooth chip and the bluetooth chip is connected to usb. The spi bus is not used on the module, so there is no problem with other chips. Setting pin 10 as output and use pin 4 as chip select should work. – Jot Sep 18 '18 at 7:43
1

The ICSP header labels on the Wiki page are wrong. In the schematic here the ICSP header has the same pinout as other Arduinos. The legend doesn't match the picture on the Wiki page but is true:

  • ICSP1: Atmega 328P
  • ICSP2: CC2540

The ICSP header is the inner one. Is right on the pictures. At pin 1 on board the corner of the white square around pins is skewed. The pins are from left to right first row Eeset, CLK, MISO, second row Ground, MOSI, 5 V.

pdf schematic for the board

enter image description here enter image description here enter image description here

  • Hi Juraj, thanks for your reply. There are many links on that page link including the one I sent you. Could you please send a direct link to the correct ICSP diagram? Appreciate it. – Conrad Addo Sep 18 '18 at 12:03
  • added to the answer – Juraj Sep 18 '18 at 12:10
  • Juraj and @Jot how does that correspond to the pins on the board in this picture? I'm not sure how to tell: ICSP Pin Pic – Conrad Addo Sep 18 '18 at 14:55
  • one corner is marked. it is pin 1 MISO – Juraj Sep 18 '18 at 16:39
  • Sorry Juraj, I don't see it. Can you be more specific as to the order and orientation? – Conrad Addo Sep 18 '18 at 18:09
1

The correct ICSP was on the right, ICSP1. However, the orientation of those pins were from left to right on the TOP: SCK, 5V, MISO; left to right on the BOTTOM: MOSI, RESET, GND. In the Wiki they had the ICSP labels 1 and 2 reversed, but correct in the text below. https://www.dfrobot.com/wiki/index.php/Bluno_Beetle_SKU:DFR0339

Therefore, there was nothing wrong with the code, only the wiring to the correct pins!

0

This is what I'm seeing with my multitester:

enter image description here

The cc2540 is the SMD chip on the same side as the ICSP pads. The atmega328p is on the opposite side of the PCB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.