nrf24l01 and arduino Pin 10 should be always high

Hi

In My Project i am using NRF24L01 for communication between two Arduino.

At receiver side i have made my PIN 10 as output. In few article i have read that pin 10 should be always HIGH.

Pin 10 will go high only when i receive some data from transmitter or it will be low always.

Can someone please suggest me am i doing wrong?

Can someone please suggest me am i doing wrong?

Not without seeing your code

Read this before posting a programming question

Also take a look at Simple nRF24L01+ 2.4GHz transceiver demo

Here is my receiver code

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <SPI.h>
#include "RF24.h"
#define LED_TILT      9
#define LED_VOLTAGE   10
#define LED_SIREN     4
#define HIGH_BATTERY  220
float pressLength_milliSeconds = 0;
int optionOne_milliSeconds = 100;
int optionTwo_milliSeconds = 2000;    
unsigned long previousMillis = 0;    
long interval = 1000; 
int buttonPin = 6;
int SIREN = 3;
int BUZZER = 5;
int counter = 0;   
struct DataPacket 
{
  int voltage;
  bool tilt;
};
const uint64_t talking_pipes[2] = { 0xF0F0F0F0D5LL, 0xF0F0F0F0C6LL };
const uint64_t listening_pipes[2] = { 0x3A3A3A3AD5LL, 0x3A3A3A3AC6LL };
DataPacket data[2];
unsigned long lastMilis[2];
RF24 radio(7,8);
void watchdogSetup(void)
{
  wdt_reset();
  WDTCSR = bit (WDCE) | bit (WDE);
  WDTCSR = bit (WDCE) | bit (WDE) | bit (WDIE) | bit (WDP3) | bit (WDP0);    // set WDIE, and 8 seconds delay
}
void setup()
{
  Serial.begin(9600);
  pinMode(LED_TILT, OUTPUT);
  pinMode(LED_VOLTAGE, OUTPUT);
  pinMode(buttonPin, INPUT);     
  pinMode(SIREN, OUTPUT); 
  pinMode( LED_SIREN, OUTPUT); 
  pinMode(BUZZER, OUTPUT);
 digitalWrite(SIREN,HIGH);
 digitalWrite(BUZZER,LOW);
  
  radio.begin();
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.setChannel(108);
   radio.openReadingPipe(1,talking_pipes[0]);
  radio.openReadingPipe(2,talking_pipes[1]);
  radio.startListening();
  
  data[0].voltage = 500;
  data[0].tilt = 1;

  data[1].voltage = 500;
  data[1].tilt = 1;

  lastMilis[0] = 0;
  lastMilis[1] = 0;
  Serial.println("Initialisation complete.");
}

