TFT display does not print the string coming from another Arduino

Hi, the project I'm doing at the moment is the following: I have a sensor that detects the Amps arriving in the house, connected from it to Arduino Uno I calculate a series of variables and print them on the serial monitor; so far no problem.

I however want to print what I see on the serial warning on a TFT screen, specifically this:
http://www.lcdwiki.com/3.5inch_Arduino_Display-Mega2560

This shield is connected to an Arduino Mega and is connected via TX / RX to the Arduino Uno to which the sensor is connected. The communication between the two works without problems.

I have no experience with this type of monitor soi don't know what type of instruction i have to use, looking on the internet I created the following code but for about two weeks I have not yet been able to print completely what comes to the arduino Mega.

What do you advise me to do, do you have experience on this monitor?


#include <LCDWIKI_GUI.h>  //librerie, colori e inizializazione schermo
#include <LCDWIKI_KBV.h>
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
LCDWIKI_KBV mylcd(ILI9486, A3, A2, A1, A0, A4);

char Test1 [106]; //variabile in cui salvo ciò che arriva dal serial monitor

void setup()
{
  Serial1.begin(9600);  //serial 0 occupato dal monitor, utilizzo serial 1
  mylcd.Init_LCD();     //inizializzo schermo
  mylcd.Fill_Screen(BLACK); //schermo tutto nero
  delay(1000);
}


void loop()
{
  {
    if (Serial1.available())
      //int array[107] = { 0 };        //altro tentativo
      //char Test1[107] = {Serial1.read()}; //altro tentativo
      //String (Serial1.read()) = String Test1;  //altro tentativo
      Test1 = Serial1.read();  // la stringa che arriva al serial lo salvo nella variabile
  }
  mylcd.Set_Text_Size(3);
  mylcd.Set_Text_Back_colour (BLACK);
  mylcd.Set_Text_colour (WHITE);
  mylcd.Print("Valori dal Sensore :", 5, 6);

  mylcd.Set_Text_Size(2);
  mylcd.Set_Text_Back_colour (BLACK);
  mylcd.Set_Text_colour (WHITE);
  //mylcd.Draw_Char(5, 80, Test1, WHITE, BLACK, 2, 0);
  mylcd.Print(Test1, 5, 100);

  delay (1000);

  mylcd.Set_Text_Size(2);
  mylcd.Set_Text_Back_colour (BLACK);
  mylcd.Set_Text_colour (BLACK);
  //mylcd.Draw_Char(5, 80, Test1, BLACK, BLACK, 2, 0);
  mylcd.Print(Test1, 5, 100);

  delay(250);
}

Are you using pins 0 and 1 on the Uno for Serial communication ? Please post the sketch that you are using on the Uno

It's not clear to me if the examples that come with the library for the LCD screen work?

It's also not clear to me if the TX / RX that you refer to are are the ones on the Mega? If so, the code that you posted makes use of Serial1 and you should use the TX1 / RX1 pins of the Mega.

Your topic is not related to Interfacing w/ Software on the Computer and has therefor been moved to a more suitable location on the forum.

Yes the examples work perfectly
I use TX1 / RX1 on the Mega with the screen and TR / RX on the Uno with the sensor
Thanks

I use TX1 / RX1 on the Mega with the screen and (0 / 1 ) TR / RX on the Uno with the sensor

code aruino uno


#include "EmonLib.h"
#define VOLT_CAL 148.7
#define CURRENT_CAL 63.9

EnergyMonitor emon1;

float currentValue;
float previousValue;
float potMedia;
float consMedio;
float consTot;


void setup()
{
  Serial.begin(9600);

  emon1.voltage(1, VOLT_CAL, 1.7);
  emon1.current(0, CURRENT_CAL);

}

void loop()
{
  emon1.calcVI(20, 1000);

  float currentDraw = emon1.Irms;
  float supplyVoltage = emon1.Vrms;

  previousValue = currentValue;
  currentValue = currentDraw;


  potMedia = (((currentValue * 220) + (previousValue * 220)) / 2); //calcolo la potenza P = V * I

  consMedio =  potMedia * (2); //consumo in W x secondo

  consTot = consMedio + consTot;


  Serial.print("Corrente [A]: ");
  Serial.print(currentDraw);

  Serial.print("    Potenza [W]: ");
  Serial.print(potMedia);

  Serial.print("    ConsumoMedio [Ws]:");
  Serial.print(consMedio, 7);

  Serial.print("    ConsumoTot [kWh]:");
  Serial.println(consTot / 3600000, 7);

}

Those pins are used by the Serial interface to upload code and communicate with the Serial monitor

Use SoftwareSerial on the Uno to create a second serial interface on pins of your choice but not 0 and 1

Ok thank you, i fixed that.
Nothing changed, i think the problems are all in the tft display code

Please post your revised sketch a project schematic

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