Dispaying heart rate readings in graph form on TFT LCD screen (Arduino)

Hi i have a Grove finger-clip heart rate sensor. I use the following code to obtain heart rate readings;

#include <Wire.h>

void setup()
{
  Serial.begin(115200);
  Serial.println("Heart Rate Sensor");
  Wire.begin();
}
void loop()
{
  Wire.requestFrom(0x50, 1);    // request 1 bytes from slave device
  while (Wire.available())          // slave may send less than requested
  {
    unsigned char c = Wire.read();   // receive heart rate value (a byte)
    Serial.println(c, DEC);         // print heart rate value
  }
  delay(500);
}

The problem i am facing is displaying the data in graph form on the TFT LCD screen. Can anyone give me further guidence in accomplishing this. Do i need to add to this code or do i need to use a new one. Bare in mind this is a i2c device with the address of 0x50 and runs with library wire.h

??

The problem i am facing is displaying the data in graph form on the TFT LCD screen. Can anyone give me further guidence in accomplishing this. Do i need to add to this code or do i need to use a new one. Bare in mind this is a i2c device with the address of 0x50 and runs with library wire.h

There's nothing about any tft in your code. Have you tried anything yet? Are you completely lost and don't know what to try? Then you need to do some reading on the tft you have and the library it uses and maybe look at some example codes. If you can at least give it a shot we can maybe help. But we're not going to just write your code for you or teach you from 0 how to code with a tft. You need to show that you've at least put in some effort.

Delta_G:
There’s nothing about any tft in your code. Have you tried anything yet? Are you completely lost and don’t know what to try? Then you need to do some reading on the tft you have and the library it uses and maybe look at some example codes. If you can at least give it a shot we can maybe help. But we’re not going to just write your code for you or teach you from 0 how to code with a tft. You need to show that you’ve at least put in some effort.

I have given it a go. I have looked at example sketches and tried in implement my heart rate sensor code into it where it seems reasonable but i have not been successful. For that reason i did not bother post the different codes that i tried because i believe they are ridculous. I have found a program called Proteus whereby you can visually design software and have coding generated for me. However that will be last result if i am unable to create the coding myself. A source of information that i can study will be benefical to me, not expecting anybody to write the whole code for me.

The coding i was previously using started off with;

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield            : <display model>,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield        : <display model>,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ITDB28,A5,A4,A3,A2);

