0

I've only just managed to get the Arduino IDE on MacOS set up with my ESP8266 board. My loop is running and I can see the lovely serial output in the Serial Monitor window in the Arduino IDE. I'm going to attach a KY038 sound sensor and I want to sample the analog pin of the KY038 at very consistent intervals and write each sample to the serial port and I want to route ALL of the data written to the serial point to a file.

My big questions are:

1) how do I route all the serial output that my sketch is writing to a file on the mac to which the 8266 is attached via USB cable? This setup seems to write to a file /dev/tty.SLAB_USBtoUART, but I have been unable to inspect the contents of this file/port/whatever either using the screen or tail commands.

EDIT: I have managed to use the screen command successfully to monitor the serial output from my 8266 board. This command shows you the serial output as it is continually written:

screen -L /dev/tty.SLAB_USBtoUART 115200

Where the 115200 is the baud rate of my sketch's serial output. I'm still not sure of the exact steps that would yield a data file on my file system. I expect you'd have to write in a pause in your sketch before it starts writing any serial output and then you could route the screen output to a file like so:

screen -L /dev/tty.SLAB_USBtoUART > /path/to/file.txt 115200 &

The ampersand at the end backgrounds the process. I'm not really sure how to halt that background process, though. Might have to do a kill on its process id? Any advice would be very welcome. This seems a bit kludgy to me. I do see some detail about job control right here which will probably be helpful.

2) I've been told I can do a "freerun" of samples on the ky038 and have the program fire off some interrupt when a certain number of samples has been collected. Can anyone refer me to a sample program which does that sort of thing?

1
  • Comments are not for extended discussion; this conversation has been moved to chat. – VE7JRO Jun 1 '20 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.