Teseo-LIV3F as I2C Positioning Sensor

Document created by Francesco Virlinzi Employee on Jun 4, 2018
Version 1Show Document
  • View in full screen mode

Teseo-LIV3F supports two interfaces: UART and I2C and on both it provides the NMEA messages.

In some applications, main-host could not care on NMEA stream at all and position awareness is required only when specific events happens.

This is the so called I2C Positioning Sensor where Host reads the real-time position data, like any other sensor over I2C (i.e.: an accelerometer).




Configure the Teseo-LIV3F firmware

The Teseo-LIV3F's firmware needs to be modified to support I2C Positioning Sensor.


The I2C port has its own NMEA message-list bitmap (CDB-ID 231 and CDB-ID 232), this 64bits bitmap specifies which messages are continuously sent on the internal I2C buffer and ready to be sent when an I2C read operation is triggered by the host microprocessor.

  1. Set the I2C-message-list to zero (CDB-ID 231 and CDB-ID 232) to avoid the GNSS continuously fills the I2C internal buffer with satellite and positioning data.
  2. Reset the CDB-227.[0:0] to disable the echo-ing replay command s

Take care that a resetted I2C-message-list affects only the autonomous NMEA messages while the answer-message sent in replay of a commands are still generated.

The following scripts can be executes to summarize the operations above.









The I2C Positioning Sensor on Teseo-LIV3F bases on the command: $PSTMNMEAREQUEST.





This means that the main-host can force the Teseo-LIV3F to replay with defined NMEA message based on the 64bits bitmap input the host provides.


Prepare the demo platform

The demo application is built using:

When an events happens (the blue-button on the NUCLEO-F401RE is pressed) the STM32 will request the message $GPGLL to the Teseo-LIV3F



The following hardware is required in this demo:

  • A X-NUCLEO-GNSS1A1 as Teseo-LIV3F solution
  • A NUCLEO-F401RE as host processor
  • USB-Cable to connect the NUCLEO-F401RE to the PC
  • FTDI-UART2USB cable


The following software has to be downloaded from www.st.com  and installed:

  • the STM32CUBE-MX
  • the Atollic-TRUE Studio

Also a Terminal-Emulator on PC is required to print-out information coming from STM32.


Configure the firmware on the X-NUCLEO-GNSS1A1

The Teseo-LIV3F configuration on top of X-NUCLEO-GNSS1A1 can be modified using the TESEO SUITE PC Tool.

Using an FTDI-UART2USB cable, connect the X-NUCLEO-GNSS1A1 to the PC as shown



On the PC:

  • open the TESEO-SUITE PC Tool and
  • enable an UART/COM connection against the X-NUCLEO-GNSS1A1.


Using the NMEA Decoding Panel (shown below) on the TESEO-SUITE send the following commands:









This set of commands will:

  • Reset the i2c message list
  • Disable the echo-ing message
  • Save the configuration on flash

Now the Teseo-LIV3F is configured to support I2C Positioning Sensor.


Prepare the demo platform

The connect the X-NUCLEO-GNSS1A1 on top of NUCLEO-F401RE as shown:




Connect the NUCLEO-F401RE to the PC using the USB-Cable.


Configure a STM32Cube-MX project

Create a new project for STM32 on NUCLEO-F401RE

Enable the I2C-1 bus, this will be the I2C communication channel between STM32 and Teseo-LIV3F as shown below




Route the I2C bus on right pins PB8 and PB9 as shown:



Configure the Blue-Button as GPIO-In as shown



In the configuration TAB press the NVIC button to configure the NVIC as shown:




Enable the Blue-Button (EXTI-interrupts) and confirm the configuration pressing the OK button as shown




Enable the USART-2 to enable communication between STM32 and the Terminal-Console running on PC as shown|:




Configure the USART-2 as show:



The configuration is completed.

The initialization C-Code can be generated as shown


The project can now be opened with the IDE: Atollic TRUE-STUDIO


Finalize the C-Code in the project

STM32Cube-MX during the Code Generation prepared all the skeleton C-Code to configure and initialized:

  • the I2C bus;
  • the UART port against the PC
  • the Blue-button interrupt


In this project very few C-Code needs to be added.


Utility function

Just added an utility function to print-out information in a Terminal on PC


void Console_Write(uint8_t *string){

  HAL_UART_Transmit(&huart2, string, strlen((char *)string), 1000);



Blue Button call-back

Added the callback called on a Blue-Button pressed event:


static volatile _read = 0;

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)


      _read = 1;



Prepare ad-hoc commands for the required message

In this demo, the host will request only the $GPGLL message. This message is identified in the message-list with the number 0x100000 (inline with the CDB-ID 231-232 description where the message $GPGLL is identified as bit 20 in the message-list-low).

The related NMEA command is defined as:


static const char *gpgll_msg = "$PSTMNMEAREQUEST,100000,0\n\r";


Main C-code

The final C-code in the main function could be like:


1             while (1) {

2             HAL_I2C_DeInit(&hi2c1);

3             HAL_I2C_Init(&hi2c1);

4             if (_read == 1) {

5                    _read = 0;

6                    Console_Write("Sending commands...");

7                    HAL_I2C_Master_Transmit(&hi2c1, 0x3A << 1, (uint8_t *)gpgll_msg, strlen(gpgll_msg), 2000);

8                    Console_Write(" got:... \r\n");

9                    for (read_buf[180-1] = 0; read_buf[180-1] != 0xff;) {

10                         HAL_I2C_Master_Receive(&hi2c1, 0x3A << 1, read_buf, 180, 2000);

11                         for (i = 0; i < 180; ++i)

12                                if (read_buf[i] != 0xff)

13                                       HAL_UART_Transmit(&huart2, &read_buf[i], 1, 1000);

14                  }

15                  Console_Write("\r\n");

16                 }

17             }




Where in detail:

  • line (4)  waits the Blue-button event happens.
  • line (7)  send to the Teseo-LIV3F on I2C-bus the $PSTMNMEAREQUEST command to request a $GPGLL message
  • line (10) read the data sent by Teseo-LIV3F on I2C-bus
  • lines (11-13) resend the received data (coming from I2C) on the PC-Terminal console


Results can be inspect on a Terminal console on PC as shown






Our demo platform based on Teseo-LIV3F configured as I2C Positioning Sensor works fine.

Host has only to raise well defined/formatted $PSTMNEAREQUEST command to query other information to the Teseo-LIV3F.

This solution can simplify the customer design because the main-macro, with a simple command, can required the data needed.