Saving data from Serial Monitor to USB using FTDI Module

Hi everyone, I'm relatively new to Arduino so apologies if my question may seem unusual.

I am in the process of setting up an automated loom resistance tester for a loom that has 66 wires.
It uses relays to sequentially switch between the wires in the loom using a matrix formation and interfaces with an Agilent 34401A DMM (sends commands via software serial and receives via hardware serial) to take the measurements, but that's not important!

I have got to the point now where the setup measures the resistance of each wire in turn and sends the data from the DMM to the serial monitor of my Arduino Mega, it checks a wire every 3 seconds and so the resistance measurements appear in the serial monitor every 3 seconds with the next result, like so:

0.14
0.23
0.22
0.20
0.13

etc etc.

Is there a way I can take this data directly from the Arduino Hardware Rx and send it straight back out of the Hardware Tx? So the data comes in from the DMM and goes straight out via the Tx?

I have a USB FTDI Module (link at bottom) to which I have set the Arduino Tx to the FTDI Rx so in theory, the data should come straight from the DMM to the Arduino and then straight back to the FTDI module where I then want to save it to a notepad, word or Excel file on a USB stick.

I understand this is a mammoth task but could anyone show me some code (as simple as possible please) that could save this data from the serial monitor onto a USB somehow?

Thanks very much in advance, I am pulling my hair out here!

USB FTDI Module I'm using:

I have also attached my code if it helps :slight_smile:

Project_Arduino_Software_V2.ino (44.8 KB)

First: if you're using an Arduino Mega, then there is no need to use a software serial port. Remember that the Mega has other 3 hardware ports too

Second: what's wrong with the board's built-in USB to serial converter that you end up using an external one instead? You know the Arduino also interfaces with a PC via USB, right?

Third: from what I understand, you want to retransmit data. Since Serial is always fixed to the USB port, use Serial1 for the multimeter. So... use Serial1 to interface with the meter, and Serial to interface with the PC.

You at least should know how to send and receive data on those ports (which is exactly the same in both cases, only the class names are different); so now you should have it all set from now.

Thanks very much, Lucario448.

With regards to the FTDI Module, I used this as it has a USB A port to plug a USB Stick into whereas the Arduino only has the USB B port.

Do you happen to know of any code that may help me write this data to the USB stick, as I can't seem to get the USB to hold any data at all at the moment!

Thanks again, the help is much appreciated
David

sill_david:
With regards to the FTDI Module, I used this as it has a USB A port to plug a USB Stick into whereas the Arduino only has the USB B port.

But still, how do you program the Arduino? If you do it the usual way, then you already have plugged an A to B cable anyways.
Nevertheless, I'm going to assume that the first serial port (aka Serial, the no number one) is interfacing with the PC, no matter which converter you choose.

sill_david:
Do you happen to know of any code that may help me write this data to the USB stick, as I can't seem to get the USB to hold any data at all at the moment!

For "USB stick" I think you mean the external converter. Since that device also behaves as a UART port, the Arduino sees it as just another serial device (like your meter, but it's actually the PC).

So, what you have to do, is read from the meter's port (e.g. Serial1); and then write to the converter's port (e.g. Serial), print() to pass textual (and presumably processed) data, or write() to simply pipe the raw (unprocessed) data stream.

Am I clear now?

PD: the meter uses RS-232 signals, so I guess you're using the corresponding MAX chip to convert them to the suitable TTL signals the Arduino needs.

Thanks again for all the detail.

Have now changed the software serial stuff over to Serial3 as you suggested.

Am still working on saving the data to a memory stick plugged into the FTDI module.

I am using a MAX232ACPE chip to convert to serial when communicating with the DMM, would I also need to use a MAX232 chip when communicating between the Arduino and FTDI aswell?

I am sending commands to the DMM and receiving results back in the Serial monitor, I just want to save these results exactly as they appear in the serial monitor onto a USB/memory stick as a txt file or ideally an Excel document.

Thanks,

Am still working on saving the data to a memory stick plugged into the FTDI module.

Can you write to a memory stick like that? Don't you need a USB host controller to handle a memory stick? All that converter is doing is passing along serial data. It isn't a USB host.

If you want to be able to do this with the Mega then it will be MUCH easier to use an SD card instead of a memory stick. The SD card can be handled directly by the Mega.

sill_david:
Am still working on saving the data to a memory stick plugged into the FTDI module.

What? I guess you mean through a PC because I haven't seen such chip as a USB host, or even as a reader of a proprietary format.

sill_david:
would I also need to use a MAX232 chip when communicating between the Arduino and FTDI aswell?

Nope, both ends already "speak" TTL.

sill_david:
I am sending commands to the DMM and receiving results back in the Serial monitor, I just want to save these results exactly as they appear in the serial monitor onto a USB/memory stick as a txt file or ideally an Excel document.

In this case, it's just a simple dump.

Once again, I know RealTerm can do that; although compatibility with Excel depends on how the Arduino formats the output. CSV (Comma-Separeted Values) is a well-known format of plain text data importing for Excel; as the name implies, you split the individual values with commas, and each record (triplet the 66 values) is separated by lines of text (by the couple of characters "\r\n", aka carriage return and line feed).

Delta_G:
If you want to be able to do this with the Mega then it will be MUCH easier to use an SD card instead of a memory stick. The SD card can be handled directly by the Mega.

This way you could dump (save) the data stream in a more standalone way.

PD: printing textual data might be a huge overhead for such underpowered CPU (the ATmega2560 MCU) when timing matters, so I guess that's why you couldn't output the triplet at 100 Hz.
Piping raw data is way more straightfoward (also giving some room to remove any headers and footers the multimeter might send in response, in order to transmit only the meaningful data), although post-processing is still required since Excel can't import binary data (for that you'll have to create your own program that handles the job).

Update: ignore the postdata. Today I realized that my mind was crossed with this thread; since both intend to send data to a PC, I easily got confused to type a reply in the wrong place.

I apologize any caused inconvenience :sweat_smile: