Database for Arduino Nano

Hey,

I want to run an Arduino Nano that reads values from a sensor and transmits them via HC-05. I want these values to be stored in a database so I can check them anytime. The problem is, I have no idea where to start because I'm a noob.
It would be nice if somebody could help.

Thanks

What is the sensor that you plan to use? Did you looked up for an Arduino library for it?

Do you intend to host the database on the Nano? Database may be a grand word for your situation. A simple text file, possibly stored on an SD card would suffice?

How much data would you like to store?

For periodic readings such as an hourly temperature reading, you could use the internal EEPROM memory to store the reading.

Im using a Watersensor

Not much, and I've heard something like this works with esp32

please indicate an exact model or link to the purchase

Decide on what value(s) you want to store, how frequently you will take the readings, and for how long you need to keep those readings before being overwritten/ erased.

That should give us some idea of the storage requirements.

Tropfensensor, Wasserstandssensor für Mikrocontroller günstig online kaufen | Funduinoshop

I want that a value gets saved all 15 min and they have to get stored 7 days (if that is realistic)

Ok, so 4 readings per hour, 96 readings per day, 672 readings in total. Do you need a timestamp?

Yes but what means that. And I need a Timstamp

Is it important that the readings are taken every 15 minutes exactly? If you are ok with a variation of a a few seconds, then you can use the internal watchdog timer as your time base. It's not particularly accurate so may be off by 30 minutes or more after 7 days, but it's free as it's built in.

If you know the start time, then you can infer the approximate time of subsequent readings.

672 readings could take 672 bytes of EEPROM, or maybe 1342 bytes if you need values greater than 255 (or 127.. -128 if values can be negative).

If you need an accurate time, then you need to consider an external time source such as a real time clock.

It does not have to be acutrat

What is EEPROM and all that other stuff

In which case I would use the internal EEPROM to store the values.

You can develop a simple system to handle querying the data over the HC05 and use the millis function for your timing - avoid using delay.

Of course things get more difficult if your project is to be battery powered.

And how do I do That :man_shrugging:

Presuming you want to use that Nano, and store a floating point value and a timestamp for each event in EEPROM, you can only store 128 such readings. So, either you'll have to spread that across your 7 days, reducing your reading frequency to every 90 minutes, for example, or you'll have to harvest it more frequently((96 readings/day at 15 minutes per, so you could do that readout once daily), or you'll need to save it somewhere else, like an SD card, which you'll have to buy.

So, it's time for you to tell us what can change. Otherwise, we end up describing many options, only to find out later which parameter wasn't really necessary.

1 Like

Then I just want it every 90 minutes

Next, re-read post#15 and answer the implied question.

Your water sensor takes readings directly from the Arduino ADC so the values you get will be between 0 and 1023. This will require 2 bytes of memory to hold the value. Your Nano has 1024 bytes of EEPROM memory available which would allow 512 readings to be stored. At 4 readings per hour (i.e. every 15 mins) you have a capacity of 128 hours of storage which equates to 5 days 8 hours.

At 3 readings per hour, you would have a recording time of just over 7 days.

Your project would need to be able to handle reading and writing to the internal EEPROM memory of your Nano (libraries are available), serial input/output using a software serial port connected to your HC-05 and the use of the millis function to determine when it was time to take the next reading.

You would also need to develop a simple text based user interface to allow you to communicate with the program over the HC-05 bluetooth serial link to download the readings to your PC/laptop/phone etc.

1 Like