Where does MySensor store in EEPROM
-
@mfalkvidd Question..looking at the details...
EEPROM_LOCAL_CONFIG_ADDRESScurrently (2.0.0) has a value of 0x19D which makes decimal 413. The atmega only having 512 bytes of EEPROM leaves only around 100 bytes for saveState (i.s.o the mentioned 256).. or am I offtrack here?@AWI could you clarify where 256 is mentioned?
Edit: Found it, on https://www.mysensors.org/download/sensor_api_20#saving-state
Yes, you are correct. "You have 256 bytes to play with" can not be true for an AtMega328. I've started a discussion for that page, https://forum.mysensors.org/topic/4832/mysensors-library-v2-0-x/
-
Hi I'm making a pH sensor with Sparkeys widgets miniPH board. This one stores parameter in eeprom using:
#include <avr/eeprom.h> #define Write_Check 0x1234and writes to eeprom like this:
params.WriteCheck = Write_Check; params.pH7Cal = 2048; //assume ideal probe and amp conditions 1/2 of 4096 params.pH4Cal = 1286; //using ideal probe slope we end up this many params.pHStep = 59.16;//ideal probe slope eeprom_write_block(¶ms, (void *)0, sizeof(params)); //write these settings back to eepromThe parametertes stored are thees:
struct parameters_T { unsigned int WriteCheck; int pH7Cal, pH4Cal; float pHStep; } params;I think this interferes with mysensosrs eeprom usage.
The whole code of the schetch is here https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino
I dont understand what this is referng to:
#define Write_Check 0x1234Pleas help me
Goran -
Hi I'm making a pH sensor with Sparkeys widgets miniPH board. This one stores parameter in eeprom using:
#include <avr/eeprom.h> #define Write_Check 0x1234and writes to eeprom like this:
params.WriteCheck = Write_Check; params.pH7Cal = 2048; //assume ideal probe and amp conditions 1/2 of 4096 params.pH4Cal = 1286; //using ideal probe slope we end up this many params.pHStep = 59.16;//ideal probe slope eeprom_write_block(¶ms, (void *)0, sizeof(params)); //write these settings back to eepromThe parametertes stored are thees:
struct parameters_T { unsigned int WriteCheck; int pH7Cal, pH4Cal; float pHStep; } params;I think this interferes with mysensosrs eeprom usage.
The whole code of the schetch is here https://github.com/SparkysWidgets/MinipHBFW/blob/master/MinipH.ino
I dont understand what this is referng to:
#define Write_Check 0x1234Pleas help me
Goran@goranrad The
Write_Checkconstant is meant to check if there is a valid number written in EEPROM. As the sketch writes from EEPROM adress "0x00" there is good chance that it interferes with MySensors as it uses the same start point
#define EEPROM_START (0u)(defined in MyEepromAddresses.h)I would advice to rewrite the code to use the MySensors
saveState(..)andloadState(..) -
@goranrad The
Write_Checkconstant is meant to check if there is a valid number written in EEPROM. As the sketch writes from EEPROM adress "0x00" there is good chance that it interferes with MySensors as it uses the same start point
#define EEPROM_START (0u)(defined in MyEepromAddresses.h)I would advice to rewrite the code to use the MySensors
saveState(..)andloadState(..)@AWI
Thank you AWI!
I would have to rewrite it like thiswrite to eeprom would be like this:
saveState(_WriteCheck, Write_Check); saveState(_pH7Cal, 2048); saveState(_pH4Cal, 1286); saveState(_pHStep, 59.16);read from eeprom would be like this:
params.WriteCheck = loadState(_WriteCheck); params.pH7Cal = loadState(_pH7Cal); params.pH4Cal = loadState(_pH4Cal); params.pHStep = loadState(_pHStep);do you think this would work?
Then change the WriteState to a int constant with a value of 1234.
Don't know if saveState(..) can store a float or do i have to define it somehow?
Best regard
Goran -
@AWI
Thank you AWI!
I would have to rewrite it like thiswrite to eeprom would be like this:
saveState(_WriteCheck, Write_Check); saveState(_pH7Cal, 2048); saveState(_pH4Cal, 1286); saveState(_pHStep, 59.16);read from eeprom would be like this:
params.WriteCheck = loadState(_WriteCheck); params.pH7Cal = loadState(_pH7Cal); params.pH4Cal = loadState(_pH4Cal); params.pHStep = loadState(_pHStep);do you think this would work?
Then change the WriteState to a int constant with a value of 1234.
Don't know if saveState(..) can store a float or do i have to define it somehow?
Best regard
Goran -
@goranrad saveState can only save a 1 byte value so you won't be able to save integers or floats directly.
You'll need to do something like this, but use saveState instead of EEPROM.write.
@mfalkvidd
Hi mfalkvidd,This code takes care of writing to eeprom
#include <avr/eeprom.h> eeprom_write_block(¶ms, (void *)0, sizeof(params));My problem is that mysensors need to handle read and write to eeprom so it dosent conflict with mysensors read and write to eeprom.
Any thoughts on solving this ?
Best regards
Goran -
@mfalkvidd
Hi mfalkvidd,This code takes care of writing to eeprom
#include <avr/eeprom.h> eeprom_write_block(¶ms, (void *)0, sizeof(params));My problem is that mysensors need to handle read and write to eeprom so it dosent conflict with mysensors read and write to eeprom.
Any thoughts on solving this ?
Best regards
Goran -
@mfalkvidd I dont understand how http://www.alexenglish.info/2014/05/saving-floats-longs-ints-eeprom-arduino-using-unions/ would make mysensors to take care of the eeprom?
Sorry i'm not seasoned programmer.
/goran -
@mfalkvidd I dont understand how http://www.alexenglish.info/2014/05/saving-floats-longs-ints-eeprom-arduino-using-unions/ would make mysensors to take care of the eeprom?
Sorry i'm not seasoned programmer.
/goran -
thank you!