Hi every one
I am working on a weather station
Setup Elegoo Mega 2560,Nano, nRF24L01 x2, TFT ili9341, RTC DS3231, DHT 22/AM2302 x2 cap’s, 3.3 power and resistors (touch and sd slot not connected) and all works together. Arduino graphics test, ArduinoILI9341Touch, TFT ILI9341_RTC_time and temp. and nrf24 “hello world” just change sketch, tells me the wiring is good But the when I run my sketch (built from all you coders thank you) the serial printer, prints inside, outside, time, date. prints fine and dose not stop all day long time and temp. change so the sketch doesn’t stop. I did get the TFT to print the temp “0.0” so I think it would work. But the TFT stops after nRF24L01. I have tried it all maybe.
All Amazon parts
Elegoo MEGA 2560 R3 Board ATmega2560 ATMEGA16U2
[CANADUINO® DS3231 RTC Module, 32kB Memory, I2C Interface, Battery Backup]
[Hosyond 3.2 Inches TFT LCD Touch Screen Shield Display Module ]
Funsto DHT22/AM2302 Digital Temperature and Humidity Sensor
[DHT22/AM2302 Digital Temperature and Humidity Sensor Module Tem]
10Gtek NRF24L01 2.4GHz Antenna Wireless transceiver Module
@Robin2 is a lot of help thanks
Please help
Thank you
barr1910
#include <RF24.h>
#include <RF24_config.h>
#include <nRF24L01.h>
#include <printf.h>
#include <Sodaq_DS3231.h>
#include <DHT.h>
//#include <DHT_U.h>
#include <Wire.h>
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_RST 49
#define TFT_CLK 52
#define TFT_MISO 50
#define TFT_MOSI 51
#define TFT_DC 46
#define TFT_CS 53
#define ILI9341_WIDTH 380 // Example: Setting width to 320
#define ILI9341_HEIGHT 240 // Example: Setting height to 240
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
#define DHTPIN 6
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
RF24 myRadio(9, 10);
byte addresses[][6] = { "0" };
float remoteHumidity = 0.0;
float remoteTemperature = 0.0;
String dateString;
String hours;
int minuteNow = 0;
int minutePrevious = 0;
struct package {
float temperature;
float humidity;
};
float previousIndoorHumidity = 0;
float previousIndoorTemperature = 10;
float previousRemoteHumidity = 0.1;
float previousRemoteTemperature = 0.1;
float indoorHumidity = 0;
float indoorTemperature = 0;
typedef struct package Package;
Package data;
char weekDay[][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
//year, month, date, hour, min, sec and week-day(starts from 0 and goes to 6)
//writing any non-existent time-data may interfere with normal operation of the RTC.
//Take care of week-day also.
DateTime dt(2025, 04, 27, 8, 36, 0, 0);
void setup() {
Serial.begin(9600);
tft.begin(); // Initialize ILI9341 display
dht.begin();
rtc.begin();
Wire.begin();
// rtc.setDateTime(dt); //Adjust date-time as defined 'dt' above
//non changing tft graphics
tft.setRotation(1); // Set screen rotation (e.g., landscape)
tft.fillScreen(ILI9341_BLACK); // Clear screen
tft.setCursor(139, 158);
tft.drawRoundRect(3, 3, 315, 71, 5, ILI9341_WHITE);
tft.drawRoundRect(4, 5, 313, 68, 5, ILI9341_RED);
tft.drawRoundRect(5, 85, 159, 150, 5, ILI9341_GREEN);
tft.drawRoundRect(6, 86, 158, 148, 5, ILI9341_GREEN);
tft.drawRoundRect(166, 85, 150, 150, 5, ILI9341_PURPLE);
tft.drawRoundRect(167, 86, 148, 148, 5, ILI9341_PURPLE);
tft.fillRect(10, 90, 150, 40, ILI9341_GREEN);
tft.fillRect(171, 90, 130, 40, ILI9341_CYAN);
tft.setCursor(13, 100);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(3);
tft.print("Indoor");
tft.setCursor(173, 100);
tft.setTextColor(ILI9341_BLACK);
tft.setTextSize(3);
tft.print("Outdoor");
tft.setCursor(139, 158);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.print("%");
tft.setCursor(289, 158);
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(2);
tft.print("%");
tft.setCursor(139, 140);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.print("F");
tft.setCursor(139, 175);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.print("o");
tft.setCursor(289, 140);
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(2);
tft.print("F");
tft.setCursor(289, 175);
tft.setTextColor(ILI9341_CYAN);
tft.setTextSize(2);
tft.print("o");
delay(100);
}
uint32_t old_ts;
void loop() {
{
myRadio.begin();
myRadio.setChannel(115);
myRadio.setPALevel(RF24_PA_MAX);
myRadio.setDataRate(RF24_250KBPS);
myRadio.openReadingPipe(1, addresses[0]);
myRadio.startListening();
delay(100);
}
if (myRadio.available())
;
{
while (myRadio.available()) {
myRadio.read(&data, sizeof(data));
previousRemoteTemperature = remoteTemperature;
previousRemoteHumidity = remoteHumidity;
remoteTemperature = data.temperature;
remoteHumidity = data.humidity;
}
tft.fillRect(90, 10, 40, 150, ILI9341_GREEN); //test TFT
/*
{
Serial.print("\nPackage:");
Serial.print("\n");
Serial.println(data.temperature);
Serial.println(data.humidity);
}
*/
Serial.print("outside Humidity: ");
Serial.print(data.humidity);
Serial.print(" %\t");
Serial.print("outside Temperature: ");
Serial.print(data.temperature);
Serial.println(" *C");
float indoorHumidity = dht.readHumidity();
float indoorTemperature = dht.readTemperature();
Serial.print("Indoor Humidity: ");
Serial.print(indoorHumidity);
Serial.print(" %\t");
Serial.print("Indoor Temperature: ");
Serial.print(indoorTemperature);
Serial.println(" *C");
DateTime now = rtc.now(); //get the current date-time
uint32_t ts = now.getEpoch();
if (old_ts == 0 || old_ts != ts) {
old_ts = ts;
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.date(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.print(weekDay[now.dayOfWeek()]);
Serial.println();
// Serial.print("Seconds since Unix Epoch: ");
//Serial.print(ts, DEC);
Serial.println();
Serial.println();
delay(3000); // Wait a few seconds between readings
tft.fillRect(90, 100, 75, 150, ILI9341_GREEN); //test TFT
}
}
}

