Hi,

I need to submit double values with 8 decimal places like "12.12345678" via Serial Monitor to my Arduino Mega 2560. For this purpose I read the serial buffer and put the seperate entrys (1,2,.,1,.2,3,4...) into a char-array. I generate the double value from these entries with the -'0' and the pow(10,n) function by multipicating the seperate entries with the correct power n and then adding them up to the correct number:

Example: 1*10^1 + 2*10^0 + 1*10^(-1) + 2*10^-2) + ... = 12.12346578

The problem is that I loose precision after the 6th decimal place. I know this calculation is a bit unhandy but I already tried atof()-commands and they all failed as well.

I tried the following to get to the problem: I added the following numbers as double-values

0.000003

+ 0.0000003

+ 0.00000003

= 0.00000333

which was calculated correctly. But as I added numbers like

1.000003

+ 0.0000003

+ 0.00000003

= 1.00000331675

I got crap like this. Obviously because of the additional value left of the decimal point.

Any ideas on how to fix this problem?

Note: I already googled the problem and read, that MEGA boards could only handle 6 decimal places or less.

Nonetheless I wanted to ask if there are any

workarounds existing?

I ask because I also use the TinyGPS++ library within my project and I think this library can handle double values with more then 6 decimal places correctly. But that could be wrong as well

Unfortunately I don't understand what is going on within the functions of TinyGPS++.

My Project:

I want my robot to drive from a point A to point B via GPS. For that I submit GPS-destination-coordinates like "12.12345678" via Serial Monitor to my Arduino Mega 2560. I use the TinyGPS++ library to get information like "distance to destination B" and "current orientation of robot". I want my robot to find the destination at least within a 5 meter-radius. But this precision needs more decimal places then 6.