void setupRadio() {
  printf_begin();

  // Setup and configure radio
  radio.begin();
  radio.setAutoAck(1);                    // Ensure autoACK is enabled
  radio.enableAckPayload();               // Allow optional ack payloads
  radio.setRetries(2,15);                 // Smallest time between retries, max no. of retries
  radio.setPayloadSize(8);
  radio.setDataRate(RF24_250KBPS);
  
  if( radio.getDataRate() == RF24_250KBPS ) 
  {
    debugPrint("Radio is available");
    radio_hw_available = true;
    
    radio.startListening();                 // Start listening
    radio.powerUp();
  
    radio.openWritingPipe(pipes[0]);       // Open different pipes when writing. Write on pipe 0, address 0
    radio.openReadingPipe(1,pipes[1]);     // Read on pipe 1, as address 1
  } else {
    debugPrint("Radio is NOT available");
  }
  //radio.printDetails(); // Dump the configuration of the rf unit for debugging
}
// Setup //
void setup(void) {
  //
  // Print preamble
  //

  printf("\n\rRF24/examples/scanner/\n\r");
  //
  // Setup and configure rf radio
  //
  radio.begin();
  radio.setAutoAck(false);
  // Get into standby mode
  radio.startListening();
  radio.stopListening();
  // Print out header, high then low digit
  int i = 0;
  while ( i < num_channels )
  {
    printf("%x",i>>4);
    ++i;
  }
  printf("\n\r");
  i = 0;
  while ( i < num_channels )
  {
    printf("%x",i&0xf);
    ++i;
  }
  printf("\n\r");
}
Example #3
0
void setup() {
  // - Setup serial port
  Serial.begin(115200);

  // - Pin initialization
  pinMode(STEP_UP_PIN, OUTPUT);
  digitalWrite(STEP_UP_PIN, LOW);

  // - Read address selection
  pinMode(ADDRESS_SELECTION_PIN, INPUT_PULLUP);
  if(digitalRead(ADDRESS_SELECTION_PIN) == HIGH) {
    nodeAddress[0] = 0x01;
  } else {
    nodeAddress[0] = 0x02;
  }

  // - Setup and configure radio
  radio.begin();
  //radio.enableDynamicPayloads();
  radio.setPayloadSize(PAYLOAD_SIZE);
  radio.setDataRate(RF24_250KBPS); // - Lower speed
  radio.setPALevel(RF24_PA_HIGH); // - Higher power level

  radio.openWritingPipe(gatewayAddress); // - To send values
  radio.openReadingPipe(1, nodeAddress); // - Not used in reality

  radio.powerDown();
}
Example #4
0
void setup(void) {
    //maxa = EEPROM.read(CONFIG_START);
    //EEPROM.write(CONFIG_START, maxa);
    lcd.begin (20,4);
    delay(10);
    lcd.setBacklightPin(BACKLIGHT,POSITIVE);
    lcd.setBacklight(HIGH);
    lcd.clear();
    delay(10);
    lcd.home ();
    
    Serial.begin(57600);

    printf_begin();
    
    radio.begin();
    radio.setPALevel(RF24_PA_MAX); //RF24_PA_MIN = 0, RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR 
    radio.setDataRate(RF24_250KBPS); //RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS
    //radio.setAutoAck(1);
    radio.setRetries(15,15);
    
    radio.enableDynamicPayloads();
    
    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1, pipes[0]);
    radio.startListening();
    radio.printDetails();
}
Example #5
0
void setup(void)
{
  printf("\n\rnRF24l01+ remotecmd\n\r");

  //
  // Setup and configure rf radio
  //

  radio.begin();

  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);

  // optionally, reduce the payload size.  seems to
  // improve reliability
