Temperature Library

Questions about Modern Device and JeeLabs Sensors
Post Reply
Posts: 1
Joined: Tue May 08, 2012 11:54 am

Temperature Library

Post by acburk » Tue May 08, 2012 11:58 am

Hi, I'm having problems with the temperature sensor ( http://shop.moderndevice.com/products/t ... ure-sensor ) since updating to Arduino 1.0 IDE and using the new temperature library. It's like it just freezes on GetTemperature(). Anyone else having this problem or know a solution?

Posts: 5
Joined: Tue Feb 14, 2012 3:41 pm

Re: Temperature Library

Post by motarius » Mon May 14, 2012 9:06 am

Yup, I ran into a similar problem. I seem to remember that this would happen when I requested temperature from an invalid address. But I could also see it happening if it's not wired correctly. The way the Lib Temperature is written, after it requests a value from a temperature node it will enter a while loop that will wait for data to be received on the bus. If no data is ever received it will just keep waiting in that loop forever. So the solution to this problem was to put bounds on this loop, an int counter that would function like a timeout. Here's a snippet from my revised library, to illustrate:

Code: Select all

uint8_t LibTemp::getRegisterValue(uint8_t deviceAddress, uint8_t registerID, uint8_t responseBytesExpected, uint8_t timeout_ms)
	unsigned long startTime = millis();
	sendCommand(deviceAddress,registerID); //just like send command but this time we wait for input
	Wire.requestFrom(deviceAddress, responseBytesExpected);

	    while(Wire.available() <= 0)
	    	if (millis() - startTime >= timeout_ms)

    return Wire.read();

Posts: 8
Joined: Wed May 09, 2012 11:52 am

Re: Temperature Library

Post by DaveW » Mon Jun 04, 2012 10:31 pm

I just purchased the MD0530 temperature/humidity sensor and the MD0545 temperature sensor. I downloaded the sample code from GITHUB to the Arduino 1.0.1 IDE, but when I try to compile the code to upload to an Arduino Uno from my mac I get errors.

For MD0530 I get 'LibHumidity' does not name a type.
For MD0545 I get 'LibTempTMP421' does not name a type.

Does anyone have an idea what could be causing this and how to fix it?


Post Reply