void loop()
{
  
  uint8_t pipe_num;
  if ( radio.available(&pipe_num) )
  {
    unsigned long got_time;
    bool done = false;
    Serial.println( pipe_num, DEC);
    radio.read(&data[pipe_num - 1], sizeof(DataPacket) );
    lastMilis[pipe_num - 1] = millis();
    Serial.println(data[pipe_num - 1].voltage, DEC);
    Serial.println(data[pipe_num - 1].tilt, DEC);
     radio.stopListening();
    radio.openWritingPipe(listening_pipes[pipe_num-1]);
    radio.write( &got_time, sizeof(unsigned long) );
    printf("Sent response to %04x.\n\r",pipe_num);
    radio.startListening();
  }

   unsigned long currentMillis = millis();
if (currentMillis > (lastMilis[0] + 100000)) 
  {
    data[0].voltage = 0;
  }
if (currentMillis > (lastMilis[1] + 100000)) 
  {
    data[1].voltage = 0;
  }
if (currentMillis > (lastMilis[0] + 600000)) 
   {  data[0].tilt = true;
     // digitalWrite(SIREN,HIGH);
      digitalWrite(BUZZER, LOW); 
      digitalWrite(LED_SIREN, LOW);
       digitalWrite(LED_TILT, LOW);
   }
if (currentMillis > (lastMilis[1] + 600000)) 
  {   data[1].tilt = true;
      //digitalWrite(SIREN,HIGH);
      digitalWrite(BUZZER, LOW); 
       digitalWrite(LED_SIREN, LOW);
       digitalWrite(LED_TILT, LOW);
  }

// SIRE ON BUT NOT OFF

if ((!data[0].tilt) || (!data[1].tilt))
    digitalWrite(LED_SIREN, HIGH);
    
 
// TILT TO GPS AND BUZZER    
if ((data[0].tilt) && (data[1].tilt))
   { 
    digitalWrite(LED_TILT, LOW);
    //digitalWrite(BUZZER, LOW);
   }
else 
    if ((!data[0].tilt) && (!data[1].tilt))
     { digitalWrite(LED_TILT, HIGH);
       digitalWrite(BUZZER, HIGH);
       Serial.println ("BOTH CAP OPEN ");
     }
    else 
    {
      if (!data[0].tilt)
        interval = 5000;
      else
        interval = 10000;
 
      unsigned long currentMillis = millis();
    
      if (currentMillis - previousMillis >= interval) 
      {
         previousMillis = currentMillis;
        if (digitalRead(LED_TILT) == LOW) 
         {
          digitalWrite(LED_TILT, HIGH);
          digitalWrite(BUZZER, HIGH);
          Serial.println (" ONE CAP OPEN ");
          } 
        else 
        {
          digitalWrite(LED_TILT, LOW);
          //digitalWrite(BUZZER, LOW);
        }
     }
   }
if ((data[0].voltage >= HIGH_BATTERY) && (data[1].voltage >= HIGH_BATTERY))
   { 
    digitalWrite(LED_VOLTAGE, LOW);
   //digitalWrite(BUZZER, LOW);
    }
else if ((data[0].voltage < HIGH_BATTERY)&& (data[1].voltage < HIGH_BATTERY))
   {
     digitalWrite(LED_VOLTAGE, HIGH);
     digitalWrite(BUZZER, HIGH);
     Serial.println ("BUZZER ON BOTH CONNECTION LOST ");
    }
    else 
  {
      if ((data[0].voltage < HIGH_BATTERY))
        interval = 10000;
      else
        interval =20000;
      unsigned long currentMillis = millis();
      if (currentMillis - previousMillis >= interval) 
    {
        previousMillis = currentMillis;
      if (digitalRead(LED_VOLTAGE) == LOW) 
       {
          digitalWrite(LED_VOLTAGE, HIGH);
          digitalWrite(BUZZER, HIGH);
          Serial.println ("BUZZER ON ONE CONNECTION LOST ");
       } 
       else 
       {
          digitalWrite(LED_VOLTAGE, LOW);
         //digitalWrite(BUZZER, LOW);
       }
    } 
  }
  { 
    while (digitalRead(buttonPin) == HIGH )
    {
    delay(100); 
    pressLength_milliSeconds = pressLength_milliSeconds + 100;   
    Serial.print("ms = ");
    Serial.println(pressLength_milliSeconds);
    }
  if (pressLength_milliSeconds >= optionTwo_milliSeconds)
   {
   digitalWrite(LED_SIREN, LOW);
   digitalWrite(SIREN,HIGH);
      if ((data[0].tilt) && (data[1].tilt))
     {digitalWrite(LED_TILT, LOW);
      
      Serial.print ("siren connection oN ");
      digitalWrite(BUZZER, LOW); 
     }
   }
else if(pressLength_milliSeconds >= optionOne_milliSeconds)
   {
    digitalWrite(SIREN,LOW);
    Serial.print ("siren connection oFF "); 
    digitalWrite(BUZZER, HIGH);
   }
      pressLength_milliSeconds = 0;
  }
}

Hi,
Have you got some basic NRF codes that JUST checks the NFR units and communications?

Tom... :slight_smile:

Pin 10 just needs to be set as OUTPUT. And it does not have to be used for the nRF24 - it can be used for anything that needs an OUTPUT pin. You can use any Arduino pins for CE and CSN.

...R