This blog is to use the ESB for building the RFID demo. On every 2 seconds, the PTX would send 4 times RFID data out.
Here is the demo code at the github
https://github.com/jimmywong2003/nrf52-esb-rtc-low-power

static void send_packet(uint8_t *data_ptr, uint32_t length)
{
static nrf_esb_payload_t esb_payload;
esb_payload.noack = 0;
esb_payload.pipe = 0;
memcpy(esb_payload.data, data_ptr, length);
esb_payload.length = length;
nrf_esb_write_payload(&esb_payload);
tx_packets_loaded++;
}
int main(void)
{
ret_code_t err_code;
NRF_POWER->DCDCEN = 1;
gpio_init();
err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
hfclock_start();
rtc_init();
err_code = esb_init();
APP_ERROR_CHECK(err_code);
NRF_LOG_DEBUG("RFID PTX Started.");
uint8_t esb_packet[4] = {0};
while (true)
{
if(tx_send_packet)
{
hfclock_start();
esb_packet[1]++;
send_packet(esb_packet, 4);
NRF_LOG_DEBUG("tx_send_packet = %d", tx_send_packet);
tx_send_packet = false;
}
if(tx_packets_loaded == 0)
{
// If the buffers are empty, disable the HF clock to save power
hfclock_stop();
NRF_LOG_DEBUG("Stop HFCLK");
}
NRF_LOG_FLUSH();
powerdown();
}
}
The average current consumption of the PTX (measured by Nordic Power Profile Kit) is around 3.6 uA shown as below.
