Hannah Light and Temperature Questions

Hi. I have a couple of questions.

The temperature I read is about “30”. Is this in Celsius to Fahrenheit? My room thermometer reads 77 degrees in California. If I convert to Fahrenheit it is 86 degrees. What am I doing wrong? I have tried more than 1 Hannah, and the Alerts are set for 29 and 31. I assume those are close to room temperature.

I am also using the light sensor. Is there an easy way to increase the range of sensitivity. In normal room light I read about 30 for the Clear channel. If I put a really bright light in front, I get 1024. Is there a way to increase the sensitivity in the lower range. I would like it to be in the 400-500 range for room brightness.

Greg

Hannah uses Celsius. It sounds like your room thermometer is reading in Fahrenheit (77F = 25C).

29C-31C is quite warm (84F-88F). Room temperature is generally considered 20C-25C or 68F to 77F (you might want to extend it a bit since your room is on the upper side of that).

I don’t believe there’s a way to change the sensitivity of the light sensor through the existing code - however you could take a look at the light sensor’s datasheet… it might be possible to do it through some I2C setup commands.

The hannah temperature sensor is also not so great (on rev2 anyway; rev3 is much better). It tended to read high by several degrees C :frowning:

@GregAmes

Here is some RGBC code that calibrates fully. Might be a variable or 2 missing, I just clipped this from a bigger segment. Key is that if init routine is called with non-zero (TRUE) parameter it will try to do an auto calibrate based on the ambient light, else it will use presaved values in Capas and Integ arrays.

If you would like to calibrate at a certain level then change the value of THRS to that level.

