Show Posts
Pages: [1] 2
1  Using Arduino / Storage / Re: SD card fails to open file to write after a day of use on: February 27, 2013, 08:09:17 pm
Hi all,

I am sorry for the late reply.  I have been troubleshooting the SD shield lately and it has continued to work for a week.  I am no programming or Arduino expert.  But here is what i have done in the code to solve it.  I hope it helps even if it may not make sense. smiley-grin

Code:
myFile=SD.open("test.txt");
if(myFile){
Serial.println("test.txt:");
if(myFile.available()){
Serial.write(myFile.read());
}
myFile.close();
}
else {Serial.println("error opening test.txt");}
The code does nothing new but after each write, it reads the SD card.  In doing so, the SD card seems to be able to communicate with Arduino without problems.  Thank you for everyone's inputs!
2  Using Arduino / Storage / Re: SD card fails to open file to write after a day of use on: February 03, 2013, 08:04:00 pm
Hello! The code is too long to be quoted in the message box.  Marco_C, i have attached the code.txt in the first post.  Would you mind to check that out?  Thank you very much for your help! smiley-grin
3  Using Arduino / Storage / Re: SD card fails to open file to write after a day of use on: January 31, 2013, 07:54:45 pm
Thank you for your help and replies, Marco_C!  I have used Sdfat.lib while the card can now be used.  However, this time when i run the program for like 24 hours with a 5 second time interval between logging, the card has stopped after 14 hours of operations, recording about 28281 data.  Is this happening still related to memory leak? Or my program is too long and there isn't any memory left for the data logging stuff? Thank you guys in advice!
4  Using Arduino / Storage / Re: SD card fails to open file to write after a day of use on: January 27, 2013, 08:24:27 pm
Thank you for the advice!  But i have another issue when using the SdFat library.  I tested the library with the ReadWriteSdFat example.  In the Serial Com, it showed "Writing to test.txt...done.", "error: opening test.txt for read failed", "SD errorCode: 0x13,0x0".  When i used another SD card, same error pops up with a different error code as 0x6,0x1.  Does anyone know what is the meaning about this?  
5  Using Arduino / Storage / SD card fails to open file to write after a day of use on: January 24, 2013, 09:17:37 pm
Dear all,

I am sorry that this topic may be discussed a million times already, but i cant still make mine working. so please bear with me.
i have attached my code in the attachment. A pretty long one. Basically i want to "real time logging temperature and voltage in a room" for a week.  I am currently using kingston SD card (4GB, FAT32). I have done an overnight run with the arduino and the data logger.  The program actually still works but the logger has stopped working after 2 hours.  Having done some searching on Google reveals the problem may due to memory leakage.  Is there any way that i could done to solve this?  Please kindly advise.  Thank you very much guys!
6  Using Arduino / Programming Questions / Sm5100b SMS send and receive.. on: December 04, 2012, 08:08:56 am
Hi all,

First of all, i would like to apologize for frequently posting questions.  But it is place where i last resort to...  So here it is..
In the main program, i have defined a polling loop around 17seconds in real time for detecting incoming SMS.  and 75/1000 seconds for sensing
temperature and voltage.  Finally, the status is reported back to my cell phone at a regular time interval.
But the program seems to have problems associating with the status reporting (SMS sending by the Arduino).  The performance is rather unstable, sometimes i got nothing
, sometimes i got them.  Is there anything wrong in the codes?  I'll be seriously in your debt if anyone can shed some light on this issue..  Your help is highly appreciated.

Regards,

Code:


#include <string.h>

#include <SoftwareSerial.h>
char a[5]={};
char incoming_char=0;
float t1;
float t2;
float t3;
float t4;
float t5;
float t6;
int j=1;
SoftwareSerial cell(2,3);
char mobilenumber[]="**********";
char textmessage[160];
char inchar;
int led1 = 9;
int led2 = 10;
int led3 = 11;
int led4 = 12;


void setup() {
  Serial.begin(9600);
  cell.begin(9600);
  delay(30000);
  cell.println("AT+CMGF=1");
  delay(200);
  cell.println("AT+CNMI=3,3,0,0");
  delay(200);
  
  pinMode(led1,OUTPUT);  //relay decoy//
  pinMode(led2,OUTPUT);  //relay decoy//
  pinMode(led3,OUTPUT);  //relay decoy//
  pinMode(led4,OUTPUT);  //relay decoy//
  
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  
  pinMode(13,OUTPUT); //SMS status lamp
  pinMode(12,OUTPUT);
  /*setTime(11,40,00,19,11,12);//hour,minutes,seconds, date,month,year*/
}

