Hello everyone,
I am an avid electronics but starting in Arduino, I trained several tutorial and exercises, I decided to go a step up and try a wireless transmission (helping me more examples on the net;)) between DHT33 (via mini arduino) and a 16x2 LCD display (via an arduino MEGA), I use a transmitter and receiver 433Mhz.
communication is established between my arduino ! and my values sent by the DHT are well converted and displayed on the Serial Monitor.
My problem is that nothing appears on my LCD ![]()
I made a lcdprint in void setup with a message to test, and it works! but not to show my values !!
therefore i need help to understand what's wrong.
here is the code for the transmitter:
#include <VirtualWire.h>
#include <VirtualWire_Config.h>
#include <dht.h>
#define DHT33_PIN 6
dht DHT;
int T;
int H;
char data[21];
void setup() {
pinMode(13,OUTPUT);
vw_setup(2000);
vw_set_tx_pin(2);
}
void loop() {
digitalWrite(13,HIGH);
uint32_t start = micros();
int chk = DHT.read33(DHT33_PIN);
uint32_t stop = micros();
H = DHT.humidity * 100;
T = DHT.temperature * 100;
sprintf(data, "%d,%d", T, H);
vw_send((uint8_t *)data, strlen(data));
vw_wait_tx();
digitalWrite(13,LOW);
delay(1000);
}
the reciver:
#include <LiquidCrystal.h>
#include <VirtualWire.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
char data[21];
int t;
int h;
float T;
float H;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(13,OUTPUT);
vw_setup(2000);
vw_set_rx_pin(6);
vw_rx_start();
}
void loop() {
memset( data, 0, sizeof( data ));
Serial.println(t);
Serial.println(h);
Serial.println(T);
Serial.println(H);
digitalWrite(13, HIGH);
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen))
{
int i;
for (i = 0; i < buflen; i++)
{
data[i] = char(buf[i]);
}
sscanf(data, "%d,%d",&t, &h);
T = t;
T = T/100;
H = h;
H = H/100;
digitalWrite(13,LOW);
}
affichage();
}
void affichage() {
lcd.clear() ;
lcd.setCursor(0, 0);
lcd.print("DHT SANS FIL");
lcd.setCursor(0, 1);
lcd.print("T ");
lcd.setCursor(2, 1);
lcd.print(T);
lcd.setCursor(8, 1);
lcd.print("H ");
lcd.setCursor(10, 1);
lcd.print(H);
lcd.setCursor(15, 1);
lcd.print("%");
}