Hello, I am using rf to send the temperature to a receiver. The code is shown below, for some reason I am unable to lcd.print() in the void loop.
// Uses nRF24 lib from here (unzip into "/home/<username>/Arduino/libraries"):
// https://github.com/nRF24/RF24
#include <printf.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
// for the set of available functions see:
// https://github.com/nRF24/RF24/blob/master/RF24.h
RF24 radio(10, 9); // CE, CSN
const unsigned char id[] = "test1"; // 5 bytes
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
// lcd.print("test");
delay(1000);
if (!radio.begin()) {}; //module did not respond // defaults to channel 76;
radio.setPALevel(RF24_PA_MAX);//RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
radio.setRetries(0, 1); //setRetries(uint8_t delay, uint8_t count)
radio.setDataRate(RF24_1MBPS);//RF24_250KBPS (does not work), RF24_1MBPS, RF24_2MBPS
radio.setChannel(70);// 0..125
radio.enableDynamicPayloads();
radio.enableAckPayload();
radio.setAddressWidth(5);
///////////////////////
// if(radio.isChipConnected())Serial.println("RF24 connected");else Serial.println("no RF24");
// if(radio.testCarrier())Serial.println("testCarrier = true");else Serial.println("testCarrier = false");
// if(radio.testRPD())Serial.println("testRPD() = true");else Serial.println("testRPD() = false");
// if(radio.isPVariant())Serial.println("isPVariant() = true");else Serial.println("isPVariant() = false");
// radio.printDetails();
// Serial.println("start");
int y = 123;
radio.openReadingPipe(1, id); //0 used for writing
radio.writeAckPayload(1, &y, sizeof(y));
radio.startListening();
}
int y = 123;
float z;
void loop() {
lcd.setCursor(0, 1);
lcd.print(555);
// int z = 123;
if (radio.available()) { // poll chip for data
lcd.setCursor(0, 1);
Serial.println("got data");
radio.read(&z, sizeof(z)); //read password
//radio.writeAckPayload(1, &z, sizeof(z)); //sends voltage to transmitter
Serial.println(z); //prints password
float temp = (100 * z * 1.8) + 32.0;
Serial.println(temp);
}
}