void startSMS() {

                  digitalWrite(13,HIGH);
                  cell.println("AT+CMGF=1");
                  cell.print("AT+CMGS=");
                  cell.write(34);
                  cell.print(mobilenumber);
                  cell.write(34);
                  cell.println();
                  delay (500);
                }
void endSMS()   {
                  cell.write(26);
                  cell.println();
                  delay(30000);
                  digitalWrite(13, LOW);
                }

void GSMTest()
{
if(cell.available() >0)
  {
  incoming_char=cell.read();
  Serial.print(incoming_char);
  }
if(Serial.available() >0)
  {
  incoming_char=Serial.read();
  cell.print(incoming_char);
  }
}

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;
}

void TMP00 ()
{
  float r;
  float temperature;
  r=readVcc()/1000.0;
  temperature = analogRead(0);
  temperature = (((r*temperature)/1024)-0.5)/0.01;
Serial.print("Measured voltage: ");
  Serial.println( r, 2 );
  Serial.print("Sensor_0 temperature:");
  Serial.println(temperature,2);
}

void TMP01 ()
{
  float r;
  float temperature;
  r=readVcc()/1000.0;
  temperature = analogRead(1);
  temperature = (((r*temperature)/1024)-0.5)/0.01;
Serial.print("Measured voltage: ");
  Serial.println( r, 2 );
  Serial.print("Sensor_1 temperature:");
  Serial.println(temperature,2);

}

void Sense()
{
  float r;
  float temperature;
  float r1;
  float measuredV;
  float correctfactor = 0.023;
  float correctedV;
  
  r=readVcc()/1000.0;
  measuredV = analogRead(3);
  measuredV = measuredV*r/1024.0;
  correctedV = measuredV - measuredV*correctfactor;
  Serial.print("Corrected voltage at voltage divider:");
  Serial.println(correctedV);
  
  r=readVcc()/1000.0;
  temperature = analogRead(0);
  temperature = (((r*temperature)/1024))/0.01;
  Serial.print("Sensor_2 temperature:");
  Serial.println(temperature,2);
}

void loop() {  
  
  startSMS();
  cell.print("Hello!");
  endSMS();
  
  delay(100);
  for(;;)  {
  t1=millis();
  Serial.println("Sensing Loop!");
  digitalWrite(9,HIGH);
  for(int i = 1;i<=3000;i++)  // each for loop is about 17.5 seconds
  {  
    if(cell.available()>0)
      {
      inchar = cell.read();
        if(inchar == 'c')
        {
          inchar = cell.read();
          if(inchar=='a')
          {
          delay(10);
          inchar = cell.read();
            if(inchar =='m')
            {
            delay(10);
            inchar = cell.read();
             if(inchar=='1')
             {
             digitalWrite(10,HIGH);
             delay(500);
             digitalWrite(10,LOW);
             cell.println("AT+CMGD=1,4");
             }
            }
          }
        }      
     } Serial.println(i);
  }
  //polling loop ends
  t2=millis();
  t3=t2-t1;
  Serial.print("Polling time: ");
  Serial.println(t3,2);
  
      t4=millis();
      digitalWrite(9,LOW);
      Sense();
      t5=millis();
      t6=t5-t4;
      Serial.print("Sensing Time: ");
      Serial.println(t6,2);
      //decision making loop
      j++;
      Serial.print("j");
      Serial.println(j);
      if(j==206) //status report loop, j=206 is equivalent to an hour approximately
      {
      j=1;
        startSMS();
        cell.print("Hello!");
        endSMS();
      }
  }
  
  
}//end void loop () {}
7  Using Arduino / Programming Questions / Re: SM5100b SMS receiving on: December 02, 2012, 09:16:01 am
Re: PaulS,

Thank you very much for your help!! Now i am having a clearer picture, and after some modifications, it seems to work!!  I really appreciated your help. smiley-grin

Regards,
8  Using Arduino / Programming Questions / Re: SM5100b SMS receiving on: December 02, 2012, 07:36:24 am
Sorry for the inconvenience caused.  Here is the codes in full: smiley

Code:


#include <string.h>
#include <SoftwareSerial.h>
char incoming_char=0;
char a[20];
SoftwareSerial cell(2,3);
char mobilenumber[]="**********";
char textmessage[160];
char inchar;
int led1 = 9;
int led2 = 10;
int led3 = 11;
int led4 = 12;
void setup() {
  Serial.begin(9600);
  cell.begin(9600);
  delay(30000);
  cell.println("AT+CMGF=1");
  delay(200);
  cell.println("AT+CNMI=3,3,0,0");
  delay(200);
  
  pinMode(led1,OUTPUT);  //relay decoy//
  pinMode(led2,OUTPUT);  //relay decoy//
  pinMode(led3,OUTPUT);  //relay decoy//
  pinMode(led4,OUTPUT);  //relay decoy//
  
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  
  pinMode(13,OUTPUT); //SMS status lamp
  pinMode(12,OUTPUT);
}


