Mbed LCD I2C output

Hello, I have an STM32 F103RB board and I have a program that measures temperature values and outputs it in Celsius onto Putty but I was wondering how I would take that data and output it onto a 16x2 I2C LCD display using the MBed comiler. Any help would be appreciated and thank you in advance.

#include "mbed.h"                  
AnalogIn analog_value(PA_0);        
Serial pc(SERIAL_TX, SERIAL_RX);    
int main() {
    float meas;
    float temp;
    while(1) {
	meas = analog_value.read();
        temp = ((meas * 5000)/10);
        pc.printf("temprature = %.0f ^C\r\n", temp);
        wait(1); // 1000 ms Delay


It is necessary to know which a display you have and which expander you have on it.

Note: The Arm Mbed API uses 8 bit addresses, so make sure to left-shift 7 bit addresses by 1 bit before passing them


#include "mbed.h"
#include "TextLCD.h"

DigitalOut led(LED1);
I2C i2cBus(I2C_SDA, I2C_SCL);
TextLCD_I2C lcd(&i2cBus, PCF8574A_SA7, TextLCD::LCD16x2); // PCF8574A_SA7 is gpio expander i2c address from a macro what is defined in TextLCD_Config.h

int main(){
    printf("LCD Hello\n");
    lcd.printf("LCD Hello\n");

    while(1) {
        led = !led;

For temperature you can use same printf like you used in your example.

BR, Jan