jurs:
Yes, easily. The method is called Parsing - Wikipedia
In lexical analyses you normally would need to tell what makes a "word", that you are looking for. Exampe: You could define that a "word" starts and ends with a "letter of the alphabet". So every character that is not a letter can be sorted out and never can belong to a word. So typically you "parse" the incoming data char by char until you have found a single "word". Then you can compare the word found against a stored list of words you like to find.
Hi, i'm working on the same project with arduino Uno and i have trouble classifying my data. I have 3 types of data from 3 sensors with timestamp. Now i want to ask the start and stop time and get the data between these times from my SD card. Here is the code i wrote so far:
[left]#include "RTClib.h" // Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <dht.h> //library for humidity sensor
#include <SPI.h>
#include <SD.h>
#define DHT11_PIN A1 //introducing the type and which pin it is connected to
const int chipSelect = 10;
RTC_DS1307 rtc;
dht DHT; // introducing the humidity sensor
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
char val; //making a variable for reading serial port
float cellvalue=0; //making a float variable for photocell numbers
float cellpin=A0;
float readvalue; //reading photocell numbers
String starttime;
String stoptime;
File dataFile;
void setup(){
Serial.begin(9600);
while (!Serial){ // for Leonardo/Micro/Z
}
Serial.print("Initializing SD card..."); // see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present"); // don't do anything more:
while (1);
}
Serial.println("card initialized.");
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);}
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // This line sets the RTC with an explicit date & time, for example to set
rtc.adjust(DateTime(2019, 11, 27, 10, 24, 20)); // January 21, 2014 at 3am you would call:
File dataFile = SD.open("datalog6.txt");
}
void loop() {
Serial.print("entert start time: ");
while ( Serial.available()==0){ }
starttime= Serial.readString();
Serial.print("entert stop time: ");
while ( Serial.available()==0){ }
stoptime= Serial.readString();
if (Serial.available()) { //writing the values into serial port
val=Serial.read();
int chk = DHT.read11(DHT11_PIN); // making variables for each sensor
int t= DHT.temperature;
int h=DHT.humidity;
int l=sendvalue; //photocell
}
char c;
if(Serial.available()) {
c = Serial.read();
if(c=='t')
sendvalue(); // if the file is available, write to it:
else { // if the file isn't open, pop up an error:
Serial.println("error opening datalog.txt");
} }
search();
RTC_Sensor();
SD_log(); }
void SD_log(){
String dataString = ""; // make a string for assembling the data to log:
for (int analogPin = 0; analogPin < 3; analogPin++) { // read three sensors and append to the string:
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += ",";}}
File dataFile = SD.open("datalog6.txt", FILE_WRITE); // open the file. note that only one file can be open at a time, so you have to close this one before opening another.
if (dataFile) { // if the file is available, write to it:
DateTime now = rtc.now();
dataFile.print(now.year(), DEC);
dataFile.print('/');
dataFile.print(now.month(), DEC);
dataFile.print('/');
dataFile.print(now.day(), DEC);
dataFile.print(" ,");
dataFile.print(now.hour(), DEC);
dataFile.print(':');
dataFile.print(now.minute(), DEC);
dataFile.print(':');
dataFile.print(now.second(), DEC);
dataFile.print( ",");
dataFile.println(dataString);
dataFile.close();
}
else { // if the file isn't open, pop up an error:
Serial.println("error opening datalog6.txt"); } }
void RTC_Sensor() {
readvalue=analogRead(A0); //photocell is connected to pin a3 so we read analog changes
}
void sendvalue(){
File dataFile = SD.open("datalog6.txt");
if (dataFile) {
while (dataFile.available()) {
Serial.write(dataFile.read());
}
dataFile.close();
}}
void search() {
while (dataFile.available()) {
dataFile.find(starttime)
Serial.print(starttime);[/left]