4 years, 9 months ago.

LM75B code problem

Hello, thanks for watching my question! when i compile the code about LM75


Error: No suitable conversion function from "LM75B" to "float" exists in "main.cpp", Line: 67, Col: 41

i have no idea to solve orz~ what's wrong QAQ Thanks :)

2 Answers

4 years, 9 months ago.


You may need to use temp() function to get temperature data from the sensor.

#include "mbed.h"
#include "LM75B.h"

//Create an LM75B object at the default address (ADDRESS_0)
LM75B sensor(p19, p20);

int main()
    //Try to open the LM75B
    if (sensor.open()) {
        printf("Device detected!\n");

        while (1) {
            //Print the current temperature
            printf("Temp = %.3f\n", (float)sensor.temp());

            //Sleep for 0.5 seconds
    } else {
        error("Device not detected!\n");

Accepted Answer

Thanks, but i try the code. The display always prints Device not detected. How could i solve it?

posted by jajn HA 31 Oct 2016
4 years, 9 months ago.

What kind of board are you using ?


posted by jajn HA 31 Oct 2016

With lpc4088 board, sda/scl are on pins : p9/p10 or p32/p31 has it is defined here : https://developer.mbed.org/platforms/EA-LPC4088/

posted by Raph Francois 31 Oct 2016


posted by jajn HA 31 Oct 2016