I have GPS, SONAR and two BLDC motors connected. I have to send data to my PC. I have radio-link. How can I send this data?

Thread Starter

umerrai1

Joined Mar 29, 2021
246
No, whenever it starts it gives some old or whatever this data is. Mixed up data. I am getting data after every 10 seconds for 10 seconds. like 00 sec to 10 seconds I want to receive and from 10 sec to 20 sec I don't want to receive data.
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,766
hi ume,
Looking at the posted results list, you are getting approx two Depth readings per second.????

What other Serial inputs are you reading at about every 8 seconds.

It does not look like a serial buffer clear problem, but a timing clash [ contention] in reading Data from more than one serial port or another input source.

Please post what other serial data ports are being read by the Sketch, also any other inputs to the program??

E

Update:
Post the Sketch that is causing your problem.
 

Attachments

Last edited:

Thread Starter

umerrai1

Joined Mar 29, 2021
246
At this time I am not using any other serial ports but will use them in the future and I will attach GPS on one port. Because of managing battery consumption, I am logging data in intervals.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
Downloaded your document, will check it over, only problem is, I don't use the DS1307, but the DS3231.

See what I can suggest.

E

Update:
Found a couple of DS1307 in my odds n ends box, should be OK, will build the RTC.
 
Last edited:

Thread Starter

umerrai1

Joined Mar 29, 2021
246
thank you so much. and please check one more thing that sometimes my circuit does not log data in the sd card. It needs to restart and then it begins logging data.
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
I have built the Depth simulator, SD card and RTC using DS1307.

Please post your DS1307 date/time set up Sketch for the Mega 2560

E
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
You are going to have to use some method of testing say 3 characters in any string, like we have done on the GPS 'GGA'.
If all your serial Sources messages start with the '$' that would help.

What are the data sources for these Serial Inputs, could you identify which port is doing what,?

For my test I use Serial1

Serial.begin(baud);
Serial1.begin(baud);
Serial2.begin(baud);
Serial3.begin(baud);
 

ericgibbs

Joined Jan 29, 2010
18,766
hi,
OK, I will see what we can do by using the '$' as an IDent sync character.

You also give it a try, then we can compare results.

E
 

ericgibbs

Joined Jan 29, 2010
18,766
hi ume
Working OK.
Make these changes to the Sketch you posted.
Samples of tests, note pressed the Reset button a number of times to test for problems...none seen.
E

OT: If we ever meet I expect one of these: Ülker Çikolatalı Gofret. ;)

C-like:
 // add this to the Header
 
String strID =""; // identifies GPS message type

   attachInterrupt (0, handleInt, FALLING);
  setSQW(0x10);
  delay (2000);
  pinMode(ledPin, OUTPUT);

//Add this to the end of the set up

// flush serial inp buffer
  while(Serial1.available() > 0) {
    char t = Serial1.read();
  }
}


// Modify all the Serial Ports to this method, note where clear
// the string is located

//echo sounder  
    if (stringComplete1){
      strID=(dataString1.substring(0,1));
  // Serial.println(strID);    
       if (strID == "$"){      
      Serial.print(dataString1);
    File dataFile = SD.open("datalog.txt", FILE_WRITE);
      // if the file is available, write to it:
      if (dataFile) {
        dataFile.print(dt);
        dataFile.print(" ");
        dataFile.print(tm);
        dataFile.print(msec);
        dataFile.print(",");
        dataFile.print(dataString1);
        dataFile.close();  
      } else {
        Serial.println("error opening datalog.txt");
      } }    
        // clear the string:
        dataString1 = "";
        stringComplete1 = false;
        strID="";
    }
 

Attachments

Top