Backlight on/off resetting Mega

I'm having a problem when I turn the backlight off then on that it appears to reset the mega. I have a pro mini monitoring my greenhouse, there is a BME280 with a NRF24L01. It samples every half hour and sends the info to a base unit in the house. On the base unit I have a Mega also with a NRF24L01 and a Adafriut 3.5 320 x 480 touch display. I have a screen saver function that if the display is not touched for 60 seconds I turn the backlight off and do a fill screen black. Everything works fine with one exception, although it doesn't happen every time it happens often enough. When the backlight comes back on the screen goes all white for a few seconds then displays the page, the last set of data sent is not displayed. When you touch the screen to get out of the screen saver mode I have it go to a home page, before it does if I left it on the data page you can see the data is there, once on the home page I go back to the data page and the info is not displayed. I have it so when you do go to that page it rewrites the info. So that's what makes me think, for some reason, the mega is being reset. If I set the backlight on all the time, the screen will go to the saver mode but when I go back the info is always there. So it must have something to do with turning the backlight off then back on. I have tried disconnecting the reset but I believe that's more for the mega to reset the TFT not the other way around but it didn't help any ways. I believe this is a hardware not a sketch issue, but what do I know.

Here's how I have the TFT connected to the mega
Mega --------- TFT
D29 ---------- D7
D28 ----------- D6
D27 ----------- D5
D26 ----------- D4
D25 ---------- D3
D24 ---------- D2
D23 ---------- D1
D22 ----------- D0
D35 ---------- Y-
A6 ------------ X-
A5 ------------ Y+
D36 ---------- X+
Reset ------- RST
D53 --------- Backlite
A0 ----------- RD
A1 ----------- WR
A2 ---------- C/D
A3 --------- CS
+5 ---------- VIN
GND ------- GND

A mentioned I think this is a hardware issue so I'll just included how I have the TFT defined if you need more of the code I can attach that.

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include "TouchScreen.h"

// These are the four touchscreen analog pins
#define YP A5  // must be an analog pin, use "An" notation!
#define XM A6  // must be an analog pin, use "An" notation!
#define YM 35   // can be a digital pin
#define XP 36   // can be a digital pin
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.