Putting your EM-406 GPS back in to NMEA mode without waiting

I've read several times that to get your EM-406 out of binary mode you need to remove power and wait three days or a week, Bah! Send it the (binary mode) command to go back to NMEA! The only catch is, you do have to know what speed it is listening/talking in binary. If you don't know that, you can try all the bit rates. If that doesn't work, then I guess that you will need to unplug for a week. :(The following sketch will set your 406 to NMEA mode, and set which messages to send, at what rate (sorry, no faster than 1x per second), and what bit rate to communicate at. As written it will set you to 9600 baud, sending GGA and GLL messages once per second and GVS message once every 5 seconds.Not a thing of beauty, but it does have a few comments so that 6 months from now I could sort what the heck I did last month. :) It may also serve as a starting point on how to send other binary commands to the 406.Note: I copied it out of other (functioning) code I wrote so it should work. I have not tested this as a sketch of its own but it is quite self contained and I don't believe there are any uninitialized variables or setup required. Let me know how it works for all y'all.Cheers!Ken-------------------------------------------------------------------------------------------------------------------void GPS_Switch_Mode_To_NMEA( void ){int checkSum;const byte magicHead[] ={0xA0, 0xA2, // start sequence0x00, 0x18 // payload length 0x18 = 24};const byte magicPayload[] ={0x81, // Message ID for "switch to NMEA"0x02, // means "do not change NMEA debug message mode"// the next bunch of fields work in pairs, first the time between messages, "period", then whether or// not to send checksum on that message//// "period" is the number of seconds between times that the GPS repeats the message// zero period is "do not send message// then 0x00 for checksum off or 0x01 for checksum on//0x01, // GGA period0x01, // checksum = on0x01, // GLL period0x01, // checksum = on0x00, // GSA period0x01, // checksum = on0x05, // GSV period0x01, // checksum = on0x00, // RMC period0x01, // checksum = on0x00, // VTG period0x01, // checksum = on0x00, // MSS period0x01, // checksum = on0x00, // unused (future message)0x01, // unused (checksum = on)0x00, // ZDA period0x01, // checksum = on0x00, // unused (future message)0x01, // unused (checksum = on)// baud rate in 2 bytes (9600 = 0x2580; 19200 = 0x4B00; etc. )0x25, // baud rate high byte0x80 // baud rate low byte};const byte magicTail[] ={0xB0, 0xB3 // end sequence};// send 4 byte headerfor( int index = 0; index < 4; index++ ){Serial.print( byte(magicHead[index] ) );}// send message body, calculating checksum as we gocheckSum = 0;for( int index = 0; index < 24; index++ ){checkSum = checkSum + magicPayload[index];Serial.print( byte( magicPayload[index] ) );}checkSum = checkSum & ( 0x7FFF );// send the 2 byte checksumSerial.print( byte(checkSum >> 8) );Serial.print( byte(checkSum & 0xff) );// send the 2 byte tailfor( int index = 0; index < 2; index++ ){Serial.print( byte( magicTail[index] ) );}}void setup(){Serial.begin( 57600 ); // set this to the baud rate that (you hope) your "stuck in binary" GPS is set for// if your GPS is really wonked, you may need to repeat this trying different baud ratesGPS_Switch_Mode_To_NMEA();}void loop(){}
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • This seemed to Do The Thing for me. Wrote a blog post about it with modified code. Many many thanks for posting this!

    http://indigoid.blogspot.com.au/2014/01/rescuing-unhappy-em406a-gps...

  • Sirfdemo requires MS Windows and a cable to connect the PC to the GPS.
  • The (free) Sirfdemo program can also put the EM406 back into "factory fresh" mode - 4800, NMEA. I used this to get my arduIMU running with the EM406 after I had used it [the GPS] a few times in other projects. And yes, I too found that the IMU code for EM406 only works when you reset it or use one "fresh from the store"
  • Tried this out... seems that mine is indeed wonked.

    Keeping the GPS on storage for a week...
  • Great ! $ £ $
    You need to test the sketch soon and update.
  • 3D Robotics
    Nice one! A much needed addition...
This reply was deleted.