clockworkpi

Temp sensor in the thermal printer

It seems like that the thermal printer has a temp sensor (a thermistor), and it’s connected to an ADC, which is connected through an I2C bus to the core. On the other hand, it seems to be ignored for now?

By checking the schematics, the thermal printer datasheet, and the ADC datasheet, I think I figured out how to read the temp value from it. Basically, on A04,

    value = subprocess.check_output("i2cget -y 1 0x54 0 w", shell=True)
    value = int(value.strip(), 16)

    # Swap byte order
    value = ((value & 0xFF) << 8) | ((value & 0xFF00) >> 8)
    # Bits 11:2 are the conversion result
    value = (value >> 2) & ((1 << 10) - 1)
    # Resistance of the thermistor, R11 = 30
    res = 30 / (1024.0 / value  - 1)
    # Temperature, R25 = 30, B = 3950, R = R25 * e ^ (B * (1 / T - 1 / T25))
    temp = 1/(math.log(res / 30) / 3950 + 1/ (25 + 273.15)) - 273.15
    print(value, res, temp)

It seems to be reporting a temperature slightly higher than my room temperature, through (~33C, while the room is ~27C), Not sure if I made any mistake. It increases to ~57C during printing, which seems reasonable.
Is there any plan to use this sensor? It seems like that maybe we can use this to measure the environment temperature.

3 Likes

The temperature is used on the printer code DevTerm/printer.c at dc925423424af6e641195c3138da06c773907039 · clockworkpi/DevTerm · GitHub

If its too hot it should give too hot error.

Ah, thanks for the pointer!

Might be a cool (pun intended? hehe) programming projects to create some kind of system tray display that shows the temperature reading?