Master-Slave Arduino GRBL

Hello,

I'm trying to run GRBL on an Arduino Uno R3 and I have an Arduino Nano that I want to use to record data. Essentially my setup is going to be a CNC style machine but, I'll be using a laser to excite a solar panel and I want to collect the voltage generated from the solar panel using a separate Arduino Nano. My idea is to use the spindle control function in G-Code from my Master(Uno) to tell my Slave (Nano) when to take data.

I know there is a master/slave Arduino code, but that would have to go on both Arduinos and I need the Uno to run GRBL.
How can I make my Arduino Nano record upon receiving a signal?

I'll then be using Pyserial to record this incoming data as described in this tutorial.

TLDR; I want to make an Arduino nano record when it receives a signal, what do?

Simply connect a digital input on the nano to the spindle output on the Uno. Whch Uno pin that is depends on how grbl is set up. I would set grbl to no spindle speed conrtol (just on&off). Then send M3 M5 sequence to send a pulse out the spindle enable pin. The Nano could be listening for the pulse and start recording on reciept. Then send another M3 M5 to stop recording.
The M3 M5 seuences will need to be inserted into the gcode file.

groundFungus:
The Nano could be listening for the pulse and start recording on reciept.

This is the portion that is confusing to me.
What kind of command would I use to listen for this signal?

If this is the typical serial read code;

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {

// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();

// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}

I would have to preface it with this command to listen.
What would that look like?

Thanks for your help!

So you are listening to the serial line from a gcode sender on the PC to the Uno with the Nano in parallel? It is unclear, to me, where the signal to start recording comes from. Is the signal to start recording embedded in the gcode?

And once the Nano stars recording, the data is sent to the PC Python program over serial? You can't listen to the serial port from the Uno and transmit over the same port to the PC. That is why I suggested using a digital port to sense when to start recording as that frees the serial port for data transmission.

If I sound confused, I am. It would help if you were more clear and detailed in the description of your system.
How about a diagram of your setup?