7 years, 5 months ago.

LM75B code problem

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

https://developer.mbed.org/components/LM75B-Temperature-Sensor/

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

7 years, 5 months ago.

https://developer.mbed.org/users/neilt6/code/LM75B/docs/7ac462ba84ac/classLM75B.html

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
            wait(0.5);
        }
    } 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
7 years, 5 months ago.

What kind of board are you using ?

LPC4088

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

Thanks

posted by jajn HA 31 Oct 2016