Slave (receiver) example of using nRF24L01 with STM32F407VET6.
Slave (receiver) example of using nRF24L01 with STM32F407VET6 black boards.
Connect (plug in) the nRF24L01 module to the NRF24L01 connector located on the STM32F407VET6 board as follows:
nRF24L01 | STM32F407VET6 |
---|---|
Vcc | +3.3V |
GND | GND |
MOSI | PB_5 (SPI1 MOSI) |
MISO | PB_4 (SPI1 MISO) |
SCK | PB_3 (SPI1 SCK) |
CSN | PB_7 (CS) |
CE | PB_6 (CE) |
Diff: main.cpp
- Revision:
- 1:9bafc8faffdf
- Parent:
- 0:818ff5c70049
- Child:
- 2:4c5ac5e09740
--- a/main.cpp Wed Jan 23 07:46:08 2019 +0000 +++ b/main.cpp Wed Jan 23 17:45:09 2019 +0000 @@ -1,7 +1,7 @@ #include "mbed.h" #include "RF24.h" -const uint64_t ADDRESS = 0xF0F0F0F0F0F0F001L; +const uint64_t ADDRESS = 0xF0F0F0F0F0F0F001LL; DigitalOut led(PA_6); RF24 radio(PB_5, PB_4, PB_3, PB_7, PB_6); // mosi, miso, sck, csn, ce, (irq=Not Connected) @@ -13,14 +13,14 @@ radio.begin(); radio.setPALevel(RF24_PA_LOW); radio.setRetries(5, 15); - radio.setPayloadSize(1); + radio.setPayloadSize(sizeof(payload)); radio.setAutoAck(true); radio.openReadingPipe(0, ADDRESS); // use pipe 0 of this slave to receive messsages and send back auto acknowledge radio.startListening(); while (1) { if (radio.available()) { - radio.read(&payload, 1); // read radio message and send acknowledge back to the master + radio.read(&payload, sizeof(payload)); // read message and send acknowledge back to the master led = payload; } }