1

I have troubles to connect a NRF24L01 transceiver to a Wemos D1 R2 board. I succeeded on an Arduino Uno. Does anyone know the pinout?

I used (same as with Uno):

D13 - SCK
D12 - MI
D11 - MO

D8 and D9 for CE and CSN

Code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

// NRF24 Radio #define CE_PIN 'D8' #define CSN_PIN 'D9'

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

// NRF24 Radio radio.begin(); if (!radio.isChipConnected()) { Serial.println("ERROR: NRF24 Chip not connected"); } else { Serial.println("NRF24 Chip connected"); radio.setDataRate( RF24_250KBPS ); radio.setRetries(3,5); // delay, count radio.openWritingPipe(slaveAddress); }

Result: ERROR: NRF24 Chip not connected

If I use:

#define CE_PIN   8
#define CSN_PIN  9

then Wemos crashes (reboot exception (4)) so I tried with D, but I get a warning, maybe related:

warning: multi-character character constant [-Wmultichar]
   22 | RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
      |            ^~~~~~
 warning: multi-character character constant [-Wmultichar]
   22 | RF24 radio(CE_PIN, CSN_PIN); // Create a Radio 
ocrdu
  • 1,775
  • 3
  • 11
  • 24
FredV
  • 11
  • 2
  • Does anyone knows the pinout? ... pinout of what? – jsotola Apr 18 '23 at 23:53
  • always format error messages as code ... fixed it for you – jsotola Apr 18 '23 at 23:57
  • 1
    strings are defined by double quote marks, eg. "abc123" ... single characters are defined by single quote marks, eg. 'e' ... two characters inside single quotes are illegal syntax, eg. 'D8' ... remove the single quotes in the two define statements .... you are doing RF24 radio('D8', 'D9');, when you should be doing RF24 radio(D8, D9); – jsotola Apr 19 '23 at 00:11
  • @jsotola Did not know that. Thanx! – FredV Apr 20 '23 at 08:05
  • FredV, answers go into the Answer box – Juraj Apr 20 '23 at 09:49
  • @juraj Thanx for teaching me how to use the forum and your answer! – FredV Apr 20 '23 at 10:59

1 Answers1

0

Select Wemos D1 R2/mini in Tools menu in IDE. Then you can use the Dx names of the pins. Don't put them in quotes.

Since D8 is CS pin at the Uno pin 10 location, you can't use it as CE. And because esp8266 has less pin than Atmega328 of Uno, there is no pin D9. I recommend you to use pins D1 and D2 for CE and CSN.

RF24 radio(D1, D2);

Here you can read how the Dx pins are mapped to esp8266 pins and what is the common function of the pins.

enter image description here

Juraj
  • 18,037
  • 4
  • 29
  • 49