Hello guys, so for a starter i have RTC module, Sd Card Module, and Arduino uno. Im trying to make a program that a data inside of array in arduino will changed automatically after a few days when arduino turned on. The data located inside of Sd Card in txt format.
I've asked to my friend, he said i can access arduino log that described when does the arduino are turned on/off, so that i can make the program based on that log.
I appreciate for the answers that will help me to make the program.
Run some tutorials to the hardware selected.
If you are happy with the results of the tutorials you can merge these to your project.
Have a nice day and enjoy coding in C++.
Дайте миру шанс!
If you want to save persistent data that will survive between turning off the Arduino and turning it back on again then you can save it to the SD card and read it back when the Arduino is turned on.
well sort of, im making a device that monitoring and controlling hydroponic tank, so monitoring the nutrition and controlling it by adding some liquid solution to the tank. And sometime the device must turned off when the crops have been harvested, and when the farmer going to planting the crops the farmer must turned on the device again.
peristaltic pumps to the liquid solution from bottle/container to the hydroponic tank
solenoid valve module to control the water flow to fill the tank if the water level are dropping
a float sensor to detecting if the water level is dropping
SD Card module to save the data about how many nutrition and ph water should be on the first week until the fourth week,
RTC module, LCD 16x2 with I2C, a submerged pump, 3 relay modules, arduino uno and power supply 24v 5 amp that has been reduced to 12v
The concept of my device are monitoring and control the hydroponic tank.
The monitoring side
my device monitoring how much does the nutrition and PH of the water, does the water level dropped, and how long does the device has been turned on.
The controlling side
The code will compare between the data and the sensors, does the sensor data are the same as the data from SD Card, if the numbers are less than the data from SD Card the peristaltic pump will turned on and flow the liquid solution to the tank, how much long does the peristaltic pump turned on have been calculated by equation that i've made, and hopefully accurate.
About the SD Card module and RTC, i want it automatically change the data to an aray inside of arduino, and according to the SD Card data that i've been collect from local hydroponic farmer eack week from week one until week four are different, so i want it to automatically change after one week.
Controlling the water level, when the float sensor going low, it will trigger the solenoid valve to flow the water to fill the tank, and of course it will reduce the amount of the nutrition and increase/decrease the PH level so the code of the nutrition and ph control will turned on again.
The servo will activate either when pushed or automatically, i still thinking about how will it go
For the program i have made the equation for the nutrition control, this include controlling the peristaltic pump and it worked and accurate, hopefully accurate when i combine it. Then i've made the program to monitoring the amount of the nutrition and the PH level which is failed due to the sensor reading on the LCD are not realtime. The water level program. Making menu for the LCD with changing menu with buttons, the menu worked but it make the sensor reading menu failed.
So far thats the program that i've been working. Right now im working on the SD Card and RTC module program.
Good to read that you are making progress. Let us know how the project turns out, if you would, and if you have issue with your project feel free to ask for help.
One of the difficulties with projects like this is testing it, especially when a full cycle takes a long time, four weeks in your case I think.
Consider using another Arduino to simulate the RTC and sensors so that you can test edge cases and run through a full four week test in a lot less time.
Okay i've made the code and testing and see if the data inside the file is according to what want, and it all works.
Here's the code that i made
#include "RTClib.h"
#include <SPI.h>
#include <SD.h>
File myFile;
RTC_DS1307 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running, let's set the time!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
while (!Serial) {
;
}
Serial.print("Initializing SD card...");
if (!SD.begin(9)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
myFile = SD.open("Date_Log.txt", FILE_WRITE);
}
void loop () {
DateTime now = rtc.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
Serial.println();
delay(3000);
if (myFile) {
Serial.print("Writing to Date_Log.txt...");
myFile.print(now.year(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.day(), DEC);
// close the file:
myFile.close();
Serial.println("done.");
}
}
I know it may seems simple, but it worked. Now i just want the sd card write only at that time (at the time when the arduino is turned on), any suggestion guys? i really appreciate your answers