I'm trying to build an IR themometer using MLX90614, the objective is to read the sensor and show the data in an android app. But i'm having issues with memory.
(it doesn't work because of line 22, this line makes the usage go to 101%)
The main problem is with DigiCDC, it works, but it is using 70%+ more of my RAM, how can I make it smaller? I thought about editing myself digiCDC library, but I cannot find it anywhere in my pc.
I tried to install the new bootloader provided by digispark, but with no success (almost destroyed the attiny)
Besided that, what can I do, any digiCDC alternatives to communicate with android phones? I just need the usage to go a little bit down. I see SoftSerial is an option but I don't have pins for that, also, I don't have an adapter for the OTG cable like this
guy.
Thanks
Indeed, i can change that to float because I need 0.1 resolution for my temperature (eg: 21.5)
In my code, I call the following:
float objTemp = mlx.readObjectTempC();
where I need to attribute float to objTemp variable bececause I still need 0.1 resolution
now, If I call the function directly
SerialUSB.println(mlx.readObjectTempC());
I get an 102% of usage.
If i Use an int value, I will not havethe resolution I want (because of int). I don't undertsand what do you mean by saying I don't need floats. Can you elaborate?
you could change the pin definition from int to define.... and just put 50 in the delay value instead of the int.... should save you a bit of memory....
float Adafruit_MiniMLX90614::readTemp(uint8_t reg) {
float temp;
temp = read16(reg);
temp *= .02;
temp -= 273.15;
return temp;
}
/*********************************************************************/
uint16_t Adafruit_MiniMLX90614::read16(uint8_t a) {
uint16_t ret;
TinyWireM.beginTransmission(_addr); // start transmission to device
TinyWireM.write(a); // sends register address to read from
TinyWireM.endTransmission(false); // end transmission
TinyWireM.requestFrom(_addr, (uint8_t)3);// send data n-bytes read
ret = TinyWireM.read(); // receive DATA
ret |= TinyWireM.read() << 8; // receive DATA
uint8_t pec = TinyWireM.read();
return ret;
}
You should be able to see from the library, the value returned from "read16()" is then used by readTemp() to convert it in to a float.
Rather than use that function, write your own to take the value from read16() and convert it in to "centiCelcius" rather than Celsius...
I.e. multiply the initial value by 100 and return an int.
You can then simply Serial.print(temp / 100) + (".") + ( temp % 100). (PSUEDO!)
Here, reg is a 16bit unsigned int. Say the temperautre sensor returned "18,000" for the sake of an example...
The little bit of code above takes that returned 16bit unsigned int, divides it by 50 (*0.02) and then takes 273.15 away from it to give the temperature in Celsius returned as a float.