Hi,
I have a problem which has been bothering me two evenings now; and I am just wondering if someone has a clever idea to get closer to the solution, or have a solution in general.
I have a NodeMCU ESP8266 setup as MQTT gateway using the default pin layout as described on https://www.mysensors.org/build/connect_radio. This works perfect, and have been doing various tests now with battery based sensors.
But, now I also want to create a backup system to a MicroSD card on this gateway using an MicroSD adapter. My receive() function will do these activities. Now the only problem is that I just cannot get the radio and SD card work together.
Even not when not including the SD.h (or other related) libraries. The moment the CS pin is removed from the breadboard, the NodeMCU almost instantly continues and the radio turns on.
These two evenings have been quite educational, but now it's time to get this to work :-). I also tested on another NodeMCU, which has the same issue. The SD card works standalone perfectly. Also with the radio connected it works perfect. It's just the radio that refuses to work and continues to give:
0;255;3;0;9;TSM:INIT
0;255;3;0;9;RF24:write register, reg=0, value=14
0;255;3;0;9;RF24:write register, reg=3, value=3
0;255;3;0;9;RF24:write register, reg=4, value=95
0;255;3;0;9;RF24:write register, reg=5, value=76
0;255;3;0;9;RF24:write register, reg=6, value=39
0;255;3;0;9;RF24:write register, reg=16, value=115
0;255;3;0;9;RF24:write register, reg=29, value=6
0;255;3;0;9;RF24:read register, reg=6, value=0
0;255;3;0;9;RF24:read register, reg=5, value=0
0;255;3;0;9;!RF24:INIT:SANCHK FAIL
0;255;3;0;9;!TSM:INIT:TSP FAIL
0;255;3;0;9;TSM:FAIL:CNT=7
0;255;3;0;9;TSM:FAIL:PDT
0;255;3;0;9;RF24:write register, reg=0, value=12
The CS of the radio is on D8 and the CS of the SD reader is D4. This matches with the pins as seen below (according to: https://pradeepsinghblog.files.wordpress.com/2016/04/nodemcu_pins.png?w=616)
This results from the before() function (serial print from the program):
RF 24 CS PIN
15
SD CS PIN
2
pins low
SD_CS_PIN is HIGH - GOOD
MY_RF24_CS_PIN is LOW - GOOD
The SD_CS pin is put to HIGH in the before() and pinmode are set in the before function:
pinMode (SD_CS_PIN, OUTPUT);
digitalWrite (SD_CS_PIN, HIGH);
pinMode (MY_RF24_CS_PIN, OUTPUT);
digitalWrite (MY_RF24_CS_PIN, LOW );
Remember: The SD libraries are not used at all. No begin() functions of any kind are called.
This is what I have learned over the evenings, and I think this is all what it should be. The only thing I can think of is that the SD module just ignores the CS value.
Hope that someone has a clue what could solve this issue. I am out of ideas right now.