-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I2C Support? #29
Comments
Hi @maxsrobotics , do you have u-blox modules working over I2C? |
Yes, my friend and I were able to get data (HEX codes) directly from the module over I2C. It's just a simple Wire.requestFrom, and then some reads over Wire.h. I'm not at my main computer with the working code right now, but in an hour or so I can post my I2C read script. Thanks so much for helping out! Thanks, |
Hi @maxsrobotics, it would be very interesting to take a look at the code! Can't guarantee I would be able to integrate it, because I don't have such a module, but let's see... What exact module from u-blox do you use? Is it on a board or do you connect directly? I2C is an interesting option, please share links/pics? |
Yea, I am using the MAX-M10S that I picked up from DigiKey, and I have been testing it from the Sparkfun GPS library: https://github.com/sparkfun/SparkFun_u-blox_GNSS_v3 Here's some code that I modified from Dave Akerman's FlexTrack sketch that is able to read and parse UBX packets over I2C from the module: `#define GPS_I2C #ifdef GPS_I2C struct TGPS // Globals char Hex(char Character) return HexTable[Character]; void FixUBXChecksum(unsigned char *Message, int Length) CK_A = 0; for (i=2; i<(Length-2); i++) Message[Length-2] = CK_A; void SendUBX(unsigned char *Message, int Length) #ifdef GPS_I2C for (i=0; i<Length; i++) void DisableNMEAProtocol(unsigned char Protocol) Disable[7] = Protocol; FixUBXChecksum(Disable, sizeof(Disable)); SendUBX(Disable, sizeof(Disable)); // Serial.print("Disable NMEA "); Serial.println(Protocol); void SetFlightMode(byte NewMode) setNav[8] = NewMode; FixUBXChecksum(setNav, sizeof(setNav)); SendUBX(setNav, sizeof(setNav)); #ifdef POWERSAVING uint8_t setGNSS[] = { #ifdef POWERSAVING setPSM[7] = SavePower ? 1 : 0; FixUBXChecksum(setPSM, sizeof(setPSM)); SendUBX(setPSM, sizeof(setPSM)); void ProcessUBX_ACK(unsigned char *Buffer, int Length) void ProcessUBX_NAV_PVT(unsigned char *Buffer, int Length) UBlox = (struct TUBlox*)(Buffer+6); GPS.FixType = UBlox->FixType; if (UBlox->FixType > 0)
} } void ProcessUBX(unsigned char *Buffer, int Length) void ProcessNMEA(unsigned char *Buffer, int Count) void SetupGPS(void) // Init I2C library if we're using it int GPSAvailable(void) #ifdef GPS_I2C Bytes = FD * 256 + FE; if (Bytes > 32) if (Bytes > 0) return Bytes; char ReadGPS(void) void PollGPSTime(void) void PollGPSPosition(void) SendUBX(request, sizeof(request)); void CheckGPS(void) do
} while (Bytes > 0); if (millis() >= PollTime)
} void setup() { void loop() { Again, thanks so much for attempting this project! |
Hey,
This library works well for use with UART applications. I wanted to suggest adding I2C support for those who don't want to work with the latency and efficiency of UART, using the Wire.h library..
Thanks!
W0MXX
The text was updated successfully, but these errors were encountered: