Convert streaming ASCII to Text to read Battery Monitor Data

@Grumpy_Mike,

Thanks again Mike, In the end, it works. I did have a couple of issues though. After pasting your additional snippet in and clicking on the Verify button, I got an error: stray '\302' on the very last line of the sketch, but found that if I delete the spaces to the left of the Right Brace and then manually put them back in, then verify again, the error shifted up one line, and the error was repeated again. This error was repeated on every line up to:
if(a ==",') count++;,
where I got a 'missing terminating " character, so I replaced the apostrophe with a quote symbol. Then it verified to completion. As you can see below are the results.

101,AH=-2.72,%=099,W=-29.4,DSC90.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-02.3,FA=00.6,PW=101,AH=-2.72,%=099,W=-34.3,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-02.6,FA=00.6,PW=101,AH=-2.72,%=099,W=-31.3,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-02.1,FA=00.6,PW=101,AH=-2.72,%=099,W=-26.4,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-01.9,FA=00.6,PW=101,AH=-2.72,%=099,W=-23.4,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-01.7,FA=00.6,PW=101,AH=-2.72,%=099,W=-21.9,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-01.6,FA=00.5,PW=101,AH=-2.72,%=099,W=-21.0,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-01.6,FA=00.5,PW=101,AH=-2.72,%=099,W=-20.7,DSC=0.14,DSE=5.81,PW=101,V=13.2,FV=13.3,V2=00.0,A=-01.5,FA=00.5,PW=101,AH=-2.72,%=099,W=-20.1,DSC=0.14,DS

This is great. I see that there is no special Start or End character to signify where the line should conclude. The sheet that I provided a link to earlier, that points to the TM-2030 pdf document describing what data comes out, has a line in the second paragraph that says,

"Regular data outputs with sometimes other additional data too."

To me, this means that occasionally additional data may come out, in addition to the 12 that we see here. So I'm worried that I might miss something if this TM-2030 decides to put out this extra data.

I have an idea about how I might be able to capture any additional data that may come out. Since I would like to see the order of this data to be:

V=13.2,FV=13.3,V2=00.0,A=-02.6,FA=00.6,PW=101,AH=-2.72,%=099,W=-31.3,DSC=0.14,DSE=5.81,PW=101

Is it possible to search for a specific set of characters, such as, ",V=", and insert a carriage return right before the "V" so that every new line would start with "V=".

It seems counter intuitive to search for content, then insert a command before it gets sent to the computer. Is this kind of thing even possible? I thought it might be possible since the Uno is faster than the data is coming in. What are your thoughts?

so I replaced the apostrophe with a quote symbol.

Sorry about that, it should have been the other way round, replace the " with a '

Yes you could put out the carriage return before you send stuff to the computer but it is a bit more complex to code. You need to use a string variable. Note and this is important this is not a String variable, the language is case sensitive and the two are very different structures. For an == to work inside an if statement you need a string, which is an array of three bytes with the last one being a zero and the first two being the last two characters you received. Then you could compair to a string of "V=" and if found send a return but if not found send just the second to last character you received.

@Grumpy_Mike,

Is there any other options to be able to make each row start with "V=". Or maybe I'm thinking about this issue wrong.

If, in the end I wish to control a relay based on the value of the Battery % of charge, I'd want to create some comparator that I could set a low % set point, that would cause a pin to go high or low to either turn a MOSFET on or off at about 90%, and then switch back when the battery % get back up to about 95%.

or

If in the end, I want to stream this data into Excel for analysis, but then I'd want to set up the same adjustable set point comparator as mentioned above.

So is it possible to include this comparator within the Arduino Uno IDE sketch?

Is there any other options to be able to make each row start with "V=".

What I would do until you know exactly how you want the data to look, is to use a terminal that will save what comes in to a text file. Then take that text file into a text editor and do a search and replace. Search for V= and replace it with CR V=, or what ever passes for CR ( new line ) in that Text editor.

You will then have a CSV file that you can import into Excel.

You can play about with that until you know exactly what you want to do. Then knowing that we can address how the Arduino could do this for you without the text editor phase.

@Grumpy_Mike,

I'm thrilled to have gotten to this point, thanks to you. For now though, I'll continue pursuing this topic and come back with a new topic when I have collected my thoughts about moving forward. Thanks again.

Steve