Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years 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
8 years 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"); } }
8 years ago.
What kind of board are you using ?
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 31 Oct 2016