Storing calibration values

Hi All,
I have create project to measure soil moisture, I am using capacitive soil moisture for which two calibration values are used like value when sensor is in air and when it is in water.
My question is, how to store these values in Arduino?

Depending on the processor in EEPROM (8 bit AVR chips) or Flash memory (ESP and ARM processors).

Which Arduino are you using?

Arduino nano

Will it work for long term, as in loop continuously we use that value, or do you mean to store it in local variable in setup only ?

Doesn't help - nano is a form factor (board layout) that has many processor variants.

1 Like

If it is an 8 bit AVR processor check out

Other processors have libraries that simulate this function using flash memory.

Post your code and say which variables you want to save.

Which "nano"? There are half a dozen of them.

1 Like

Its ATmega328

Hello mrnams

Code these values a constant variable in the sketch.

Consider:

enum SoilMoisture {Dry,Wet}; 
constexpr uint16_t soilMoisture[] {200,5000}; 

Thanks, yes i did it already but these are hard coded values, i want make unit where user has to specify these values during calibration setup.
Like when we purchase some new gadget and start it, it ask for some info e..g mobile it ask for country,timezone,compass calibration etc etc.
Similar way when use take this unit of moisture measurement then at start it should ask user to provide value of sensor when in air and when in water.
Also if these values already provide( case of restart of device) it should not ask, and also provide user to re calibrate(override earlier values) at any time

Then use the EEPROM library in post 6. You will have to write code to prompt for the values and store them (or skip prompting if you have already done it). Then you need code to read in the values to ram variables to use in the program. See the library examples.

1 Like

Thanks, this is how it works for commercial gadgets?

You should acquire a copy of the Arduino Cookbook and skim it cover to cover, then read the sections that are relevant to your project. Computers are sort of like hair dye, you need the right color to get the appropriate outcome. You would not use black and expect to get white. In this case the project is the hair and the processor is the dye. I suspect there are more processor varieties then hair dye colors.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.