void SMSreceive() {
                    /*Receive setup*/

                    /*Loop Logic*/
                    
                    
                      
                        inchar=cell.read();
                        if (inchar=='#') // OK - the start of our command
                        {
                          delay(10);
                          inchar=cell.read();
                            if (inchar=='a')
                              {
                                delay(10);
                                inchar=cell.read();
                                  if (inchar=='0')
                                    {
                                      digitalWrite(led1, LOW);
                                    }

                                  else if (inchar=='1')
                                    {
                                      digitalWrite(led1, HIGH);
                                    }
                                      delay(10);
                                      inchar=cell.read();
                                        if (inchar=='b')
                                          {
                                            inchar=cell.read();
                                              if (inchar=='0')
                                                {
                                                  digitalWrite(led2, LOW);
                                                 }
                                              else if (inchar=='1')
                                                 {
                                                   digitalWrite(led2, HIGH);
                                                  }
                                                    delay(10);
                                                     inchar=cell.read();
                                                       if (inchar=='c')
                                                         {
                                                           inchar=cell.read();
                                                              if (inchar=='0')
                                                                 {
                                                                  digitalWrite(led3, LOW);
                                                                  }
                                                               else if (inchar=='1')
                                                                  {
                                                                   digitalWrite(led3, HIGH);
                                                                   }
                                                                    delay(10);
                                                                    inchar=cell.read();
                                                                      if (inchar=='d')
                                                                        {
                                                                         delay(10);
                                                                         inchar=cell.read();
                                                                            if (inchar=='0')
                                                                              {
                                                                               digitalWrite(led4, LOW);
                                                                               }
                                                                            else if (inchar=='1')
                                                                               {
                                                                                digitalWrite(led4, HIGH);
                                                                                }
                                                                                 delay(10);
                                                                          }

                                                              } // close c
                                                                  cell.println("AT+CMGD=1,4"); // delete all SMS

                                                           }//close b
                                                     }//close a
                                                  }//close #
                                                }//close available
                                              // close function


void startSMS() {

                  digitalWrite(13,HIGH);
                  cell.println("AT+CMGF=1");
                  cell.print("AT+CMGS=");
                  cell.write(34);
                  cell.print(mobilenumber);
                  cell.write(34);
                  cell.println();
                  delay (500);
                }
void endSMS()   {
                  cell.write(26);
                  cell.println();
                  delay(15000);
                  digitalWrite(13, LOW);
                }

void GSMTest()
{
if(cell.available() >0)
  {
  incoming_char=cell.read();
  Serial.print(incoming_char);
  }
if(Serial.available() >0)
  {
  incoming_char=Serial.read();
  cell.print(incoming_char);
  }
}


void dateFunction ()
{
time_t t = now();
Serial.print("System Date:  ");
Serial.print(day(t));
Serial.print(" : ");
Serial.print(month(t));
Serial.print(" : ");
Serial.println(year(t));
}
void timeFunction ()
{
time_t t = now();
Serial.print("System Time:  ");
Serial.print(hour(t));
Serial.print(" : ");
Serial.print(minute(t));
Serial.print(" : ");
Serial.println(second(t));
}

long readVcc() {
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;
}


float LM3500()
{
  float r;
  float temperature;
  r=readVcc()/1000.0;
  temperature = analogRead(0);
  temperature = (((r*temperature)/1024))/0.01;
  Serial.print("Measured voltage: ");
  Serial.println( r, 2 );
  Serial.print("Sensor_2 temperature:");
  Serial.println(temperature,2);
  return temperature;
}

void voltmeter03()
{
  float r;
  float measuredV;
  float correctfactor = 0.023;
  float correctedV;
  
  r=readVcc()/1000.0;
  measuredV = analogRead(3);
  measuredV = measuredV*r/1024.0;
  correctedV = measuredV - measuredV*correctfactor;
  Serial.print("Vcc Supply voltage");
  Serial.println( r, 2 );
  Serial.print("Measured voltage at voltage divider:");
  Serial.println(measuredV,2);
  Serial.print("Corrected voltage at voltage divider:");
  Serial.println(correctedV);
}

