#!/usr/bin/env python # # Example communicate with NRFLite RX # # from __future__ import print_function import time import struct from RF24 import * import RPi.GPIO as GPIO irq_gpio_pin = None ########### USER CONFIGURATION ########### # See https://github.com/TMRh20/RF24/blob/master/pyRF24/readme.md # Radio CE Pin, CSN Pin, SPI Speed # CE Pin uses GPIO number with BCM and SPIDEV drivers, other platforms use their own pin numbering # CS Pin addresses the SPI bus number at /dev/spidev. # ie: RF24 radio(, *10+); spidev1.0 is 10, spidev1.1 is 11 etc.. # Generic: radio = RF24(25,0); # RPi Alternate, with SPIDEV - Note: Edit RF24/arch/BBB/spi.cpp and set 'this->device = "/dev/spidev0.0";;' or as listed in /dev #radio = RF24(22, 0); # Setup for connected IRQ pin, GPIO 24 on RPi B+; uncomment to activate # irq_gpio_pin = 24 pipes = [0x0004030201, 0x0104030201] radio_id = 1 FailedTxCount = 0 millis = lambda: int(round(time.time() * 1000)) & 0xffffffff print('pyRF24/examples/basic_TX/') radio.begin() radio.setChannel(100) # channel 100 radio.setPALevel(RF24_PA_MAX) # MAX power radio.setDataRate(RF24_2MBPS) # 2MBPS radio.setRetries(1, 15) # 250+1*250us delay, 15 retries radio.enableDynamicAck() # Enable auto ack radio.enableAckPayload() # enable payload with ack and dynamic payload length radio.setCRCLength(RF24_CRC_8) # CRC8 radio.printDetails() radio.openWritingPipe(pipes[0]) radio.openReadingPipe(1, pipes[1]) # forever loop while True: # First, stop listening so we can talk. radio.stopListening() # Take the time, and send it. This will block until complete timestamp = millis() payload = struct.pack('