Show Posts
Pages: [1] 2 3
1  Using Arduino / Networking, Protocols, and Devices / Re: How Does TinyGPS calculate Speed? on: September 12, 2013, 02:41:29 pm
Yes, I know how to calculate speed. But my question is why does it use the date? It should only need hours/mins/sec to calculate speed. Not date.

2  Using Arduino / Networking, Protocols, and Devices / How Does TinyGPS calculate Speed? on: September 10, 2013, 05:02:10 pm
I am using a Uno, EM406A GPS, Sparkfun SD shield, and TinyGPS. It is working fine except for two issues with this setup:

1. sometimes I can not get a date, it displays 0/0/2000. I assume it is because I don't have enough good signals from enough satelites. When I can't get a valid date, it displays a speed of 11507795.00 mph!

2. I am using    Serial.print(gps.f_speed_mph());      to display speed in MPH. Problem is zipping along in my car at any speed it displays a speed of
latitude   longitude                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
41.60084   -73.84809   15:32:01   0.43mph   even when I am getting a valid date.

So two questions are:
1. why is TinyGPS using DATE to calculate speed? How does it calculate speed?
2. what could be the reason why I am getting a speed of .43 MPH when I am moving at 40, 50 or 60 MPH using gps.f_speed_mph() when all other data is valid (lat, long, date, time)?


3  Using Arduino / Storage / Re: How to store numbers > 255 in EEPROM? on: August 27, 2013, 04:19:54 pm
Thanks for the quick reply. I looked under LIBRARIES - EEPROM on the Arduino Reference page but it didn't have alot of info. I'll look into that lib you mention.

4  Using Arduino / Storage / How to store numbers > 255 in EEPROM? on: August 27, 2013, 02:07:48 pm
My sketch needs to store int numbers between 0 and 3000. I need to store just one number. Is there a lib function which does this or do I have to break up the number manually and store it in 2 or 3 locations? Thanks.

5  Using Arduino / Programming Questions / Re: Difference between " and ' on: August 13, 2013, 08:18:06 am
Thank you for the quick response. I have another question then...

doesn't      myFile.println(kilowattHourt);    add an \n and \r after it writes kilowattHourt? If so, do I even need to write a seperate \r? I think I would need it for sure if I was using    myFile.print(kilowattHourt);   , right?

6  Using Arduino / Programming Questions / Difference between " and ' on: August 13, 2013, 06:54:54 am
I am trying to find out why my code to write to an SD card is not working. I am not sure if I am not writing to the card right or reading from the card as it seems like the program does successfully write to start with.

The code to write is shown below. One question I have concerns the line    myFile.print('\r');
I have it there because when I do a read I stop when I encounter a \r.  But should I use "\r" or '\r' or doesn't it make a diference?

Also, kilowattHourt is a float. Should I be using  myFile.println(kilowattHourt, 2);  instead?

myFile ="killog.txt", FILE_WRITE); //open file for writing
      delay(1000);; //set to always write to first byte of file
      myFile.println(kilowattHourt);  //kilowattHourT format  xx.yy
      myFile.close(); } //save kilowattHour to file

Code to read first float from file:

//myFile ="killog.txt");  //killog.txt holds kilowatt hour running total
     j = 0;
      do {
      // test for kwh full
      if (j == sizeof(kwh)) {
        Serial.println(F("line too long"));
        break; }
      kwh[j] =; }
      while (kwh[j++] != '\r');
      kilowattHourt = atof(&kwh[0]);  //convert read string to float
      //Serial.print(F("KWH from SD "));

Thanks guys for your help.

7  Using Arduino / Storage / Largest SD Card Accepted by Arduino Ethernet Shield? on: August 12, 2013, 11:00:02 am
I am using an Arduino Ethernet shield with the SD card slot on my Arduino Mega 2560. The sketch is not working reliabily. Could it be the SD card? I am using a 4 gig microSD card. I have not found listed anywhere the max size of an SD card that the shield will accept. Maybe I should use a 2 gig one instead?

8  Using Arduino / Storage / Getting SD Fail errors on: July 24, 2013, 08:39:34 pm
I have an Arduino Mega 2560 and Arduino Ethernet shield with SD card slot and 4 gig SD card. I am getting an SD Fail error most of the time. Sometimes it works but mostly it fails. So it is never exiting SETUP without a fail. The simple test sketch I am using to test is:

#include <SD.h>
#include <SPI.h>

File myFile;     
int j;   //loop counter
char kwh[10];

float testk = 10.00;
float results;

