Wireless thermostat with RF24

Hello again!

I'm playing with arduino, LCD display and RF24 to make simple wireless thermostat. But I have problem with the RF module. It show me that it doesn't send the data. What's interesting that when I disconnect the RF module, it show that the data was send successfully :astonished:

I use Arduino Nano3, LCD keypad shield, LM35 as temperature sensor and NRF24L01+. BTW pin 13 is on arduino connected also to on board LED. Could be this the problem?

Here is the whole code of the remote side:

#include 
#include "nRF24L01.h"
#include "RF24.h"
#include 


RF24 radio(9,10); // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

const uint64_t pipe = 0xE8E8F0F0E1LL; // Single radio pipe address for the 2 nodes to communicate.

uint8_t state[1];

volatile float temp = 0.0;
volatile float set_tmp = 20.0;
volatile int i = 0;

//LiquidCrystal lcd(5, 4, 9, 8, 7, 6);    //reversed pins!
LiquidCrystal lcd(4, 3, 8, 7, 6, 5);      //shifted pins

int read_buttons(void)
{
  int key_read = analogRead(0);
  
  if (key_read > 900)  return 0;  //NONE
  if (key_read < 50)   return 1;  //Right  0
  if (key_read < 180)  return 2;  //UP  132
  if (key_read < 360)  return 3;  //Down 310
  if (key_read < 530)  return 4;  //Left 482
  if (key_read < 770)  return 5;  //Select  722
  return 0;                       //NONE
}

void setup(void)
{
  state[0] = 0;
  
  radio.begin();     // Setup and configure rf radio

  radio.openWritingPipe(pipe);    // Open pipes to other nodes for communication

  radio.printDetails();    // Dump the configuration of the rf unit for debugging
  
  lcd.begin(16, 2);    // set up the LCD's number of columns and rows:
  
  // Print a message to the LCD.
  lcd.setCursor(0,0);
  lcd.print("Teplota:");
  lcd.setCursor(14,0);
  lcd.print((char)223);
  lcd.setCursor(15,0);
  lcd.print("C");  

}

void loop(void)
{
  char key = read_buttons();
  if(key == 2)
  {
    set_tmp = set_tmp + 0.1;
    delay(10);
  }
  
  if(key == 3)
  {
    set_tmp = set_tmp - 0.1;
    delay(10);
  }
  
  temp = 0;  
  for (i=0; i<64; i++)
  {
    temp = temp + ((float)analogRead(2)*494.3/1023);
  }
  

  temp = temp/64;
  
  lcd.setCursor(9,0);
  lcd.print(temp);
  
  if (temp < (set_tmp-0.5))
  {
    state[0] = 11;
    lcd.setCursor(0,1);
    lcd.print("zapnuto");
  }
  else if(temp > (set_tmp+0.5))      
  {
    state[0] = 0;
    lcd.setCursor(0,1);
    lcd.print("vypnuto");
  }
  
  lcd.setCursor(9,1);
  lcd.print(set_tmp);
  
  
  // Remote role
      bool ok = radio.write(state, sizeof(state) );
      lcd.setCursor(14,1);
      if (ok)
        lcd.print("ok");
      else
        lcd.print("--");
}

Thanks for any help and happy new year! :)

Pin 10 is used on the keypad shield for backlight control and it may be conflict with

RF24 radio(9,10); // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

Well it looks that this should be the problem. But another problem is, that I don't have any free digital pin... I tried to use A1 as digital, but still it doesn't send the data and also is interesting, that after this change when I disconnect and connect back the RF24 module, the arduino reboot itself...

I don't know why you can't get one of the analog pins to work as digital in your application. Your reset problems are also confusing.

If for some unknown reason you continue to have problems using an analog pin as digital, I suggest that you temporarily free one of the used digital pins, and confirm that the pin 10 conflict is indeed the source of your problem.

If that's truly the case, there are some hardware modifications you can make to the lcd shield if you don't need to turn the backlight on and off. You would disconnect pins 15/16 from the transistor and pin 10 backlight control and power them from jumper wires with a resistor.

Well I will try to remove the unused pins of the LCD (I don't need the back-light control now) I thought that the pin is used in LCD library, but now I discovered that no, right? If I would like to use it, I need to program it my way...

Well then there must be something wrong. BTW the RF24 is powered by 3,3V but all people connect the rest of the pins directly into arduino (which is 5V logic). Isn't that killing the RF24?

Anyway I just ordered esp8266 esp-07 wireless module and I will try to play with this (but it will take at least 14 days until it came)... Still I would like to get these RF24 working.

EDIT: Removed the pins and even the LED on pin13 and still nothing. What is interesting. The arduino makes different thing when the RF24 is plugged or not. When disconect it, it makes only short "ticks" on the pin13. When connected, it makes longer. I can see it on the LED and on a noise on ADC...

Read this “sticky” post from the Displays section of this forumhttp://forum.arduino.cc/index.php?topic=96747.0 It explains about the pin 10 issue and shows a circuit diagram.

Edit: I would get the RF 24 part of your sketch running without the shield and use the Serial Monitor. One you are solid with the radios, work on the display and the buttons if you use them.

I know about the problem with backlight control. That's why I didn't use it...

I will try to make the RF24 working without the LCD shield if it will help..

cattledog: Pin 10 is used on the keypad shield for backlight control and it may be conflict with

RF24 radio(9,10); // Set up nRF24L01 radio on SPI bus plus pins 9 & 10

Did someone say pins might conflict?

From the playground: :: Shield Pin Usage :: http://playground.arduino.cc/Main/ShieldPinUsage

Well I just tried to make code only with sending data through the RF24 and still the same problem. Probably is something wrong with the RF24. I will continue with the ESP modules...

Benik3: Well I just tried to make code only with sending data through the RF24 and still the same problem. Probably is something wrong with the RF24. I will continue with the ESP modules...

Benik3, did you check pins 9 & 10 as suggested? There may be a conflict.

Jesse