I'm trying to save high precision numbers to EEPROM and have not found a solution. Does anyone have any suggestions?
Here are examples:
-1.156012116E-03
.8825503296E-07
-.8422240081E-07
BTW, I'm using an ESP32.
Thanks,
I'm trying to save high precision numbers to EEPROM and have not found a solution. Does anyone have any suggestions?
Here are examples:
-1.156012116E-03
.8825503296E-07
-.8422240081E-07
BTW, I'm using an ESP32.
Thanks,
So, what data types are supported on that processor and what types do you want to store in EPROM?
Since I'm still using the Arduino IDE, I'd need the variables to be compatible. Right now I'm using:
float var1 = 1.156012116E-03
Would like to store this in the EEPROM... so whatever would support reading into the same type.
Also, I understand that the ESP32 memory isn't the same as the Atmega. Not sure of the details, but I believe it's emulated in some manner.
Bwanna:
Also, I understand that the ESP32 memory isn't the same as the Atmega. Not sure of the details, but I believe it's emulated in some manner.
I have the same understanding as you have on the nature of ESP's memory.
Try this sketch: (tested on ESP8266-NodeMCU)
#include<EEPROM.h>
int adr = 0;
void setup()
{
Serial.begin(9600);
Serial.println();
EEPROM.begin(512);
//EEPROM.write(0, 62);
//EEPROM.write(10, 103);
float x1 = -1.156012116E-03;
float x2 = 0.8825503296E-07;
float x3 = -0.8422240081E-07;
//-----------------------------
EEPROM.put(adr, x1);
EEPROM.put(adr + 4, x1);
EEPROM.put(adr + 8, x1);
EEPROM.commit();
//------------------//EEPROM.end();
float y1;
EEPROM.get(adr, y1);
Serial.println(y1, 11); //shows: -0.00115601206 ==> -1.15601E-03
}
void loop()
{
}


Does the Arduino IDE let you use 64-bit floating point doubles on ESP chips?
GoForSmoke:
Does the Arduino IDE let you use 64-bit floating point doubles on ESP chips?
It does support double (binray64 standard) data type for floating point number.
#include<EEPROM.h>
int adr = 0;
void setup()
{
Serial.begin(9600);
Serial.println();
EEPROM.begin(512);
//EEPROM.write(0, 62);
//EEPROM.write(10, 103);
double x1 = -1.156012116E-03;
float x2 = 0.8825503296E-07;
float x3 = -0.8422240081E-07;
//-----------------------------
EEPROM.put(adr, x1);
EEPROM.put(adr + 8, x1);
EEPROM.put(adr + 8, x1);
EEPROM.commit();
//------------------//EEPROM.end();
double y1;
EEPROM.get(adr, y1);
Serial.println(y1, 15); //shows: -0.001156012116000 ==> -1.156012116E-03
}
void loop()
{
}


