I use this code and try to connect my esp8266 so it will upload temperature to thingspeak.com
#include <SoftwareSerial.h>
#include <stdlib.h>
// LED
int ledPin = 13;
// LM35 analog input
int lm35Pin = A0;
// replace with your channel's thingspeak API key
String apiKey = "xxxxxx";
// connect 10 to TX of Serial USB
// connect 11 to RX of serial USB
SoftwareSerial ser(10, 11); // RX, TX
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
ser.begin(115200);
ser.println("AT+RST");
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
int val = 0;
for(int i = 0; i < 10; i++) {
val += analogRead(lm35Pin);
delay(500);
}
float temp = val*50.0f/1023.0f;
char buf[16];
String strTemp = dtostrf(temp, 4, 1, buf);
Serial.println(strTemp);
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += "184.106.153.149"; // api.thingspeak.com
cmd += "\",80";
ser.println(cmd);
if(ser.find("Error")){
Serial.println("AT+CIPSTART error");
return;
}
String getStr = "GET /update?api_key=";
getStr += apiKey;
getStr +="&field1=";
getStr += String(strTemp);
getStr += "\r\n\r\n";
cmd = "AT+CIPSEND=";
cmd += String(getStr.length());
ser.println(cmd);
if(ser.find(">")){
ser.print(getStr);
}
else{
ser.println("AT+CIPCLOSE");
Serial.println("AT+CIPCLOSE");
}
delay(16000);
}
When running the code i get this in the serial monitor:
21
AT+CIPCLOSE
21
AT+CIPCLOSE
21
AT+CIPCLOSE
21 will be the temperature
On the firmware version that I use the return for a failure on AT+CIPSTART is "ERROR" and not "Error" so that might be the reason why you never see that the connection has failed. Try the above via a serial Terminal connected to the ESP8266 and check what the returns are.
Also, you need to learn to stay away from Strings in AVR programming. Rather use char arrays.
Related
I have wrtitten a code for automatically watering plant using esp8266, dht11, moisture sensor but my code has some error, i dont know how to fix it
#include <DHT.h>
#include <ESP8266WiFi.h>
String apiKey = "X5AQ3EGIKMBYW31H"; // Enter your Write API key here
const char* server = "api.thingspeak.com";
const char *ssid = "CircuitLoop"; // Enter your WiFi Name
const char *pass = "circuitdigest101"; // Enter your WiFi Password
#define DHTPIN D3 // GPIO Pin where the dht11 is connected
DHT dht(DHTPIN, DHT11);
WiFiClient client;
const int moisturePin = A0; // moisteure sensor pin
const int motorPin = D0;
unsigned long interval = 10000;
unsigned long previousMillis = 0;
unsigned long interval1 = 1000;
unsigned long previousMillis1 = 0;
float moisturePercentage; //moisture reading
float h; // humidity reading
float t; //temperature reading
void setup()
{
Serial.begin(115200);
delay(10);
pinMode(motorPin, OUTPUT);
digitalWrite(motorPin, LOW); // keep motor off initally
dht.begin();
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print("."); // print ... till not connected
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop()
{
unsigned long currentMillis = millis(); // grab current time
h = dht.readHumidity(); // read humiduty
t = dht.readTemperature(); // read temperature
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
moisturePercentage = ( 100.00 - ( (analogRead(moisturePin) / 1023.00) * 100.00 ) );
if ((unsigned long)(currentMillis - previousMillis1) >= interval1) {
Serial.print("Soil Moisture is = ");
Serial.print(moisturePercentage);
Serial.println("%");
previousMillis1 = millis();
}
if (moisturePercentage < 50) {
digitalWrite(motorPin, HIGH); // tun on motor
}
if (moisturePercentage > 50 && moisturePercentage < 55) {
digitalWrite(motorPin, HIGH); //turn on motor pump
}
if (moisturePercentage > 56) {
digitalWrite(motorPin, LOW); // turn off mottor
}
if ((unsigned long)(currentMillis - previousMillis) >= interval) {
sendThingspeak(); //send data to thing speak
previousMillis = millis();
client.stop();
}
}
void sendThingspeak() {
if (client.connect(server, 80))
{
String postStr = apiKey; // add api key in the postStr string
postStr += "&field1=";
postStr += String(moisturePercentage); // add mositure readin
postStr += "&field2=";
postStr += String(t); // add tempr readin
postStr += "&field3=";
postStr += String(h); // add humidity readin
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length()); //send lenght of the string
client.print("\n\n");
client.print(postStr); // send complete string
Serial.print("Moisture Percentage: ");
Serial.print(moisturePercentage);
Serial.print("%. Temperature: ");
Serial.print(t);
Serial.print(" C, Humidity: ");
Serial.print(h);
Serial.println("%. Sent to Thingspeak.");
}
}
This is the error which i get
Arduino: 1.8.9 (Windows 8.1), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled, All SSL ciphers (most compatible), ck, 26 MHz, 40MHz, DOUT (compatible), 512K (no SPIFFS), 2, nonos-sdk 2.2.1 (legacy), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
sketch_oct03a:7:16: error: 'D3' was not declared in this scope
#define DHTPIN D3 // GPIO Pin where the dht11 is connected
^
C:\Users\Shweta\Desktop\Libraries\sketch_oct03a\sketch_oct03a.ino:8:9: note: in expansion of macro 'DHTPIN'
DHT dht(DHTPIN, DHT11);
^
sketch_oct03a:12:22: error: 'D0' was not declared in this scope
const int motorPin = D0;
^
exit status 1
'D3' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Digital pins are not prefixed with D, unlike their analog counterparts.
#define DHTPIN 3
const int motorPin = 0;
I am trying to verify the Arduino code in ADS1198 and Arduino Due. It comes the error show 'Serial1' does not name a type' even I defined two serial port in the beginning(where I gave the comments now). How to deal with this error 'Serial1' does not name a type'. how can I define these two port on ArduinoDue so that complieling successfully.
#include <ads1298.h>
#include <Base64.h>
// Minimal sketch for connection to ADS129n family. Load this script and open Tools/SerialMonitor.
// You should see text like this
// Device Type (ID Control Register): 62 Channels: 8
// If you see "Channels: 0" then check your wiring
#include "ads1298.h"
#include "adsCMD.h"
#include <Base64.h>
#include <SPI.h> // include the SPI library:
int gMaxChan = 0; //maximum number of channels supported by ads129n = 4,6,8
int gIDval = 0; //Device ID : lower 5 bits of ID Control Register
int activeSerialPort = 0; //data will be sent to serial port that last sent commands. E.G. bluetooth or USB port
const int kPIN_LED = 13; //pin with in-built light - typically 13, 11 for Teensy 2.0.
//ADSCMD
#include "Arduino.h"
//For Leonardo SPI see http://openenergymonitor.blogspot.com/2012/06/arduino-leonardo-atmega32u4-and-rfm12b.html
//constants define pins on Arduino
// Arduino Due
const int IPIN_PWDN = 47; //not required for TI demo kit
const int PIN_CLKSEL = 49; //6;//*optional
const int IPIN_RESET = 48; //*optional
const int PIN_START = 46;
const int IPIN_DRDY = 45;
const int IPIN_CS = 52;
const int PIN_DOUT = 11; //SPI out
const int PIN_DIN = 12; //SPI in
const int PIN_SCLK = 13; //SPI clock
//
//function prototypes
void adc_wreg(int reg, int val); //write register
void adc_send_command(int cmd); //send command
int adc_rreg(int reg); //read register
//start Serial Peripheral Interface
int numActiveChannels = 0;
boolean gActiveChan[9]; // reports whether channels 1..9 are active
boolean isRdatac = false;
boolean base64Mode = false;
int sampleCount=0;
boolean isLimit=false;
char hexDigits[] = "0123456789ABCDEF";
uint8_t serialBytes[200];
char sampleBuffer[1000];
uint8_t chan1[2];
const char *hardwareType = "unknown";
const char *boardName = "HackEEG";
const char *makerName = "Hamid, Mujahid, Abdul Hameed";
const char *driverVersion = "ADS1298 driver v0.1";
#if defined(__SAM3X8E__)
//#define isDUE //Detect Arduino Due
//#define WiredSerial SerialUSB //Use Due's Native port
//#define NSerial SerialUSB
#endif
void setup(){
using namespace ADS1298;
//prepare pins to be outputs or inputs
pinMode(PIN_SCLK, OUTPUT); //optional - SPI library will do this for us
pinMode(PIN_DIN, OUTPUT); //optional - SPI library will do this for us
pinMode(PIN_DOUT, INPUT); //optional - SPI library will do this for us
pinMode(IPIN_CS, OUTPUT);
pinMode(PIN_START, OUTPUT);
pinMode(IPIN_DRDY, INPUT);
pinMode(PIN_CLKSEL, OUTPUT); // *optional
pinMode(IPIN_RESET, OUTPUT); // *optional
pinMode(IPIN_PWDN, OUTPUT); // *optional
digitalWrite(PIN_CLKSEL, HIGH); // External clock
//start Serial Peripheral Interface
SPI.begin();
SPI.setBitOrder(MSBFIRST);
#ifndef isDUE
SPI.setClockDivider(SPI_CLOCK_DIV4); //forum.pjrc.com/.../1156-Teensy-3-SPI-Basic-Clock-Questions
#endif
SPI.setDataMode(SPI_MODE1);
//Start ADS1298
delay(500); //wait for the ads129n to be ready - it can take a while to charge caps
digitalWrite(PIN_CLKSEL, HIGH); // External clock
delay(10); // wait for oscillator to wake up
delay(1);
digitalWrite(IPIN_PWDN, HIGH); // *optional - turn off power down mode
digitalWrite(IPIN_RESET, HIGH);
delay(1000);// *optional
digitalWrite(IPIN_RESET, LOW);
delay(1);// *optional
digitalWrite(IPIN_RESET, HIGH);
delay(1500); // *optional Wait for 18 tCLKs AKA 9 microseconds, we use 1 millisecond
adc_send_command(SDATAC); // Send SDATAC Command (Stop Read Data Continuously mode)
// delayMicroseconds(2);
delay(100);
// Determine model number and number of channels available
gIDval = adc_rreg(ID); //lower 5 bits of register 0 reveal chip type
switch (gIDval & B00011111 ) { //least significant bits reports channels
case B10000: //16
hardwareType = "ADS1294";
gMaxChan = 4; //ads1294
break;
case B10001: //17
hardwareType = "ADS1296";
gMaxChan = 6; //ads1296
break;
case B10010: //18
hardwareType = "ADS1298";
gMaxChan = 8; //ads1298
break;
case B11110: //30
hardwareType = "ADS1299";
gMaxChan = 8; //ads1299
break;
case B10110: //22
hardwareType = "ADS1198";
gMaxChan = 8; //ads1198
break;
default:
gMaxChan = 0;
}
}
void detectActiveChannels() { //set device into RDATAC (continous) mode -it will stream data//
if ((isRdatac) || (gMaxChan < 1)) return; //we can not read registers when in RDATAC mode
//Serial.println("Detect active channels: ");
using namespace ADS1298;
numActiveChannels = 0;
for (int i = 1; i <= gMaxChan; i++) {
delayMicroseconds(1);
int chSet = adc_rreg(CHnSET + i);
gActiveChan[i] = ((chSet & 7) != SHORTED);
if ( (chSet & 7) != SHORTED) numActiveChannels ++;
}
}
//start serial port
Serial1.begin(115200);
Serial.begin(115200); //use native port on Due
Serial1.begin(115200) and Serial.begin(115200) need to be placed in a function. Put them in setup().
I'm working on Galileo gen 2;
And I'm trying to use the following two web services:
POST /dashboard/read_write_ard.php?temp="+tempValue
POST /dashboard/appinsert.php?valeur="+tempValue
The first one inserts into table one...
and the second one will be used only if (tempValue < 24).
This is my code so far:
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h>
#include "rgb_lcd.h"
rgb_lcd lcd;
const int pinLight = A1;
const int pinLed = 13;
const int thresholdvalue = 400;
const int idealLightValue = 400 ;
const int pinTemp = A0;
const int B = 3975;
int etat=0;
const int pinSound = A2;
byte mac[] = {
0x98, 0x4F, 0xEE, 0x05, 0x37, 0x33
};//adress mac du carte
EthernetClient client;
IPAddress server(192,168, 1,7);
void setup() {
Serial.begin(9600);
pinMode(pinLed, OUTPUT);
lcd.begin(16, 2);
delay(1000);
system("ifup eth0");
if (Ethernet.begin(mac) == 0) {
Serial.println("\nFailed to configure Ethernet using DHCP");
delay(500);
}
delay(1000);
Serial.println(Ethernet.localIP());
}
void loop() {
system("ifup eth0");
digitalWrite(pinLed, HIGH);
lcd.print("Starting to loop ");
delay(1000);
lcd.clear();
int TempSensorValue = analogRead(pinTemp);
int LightSensorValue = analogRead(pinLight);
int SoundSensorValue = analogRead(pinSound);
float resistance = (float)(1023-TempSensorValue)*10000/TempSensorValue;
int temperature = 1/(log(resistance/10000)/B+1/298.15)-273.15;
Serial.println( temperature);
Serial.println(SoundSensorValue);
Serial.println( LightSensorValue);
delay(1000);
String chEtat = "POST /dashboard/read_write_ard.php?temp=";
chEtat += temperature ;
chEtat += "&light=";
chEtat += LightSensorValue;
chEtat +="&sound=";
chEtat +=SoundSensorValue;
if (client.connect(server, 80) ) {
Serial.println("connected");
lcd.print("Connected ");
delay(500);
lcd.clear();
if (temperature <= 40 ){
String chEtat2 = "POST /dashboard/appinsert.php?valeur=";
chEtat2 += temperature ;
chEtat2 += "&type=temperature" ;
client.println(chEtat2);
client.println(chEtat);
}else{
client.println(chEtat);
client.println();
}
}
while (client.available()) {
char c = client.read();
Serial.print(c);
}
if(client.connected()) {
Serial.println();
Serial.println("disconnecting.");
lcd.print("Dissconnecting");
delay(1000);
lcd.clear();
client.stop();
for (;;);
}
}
I have a database containing 2 tables - one for alert values like temperature and the other for normal cases - so I want to put a code when my cart Galileo can add in table 1 : the normal one.
And in case of temperature, let's say more than 24, the value of that temperature will be added to the second table using the web service created for that.
I'd like to know how to get these data soon.
I'm building a little car, remote controlled by a Wemos D1 board, in order to set the WiFi connection and the control logic I'm running this script:
#include <ESP8266WiFi.h>
const char* pass = "**********";
const char* ssid = "**********";
IPAddress ip(192,168,1,91);
IPAddress gat(192,168,1,1);
IPAddress dns(192,168,1,1);
IPAddress sub(255,255,255,0);
WiFiServer s(2000);
int inA1 = 1;
int inA2 = 2;
int enA = 3;
int inB1 = 4;
int inB2 = 5;
int enB = 6;
int trigger = 7;
int echo = 8;
double vSuono = 343; //Unità di misura: m/s
int speed = 255;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
WiFi.config(ip,gat,sub,dns);
WiFi.begin(ssid,pass);
delay(500);
while(WiFi.status() != WL_CONNECTED){
delay(500);
Serial.println(".");
}
Serial.println("Connected!");
delay(30);
s.begin();
Serial.println("Server running!");
delay(30);
//Here starts the problems
pinMode(inA1,OUTPUT);
pinMode(inA2,OUTPUT);
pinMode(enA,OUTPUT);
pinMode(inB1,OUTPUT);
pinMode(inB2,OUTPUT);
pinMode(enB,OUTPUT);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
delay(500);
}
void loop() {
// put your main code here, to run repeatedly:
WiFiClient c = s.available();
delay(30);
if(c){
Serial.println("New client connected!");
delay(3);
while(c.connected()){
if(c.available()){
String command = c.readStringUntil('\n');
if(command == "forward"){
Serial.println("forward");
forward(speed);
}else if(command == "right"){
Serial.println("right");
right(speed);
}else if(command == "left"){
Serial.println("left");
left(speed);
}else{
Serial.println("back");
back(speed);
}
}
delay(30);
}
c.stop();
}
}
void forward(int velocita){
digitalWrite(inA1,HIGH);
digitalWrite(inA2,LOW);
digitalWrite(inB1,HIGH);
digitalWrite(inB2,LOW);
analogWrite(enA,velocita);
analogWrite(enB,velocita);
}
void left(int velocita){
digitalWrite(inA1,HIGH);
digitalWrite(inA2,LOW);
digitalWrite(inB1,LOW);
digitalWrite(inB2,HIGH);
analogWrite(enA,velocita);
analogWrite(enB,velocita);
}
void right(int velocita){
digitalWrite(inA1,LOW);
digitalWrite(inA2,HIGH);
digitalWrite(inB1,HIGH);
digitalWrite(inB2,LOW);
analogWrite(enA,velocita);
analogWrite(enB,velocita);
}
void back(int velocita){
digitalWrite(inA1,LOW);
digitalWrite(inA2,HIGH);
digitalWrite(inB1,LOW);
digitalWrite(inB2,HIGH);
analogWrite(enA,velocita);
analogWrite(enB,velocita);
}
void stop(){
digitalWrite(inA1,LOW);
digitalWrite(inA2,LOW);
digitalWrite(inB1,LOW);
digitalWrite(inB2,LOW);
}
The problem is that when the board execute the pinMode function in the setup() block, the board stop the execution, crash and restart, and I'm not able to ping the board.
If I comment all the portion of the setup() block, with the pinMode calls, the program starts to work but obviously I can't use the pins.
On the serial monitor when the board crash appears this messages:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
What could be the problem?
I don't know the pin mapping by heart, but you should stick to the GPIO pins named D1, D2...D8. You've named them 1, 2...8 which are different pins. You likely used a pin which is used by something else (like serial or reset).
int inA1 = D1;
int inA2 = D2;
int enA = D3;
int inB1 = D4;
int inB2 = D5;
int enB = D6;
int trigger = D7;
int echo = D8;
I was getting the same wdt reset error while trying to use pinMode with digitalWrite() function.
I solved it by figuring out how the Wemos Pin mapping works.
Actually, you need to refer the pin in 'Dx' notation.
e.g
digitalWrite(D15,LOW);
or
pinMode(D15, OUTPUT);
Also, make sure to select "Wemos D1 R1" in Tools > Boards so that Dx constants will match
the labels.
Have a look at the conversation here on Arduino FOrum to understand more about wemos pin mapping:
https://forum.arduino.cc/index.php?topic=545113.0
I'm creating a RFID logger with Arduino. I connected a RFID scanner, RTC module and a SD card reader. All parts are working fine together but when i started combining different sketches a problem occured.
Reading files and writing to files on the SD card is no problem as long as i don't scan a RFID card. When input is received from the RFID scanner it is no longer possible to read or write to the sd card. The connection seems to be "disconnected" as soon as RFID input is received.
I tried using different pins for the RFID scanner, another sequence of initializing in the setup but it doesn't make a difference.
Is this a limitation of the Arduino or am I doing something wrong?
I'm using a ATS125KRW RFID shield and a Catalex MicroSD card adpater in combination with a Arduino Mega.
// SD
#include <SD.h>
File myFile;
char idArray[100][11];
char nameArray[100][11];
// RTC
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
// RFID
#include <SoftwareSerial.h>
SoftwareSerial rfid = SoftwareSerial(A8 , A9); //(RX,TX)
String cardID; //string to store card id
char c;
char cardArray[11];
int incomingByte = 0; // for incoming serial data
String rfidInput;
boolean logtosd;
void setup()
{
Serial.begin(9600);
initializeRFID();
initializeSD();
initializeRTC();
readfromSD();
}
void loop()
{
while(rfid.available()>0)
{
c = rfid.read();
rfidInput += c;
}
if(rfidInput.length() >=12)
{
Serial.print("SCanned: ");
Serial.println(rfidInput);
//writetoSD(rfidInput);
writetoSD("kaart");
rfidInput = "";
}
while(Serial.available()>0)
{
c = Serial.read();
cardID += c;
}
if(cardID.length() >= 2)
{
writetoSD(cardID);
cardID = "";
}
}
void initializeSD()
{
// GND en VCC aansluiting via pin 48 en 49
pinMode(48, OUTPUT); // set pin to output
digitalWrite(48, LOW); // GND pin dus LOW
pinMode(49, OUTPUT); // set pin to output
digitalWrite(49, HIGH); // VCC pin dus HIGH
pinMode(53, OUTPUT);
if (!SD.begin(53))
{
Serial.println("SD initialization failed");
return;
}
Serial.println("SD initialized");
}
void readfromSD()
{
//open the file for reading:
myFile = SD.open("db.txt");
if (myFile)
{
char line[25]; //Array to store entire line
int linenumber = 0;
int arrayPlace = 0;
while (myFile.available())
{
char ch = myFile.read();
if(ch != '\n')
{
line[arrayPlace] = ch;
arrayPlace ++;
}
else
{
char id[11];
char name[11];
//get ID from entire line
for(int x = 0; x <= 10 ; x++)
{
id[x] = line[x];
}
//Get NAME from entire line
for(int x = 11; x <= 19 ; x++)
{
if (line[x] != ';')
{
name[x-11] = line[x];
}
else
{
// NULL TERMINATE THE ARRAY
name[x-11] = '\0';
//STOP
x = 20;
}
}
// save name to nameArray
for(int x = 0; x <= 11 ; x++)
{
nameArray[linenumber][x] = name[x];
}
// NULL TERMINATE THE ARRAY
id[10] = '\0';
// save id to idArray
for(int x = 0; x <= 11 ; x++)
{
idArray[linenumber][x] = id[x];
}
linenumber +=1;
arrayPlace = 0;
} //else
} //while
// close the file:
myFile.close();
}
else
{
// if the file didn't open, print an error:
Serial.println("error opening db.txt");
}
}
void writetoSD(String cardID)
{
//open file for writing
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile)
{
Serial.println("Writing time to test.txt...");
DateTime now = rtc.now();
myFile.print(now.day(), DEC);
myFile.print('/');
myFile.print(now.month(), DEC);
myFile.print('/');
myFile.print(now.year(), DEC);
myFile.print(' ');
myFile.print(now.hour(), DEC);
myFile.print(':');
myFile.print(now.minute(), DEC);
myFile.print(':');
myFile.print(now.second(), DEC);
myFile.print('\t');
Serial.println("Writing string to test.txt...");
myFile.println(cardID);
// close the file:
myFile.flush();
Serial.println("done.");
}
else
{
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void initializeRTC()
{
// GND en VCC aansluiting via pin 18 en 19
pinMode(18, OUTPUT); // set pin to output
digitalWrite(18, LOW); // GND pin dus LOW
pinMode(19, OUTPUT); // set pin to output
digitalWrite(19, HIGH); // VCC pin dus HIGH
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
Serial.print("RTC Initialized: ");
DateTime now = rtc.now();
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}
void initializeRFID()
{
rfid.begin(9600);
Serial.println("RFID initialized");
}
I think you are running out of RAM ,i have done a lot of data logging on SD card with Arduino and its a very resources taking job for the minial 2kb ram on the UNO (assuming u using UNO).
Try using MemoryFree() library before every place you see there might be problem to see if you are running outta memory?