Shout if more info required.
// ***************** ADJD-S311-CR999 RGB Digital Colour Sensor ************* if{ function rgbdcsInit(init) { const rgbdcsControl = 0x00; const rgbdcsConfig = 0x01; const rgbdcsRed = 0x06; // -? 0x09 (x4) for Red, Green, Blue & Clear const rgbdcsIntRedLo = 0x0A; const rgbdcsIntRedHi = 0x0B; // -> 0x11 (x4) for Red, Green, Blue & Clear const rgbdcsDatRedLo = 0x40; const rgbdcsDatRedHi = 0x41; // -> 0x47 (x4) for Red, Green, Blue & Clear const rgbdcsOffsetRed = 0x48; // -> 0x4B (x4) for Red, Green, Blue & Clear sx1509SetPin(pinRgbSleep, LOW); // Must be set LOW to Disable the RGB Sensor SLEEP sx1509SetDir(pinRgbSleep, ioexpPinDirOut); // rgbdcsCapas <- [15, 15, 15, 15 ]; rgbdcsInteg <- [88, 104, 120, 64 ]; // sunny indirect // rgbdcsCapas <- [15, 15, 15, 15 ]; rgbdcsInteg <- [308, 372, 532, 196 ]; // Inside + cloudy rgbdcsCapas <- [13, 13, 13, 13 ]; rgbdcsInteg <- [1157, 869, 1641, 441 ]; // Early eve + Fluorescent rgbdcsLevel <- [0x0000, 0x0000, 0x0000, 0x0000 ]; // Last Read levels rgbdcsOffset <- [0x0000, 0x0000, 0x0000, 0x0000 ]; // Last read Offset if (init) rgbdcsCalibrate(); // RGB Digital Colour Sensor rgbdcs object else { for (local col = rgbdcsRED; col <= rgbdcsCLEAR; col++) { rgbdcsSetCapas(col, rgbdcsCapas[col]); rgbdcsSetInteg(col, rgbdcsInteg[col]); } } if (debug & debugRGBC) rgbdcsShowConf(); } function rgbdcsCalibrate() { const INTEG = 4; const THRS = 950; local color = 0, integ = 0, capas = 0x0D; for (color = rgbdcsRED; color <= rgbdcsCLEAR; color++ ) { // Now cycle through colors from RED thru CLEAR rgbdcsSetCapas(color, capas); for (integ = INTEG+1; integ < 4096; integ += INTEG) { rgbdcsSetInteg(color, integ); rgbdcsReadSensor(color); if (rgbdcsLevel[color] > THRS) break; } if (rgbdcsLevel[color] < THRS) MessageLog(format("Calibration error Ca=0x%x Col=0x%x, Int=0x%04X, Val=0x%04X", capas, color, integ, rgbdcsLevel[color])); else rgbdcsSetInteg(color, integ - INTEG); // Reset to previous value } // rgbdcsReadOffset(); // rgbdcsReadSensor(); } function rgbdcsSetCapas(color, value) { if ((color > rgbdcsCLEAR) || (color < rgbdcsRED) || (value > 0x0f) || (value < 0x00)) { MessageLog(format("SetCapas: color %d / capas %d OOR", color, value)); return (ERROR); } WriteByte(i2c_als, rgbdcsRed + color, value); rgbdcsCapas[color] = value; } function rgbdcsSetInteg(color, value) { if ((color > rgbdcsCLEAR) || (color < rgbdcsRED) || (value > 0x0FFF) || (value < 0x0000)) { MessageLog(format("SetInteg: color %d / integ %d OOR", color, value)); return (ERROR); } WriteWord(i2c_als, rgbdcsIntRedLo + (color * 2), value); // Write a 12 bit value for Integration Window rgbdcsInteg[color] = value; } function rgbdcsSetupRead(command) { local status = 0; status = WriteByte(i2c_als, rgbdcsControl, command); // Setup for reading of Offset if (status || (status == null)) return ERROR; do {imp.sleep(0.001); // Wait for conversion status = ReadByte(i2c_als, rgbdcsControl); // Done ? if (status == null) // Error ? return ERROR; // Yes, return } while(status) // No, wait more... return status; } function rgbdcsReadSensor(...) { if (rgbdcsSetupRead(0x01)) return ERROR; if (vargv.len() > 0) { local col = vargv[0] & 0x03; rgbdcsLevel[col] = ReadByteS(i2c_als, rgbdcsDatRedLo + (col * 2)); return rgbdcsLevel[col]; } else { rgbdcsLevel[rgbdcsRED] = ReadByteS(i2c_als, rgbdcsDatRedLo + (rgbdcsRED * 2)); rgbdcsLevel[rgbdcsGREEN] = ReadByteS(i2c_als, rgbdcsDatRedLo + (rgbdcsGREEN * 2)); rgbdcsLevel[rgbdcsBLUE] = ReadByteS(i2c_als, rgbdcsDatRedLo + (rgbdcsBLUE * 2)); rgbdcsLevel[rgbdcsCLEAR] = ReadByteS(i2c_als, rgbdcsDatRedLo + (rgbdcsCLEAR * 2)); } return 0; } function rgbdcsReadOffset() { // Light source MUST be turned off before running this.. if (rgbdcsSetupRead(0x02)) // Setup for Offset value read return ERROR; local status = WriteByte(i2c_als, rgbdcsConfig, BIT0); // Acquire the offsets rgbdcsOffset[rgbdcsRED] = Convert2Complement(ReadByte(i2c_als, rgbdcsOffsetRed + rgbdcsRED), 8); rgbdcsOffset[rgbdcsGREEN] = Convert2Complement(ReadByte(i2c_als, rgbdcsOffsetRed + rgbdcsGREEN), 8); rgbdcsOffset[rgbdcsBLUE] = Convert2Complement(ReadByte(i2c_als, rgbdcsOffsetRed + rgbdcsBLUE), 8); rgbdcsOffset[rgbdcsCLEAR] = Convert2Complement(ReadByte(i2c_als, rgbdcsOffsetRed + rgbdcsCLEAR), 8); } function rgbdcsShowConf() { rgbdcsReadSensor(); rgbdcsReadOffset(); MessageLog(format("Capas : R = %02d G = %02d B = %02d C = %02d", rgbdcsCapas[rgbdcsRED], rgbdcsCapas[rgbdcsGREEN], rgbdcsCapas[rgbdcsBLUE], rgbdcsCapas[rgbdcsCLEAR])); MessageLog(format("Integ : R=%04d G=%04d B=%04d C=%04d", rgbdcsInteg[rgbdcsRED], rgbdcsInteg[rgbdcsGREEN], rgbdcsInteg[rgbdcsBLUE], rgbdcsInteg[rgbdcsCLEAR])); MessageLog(format("Offset: R=%04d G=%04d B=%04d C=%04d", rgbdcsOffset[rgbdcsRED], rgbdcsOffset[rgbdcsGREEN], rgbdcsOffset[rgbdcsBLUE], rgbdcsOffset[rgbdcsCLEAR])); MessageLog(format("CurVal: R=%04d G=%04d B=%04d C=%04d", rgbdcsLevel[rgbdcsRED], rgbdcsLevel[rgbdcsGREEN], rgbdcsLevel[rgbdcsBLUE], rgbdcsLevel[rgbdcsCLEAR])); } //}

and about the temperature, I’m told that the readings might be affected by the temperature of the board itself.

my experience is that as long as the supply voltage remain nice and constant, the temperature readings are reasonably accurate (+/-1 maybe 2 degC)

As per a previous discussion, should Wifi transmission take place at the same time, the voltage can be slightly affected and hence the temperature readings…