Hi folks,
I’m playing with 5TE (a sensor for soil water content) using SDIserial library. However new problem comes out.
When I use SD.h and RTClib.h together, it works well, you can check code NO 1 and screenshot NO1.
When I use SDIserial.h and RTClib.h together, it works well, you can check code NO 2 and screenshot NO2.
When I use SD.h and SDIserial.h together, it also works well, you can check code NO 3 and screenshot NO3.
However, When I combine SD.h, RTClib.h and SDIserial.h together, it doesn’t work! No data is showed in the screen. It’s so strange. You can check code NO4 where I just put “#include <SD.h>” inside.
I also attach the libraries I use. I really confused with that it doesn’t work when I combine three libraries.
I’m looking forward to your reply
Best regards
Jingbo
No data is showed in the screen. It’s so strange. You can check code NO4 where I just put “#include <SD.h>” inside.
Including SD.h reserves 1/4 of the Uno's memory for reading from/writing to the SD card. If just including that file causes problems, it is because you have run out of memory.
Quit wasting it:
Serial.println(F("SDIserial.h and RTC.h with SD.h"));
Hello Pauls,
please check the code below. when I delete the statements" #include <Wire.h>, #include "RTClib.h" , RTC_DS1307 rtc; ", the code worked well, you can check the picture 1, where card is ready and there is data.
However, When I put the statements " #include <Wire.h>, #include "RTClib.h" , RTC_DS1307 rtc; " inside the code. The code didn't work well, you can check the picture 2, where card failed and there is not data.
In my opinion, SD, RTC DS1307 and 5TE are all I2C divices, maybe they are not compatible. Could you tell me how to make them work together well?
The libraries of SD.h, RTClib.h and SDIserial.h which I'm using also are attached behind.
#include <SD.h>
int chipselect=4;
int i=1;
// #include <Wire.h>
//#include "RTClib.h"
// RTC_DS1307 rtc;
char X='+';
#include <SDISerial.h>
#define DATALINE_PIN 5
#define INVERTED 1
SDISerial sdi_serial_connection(DATALINE_PIN, INVERTED);
char* get_measurement()
{
char* service_request = sdi_serial_connection.sdi_query("?M!",150);
//you can use the time returned above to wait for the service_request_complete
char* service_request_complete = sdi_serial_connection.wait_for_response(150);
//dont worry about waiting too long it will return once it gets a response
return sdi_serial_connection.sdi_query("?D0!",150);
}
void setup()
{
Serial.begin(57600);
if(!SD.begin(chipselect))
{
Serial.println("Card Failure!");
// return;
}
Serial.println("Card Ready!");
File datafile=SD.open("TEST.csv",FILE_WRITE);
if(datafile)
{
String Title="NO,DATA";
datafile.println(Title);
delay(100);
datafile.close();
}
else
{
Serial.println("Couldn't open data file!");
}
sdi_serial_connection.begin();
delay(1000);
}
void loop()
{
char* response = get_measurement(); // get measurement data
String FTE=response;
char tmp1='+';
int tmp2=FTE.indexOf(tmp1);
while(tmp2!=1)
{
char* response = get_measurement(); // get measurement data
FTE=response;
tmp2=FTE.indexOf(tmp1);
}
String datastring = "NO: "+String(i)+" data: "+FTE;
Serial.println(datastring);
delay(50);
File datafile=SD.open("TEST.csv",FILE_WRITE);
if(datafile)
{
datafile.println(datastring);
delay(100);
datafile.close();
}
i++;
}