Hi for all,
I need advice about my intention to create one sender (DHT11, NRF24L01 and UNO) and one receiver (NRF24L01 and UNO, 16x2 LCD). I test via serial monitor, sender says data can not sent but it can measure the temperature and humidity. I have a problem about LCD i guess, but when i tried to write hello world it works. Here is my codes. Please check. My LCD display photos are attached. I double checked my codes, solders and connections. They're all OK. What's wrong about my project? I guess it could be about something missing in my code.
#include <SPI.h>
#include <nRF24L01p.h>
#include <String.h>
#include <dht11.h>
#define DHT11PIN A0
dht11 DHT11;
nRF24L01p transmitter(9,10);
/* CSN - > 10, CE -> 9 defined */
float temp_variable;
float hum_variable;
static char temp[10];
static char hum[10];
void setup() {
Serial.begin(9600);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
/* SPI initialize */
transmitter.channel(80);
transmitter.TXaddress("0xe7e7e7e7e7");
transmitter.init();
/* Transmitter settings done */
}
void loop() {
int chk = DHT11.read(DHT11PIN);
temp_variable = (float)DHT11.temperature;
hum_variable = (float)DHT11.humidity;
Serial.print("Nem (%): ");
Serial.println(hum_variable, 2);
Serial.print("Sicaklik (Celcius): ");
Serial.println(temp_variable, 2);
dtostrf(hum_variable,5, 2, hum);
dtostrf(temp_variable,5, 2, temp);
/* float value converted to string value for temperature */
transmitter.txPL(temp);
transmitter.txPL(hum);
boolean sendstate = transmitter.send(FAST);
/* Temperature information transmitted to nRF24L01 */
/* If there is a failure, sendstate's value will be false */
if(sendstate==true){
Serial.println("Data sent successfully");
}else{
Serial.println("Data can not sent!");
}
delay(1000);
}
#include <SPI.h>
#include <nRF24L01p.h>
#include <LiquidCrystal.h>
#include "printf.h"
#include <stdlib.h>
#include <stdio.h> /* printf, NULL */
LiquidCrystal lcd(10, 9, 5, 4, 3, 2);
nRF24L01p receiver(7,8);
/* CSN - > 7, CE -> 8 defined */
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
/* SPI initialized */
receiver.channel(80);
receiver.RXaddress("0xe7e7e7e7e7");
receiver.init();
/* Receiver settings done */
}
String temp_variable;
String hum_variable;
void loop(){
while(receiver.available()){
receiver.read();
receiver.rxPL(temp_variable);
delay(10);
receiver.rxPL(hum_variable);
/* Temperature and humidity datas received*/
if(temp_variable.length()>0)
{
Serial.print("temperature = ");
Serial.println(temp_variable);
Serial.print("humidity = ");
Serial.println(hum_variable);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Humidity = ");
lcd.print(hum_variable);
lcd.setCursor(0,1);
lcd.print("Temp = ");
lcd.print(temp_variable);
temp_variable="";
hum_variable="";
/* old datas deleted */
}
}
}
By the way i get the same problem with a brand new lcd and i tested the nrf24's several times. They work.