//  radio.setPayloadSize(PACKET_LENGTH);
  radio.setChannel(0x4c);
  radio.setPALevel(RF24_PA_MAX);

  //
  // Open pipes to other nodes for communication
  //

  // Open pipe for writing
  // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading)

  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);

}
Example #6
0
void setup(void)
{
  TRI_LOG(sizeof(long));
  TRI_LOG(sizeof(int));
	// Refer to RF24.h or nRF24L01 DS for settings

  TRI_LOG_STR("radio.begin()");
  radio.begin();

  TRI_LOG_STR("CONFIGURE_RADIO(radio)");
  CONFIGURE_RADIO(radio);

	// Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading )
  radio.openWritingPipe(WRITING_PIPE);
  radio.openReadingPipe(1, READING_PIPE);

  radio.startListening();

	//
	// Dump the configuration of the rf unit for debugging
	//
  radio.printDetails();

  memset(&EMPTY_MESSAGE, 0, sizeof(ArPiMessage));
}
Example #7
0
void setup(void)
{
	wiringPiSetupGpio();

	//
	// Refer to RF24.h or nRF24L01 DS for settings
	radio.begin(WPI_MODE_GPIO);
	radio.enableDynamicPayloads();
	radio.setAutoAck(1);
	radio.setRetries(15,15);
	radio.setDataRate(RF24_1MBPS);
	radio.setPALevel(RF24_PA_MAX);
	radio.setChannel(76);
	radio.setCRCLength(RF24_CRC_16);

	// Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading )
	radio.openWritingPipe(pipes[0]);
	radio.openReadingPipe(1,pipes[1]);
	radio.openReadingPipe(2,pipes[2]);
	radio.openReadingPipe(3,pipes[3]);
	radio.openReadingPipe(4,pipes[4]);
	radio.openReadingPipe(5,pipes[5]);

	//
	// Dump the configuration of the rf unit for debugging
	//

	// Start Listening
	radio.startListening();

	radio.printDetails();
	printf("\n\rOutput below : \n\r");
	usleep(1000);
}
Example #8
0
/********************************************************************************
Main
********************************************************************************/
int main(void) {
    // initialize code
	usart_init();

    // enable interrupts
    //sei();

	_delay_ms(2000);

    printf("Start NRF24L01P test...");

    radio.begin();
    radio.setRetries(15,15);
    radio.setPayloadSize(8);
    radio.setPALevel(RF24_PA_MAX);
    radio.setChannel(120);

    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1,pipes[0]);

    radio.startListening();

    radio.printDetails();

	loop();

    // main loop
    while (true) {
    	_delay_ms(1000);
    	printf("Elapsed: %u \n", TCNT1);
    }
}
Example #9
0
void setup(void)
{
        //
        // Refer to RF24.h or nRF24L01 DS for settings
        radio.begin();
        radio.enableDynamicPayloads();
        radio.setAutoAck(1);
        radio.setRetries(15,15);
        radio.setDataRate(RF24_250KBPS);
        radio.setPALevel(RF24_PA_MAX);
        radio.setChannel(70);
        radio.setCRCLength(RF24_CRC_8);

        // Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading )
        radio.openWritingPipe(pipes[0]);
        radio.openReadingPipe(1,pipes[1]);
        radio.openReadingPipe(2,pipes[2]);
        radio.openReadingPipe(3,pipes[3]);
        radio.openReadingPipe(4,pipes[4]);
        radio.openReadingPipe(5,pipes[5]);

        // Start Listening
        radio.startListening();

        radio.printDetails();

        usleep(1000);
}
void setup(void){
	//Prepare the radio module
	printf("\nPreparing NRF24L01 interface\n");
	radio.begin();
	radio.setRetries( 15, 15);
	radio.setChannel(120);
	radio.enableAckPayload();
	//radio.disableCRC();
	radio.setAutoAck(true);
	radio.openWritingPipe(pipes[0]);
	radio.openReadingPipe(2,pipes[1]);
	radio.openReadingPipe(3,pipes[2]);
	radio.openReadingPipe(1,pipes[0]);
	radio.printDetails();
	printf("\nPreparing MySQL interface.\n");
	mysql_connect();
	if ((mysql1 != NULL)) {
		sprintf(SQLstring,"CREATE TABLE IF NOT EXISTS CC_SENSOR_DYN (timestamp DATETIME, id INTEGER, temperature FLOAT, value INTEGER);");
		if (!mysql_query(mysql1, SQLstring)) { printf("SQL CC_SENSOR_DYN Table is Ok: %s\n",SQLstring); }  else { printf("SQL CC_SENSOR_DYN NOk: %s\n",SQLstring); printf("%s\n", mysql_error(mysql1)); }

		sprintf(SQLstring,"CREATE TABLE IF NOT EXISTS CC_SENSOR_HIST (timestamp DATETIME, id INTEGER, hist_type VARCHAR(1), hist_period INTEGER, value FLOAT);");
		if (!mysql_query(mysql1, SQLstring)) { printf("SQL CC_SENSOR_HIST Table is Ok: %s\n",SQLstring); }  else { printf("SQL CC_SENSOR_HIST NOk: %s\n",SQLstring); printf("%s\n", mysql_error(mysql1)); }
				
		}
	radio.startListening();
	printf("\nNow Listening...\n");

}
Example #11
0
int main(int argc, char** argv){
	radio.begin();

	// optionally, increase the delay between retries & # of retries
	radio.setRetries(0,0);

	// Dump the configuration of the rf unit for debugging
	radio.printDetails();
	string input = "";
	cout << "Choose your node number. #0-6 \n>";
	getline(cin,input);

	int radioNumber = (int)input[0]-48;

	cout << "input" << input << "\n";

	radio.openWritingPipe(pipes[radioNumber]);

	for (int i = 0; i < 6; i++) {
		if (i != radioNumber) {
			cout << i << "\n";
    		radio.openReadingPipe(i,pipes[i]);
		}
	}

}
void setup(void)
{
	// setup interrupt
	gpio_export(int_gpio_num);
	gpio_set_edge(GPIO_STR, "rising", "1");

	radio.begin();
	// enable dynamic payloads
	radio.enableAckPayload();
	radio.enableDynamicPayloads();
	radio.setAutoAck(1);
	// optionally, increase the delay between retries & # of retries
	radio.setRetries(15, 15);
	radio.setDataRate(RF24_2MBPS);
	radio.setPALevel(RF24_PA_MIN);
	radio.setChannel(50);
	radio.setCRCLength(RF24_CRC_16);
	// Open pipes to other nodes for communication
	// Open pipe for reading
	radio.openReadingPipe(0, pipes[0]);
	radio.openReadingPipe(1, pipes[1]);
	// Start listening
	radio.startListening();
	// Dump the configuration of the rf unit for debugging
	radio.printDetails();
}
Example #13
0
int main(int argc, char** argv){

//  bool role_ping_out = true, role_pong_back = false;
//  bool role = role_pong_back;

  printf("RF24/examples/GettingStarted/\n");

  // Setup and configure rf radio
  radio.begin();

  radio.setChannel(2);
  radio.setDataRate(RF24_2MBPS);
  radio.setPayloadSize(8);

  // optionally, increase the delay between retries & # of retries
//  radio.setRetries(15,15);
  // Dump the configuration of the rf unit for debugging
  radio.printDetails();


/***********************************/
	radio.startListening();
	
	// forever loop
	while (1)
	{

		// if there is data ready
		if ( radio.available() )
		{
			// Dump the payloads until we've gotten everything
			unsigned long got_time;

			// Fetch the payload, and see if this was the last one.
			while(radio.available()){
				radio.read( &got_time, sizeof(unsigned long) );
			}
//			radio.stopListening();
				
//			radio.write( &got_time, sizeof(unsigned long) );

			// Now, resume listening so we catch the next packets.
//			radio.startListening();

			// Spew it
			printf("Got payload(%d) %lu...\n",sizeof(unsigned long), got_time);
			
				
		}
		delay(925); //Delay after payload responded to, minimize RPi CPU time
		printf("."); fflush(stdout);
//  radio.printDetails();
		

	} // forever loop

  return 0;
}
Example #14
0
void setup(void)
{
  //Serial.begin(57600);
  //Serial.println("RF24Network/examples/helloworld_rx/");
  printf("RF24Network/examples/helloworld_rx/");
 
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
}
Example #15
0
void setupRadio() {
  radio.begin();
  radio.setRetries(0,15);
  radio.setPayloadSize(sizeof(PosData));
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1,pipes[1]);

  radio.startListening();
}
Example #16
0
void pcmRF::begin(){
	radi.begin();
	radi.setChannel(1);                 // Set RF channel to 1
	radi.setAutoAck(0);                 // Disable ACKnowledgement packets
	radi.setDataRate(RF24_1MBPS);         // Set data rate as specified in user options
  	radi.setCRCLength(RF24_CRC_8);
    radi.openWritingPipe(addresses[1]);
    radi.openReadingPipe(1,addresses[0]);
}
Example #17
0
void setup(void){

    radio.begin();
    radio.setPALevel(RF_24_PA_MAX);
    radio.setChannel(0x75);
    radio.openWritingPipe(0xF0F0F0F0E1LL);
    radio.enableDynamicPayloads();
    radio.powerUp();

}
/********************************************************************************
	Main
********************************************************************************/
int main(void) {
    // initialize usart module
	usart_init();

    // enable interrupts
    sei();

    // Init GPIO
    initGPIO();

    // Init Timer 1
    initTimer();

    // Init Timer 0 & 2
    initTimers();

	OCR0A = 255;
	OCR0B = 255;
	OCR2A = 255;
	OCR2B = 255;

    _delay_ms(1000);

	OCR0A = 0;
	OCR0B = 0;
	OCR2A = 0;
	OCR2B = 0;

    fixZeroValueOCR();

	// Console friendly output
    printf("Start...");
    printf(CONSOLE_PREFIX);

    // Init NRF24L01+
    radio.begin();
    radio.setRetries(15,15);
    radio.setPayloadSize(8);
    radio.setPALevel(RF24_PA_MAX);
    radio.setChannel(115);

    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);

    radio.startListening();

    // Some RF module diagnostics logs
    radio.printDetails();

	// main loop
    while (1) {
    	// main usart loop for console
    	usart_check_loop();
    }
}
Example #19
0
void setup()
{
  Serial.begin(9600);
  //delay(1000);
  radio.begin();
  print_welcome_message();
  radio.openReadingPipe(1,pipe[0]);//For Receiving Operation
  radio.openWritingPipe(pipe[1]);//For Transmitting Operation
  radio.startListening();

}
void setup()
{

    Serial.begin(115200);
    printf_begin();
    Serial.println(F("\n\n** NeoPixelWirelessClient ** \n\n"));

    Serial.println(F("Reading client configuration...."));
    if( !readClientConfiguration( (client_configuration_t *)&clientConfig) )
    {
        Serial.println(F("** Error reading client configuration\n"));
        clientConfig.version = CLIENT_CONFIG_V10;
        clientConfig.nodeId = 0x01;
        if( !writeClientConfiguration((client_configuration_t *)&clientConfig) )
        {
            Serial.println(F("** Error writing client configuration\n"));
        }
        else
        {
            Serial.println(F("Successfully wrote client configuration\n"));
        }
    }
    else
    {
        Serial.println(F("Successfully Read Configuration:\n"));
    }
    dumpClientConfiguration((client_configuration_t *)&clientConfig);

    // Setup and configure radio
    radio.begin();
    radio.enableAckPayload(); // enable payload ack
    radio.enableDynamicPayloads(); // Ack payloads are dynamic payloads

    setNodeId(clientConfig.nodeId);
//	radio.openWritingPipe(addresses[1]);
//	radio.openReadingPipe(1, addresses[0]);
//	radio.startListening(); // we're the client, so start listening
    radio.writeAckPayload(1, &message_count, sizeof(message_count));
    ++message_count;
    radio.printDetails(); // Dump the configuration of the rf unit for debugging
    delay(50);
    attachInterrupt(0, check_radio, LOW); // Attach interrupt handler to interrupt #0 (using pin 2) on BOTH the sender and receiver

    if (controller.initialize(50, 2) == false)
    {

    }
    else
    {
        controller.fill(CRGB::Black, true);
    }

}
Example #21
0
void rf24_init(RF24& radio) {
	const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
	radio.begin();
	//	radio.setChannel(100);
	radio.setRetries(15, 15);
	radio.setPayloadSize(sizeof(report_t));
	radio.setDataRate(RF24_250KBPS);
	radio.openWritingPipe(pipes[1]);
	radio.openReadingPipe(1, pipes[0]);
	radio.startListening();
	radio.printDetails();
}
Example #22
0
int main(int argc, char** argv)
{
  printf("RF24 example starting.")

  /** Set up the radio **/
  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1, pipes[1]);
  radio.startListening();


  /** Loop forever, writing and then listening for response **/
  while (1)
  {
    /** Send out the current time **/
    radio.stopListening();
    unsigned long time = millis();
    bool ok = radio.write(&time, sizeof(unsigned long));

    if (!ok)
      printf("Failed to send for some reason.\n");

    radio.startListening();


    /** Start waiting around for the response **/
    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while( !radio.available() && !timeout )
    {
      if (millis() - started_waiting_at > 200)
        timeout = true;
    }


    /** Describe the results **/
    if (timeout)
    {
      printf("Failed. Response timed out.\n")
    }
    else
    {
      unsigned long got_time;
      radio.read(&got_time, sizeof(unsigned long))

      printf("Got response %lu, round-trip delay: %lu\n",
            got_time, millis() - got_time);

      sleep(1);
    }
  }
