Where does MySensor store in EEPROM
-
Hi, I start using MySensor. I red that MySensor also stores data in EEPROM, to have it available after the device has rebooted (like the state of a relais). What address locations does it need/use? This is relevant, because I use EEPROM in my Sketch as well.
Regards, DJ
-
@djdehaan see https://www.mysensors.org/download/sensor_api_20#saving-state for information on how to store things in eeprom without interfering with MySensors. The library will handle the addressing to so you don't need to bother with the details.
If you do want to bother with the details, look at https://github.com/mysensors/MySensors/blob/986389b12591917ecbc44021c63a2cdf6f8c8222/core/MyEepromAddresses.h
-
Thanks! That is what I was looking for!
-
@mfalkvidd Question..looking at the details...
EEPROM_LOCAL_CONFIG_ADDRESS
currently (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 0x1234
and 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 eeprom
The 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 0x1234
Pleas help me
Goran
-
@goranrad The
Write_Check
constant 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
-
@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
-
@goranrad Yes. My suggestion is in my previous post.
-
@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
-
@goranrad it does if you use saveState instead of EEPROM.write
-
thank you!