I have a sketch that uses a Capacitance Soil Moisture Sensor. I have hard coded the raw input to output in a class so that the readings are 0-100% moisture. I would like to keep the configuration data in a configuration file that gets loaded when the program starts. How do I load this file to included the (raw_low=850 and raw_high=340) data which then is used in my class library? Do I #include moisture_config.h file that has the definitions?
I don't want to update my custom library file every time I recalibrate. I just want to update a small config file with the specific calibration data.
//
// EEPROM image - we need pointers, not variables
//
const int promTempFC = 0; // Flag - EEPROM BASE - ONLY ADD AT END
const int promAlarmSet = 1; // Flag
const int promMatrixBright = 2; // Int, 0-15
#include <EEPROM.h> // EEPROM support for tables
// in setup()
clockMode12 = EEPROM.read(promClockMode12 ); // Default to 12 hr time, false for 24,
AlarmSet = EEPROM.read(promAlarmSet ); // Alarm Set/not, save in EEPROM
tempFC = EEPROM.read(promTempFC ); // Farenheit/not celcius
//
// Updates given EEPROM *BYTE* address with value, ints > 255 need TWO!
//
void logProm(int Addr, int Valu)
{
EEPROM.update(Addr, Valu);
}
You posted an example of how to save a byte, which is not what is required. Unfortunately the function that you posted takes an int as the parameter for the value to be saved but only saves one byte of it. The function has a comment indicating that it will not save an int but you have not explained how to do this
You want code that saves an int ?
void logProm(int Addr, int Valu)
{
EEPROM.put(Addr, Valu);
}
I have run into a problem using EEPROM. The data that I EEPROM.get is not the same data that I EEPROM.put. Can anyone explain why? For example, I am writing (put) the int value of 312 to address 0 and when I use get to retrieve the data from address 0, I get 56. I am a bit confused on why this is happening.