void radioSetup() {
  radio.begin();
  radio.setRetries(15, 15);
  radio.setChannel(0x4c); //76
  radio.setPALevel(RF24_PA_MAX);
  radio.setPALevel(RF24_PA_MAX);

  radio.openWritingPipe(pipes[0]);
  radio.openReadingPipe(1, pipes[1]);
  radio.startListening();
  radio.printDetails();
  printf("Radio setup is complete!\n");
}
//Initial setup of GPIO Pins and pipe modes (read/write).
void setup(void)
{
  radio.begin();
  radio.setRetries(15,15);
  radio.setChannel(0x4c);
  radio.setPALevel(RF24_PA_MAX);
    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
    radio.openReadingPipe(2,pipes[2]);
    radio.openReadingPipe(3,pipes[3]);

  radio.startListening();
  radio.printDetails();
}
Example #25
0
void setup(void)
{
    // init radio for reading
    radio.begin();
    radio.enableDynamicPayloads();
    radio.setAutoAck(1);
    radio.setRetries(15,15);
    radio.setDataRate(RF24_1MBPS);
    radio.setPALevel(RF24_PA_MAX);
    radio.setChannel(76);
    radio.setCRCLength(RF24_CRC_16);
    radio.openReadingPipe(1,0xF0F0F0F0E1LL);
    radio.startListening();
}
Example #26
0
void initialiseBoard()
{
    Serial.begin(57600);
    radio.begin();
    mapFreeCH();
    // optionally, increase the delay between retries & # of retries
    radio.setRetries(15,15);
    radio.setPayloadSize(PAYLOAD_SIZE);
    \
    radio.openWritingPipe(pipes[0]);
    radio.openReadingPipe(1,pipes[1]);
    radio.startListening();

}
Example #27
0
void setup(void){
	//Prepare the radio module
	printf("\nPreparing interface\n");
	radio.begin();
	radio.setRetries( 15, 15);
	radio.setChannel(0x4c);
	radio.setPALevel(RF24_PA_MAX);
	radio.setPALevel(RF24_PA_MAX);

	radio.openWritingPipe(pipes[0]);
	radio.openReadingPipe(1,pipes[1]);
	radio.startListening();
	radio.printDetails();

}
Example #28
0
void setup(void) {
   // init radio for reading
   radio.begin();
   radio.enableDynamicPayloads();
   radio.setAutoAck(1);
   radio.setRetries(15,15);
   //radio.setDataRate(RF24_1MBPS);
   //radio.setPALevel(RF24_PA_MAX);
   //radio.setChannel(76);
   //radio.setCRCLength(RF24_CRC_16);
   radio.openReadingPipe(1,pipes[1]);
   radio.startListening();
   radio.printDetails();
   cout << "Listening...\n";
}
Example #29
0
void setupRF24(){
    radio.begin();

    // Set the PA Level low to prevent power supply related issues since this is a
    // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
    // radio.setPALevel(RF24_PA_LOW);
    radio.setPALevel(RF24_PA_MAX);

    // Open a writing and reading pipe
    radio.openWritingPipe((byte *) TXNAME);
    radio.openReadingPipe(1, (byte *) RXNAME);

    // Start the radio listening for data
    radio.startListening();

    radio.powerDown();
}
Example #30
0
void setup(void)
{
  //
  // Print preamble
  //

  //Serial.begin(57600);
  //printf_begin();
  printf("\n\rRF24/examples/scanner/\n\r");

  //
  // Setup and configure rf radio
  //

  radio.begin();
  radio.setAutoAck(false);
//	radio.enableDynamicPayloads();
	radio.setPayloadSize(2);
	radio.setDataRate(RF24_250KBPS);
	radio.setPALevel(RF24_PA_MAX);
//	radio.setChannel(76);
	radio.setCRCLength(RF24_CRC_16);

  // Get into standby mode
  radio.startListening();
  radio.stopListening();

  radio.printDetails();

  // Print out header, high then low digit
  int i = 0;
  while ( i < num_channels )
  {
    printf("%x",i>>4);
    ++i;
  }
  printf("\n\r");
  i = 0;
  while ( i < num_channels )
  {
    printf("%x",i&0xf);
    ++i;
  }
  printf("\n\r");

}