Notifications
Clear all

tried to copy/paste the gps logger code over to an esp12-e an 8266 no luck

80 Posts
4 Users
6 Likes
3,754 Views
(@madmike970)
Eminent Member
Joined: 2 years ago
Posts: 32
Topic starter  
/*
  GPS Position Logger
  gps-position-logger.ino
  Read GPS data from BN-220 or any serial GPS sensor
  Requires TinyGPS++ Library
  Save to SD or microSD card

  DroneBot Workshop 2021
  
*/

// Include required libraries
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
//#include <SPI.h>
//#include <SD.h>

// GPS Connections
static const int RXPin = 4, TXPin = 3;

// GPS Baud rate (change if required)
static const uint32_t GPSBaud = 9600;

// SD Card Select pin
//const int chipSelect = 5;

// Write LED
const int recLED = 7;

// String to hold GPS data
String gpstext;

// GPS write delay counter variables
// Change gpsttlcount as required
int gpscount = 0;
int gpsttlcount = 30;

// TinyGPS++ object
TinyGPSPlus gps;

// SoftwareSerial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup()
{
  // Set LED pin as output
  pinMode(recLED, OUTPUT);

  // Start Serial Monitor for debugging
  Serial.begin(115200);

  // Start SoftwareSerial
  ss.begin(GPSBaud);

  // Initialize SD card
 // if (!SD.begin(chipSelect)) {
   // Serial.println("Card failed, or not present");
    //don't do anything more:
   // while (1);
 // }
 // Serial.println("card initialized.");

  // Blink LED so we know we are ready
  digitalWrite(recLED, HIGH);
  delay(500);
  digitalWrite(recLED, LOW);
  delay(500);
  digitalWrite(recLED, HIGH);
  delay(500);
  digitalWrite(recLED, LOW);
  delay(500);
  digitalWrite(recLED, HIGH);
  delay(500);
  digitalWrite(recLED, LOW);

}

void loop()
{

  // Turn off LED
  digitalWrite(recLED, LOW);


  // See if data available
  while (ss.available() > 0)
    if (gps.encode(ss.read()))

      // See if we have a complete GPS data string
      if (displayInfo() != "0")
      {

        // Get GPS string
        gpstext = displayInfo();


        // Check GPS Count
        Serial.println(gpscount);
        if (gpscount == gpsttlcount) {

          // LED On to indicate data to write to SD card
          digitalWrite(recLED, HIGH);

          //Open the file on card for writing
         // File dataFile = SD.open("gpslog.csv", FILE_WRITE);

          //if (dataFile) {

            // If the file is available, write to it and close the file
            //dataFile.println(gpstext);
            //dataFile.close();

            // Serial print GPS string for debugging
            Serial.println(gpstext);
        //  }
          // If the file isn't open print an error message for debugging
          //else {
            //Serial.println("error opening datalog.txt");
          }

        }
        // Increment GPS Count
        gpscount = gpscount + 1;
        if (gpscount > gpsttlcount) {
          gpscount = 0;
        }

      //}


}

// Function to return GPS string
String displayInfo()
{
  // Define empty string to hold output
  String gpsdata = "";

  // Get latitude and longitude
  if (gps.location.isValid())
  {
    gpsdata = String(gps.location.lat(), 6);
    gpsdata += (",");
    gpsdata += String(gps.location.lng(), 6);
    gpsdata += (",");
  }
  else
  {
    return "0";
  }

  // Get Date
  if (gps.date.isValid())
  {
    gpsdata += String(gps.date.year());
    gpsdata += ("-");
    if (gps.date.month() < 10) gpsdata += ("0");
    gpsdata += String(gps.date.month());
    gpsdata += ("-");
    if (gps.date.day() < 10) gpsdata += ("0");
    gpsdata += String(gps.date.day());
  }
  else
  {
    return "0";
  }

  // Space between date and time
  gpsdata += (" ");

  // Get time
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) gpsdata += ("0");
    gpsdata += String(gps.time.hour());
    gpsdata += (":");
    if (gps.time.minute() < 10) gpsdata += ("0");
    gpsdata += String(gps.time.minute());
    gpsdata += (":");
    if (gps.time.second() < 10) gpsdata += ("0");
    gpsdata += String(gps.time.second());
  }
  else
  {
    return "0";
  }

  // Return completed string
  return gpsdata;
}


   
ReplyQuote
(@madmike970)
Eminent Member
Joined: 2 years ago
Posts: 32
Topic starter  

