Internal temperature sensor of AVR MCUs

Several MCUs can report their internal temperature via
[temperature_sensor mcu_temp]. Unfortunately that does not (yet) work for AVR chips. I’d like to make that feature available also for AVR. I can program a function (in C) to read out the temperature ADC. I did not find an appropriate location in the klippy code base where to integrate it, however. Any help, tips, pointers appreciated

Someone already did it for the avr atm328p but it did not get merged: add atmega328/p internal temperature sensor adc pin support by eikeime · Pull Request #4988 · Klipper3d/klipper · GitHub
But I believe not all avr processors have an internal temp sensor(afaik the atm1284p does not have one for example)

Correct.

Post must be at least 20 characters

I dug around a bit and part of it would need to go into the temperature_mcu class, the other part would need to go into src/avr/adc.c (in the mcu firmware you would need to enable the pin and define it while in the klippy part you’d need to “link” it)

1 Like