How to code this voltage and current measurement to put into plx daq excel

Hello, so I start learning and using arduino eventhough I have no background in microcontroller and coding.For past couple days I found that arduino can send serial monitors data to excel through this app called ( plx daq ) *sorry if this is not the correct words to put it. I try to build myself a dual axis solar tracker with the PV panel can measure the current and voltage of the panel to view it in excel.
How do I put what I call as PLX DAQ commands to this current and voltage sensor measurement coding? I am so confused with the if brackets and how do I somehow get voltage and current to get viewed in serial monitors and then Excel? I would be very appreciate if someone could help modify this coding. I try to do it myself with putting all plx daq command in if's voltage measurement bracket but what i found is the current will somehow be generated wrongly even with no battery suply.I will put the original coding not created by me here . Thank you so much for support

const byte current_pin = A4;
const byte voltage_pin = A5;

const int max_current_sample_count = 1000;
const int current_sample_interval = 3;
const int voltage_sample_interval = 500;

// voltage divider parameters
const float R1 = 30000;
const float R2 = 7500;

// 5A current sensor parameters
const float current_sensor_scale = 0.0264;
const float current_sensor_offset = -13.385;

float current_sum = 0; // for accumulated measurements
int current_count = 0; // counter for measurements

unsigned long last_current_measure = 0; // for timing the current measurement
unsigned long last_voltage_measure = 0; // for timing the voltagemeasurement

void setup() {

void loop() {
    unsigned long time = millis();

    if (time - last_current_measure > current_sample_interval) { // if enough time elapsed to make another measurement
        last_current_measure = time; // save the time this action ran

        current_sum += current_sensor_scale * analogRead(current_pin) + current_sensor_offset;
        current_count++; // increase the counter
        if (current_count >= max_current_sample_count) { // when we reached number of samples
            // output the average and reset the sum and counter
            Serial.print("A = ");
            current_sum = 0;
            current_count = 0;
    if (time - last_voltage_measure > voltage_sample_interval) { // if enough time elapsed to make another measurement
        last_voltage_measure = time; // save the time this action ran

        int value = analogRead(voltage_pin);
        float vout = (value * 5) / 1024.0;
        float vin = vout / (R2/(R1+R2));
        Serial.print("V = ");
        Serial.println(vin, 2);

Have you seen the section where you posted ? (tutorials)

have you noted the posts that are pinned there:

(well done on using code tags though :wink: )

moved to General discussion on Programming questions

You will use Serial.print() to send values to the spreadsheet. Study the PLX-DAQ examples to learn how.

There is a "speed limit" to how fast this process works between the two computers, so time the data collection intervals accordingly.

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