Help with PUTTY and Arduino on Mac

Hello everyone. I am having a spot of trouble using PuTTY to transfer the information printed on my serial monitor. The data shows up, but there is no timestamp, and I want to transfer the data to Excel. How can I add the timestamp?
I am using an Arduino UNO, and using an Infrared CO2 sensor.

Here is the code:

#include <Wire.h>
#include <SPI.h>
#include <SC16IS750.h>
#include <string.h>
#include <NDIRZ16.h>


SC16IS750 i2cuart = SC16IS750(SC16IS750_PROTOCOL_I2C,SC16IS750_ADDRESS_BB);
NDIRZ16 mySensor = NDIRZ16(&i2cuart);

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

    if (i2cuart.ping()) {
        Serial.println("SC16IS750 found.");
        Serial.println("Wait 10 seconds for sensor initialization...");
    } else {
        Serial.println("SC16IS750 not found.");
        while(1);
    }

    power(1);
    //Wait for the NDIR sensor to initialize.
    delay(10000);
};

void loop() {
    if (mySensor.measure()) {
        Serial.print("CO2 Concentration is ");
        Serial.print(mySensor.ppm);
        Serial.println("ppm");
    } else {
        Serial.println("Sensor communication error.");
    }
    delay(1000);
}

//Power control function for NDIR sensor. 1=ON, 0=OFF
void power (uint8_t state) {
    i2cuart.pinMode(0, INPUT);      //set up for the power control pin
 
    if (state) {
        i2cuart.pinMode(0, INPUT);  //turn on the power of MH-Z16
    } else {
        i2cuart.pinMode(0, OUTPUT);
        i2cuart.digitalWrite(0, 0); //turn off the power of MH-Z16
    }
}

//Zero Point (400ppm) Calibration function for NDIR sensor. Only used when necessary.
//Make sure that the sensor has been running in fresh air (~400ppm) for at least 20 minutes before calling this function.
void calibrate() {
    i2cuart.pinMode(1, OUTPUT);    //set up for the calibration pin.
     
    i2cuart.digitalWrite(1, LOW);  //start calibration of MH-Z16 under 400ppm
    delay(10000);                  //5+ seconds needed for the calibration process
    i2cuart.digitalWrite(1, HIGH); //toggle the pin HIGH back to normal operation
}

Why not use the Serial monitor in the IDE ?

How are you going to copy the data to Excel ?

You don't print a timestamp.

Another thought

Have a look at the Excel Data Streamer addon

I need help doing that. I asked many people and they all told me to use PuTTY, as it will put the data into a document. Also, the Arduino UNO has an RTC clock.

Excel Data Streamer cannot install on Mac, even with Wine.

Print the data to the IDE Serial monitor. When it is complete select it all and copy it. Paste it into Excel

To print time stamp you need some form of running clock - either a real time clock ( DS3231) or you could , I guess, print millis()?

Is there a way to put the timestamp in one column of excel, and the data in the other column?

Can you import to excell with a space as a separator?

Im not sure

You can do it with OpenOffice Spreadsheet and later import that into eXcell.

If you turn on the timestamp in the Serial monitor, and print a space between subsequent data items then you can copy the output to Excel and use "Text to columns" to split the data into columns

The serial monitor will create time stamps for you, but not log to a file (except by manual cut&paste)

I guess PuTty will log to a file, but doesn’t have the ability to add time stamps…

Serial.print(date and time from the clock);
Serial.print(",");  // comma separation
Serial.print(a data field);
Serial.print(",");  // comma separation
Serial.print(another data field);
Serial.println();

Or as @sterretje has finally pointed out, use a comma. Tabs work for separation of row elements also, it can make the text file easier to read by humans.

I've had a draft saying so for some time... doesn't anyone around here use spreadsheets as much as I do for all kinds things?

a7

My suggestion to use a space was to make the use of Text to Columns as easy as possible but, of course, a comma is equally as good. In fact, if you printed a comma before the first data item and between them you could copy the output to a .csv file and import it directly into Excel

You could, of course, use a terminal emulator such as Coolterm which will add the timestamps and output the data to a file with no need to do the copy/paste

+1 for Coolterm.

I've Paypalled the author of Coolterm on multiple occasions over the years, enough for (around here) lunch for two at a nice enough restaurant.

I tried the Serial Monitor time stamping some time ago. It didn't do what I needed right away and about 3 minutes of googling research left me back to just using Coolterm for whatever it was I need the times for.

Good a place as any: Does Serial Monitor time sampling work? Are there known limitations?

a7

Wait a minute.

@cwisgunza is unfortunate enough to be using a Mac otherwise he/she could just use Excel Data Streamer and I am not sure if Coolterm is available for the Mac

I make it look like you said that; it is available on the Mac and I assume since it was developed with REALBasic is more or less identical in function to the other platform versions.

a7