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 }
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]); }
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); }
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){ //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"); }
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(); }
/******************************************************************************** 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); } }
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(); }
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); }
void setupRadio() { radio.begin(); radio.setRetries(0,15); radio.setPayloadSize(sizeof(PosData)); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.startListening(); }
/******************************************************************************** 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(); } }
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(); }
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"); }
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(); }
//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(); }
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(); }
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(); }
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"; }
void setup(void) { Serial.begin(115200); radio.begin(); // enable dynamic payloads radio.enableDynamicPayloads(); // optionally, increase the delay between retries & # of retries radio.setRetries(5,15); radio.openWritingPipe(pipes[1]); radio.openReadingPipe(1,pipes[0]); radio.printDetails(); }
void setup(void){ //Prepare the radio module printf("\nPreparing interface\n"); 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.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.startListening(); radio.printDetails(); }
void setup(){ uextPowerOn(); pinMode(LED, OUTPUT); pinMode(OUT, OUTPUT); Serial.begin(115200); printf_begin(); radio.begin(); radio.setCRCLength(RF24_CRC_16); radio.setDataRate(RF24_1MBPS); radio.setAutoAck(0); radio.setRetries(0,0); radio.setPayloadSize(3); radio.powerUp(); radio.printDetails(); setupReceive(); }
int main(int argc, char** argv){ uint8_t tank1pipes[][6] = {"1Node","2Node"}; uint8_t tank2pipes[][6] = {"3Node","4Node"}; if (argc > 1) { int tank; sscanf(argv[1],"%d", &tank); int num; sscanf(argv[2],"%d", &num); radio.begin(); radio.setRetries(15,15); if(tank>0 && tank < 3){ if(tank==1) { radio.openWritingPipe(tank1pipes[1]); radio.openReadingPipe(1,tank1pipes[0]); } if(tank==2) { radio.openWritingPipe(tank2pipes[1]); radio.openReadingPipe(1,tank2pipes[0]); } bool ok = radio.write( &num, sizeof(int) ); if (!ok){ printf("failed.\n"); } } else { printf("Usage: senddata <tanknumber> <action number>\n"); } } else { printf("Usage: senddata <tanknumber> <action number>\n"); } return 0; }
void setup(void) { time_t now = time(0); char* dt = ctime(&now); cout << "The local time is: " << dt << endl; tm * gmtm = gmtime(&now); dt = asctime(gmtm);; cout << "The UTC date and time is: " << dt << endl; // // Refer to RF24.h or nRF24L01 DS for settings 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); // 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); }
void setup(void) { radio.begin(); radio.setPayloadSize(PAYLOAD_SIZE); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_1MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(10); radio.setCRCLength(RF24_CRC_16); //open the pipe radio.openReadingPipe(1,0xF0F0F0F0E1LL); // Start Listening radio.startListening(); //print output radio.printDetails(); printf("\n\rOutput below : \n\r"); usleep(1000); }
void setup(void) { radio.begin(); // enable dynamic payloads radio.enableDynamicPayloads(); // optionally, increase the delay between retries & # of retries radio.setRetries(15, 15); radio.setDataRate(RF24_2MBPS); radio.setPALevel(RF24_PA_HIGH); radio.setChannel(50); // Open pipes to other nodes for communication // Open 'our' 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]); radio.setCRCLength(RF24_CRC_16); radio.setAutoAck( true ) ; // Start listening radio.startListening(); // Dump the configuration of the rf unit for debugging radio.printDetails(); }
void setup(void) { // // Setup and configure rf radio // radio.begin(); // optionally, increase the delay between retries & # of retries radio.setRetries(20, 20); radio.setPayloadSize(PAYLOAD); // TODO: set other crap (data rate, spi rate, etc) radio.setDataRate(RF24_2MBPS); radio.setChannel(0x4c); radio.setPALevel(RF24_PA_MAX); // // Open pipes to other nodes for communication // // TODO: configure this to match correctly on the Arduino radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1, pipes[1]); // // Start listening // radio.startListening(); // // Dump the configuration of the rf unit for debugging // //radio.printDetails(); std::cerr << "OK Listening for commands" << std::endl; }
void setup(void) { // set up the role pin pinMode(role_pin, INPUT); digitalWrite(role_pin,HIGH); delay(20); // Just to get a solid reading on the role pin // // Setup and configure rf radio // radio.begin(); // enable dynamic payloads radio.enableDynamicPayloads(); // optionally, increase the delay between retries & # of retries radio.setRetries(15,15); radio.setDataRate(RF24_250KBPS); // // Open pipes to other nodes for communication // // Open 'our' 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]); // // Start listening // radio.startListening(); // // Dump the configuration of the rf unit for debugging // radio.printDetails(); }
bool COM_24g::initiate(RF24 _radioCom) { bool status = false; int i; //RF24 _radioCom(_ce,_csn); _radioCom.begin(); // optionally, increase the delay between retries & # of retries _radioCom.setRetries(15,_maxRetry); _radioCom.setChannel(_channel); // optionally, reduce the payload size. seems to improve reliability //_radioCom.setPayloadSize(8); // Open pipes to other nodes for communication //seen if this is an issue _radioCom.openWritingPipe(_writingPipe); for (i=1;i<5;i++) { if (_readingPipe[i] != NULL) { _radioCom.openReadingPipe(i,_readingPipe[i]); printf("Now listening pipe %d at adress %x \n",i,_readingPipe[i]); status = true; } } if (status == true) { printf("INITIALIZATION : We are listening \n"); _radioCom.startListening(); _radioCom.powerUp(); } else { printf("We are doing a f*****g power down"); _radioCom.powerDown(); } return status; }
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(); // optionally, increase the delay between retries & # of retries radio.setRetries(15,15); // Dump the configuration of the rf unit for debugging radio.printDetails(); /********* Role chooser ***********/ printf("\n ************ Role Setup ***********\n"); string input = ""; char myChar = {0}; cout << "Choose a role: Enter 0 for pong_back, 1 for ping_out (CTRL+C to exit) \n>"; getline(cin,input); if(input.length() == 1) { myChar = input[0]; if(myChar == '0'){ cout << "Role: Pong Back, awaiting transmission " << endl << endl; }else{ cout << "Role: Ping Out, starting transmission " << endl << endl; role = role_ping_out; } } /***********************************/ // This simple sketch opens two pipes for these two nodes to communicate // back and forth. if ( !radioNumber ) { radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); } else { radio.openWritingPipe(pipes[1]); radio.openReadingPipe(1,pipes[0]); } radio.startListening(); // forever loop while (1) { if (role == role_ping_out) { // First, stop listening so we can talk. radio.stopListening(); // Take the time, and send it. This will block until complete printf("Now sending...\n"); unsigned long time = millis(); bool ok = radio.write( &time, sizeof(unsigned long) ); if (!ok){ printf("failed.\n"); } // Now, continue listening radio.startListening(); // Wait here until we get a response, or timeout (250ms) 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 { // Grab the response, compare, and send to debugging spew unsigned long got_time; radio.read( &got_time, sizeof(unsigned long) ); // Spew it printf("Got response %lu, round-trip delay: %lu\n",got_time,millis()-got_time); } sleep(1); } // // Pong back role. Receive each packet, dump it out, and send it back // if ( role == role_pong_back ) { // 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 } } } // forever loop return 0; }