Thank you everyone for the great help!! it's why I really enjoy this forum.
In working from what was given, I realize that the ESP32 has some extended EEPROM instructions that work for this ESP32 EEPROM extended
Here's the code that shows it working:
#include<EEPROM.h>
int adr = 0;
void setup()
{
Serial.begin(115200);
Serial.println();
EEPROM.begin(512);
//EEPROM.write(0, 62);
//EEPROM.write(10, 103);
double x1 = -1.156012116E-06;
float x2 = 0.8825503296E-07;
float x3 = -0.8422240081E-07;
//-----------------------------
EEPROM.put(adr, x1);
EEPROM.put(adr + 8, x1);
EEPROM.put(adr + 8, x1);
EEPROM.commit();
//------------------//EEPROM.end();
double y1;
EEPROM.get(adr, y1);
Serial.println(y1, 15); //shows: -0.001156012116000 ==> -1.156012116E-03
EEPROM.writeDouble(100,x1);
EEPROM.commit();
Serial.println(EEPROM.readDouble(100), 15); //ALSO shows: -0.001156012116000 ==> -1.156012116E-03
}
void loop()
{
}
I have down loaded arduino-esp32-master.zip file which contains an EEPROM folder that contains writeDouble() method, but I have problem to include the zip file in my IDE. Please, list the steps how to in do it.
GolamMostafa:
I have down loaded arduino-esp32-master.zip file which contains an EEPROM folder that contains writeDouble() method, but I have problem to include the zip file in my IDE. Please, list the steps how to in do it.
There are a few ways to do it, but most times I just extract the zip file to the Library folder of your IDE installation. It should create a directory call "ESP32_Master" or something like that. I usually remove the "_Master" part and just leave the "ESP32".
Then restart your IDE. Make sure to add the "Include..." line in your sketch.
Your instructions are too brief; I give you -1k.
GolamMostafa:
Your instructions are too brief; I give you -1k.
Actually, his instructions should work just fine.
Yeah but does your reality have a subtract karma button in it? Mine doesn't.
If you're after more precision, there's the big number library.
// BigNumber test: factorials
#include "BigNumber.h"
// function to display a big number and free it afterwards
void printBignum (BigNumber & n)
{
char * s = n.toString ();
Serial.println (s);
free (s);
} // end of printBignum
void setup ()
{
Serial.begin (115200);
Serial.println ();
BigNumber::begin (); // initialize library
//factorials
BigNumber fact = 1;
for (int i = 2; i <= 200; i++)
{
Serial.print (i);
Serial.print ("! = ");
fact *= i;
printBignum (fact);
}
} // end of setup
void loop () { }
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
11! = 39916800
12! = 479001600
13! = 6227020800
14! = 87178291200
15! = 1307674368000
16! = 20922789888000
17! = 355687428096000
18! = 6402373705728000
19! = 121645100408832000
20! = 2432902008176640000
21! = 51090942171709440000
22! = 1124000727777607680000
23! = 25852016738884976640000
24! = 620448401733239439360000
25! = 15511210043330985984000000
26! = 403291461126605635584000000
27! = 10888869450418352160768000000
28! = 304888344611713860501504000000
29! = 8841761993739701954543616000000
30! = 265252859812191058636308480000000
31! = 8222838654177922817725562880000000
32! = 263130836933693530167218012160000000
33! = 8683317618811886495518194401280000000
34! = 295232799039604140847618609643520000000
35! = 10333147966386144929666651337523200000000
36! = 371993326789901217467999448150835200000000
37! = 13763753091226345046315979581580902400000000
38! = 523022617466601111760007224100074291200000000
39! = 20397882081197443358640281739902897356800000000
40! = 815915283247897734345611269596115894272000000000
41! = 33452526613163807108170062053440751665152000000000
42! = 1405006117752879898543142606244511569936384000000000
43! = 60415263063373835637355132068513997507264512000000000
44! = 2658271574788448768043625811014615890319638528000000000
45! = 119622220865480194561963161495657715064383733760000000000
46! = 5502622159812088949850305428800254892961651752960000000000
47! = 258623241511168180642964355153611979969197632389120000000000
48! = 12413915592536072670862289047373375038521486354677760000000000
49! = 608281864034267560872252163321295376887552831379210240000000000
50! = 30414093201713378043612608166064768844377641568960512000000000000
51! = 1551118753287382280224243016469303211063259720016986112000000000000
52! = 80658175170943878571660636856403766975289505440883277824000000000000
53! = 4274883284060025564298013753389399649690343788366813724672000000000000
54! = 230843697339241380472092742683027581083278564571807941132288000000000000
55! = 12696403353658275925965100847566516959580321051449436762275840000000000000
56! = 710998587804863451854045647463724949736497978881168458687447040000000000000
57! = 40526919504877216755680601905432322134980384796226602145184481280000000000000
58! = 2350561331282878571829474910515074683828862318181142924420699914240000000000000
59! = 138683118545689835737939019720389406345902876772687432540821294940160000000000000
60! = 8320987112741390144276341183223364380754172606361245952449277696409600000000000000
61! = 507580213877224798800856812176625227226004528988036003099405939480985600000000000000
62! = 31469973260387937525653122354950764088012280797258232192163168247821107200000000000000
63! = 1982608315404440064116146708361898137544773690227268628106279599612729753600000000000000
64! = 126886932185884164103433389335161480802865516174545192198801894375214704230400000000000000
65! = 8247650592082470666723170306785496252186258551345437492922123134388955774976000000000000000
66! = 544344939077443064003729240247842752644293064388798874532860126869671081148416000000000000000
67! = 36471110918188685288249859096605464427167635314049524593701628500267962436943872000000000000000
68! = 2480035542436830599600990418569171581047399201355367672371710738018221445712183296000000000000000
69! = 171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
70! = 11978571669969891796072783721689098736458938142546425857555362864628009582789845319680000000000000000
71! = 850478588567862317521167644239926010288584608120796235886430763388588680378079017697280000000000000000
72! = 61234458376886086861524070385274672740778091784697328983823014963978384987221689274204160000000000000000
73! = 4470115461512684340891257138125051110076800700282905015819080092370422104067183317016903680000000000000000
74! = 330788544151938641225953028221253782145683251820934971170611926835411235700971565459250872320000000000000000
75! = 24809140811395398091946477116594033660926243886570122837795894512655842677572867409443815424000000000000000000
76! = 1885494701666050254987932260861146558230394535379329335672487982961844043495537923117729972224000000000000000000
77! = 145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000
78! = 11324281178206297831457521158732046228731749579488251990048962825668835325234200766245086213177344000000000000000000
79! = 894618213078297528685144171539831652069808216779571907213868063227837990693501860533361810841010176000000000000000000
80! = 71569457046263802294811533723186532165584657342365752577109445058227039255480148842668944867280814080000000000000000000
...
econjack:
Actually, his instructions should work just fine.
I requested for a list; he has given a bureaucratic description. I wished to have something like --
Where is the IDE installation? What does it mean? arduino-esp32-master.zip file has been stored in my download folder. What do I do now? I tried to include it via Add .Zip Library... tool of the IDE; it does not include the file.
GolamMostafa:
I requested for a list; he has given a bureaucratic description. I wished to have something like --
- Do this; this is the response;
- Do this; this is the response;
..............................................Where is the IDE installation? What does it mean? arduino-esp32-master.zip file has been stored in my download folder. What do I do now? I tried to include it via Add .Zip Library... tool of the IDE; it does not include the file.
More than willing to help, but please realize your question was about adding a new library to the IDE... this is quite different than what I originally posted. Some might think it's hyjacking the thread. Also, adding Libraries to the IDE is basic stuff with plenty of tutorials available on a google search. If I could suggest... take the time to research your question "How to add a library to Arduino IDE" and maybe review the youtube videos, instructions, etc. THEN, if you have a problem, start a NEW thread in the appropriate section asking more specifically what the issue is.
I hope this helps.
If you're on a NODEMCU, skit the EEPROM, and setup the SPIFFS filesystem instead. Then you can use standard c file i/o to read and write actual files. MUCH simpler and MUCH more flexible.
Regards,
Ray L.
Bwanna:
More than willing to help, [...]
If you would come with willingness to see my job is done, then you would say something like --
There is an EEPROM folder under libraries folder of Step-4 which contains the writeDouble() method. How do I tell my ESP sketch to search this folder for the said method not the EEPROM folder that we use for the internal EEPROM of ATmega328P.
I always use Add .ZIP Library... tool to add .zip file and work for most of the times. This time, it is not in my favor. You said there are many ways to do it; please, tell about a way with 'check/done list'.
Note: The following sketch of your Post#6 does not get compiled in my ESP8266 -- the writeDouble() method is not found.
#include<EEPROM.h>
int adr = 0;
void setup()
{
Serial.begin(115200);
Serial.println();
EEPROM.begin(512);
//EEPROM.write(0, 62);
//EEPROM.write(10, 103);
double x1 = -1.156012116E-06;
float x2 = 0.8825503296E-07;
float x3 = -0.8422240081E-07;
//-----------------------------
EEPROM.put(adr, x1);
EEPROM.put(adr + 8, x1);
EEPROM.put(adr + 8, x1);
EEPROM.commit();
//------------------//EEPROM.end();
double y1;
EEPROM.get(adr, y1);
Serial.println(y1, 15); //shows: -0.001156012116000 ==> -1.156012116E-03
EEPROM.writeDouble(100,x1);
EEPROM.commit();
Serial.println(EEPROM.readDouble(100), 15); //ALSO shows: -0.001156012116000 ==> -1.156012116E-03
}
void loop()
{
}
Bwanna:
Also, adding Libraries to the IDE is basic stuff with plenty of tutorials available on a google search.
He gets off on being a crank and acting like it's smart.
When you get a request for is already available on the web, give a link is plenty enough.
If they keep coming back demanding your personal unpaid time, chances are you've found a troll trying to suck the life out of you.
GoForSmoke:
He gets off on being a crank and acting like it's smart.When you get a request for is already available on the web, give a link is plenty enough.
If they keep coming back demanding your personal unpaid time, chances are you've found a troll trying to suck the life out of you.
When he got solution without payment, why is now reluctant to extend solution that he knows?
GolamMostafa:
When he got solution without payment, why is now reluctant to extend solution that he knows?
Oh, understand now. Well, if you can please provide your IP address to your PC, turn on remote access, and post your login and password info... I'm sure someone will help you with the problem.
Otherwise, Please start a new post in the appropriate section of this forum requesting help.