void loop() {
  
  /*dateFunction();
  timeFunction();*/
  
  /****************************Initialization for GSM Shield**********/
  /*Serial.println("Starting SM5100B Communication...");
  for(int i =1;i<=4800;i++) //cannot be used with the SMS receive function
  {
  GSMTest();
  delay(25);
  }*/
  /****************************End of Initalization*******************/
  
  
  //Transitional State//
  Serial.println("GSM Shield Initalization Completed!");
  Serial.println("Now proceed to the measuring stage...");
  
  
  
 /******************************Sending SMS***************************/
   startSMS();
  cell.print("Arduino Initalization completed!");
  endSMS();
 /******************************End of SMS****************************/
  
  delay(100);
  
  for(;;)  
  {  
    while(cell.available() >0)
   {
    inchar=cell.read();      
    a[0]=inchar;
    delay(10);
    inchar=cell.read();  
    a[1]=inchar;
    delay(10);
    inchar=cell.read();    
    a[2]=inchar;  
   }
   LM3500();
  
    if(a[0] == '#')    
    digitalWrite(13,HIGH);
  }
  
  
  
}
9  Using Arduino / Programming Questions / SM5100b SMS receiving on: December 02, 2012, 05:11:48 am
hi all,

Here is what i want to do: sense the temperature, check if any SMS has arrived, turn on the leds as instructed by the SMS, repeat the loop.
Code:
void loop () {

while (cell.available() >0)
{
char a[10];
inchar = cell.read();
a[0] = inchar;
if ( a[0]== '#')
digitalWrite(11,HIGH);
}
temperature = analogRead(0);
temperature = (temperature/1024)*5*1000;
Serial.print(temperature);
}

in the code, i would like to make it works like a interrupt, when there is a SMS being sent to the shield, the Arduino can respond as instructed.  But from what i have observed, the led fails to turn on.  Is there anything i have done wrong?  It should be..smiley-eek  Can anyone give me some advice?? Thanks!

Regards
10  Using Arduino / Project Guidance / Web interface for equipment status? on: November 28, 2012, 09:51:59 pm
Hi all,

I have been working on a remote temperature and voltage monitoring device, featuring Arduino, GSM Cellular Shield (SM5100b).  I have no problems in the monitoring side.  However, instead of sending SMS (status reporting) to my mobile i want the GSM Cellular Shield to send it to another Cellular Shield which is located somewhere in the office, and at the same time it updates the status to the internet by Arduino Ethernet shield.  My question is : is it feasible to do so in the receiver side? smiley-small  As always any help, tips will be welcomed. Thank you in advance!! smiley

Regards,
11  Using Arduino / Project Guidance / Re: Power Supply on: November 28, 2012, 08:58:44 pm
Thank you for the tips and answers guys! i really appreciated all of your helps!  I will see what i can do and test on it! smiley-mr-green
12  Using Arduino / Project Guidance / Re: Power Supply on: November 27, 2012, 08:15:45 pm
Hi again!

Thank you for answering my question in the first place smiley-grin.  I have selected the voltage ( 5v ), please refer to the attachment.
There is still no power being supplied to the bread board... and the AMS1117 chips is smoking smiley-eek-blue  Is the chips being defective or its me..? the power being supplied to the Bread Board power module is from a 220VAC to 9VDC transformer.  Any help will be appreciated!  Thanks in advance! smiley-lol

Regards,
13  Using Arduino / Project Guidance / Power Supply on: November 27, 2012, 02:11:13 am
Hi all,

I am planning to use the MB102 Breadboard power supply module for my project, kinda stupid though, what i am in doubt is...
Is it a plug to use module?  cause when i attempt to do so, there is no voltage at the output.  is jumper wiring required to make this thing
work?

Another question is about the SM5100b GSM cellular Shield.  In order to prevent short burst, an external power supply is given to the shield at the 5v pin on the shield.  reference to http://tronixstuff.wordpress.com/2011/01/19/tutorial-arduino-and-gsm-cellular-part-one/
, however, whenever i apply the external power to the shield, i have the error code as: AVRdude not in Sync().  In the fear of burning
the Shield and  the arudino altogether.  Is there another way of connecting the external 5v 2A to the shield?

Regards,
14  Using Arduino / Project Guidance / Re: Temperature Sensor behaves strangely on: November 26, 2012, 09:11:01 pm
Problem solved! Thank you very much for your help! smiley
15  Using Arduino / Project Guidance / Re: Temperature Sensor behaves strangely on: November 26, 2012, 03:54:22 am
I believe no sir!  Which ground on the arduino shall i connect smiley-yell

It may be the cause of it!  Thank you  for replying! smiley-mr-green
Pages: [1] 2