I2C: GPS as master, MEGA as slave

Very limitied experience and background regarding I2C...

I have older GPS module (from 2013) can support both: Serial (Rx/Tx, 4800 up to 115200 baud) and I2C. It is based on SiRF Star IV, supports NMEA-0183 and as well OSP protocol.

However, its only configuration in I2C is to behaves as a master. What impact can be expected if MEGA act as a slave, since it have to do many additional work (as to calculate distance to desire point, visualize some data on display, write data to SD card, using second hardware UART to send data, etc)?

Currently data are read from GPS Tx using default 4800 baud (first HW UART on Mega), sending constantly data each 1s (it is configurable, can be on 5s or more), through an interrupt, writing incoming data to global circular buffer. It works without any problems some 6 hours, which is current battery life (only module use 48mA, which is quite high in nowadays standards).

Is there any benefit to switch to I2C, or it is advisable to keep as is?

I would like also to try OSP protocol (never did actually), which can be send data through UART, however with quite more data than NMEA and that is the main reason I'm considering to use I2C.

I would like to see some comments from people have experience using I2C and as well OSP with GPS modules as this I have.

noob314:
Is there any benefit to switch to I2C, or it is advisable to keep as is?

This question cannot be answered generally. The microcontroller world is always struggling with bill of material and therefore compromises.

The I2C bus was designed as a simple and cheap to manufacture bus for peripherals. That’s why it is successful. You can have multiple slaves on a two-wire bus, but its low speed and can only communicate half duplex.

On the other hand, SPI needs at least 3 signals plus chip select for each slave, but its faster and full duplex. And UART are full duplex but asynchronous and slow.

Still sometimes saving a few I/O pins can save you a few cents on the microcontroller and that is important to some applications.

The same could be true for your application. If you need the UART for something else, you can investigate using I2C instead. There are not clear benefits if your application is working as is and you do not need that UART.

If you are here for the experience and have the time, try to get it running with I2C. You will learn something. Don't forget those pull-ups, they have cost many engineers hours. :slight_smile:

Klaus_K:
If you are here for the experience and have the time, try to get it running with I2C. You will learn something. Don't forget those pull-ups, they have cost many engineers hours. :slight_smile:

Switching to I2C is not quite simple with 1.8V GPS module, especially on already working setup and PCB made for UART. Then rather a question and other experience, since making I2C slave of MEGA (which already is quite busy) sound not quite good idea...

As mentioned, my experience with I2C is limited and mostly based with EEPROMs (24CXXXX series) as slave, however not vice verse with a GPS module require to be master...

Anyway, thank you for your post.