It is better answer for some reseans in Enrf library you can not send data with write untill txbuf_len==0
size_t Enrf24::write(uint8_t c) {
if (txbuf_len == 32) { flush(); // Blocking OTA TX } txbuf[txbuf_len] = c; txbuf_len++; return 1; }
dont use purge then
txbuf_len = 0
this is for read dat
#include <SPI.h>
#include <Enrf24.h>
#include <nRF24L01.h>
#define ce_nrf PB12
#define csn_nrf PB13
#define irq_nrf PA0
Enrf24 radio(ce_nrf, csn_nrf, irq_nrf); // P2.0=CE, P2.1=CSN, P2.2=IRQ
const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
const char *str_on = "ON";
const char *str_off = "OFF";
void dump_radio_status_to_serialport(uint8_t);
void setup() {
Serial.begin(9600);
SPI.begin();
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
radio.begin(); // Defaults 1Mbps, channel 0, max TX power
radio.setRXaddress((void*)rxaddr);
radio.enableRX(); // Start listening
// radio.autoAck(false);
}
void loop() {
char inbuf[35];
if (radio.read(inbuf))
{
Serial.print("Received packet: ");
Serial.println(inbuf);
}
}
this is write for write data:
#include <SPI.h>
#include <Enrf24.h>
#include <nRF24L01.h>
#include <string.h>
#define ce_nrf PB12
#define csn_nrf PB13
#define irq_nrf PA0
Enrf24 radio(ce_nrf, csn_nrf, irq_nrf); // P2.0=CE, P2.1=CSN, P2.2=IRQ
const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };
void setup() {
Serial.begin(9600);
SPI.begin();
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
radio.begin(); // Defaults 1Mbps, channel 0, max TX power
radio.setTXaddress((void*)txaddr);
}
int i=0;
void loop() {
i++;
Serial.print("Sending packet: ");
Serial.println(i);
radio.print("1234567890123456789012--------->");
//radio.purge();
delay(100);
}