if i plug my gps device into my computer via usb and open serial monitor i get a constant signal dump


   
ReplyQuote
Will
 Will
(@will)
Famed Member
Joined: 2 years ago
Posts: 2288
 
Posted by: @madmike970

ok got one to compile and upload... now no serial monitor output at all, no led blinks, gps device is blinking..

Unplug the USB cord from your computer

Close the serial monitor and shut down the IDE on your computer

Unplug your uController from the computer

now ..

Plug the uController back into the computer

Start the IDE and make sure it sees the right port for the uController

Load your sketch into the IDE

Click the button to recompile your sketch to make sure it's not damaged

Click the button to start the Serial monitor

Compile and upload your sketch to the uController and

 

Test running it again

Experience is what you get when you don't get what you want.


   
Ron reacted
ReplyQuote
(@madmike970)
Eminent Member
Joined: 2 years ago
Posts: 32
Topic starter  

ok took all of the above steps.. now i have a blinking blue led on the board and gps light is also blinking and this from serial monitor:

 

14:58:34.586 ->
14:58:34.586 -> ets Jan 8 2013,rst cause:4, boot mode:(3,7)
14:58:34.586 ->
14:58:34.586 -> wdt reset
14:58:34.586 -> load 0x4010f000, len 3460, room 16
14:58:34.586 -> tail 4
14:58:34.586 -> chksum 0xcc
14:58:34.586 -> load 0x3fff20b8, len 40, room 4
14:58:34.586 -> tail 4
14:58:34.586 -> chksum 0xc9
14:58:34.586 -> csum 0xc9
14:58:34.586 -> v000448c0
14:58:34.620 -> ~ld

 

 


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 You need to declare displayinfo. I suspect you inadvertantly commented it out. Just use Find to locate it and make sure it is not commented out.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 What you call nonsense is how you explain to the device what you want done. You have to follow the rules or it won't play with you. 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 Great. Now start adding debug serial.println's to check what the sketch is doing and when that shows you what is wrong, fix it and done!

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 Is there a question?

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 WHAT? That can't be done as far as I know. Why are you not debugging?

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
(@madmike970)
Eminent Member
Joined: 2 years ago
Posts: 32
Topic starter  

ok... my skill level in this subject is WAY below what you are assuming.... last 2 messages from you to me ron were like charlie browns teacher.... wah wa wuh wuh wah....  what do i need to do to be "debugging"

 


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 Ok, I think I showed you that last night, It's what I get too. I assumed it was because I had no gps to attach. I am just firing up a debug version of the code, something doesn't make sense to me. It takes a few tries for this sketch to upload for some reason, I will post back once it does with results.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 Yes, me too, no idea where that is coming from. I am just now getting the debug version up. gimme a sec. Wow, I never see any of the debug prints. See pic for setup. No idea what is happening.

Screen Shot 2022 04 10 at 15.04.28

 

Screen Shot 2022 04 10 at 15.02.46

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 I don't know what to say. Contrary to popular belief most programmers spend more time debugging than they do programming. Either this sketch is not the sketch that Bill used, or the board I am using is not the right board.The messages being produced are foreign to me, has @will seen this sort of message before, it sounds like technical jargon, I see chksum, tail etc but no idea who is producing it.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Ron
 Ron
(@zander)
Illustrious Member
Joined: 2 years ago
Posts: 4454
 

@madmike970 The setup function is NEVER entered, that is a major problem. So I switched boards to what the random nerds recommend, a DOIT ESP32. It will not even compile, missing SoftwareSerial. I am totally stumped at this point.

Tried another ESP32 board and same error. Something doesn't make sense. Maybe tomorrow when I have some time I will watch Bill's video to see what I can learn.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
(@madmike970)
Eminent Member
Joined: 2 years ago
Posts: 32
Topic starter  

mioght have to use the esp8266 softwareserial library???? i dunno dude. hopefully i will learn something from this... if not i hope i end up with a working collar at least lol


   
ReplyQuote
Page 4 / 6