Library for SC16IS750 I2C to Serial module

I’d like to use a SC16IS750 module to take serial data from a GPS module and put it on the I2C bus. I’ve used these modules together before with ESP8266’s and ESP32’s with much success. There is a library for it (SC16IS750.h and SC16IS750.cpp for Arduino’s/ESP’s.

Does anyone know if this library is already supported/converted?

I’m already using UART1 on the Electron for a Bluetooth module (working fine), and I’ve tried using UART4 for talking to the serial GPS module directly. But there seems to be some data loss on UART4 (also tried UART5 just for laughs). Data speeds on both ports are low (9600 Baud), and there isn’t much processing going on that would cause data loss. But there is data loss from the GPS module. Thus the desire to insert the SC16IS750 module for buffering purposes and receive the data over I2C.

Thanks.

The extra serial ports are more than fast enough to read 9600 baud, with one caveat:

In the default automatic with system thread disabled, the Electron loop only runs 100 times per second.

If you only read 1 byte on every loop, you can only read 100 bytes per second, and the serial FIFO is only 64 bytes long. You will easy lose data at any rate.

Make sure you process all available characters for serial on every pass through loop.

Using SYSTEM_THREAD(ENABLED) will also help, as the loop will run much more frequently.

That's exactly what I thought. But I'm losing characters.

I already have SYSTEM_THREAD(ENABLED) in the code because I don't want to be blocked on Publish's. And for testing purposes, I took the TinyGPS code by itself, and added a Serial.print:

    while (Serial5.available()){
        char c = Serial5.read();
        Serial.print(c);
        
        // parse GPS data
        if (gps.encode(c))
            isValidGPS = true;
    }

I can see that characters get lost. So I want to try using the SC16IS750 module to buffer things and see if that helps.

Do you have anything else that’s blocking in the rest of your loop?

I’m not convinced that the SC16IS740 will help at at all. It also has a 64-byte FIFO. The hardware USART on the STM32 doesn’t really lose data, but if you don’t empty the FIFO fast enough, data will be lost when full. Since the FIFO on the SC16IS740 is the same size, I suspect you’ll run into the same problem.

1 Like

Hmmmm. That's not reassuring. When I saw the GPS problem, I dropped back to some example code that only deals with the GPS, so there's nothing else there to even try to block or delay. And the original example code had a delay between good GPS readings (maybe 15 seconds if I remember correctly) and I eliminated that entirely. So the code only reads from the serial port and gives characters to the GPS decoder (and now echos each character to the USB serial port so I can see them).

I've been assuming it was a serial problem because the response strings that I get from the GPS module (I've tried 3 different ones just in case) have random lost characters. Not a lot, but enough that the decoder isn't happy.

These things are rock-solid in an ESP8266 and/or ESP32 environment. They're actually pretty amazing - approx 1" by 1" by 1/2". Power, ground and serial out. Acquire quickly, hardly ever lose tracking even buried in a vehicle. But I digress.