2

I'm trying to combine a MySensors network with the usage of a SD card. Currently I'm working with the SD card reader on the EthernetShield v2. The NRF24L01+ chip I'm using is also using SPI but we used Soft-SPI to change the pins that is uses so I'm not using pin 4 or 10 (that are used to select the SD card as far is I know).

To read from the SD card I'm using the SdFat library. When I exclude the following part of code, the messages are getting send and I don't have any weird resets:

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

But the card keeps resetting after booting and it gives these logs:

0;255;3;0;9;!TSF:MSG:SEND,0-0-15-15,s=0,c=1,ne.
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
14;Gateway startup complete.
0;255;0;0;18;2.1.1
0;255;3;0;9;MCO:BGN:STP
initialization done.
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.1.1
0;255;3;0;9;MCO:BGN:STP
initialization done.
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
0;255;3;0;9;!TSF:MSG:SEND,0-0-15-        15,s=0,c=1,t=24,pt=0,l=25,sg=0,ft=0,st=NACK:Message Gateway -> Pongno
0;255;3;0;9;MCO:BGN:INIT GW,CP=RNNGA--,VER=2.1.1
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSF:WUR:MS=0
0;255;3;0;9;TSM:INIT:TSP OK
0;255;3;0;9;TSM:INIT:GW MODE
0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
0;255;3;0;9;MCO:REG:NOT NEEDED
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.1.1
0;255;3;0;9;MCO:BGN:STP
initialization done.
0;255;3;0;9;MCO:BGN:INIT OK,TSP=1

The code:

#define MY_DEBUG

#define MY_SOFTSPI
#define MY_RF24_CE_PIN 11
#define MY_RF24_CS_PIN 6
#define MY_SOFT_SPI_SCK_PIN 8
#define MY_SOFT_SPI_MISO_PIN 9
#define MY_SOFT_SPI_MOSI_PIN 7

#define MY_RADIO_NRF24
#define MY_RF24_CHANNEL 69
#define MY_NODE_ID 0
#define MY_GATEWAY_SERIAL


#include <MySensors.h>
#include <SPI.h>
#include "SdFat.h"
SdFat SD;

#define SD_CS_PIN 4

File myFile;
#define PONGNODEID 15


MyMessage msg(MY_NODE_ID, V_VAR1);

void setup() {
  // Open serial communications and wait for port to open:

  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  msg.setDestination(PONGNODEID);

  pinMode(10, OUTPUT); 
  digitalWrite(10, HIGH); 

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


}

void presentation() {}

long lastSent = 0;

void loop() {
  if (millis() - lastSent >= 3000) {
    lastSent = millis();
    send(msg.set("Message Gateway -> Pongnode"), true);
  }
}

Your Answer

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

Browse other questions tagged or ask your own question.