Store Data in an array to print it through a Thermal Printer

Hi, I am currently doing a project for an Engineering Class of ours. We are using a Arduino MEGA and have 5 different data points that we want to print these are the; data from the Oximeter, Thermal Cam, Load Cell, Ultrasonic Sensor and our BMI. Now, I want to store these in an array to print thru our thermal printer but, our problem is the data from our Oximeter takes atleast 5 seconds to stabilise/calibrate and our test subjects will not take these tests simultaneously and will take them one by one and We only want it to serial print when a person/subject approaches the machine and when they finish the relay is for a UVC light to sterilize the surface they touched. Now, I've used arduino before but all of those projects have taken data from sensors simultaneously. Any idea on how to store these data into an array and only take the most recent one to print through our thermal printer? Is this even possible in an Arduino MEGA?

Here is our Code:

void loop() {

  //read all the pixels
  float maxx = -99.9;

  for (int i = 0; i < AMG88xx_PIXEL_ARRAY_SIZE; i++) {
    uint8_t colorIndex = map(pixels[i], MINTEMP, MAXTEMP, 0, 255);
    colorIndex = constrain(colorIndex, 0, 255);

    //draw the pixels!
    if (pixels[i] > maxx) {
      maxx = pixels[i];

  scale.set_scale(calibration_factor); //Adjust to this calibration factor
  uint8_t num_samples = MAX32664.readSamples();
  digitalWrite(trigPin, LOW);
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distanceCm = duration * 0.034 / 2;
  //distanceInch = duration*0.0133/2;
  b = 213.36 - distanceCm;
  int c = b / 100;

  int weight = (scale.get_units(), 3);

  int height = (c * c);

  int bmi = weight / height;

  while (ir == HIGH) {
    if (num_samples) {
      Serial.print(" sys = " + String(MAX32664.max32664Output.sys));
      Serial.print(" dia = " + String(MAX32664.max32664Output.dia));
      Serial.print(" hr = " + String(;
      Serial.print(" spo2 = " + String(MAX32664.max32664Output.spo2));
      Serial.print(" , ");

      // Temp
      Serial.print(" Temp(C): " + String(maxx));
      Serial.print(" , ");

      Serial.print(" Weight(kg): " + String(weight)); //weight
      Serial.print(" , ");

      Serial.print(" Height(cm): " + String(b)); // Heights
      Serial.print(" , ");

      Serial.print("BMI: " + String(bmi));
      Serial.print(" , ");

      if (bmi <= 18.4) {
      else if (bmi <= 24.9) {
      else if (bmi <= 29.9) {
      else if (bmi <= 34.9) {
        Serial.println(("Severely Overweight"));
      else if (bmi <= 39.9) {
      else {
        Serial.println("Severely Obese");


  else {
    digitalWrite(relay, HIGH);


First get rid of the idea that all the data from the sensors was taken simultaneously. Your program did it sequentially, one after another.

IF you store the data and then print it from the store, you will always have the most recent value from each sensor. Why do you think otherwise?

It was just a stupid assumption. I've always viewed Arduino as taking/giving multiple input and output simultaneously. Do you know how to do this? At least putting data from multiple sensors on an empty array for use later? Can you show us how to do this? Sorry for the noob question...

Is using an array part of the assignment?

No, it was just a thing that I saw from a tutorial using a thermal printer on arduino. From a very few codes that I read using a thermal printer it was either printing incrementally or put a delay and print every line (which is a huge waste of thermal paper) and the other which used an array (I thought of doing this so that it will only print as long as the array has all the data in it). But, if you have another way of doing it I'm happy to hear it.

How much experience do you have with using the Serial.print() and Serial.println() functions? Printing on your thermal printer is no different.
You can Serial.print() many fields, all on the same line, and then only move to the next line when you use Serial.println() to print the last field for that line. Get that to work before wasting paper.

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