I intend to perform data logging from sensors and store it on SD card as CSV format. The data is related to weather and I would like to send it at the end of the day/ Any available codes how to deploy the SD files from Arduino to the cloud/online at specific time of the day? Thank you in advance.
2 Answers
You should use arduino as an ftp client, then stream the csv file to the site in binary mode. You should find examples on the web.
Well for CSV, you might as well do dataFile.print(",");
. It will log a comma and thus separating your values with a comma.
For logging your data at the end of the day, you have multiple ways.
1- Use a delay (worst idea EVER! Don't do this!). This will require you putting delay(86400000);
. Yes that is indeed a 24h delay!
2- Use the millis()
function. This function returns the number of milliseconds since the programmed started running. There is an example code called blinkWithOutDelay
(or something like that). This method is somewhat "ok" but after 49 days there is a rollover which makes things complicated. To solve that rollover, see here.
3- Use a RTC. RTC stands for Real Time Clock. It is pretty much a module that keeps actual time even if the power to your project is disconnected. There are many popular models out there such as the DS3231. There are many libraries for it. You can do so that each day, at a specific time, it logs the data to your SD card.
Now to send the data. You have may options for this too.
1- Use an Arduino Ethernet shield. This will connect your Arduino to the Ethernet via an Ethernet cable. From there, you can either log your data to a Google Sheets file or a custom web server. Many tutorials out there for you.
2- Use an ESP8266. With this Wifi module, you can easily host your own web server with it. Note that This makes it somewhat harder for your code then simply using an Ethernet cable but it makes you project wireless. Note that if you do use an ESP8266, you can put the Arduino aside. The ESP has many GPIOs that can be used to do many things, but I'll still suggest keeping the Arduino for sake of simplicity. Again, many tutorials out there.
Note that there are many cloud services out there. A quick Arduino IOT search will bring out many result and interresting projects ideas for you.