void setup() {
  pinMode(53, OUTPUT);
 //pinMode(10, OUTPUT);

  while (!SD.begin(53)) {       
    Serial.println("SD fail");
    return; }

  if (SD.begin(53)) Serial.println("SD card ready");


void loop() {

  Serial.println("Start of test");

  myFile ="test.txt", FILE_WRITE); //open file for writing
  if (myFile) {   
    Serial.println("Open file test for Write");; //set to write to first byte of file
    myFile.close();  //save kilowattHour to file

    myFile ="test.txt");
    j = 0;
    do {
      // test for kwh full
      if (j == sizeof(kwh)) {
        Serial.println("line too long");
        break; }

      kwh[j] =; }
    while (kwh[j++] != '\r');

    results = atof(&kwh[0]); 
    Serial.print("Read from SD card: ");

  } // end of if myfile code
  else {
    // if the file didn't open, print an error:
    Serial.println("error reading test.txt");

}  // LOOP end

I don't know why it is not working. I tried various CS pins and BEGIN statements but nothing works. This shouldnt be so hard!! Ideas?
9  Using Arduino / Project Guidance / Re: More Questions About Memory Reported by Compiler on: July 18, 2013, 05:50:51 am
As I stated in another thread, I downloaded some code which shows SRAM usage. My sketch started at 404 and went down to 187 after it loop a few times. Below 200 the sketch would start to act up like either hang or be unable to open the SD card. I corrected an error in the program where I was reading from an array and now the SRAM drops to 387 and stays there and the program is stable.

10  Using Arduino / Project Guidance / Re: How much USABLE memory on UNO? on: July 18, 2013, 05:45:47 am
I installed the code from above and found my SRAM starting at 404 and going down to 187 after the program had run for awhile. I noticed once it got below 200 the program would act up sometimes like either hang or unable to open the SD card. I also found a better way to read an array which was causing problems. With that fix the SRAN drops to 386 and stays there and the program is stable.

I found a "real" (Arduino) Mega 2560 for $35 so I ordered one!

11  Using Arduino / Storage / Re: Can't do subsequent reads from SD card on: July 17, 2013, 08:54:19 pm
Excellent. I used that code and it worked fine.

I also tried the code given to me elsewhere here to measure SRAM because I am running out of it. Before I used your code, my available SRAM started at 404 and gradually dropped to below 200. With you code, it goes from 404 and drops to 386 and stays there. Very interesting!



The problem is this while loop.  kwh[j] has not been read when you test it.  Who knows what memory is being written over.
      while (kwh[j] != '\r') {
      kwh[j] =;
      j++;  }

Here is a loop that should work better.  Replace the above loop with this.

    do {
      // test for kwh full
      if (j == sizeof(kwh)) {
        Serial.println("line too long");
      kwh[j] =;
    } while (kwh[j++] != '\r');

12  Using Arduino / Project Guidance / Re: More Questions About Memory Reported by Compiler on: July 17, 2013, 09:21:06 am
Thank you guys for clearing that up.

I searched and found a couple of web pages listing some code to display SRAM usage. Will try those tonight and see how much SRAM I have left. (

13  Using Arduino / Project Guidance / More Questions About Memory Reported by Compiler on: July 17, 2013, 06:55:05 am
Sorry but I have more questions regarding the memory reported being used by the compiler...

In my search to reduce the bytes my sketch code uses, I was deleting lines of code and then compiling to see how much memory the sketch uses.

I was surprised to see that deleting an INCLUDE made almost no difference in memory usage. Deleting an 50 element array also didn't seem to make much difference. Reducing text in Serial.print statements made a big difference but changing a Serial.print("xx") to Serial.print(F("xx")) actually uses more bytes although I thought the "F" function suppose to help with memory.

Lastly, as mention in a previous post, the reported bytes used by the program does not include the bootloader which takes up x bytes of the 32k (for the Uno).

14  Using Arduino / Project Guidance / Re: How much USABLE memory on UNO? on: July 17, 2013, 06:42:16 am
Thanks for the feedback guys. "Strange" like the Uno will run SETUP, LOOP and then SETUP again and other program flow issues. Sometimes the serial monitor starts showing random characters, the program hangs and the like.

I have already 2 Megas but they are already being used in 2 other projects. I hate to buy another Mega because, except of memory, it is way overkill for my current project, the enomcms type energy monitor. But if I can find another Mega for a good price I'll probably pick one up as I am not done with the energy monitor. I sill want to add outside temp measurement and reporting and I am sure that code will push me over the top for sure of the Uno's memory!

15  Using Arduino / Storage / Re: Can't do subsequent reads from SD card on: July 17, 2013, 06:30:00 am
Pete, thanks. The file DOES have a CR/LF at the end and I will change the WHILE and try it again.

But I don't understand why it would effect the file as I am only doing a read, close and reopen. I'll let you know if it works.

Pages: [1] 2 3