void setup()
{
  randomSeed(analogRead(0));
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop()
{
  int buf[318];
  int x, x2;
  int y, y2;
  int r;

// Clear the screen and draw the frame
  myGLCD.clrScr();

@delta_G

hoxymade:
For that reason i did not bother post the different codes that i tried because i believe they are ridculous.

For that reason you wouldn't get any help at all. So which is more ridiculous?

What you posted is incomplete. You show the setup, but the loop seems to be cut off a bit early.

Delta_G:
What you posted is incomplete. You show the setup, but the loop seems to be cut off a bit early.

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];


UTFT myGLCD(ITDB28,A5,A4,A3,A2);

void setup()
{
  randomSeed(analogRead(0));
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}

void loop()
{
  int buf[318];
  int x, x2;
  int y, y2;
  int r;

// Clear the screen and draw the frame
  myGLCD.clrScr();

  myGLCD.setColor(255, 0, 0);
  myGLCD.fillRect(0, 0, 319, 13);
  myGLCD.setColor(64, 64, 64);
  myGLCD.fillRect(0, 226, 319, 239);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(255, 0, 0);
  myGLCD.print("* Heart Rate *", CENTER, 1);
  myGLCD.setBackColor(64, 64, 64);
  myGLCD.setColor(255,255,0);
  myGLCD.print("Heart Rate", CENTER, 227);

  myGLCD.setColor(0, 0, 255);
  myGLCD.drawRect(0, 14, 319, 225);

// Draw crosshairs
  myGLCD.setColor(0, 0, 255);
  myGLCD.setBackColor(0, 0, 0);
  myGLCD.drawLine(0x50);
  myGLCD.drawLine(0x50);
  for (int i=9; i<310; i+=10)
    myGLCD.drawLine(0x50);
  for (int i=19; i<220; i+=10)
    myGLCD.drawLine(0x50);

myGLCD.setColor(0,255,255);
  myGLCD.print("Heart Rate", 5, 15);
  for (int i=1; i<318; i++)
  {
    myGLCD.drawPixel(0x50, 1);
  }

@delta_G
As you can see this is clearly incrorrect.

What type of Arduino? If it is an UNO as I suspect then you’ve got a pin conflict. I2C for the sensor will be on A4 and A5 so you can’t use those two for the tft.

"As you can see this is clearly incrorrect."

Not as clearly as you may think. What exactly is it supposed to do? What actually happens? How do those two things differ?

Delta_G:
“As you can see this is clearly incrorrect.”

Not as clearly as you may think. What exactly is it supposed to do? What actually happens? How do those two things differ?

Well i would like it to display the heart rate graph bpm vs time, which it shows on the Serial plotter on Arduino ide when i use the following code for the heart rate reading;

#include <Wire.h>

void setup()
{
  Serial.begin(115200);
  Serial.println("Heart Rate Sensor");
  Wire.begin();
}
void loop()
{
  Wire.requestFrom(0x50, 1);    // request 1 bytes from slave device
  while (Wire.available())          // slave may send less than requested
  {
    unsigned char c = Wire.read();   // receive heart rate value (a byte)
    Serial.println(c, DEC);         // print heart rate value
  }
  delay(500);
}

I asked three questions. You answered one. I don't like typing out help for you if you're just going to ignore large parts of it. Are you just wasting my time here? I don't like that.

Delta_G:
I asked three questions. You answered one. I don't like typing out help for you if you're just going to ignore large parts of it. Are you just wasting my time here? I don't like that.

Theres no need to get emotional pal.

-It is an arduino uno yes.

-At the moment it is just displaying the example code axis from before. But i want it to display the heart rate readings.

-And i do not know what you are askin by "how do those two things differ?" - if you are refering to bpm vs time then as time increases it takes readings from heart beat so it should go up and down on plot.

By how do those two things differ I mean how does what it does now differ from what you want it to do. Compare and contrast kind of statement.

And I'm not emotional. Just letting you know that i won't waste my time with you if you're not going to take it seriously.

Can you calculate where on the screen a given data point should be? If I gave you a time and a bpm could you figure out what pixel that relates to? From there all you need to do is draw a line from the last point to that point.

Delta_G:
By how do those two things differ I mean how does what it does now differ from what you want it to do. Compare and contrast kind of statement.

And I'm not emotional. Just letting you know that i won't waste my time with you if you're not going to take it seriously.

Can you calculate where on the screen a given data point should be? If I gave you a time and a bpm could you figure out what pixel that relates to? From there all you need to do is draw a line from the last point to that point.

but the thing is i want it to display as it reads the heart rate. So i wont know the bpm untill it reads it at the time whereby it will vary - i was wondering i there was a command that i could input into the coding the draw the lines obtained in real time from the heart rate sensor.

I dont want it to compare or anything but just to simply show the heart rate figure in bpm and plot it on the graph. IVe done a lot of research and not finding much information.

I don't think you understood the question. Let me try a different way.

A graph has two axes and each point on the graph is defined by two numbers, the x and the y. So if at time 3 the bpm is 100 can you calculate which pixel on the screen is point 3,100. If you can then you can do this. If not then you need to go study math.

You start at time 0 so x is 0 and y is the first bpm measurement, let's say it's 100. Save that point in a pair of variables, say currrentX and currentY or something. Then at the next measurement you will again have a time and a bpm and that is a new x and y. Let's say it is time 1 and bpm is 110. You save the last set of values (the 0 and 100) into a new set of variables maybe called oldX and oldY and the new set (the 1 and 110) into your currentX and currently variables. Then you just draw a line from the old point to the new point. Move the new point into the old point variables and get a new set of measurement in the new point variables. Rinse and repeat.

But this all assumes that you can turn a data point (time , bpm) into a point on the screen and that is a math problem not a coding problem.