Jonas
January 10, 2023, 7:49pm
1
I have a question how to add the stm32 temperature sensor in klipper?
Easy peasy, add the following statement to your printer.cfg:
[temperature_sensor mcu_temp]
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100
I’ve defined the controller as “mcu”, as in:
[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_##UNIQUE#USB#SERIAL#HERE##-if00
1 Like
Jonas
January 11, 2023, 11:44am
3
Thank you but I tried this already. I have a BTT SKR3 and when i add the sensor it answers ADC_TEMPERATURE not found.
Please post your klippy.log
You have:
[temperature_sensor mcu_temp]
sensor_type = temperature_mcu
min_temp = 0
max_temp = 100
I believe it should be:
[temperature_sensor mcu_temp]
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100
It looks like you’re using an equals sign (“=”) when you should be using a colon (“:”). It seems like you use equals everywhere - I think you need to go through your .cfg files and make sure you have the correct statement assignment character.
Jonas
January 11, 2023, 1:52pm
7
Thats strange when I look in my printer.cfg I have (“:“).
And that is the Klipper error:
Pin ‘ADC_TEMPERATURE’ is not a valid pin name on mcu ‘mcu’
Once the underlying issue is corrected, use the “RESTART”
command to reload the config and restart the host software.
Printer is halted
It seems that at some point the colons are replaced. Sorry about that.
Now, your rPi temperature_sensor looks funny. Mine is:
[temperature_sensor raspberry_pi]
sensor_type: temperature_host
min_temp: 10
max_temp: 100
Could that be the problem?
Jonas
January 11, 2023, 2:13pm
9
With deleting the RPI Sensor the problem is still the same. I dont now why the MCU Temp Sensor dont work but its not so important for me. Maybe a Klipper patch in future can fix it.
Sineos
January 11, 2023, 3:23pm
10
Function-wise both are treat equal. As “configuration policy” the colon is preferred
1 Like
Sineos
January 11, 2023, 3:33pm
11
WRT to the H7 MCU temperature, there seem to be some discussions in various pull requests, e.g.
Klipper3d:master
← Klipper3d:work-stm32h7adc-20221212
opened 08:06PM - 13 Dec 22 UTC
The stm32h7_adc.c code is used on a number of chips now - stm32g431, stm32l412, … stm32h723, stm32h743, and stm32h750. The adc code had a lot of ifdefs and slightly different behavior between chips. Most of these differences were unnecessary. This PR reworks the code to use less ifdefs.
I found and (hopefully) fixed a few bugs while doing this:
1. The stm32l412 should not use CKMODE=0.
2. On stm32h7 the adc actually runs at 25Mhz so the code should use BOOST=0b10.
3. The ISR clear of ADRDY should use explicit writes instead of read-modify-write.
I have also reworked the code to use explicit register writes where practical (instead of read-modify-write).
I have tested this on stm32h723. I don't have stm32l4, stm32g4, stm32h743, nor stm32h750 chips to test.
@D4SK , @adelyser, @mattthebaker, @bigtreetech - FYI.
-Kevin
Klipper3d:master
← adelyser:stm32h743_mcu_temp_fix
opened 04:30AM - 17 Aug 22 UTC
module: stm32h7 ADC
Fix mcu temperature on SKR-3
Signed-off-by: Aaron DeLyse… r [bluwolf@gmail.com](mailto:bluwolf@gmail.com)
1 Like
Jonas
January 11, 2023, 4:11pm
13
The solution is to change two files, wich @Sineos found on GitHub:
Klipper3d:master
← Klipper3d:work-stm32h7adc-20221212
opened 08:06PM - 13 Dec 22 UTC
The stm32h7_adc.c code is used on a number of chips now - stm32g431, stm32l412, … stm32h723, stm32h743, and stm32h750. The adc code had a lot of ifdefs and slightly different behavior between chips. Most of these differences were unnecessary. This PR reworks the code to use less ifdefs.
I found and (hopefully) fixed a few bugs while doing this:
1. The stm32l412 should not use CKMODE=0.
2. On stm32h7 the adc actually runs at 25Mhz so the code should use BOOST=0b10.
3. The ISR clear of ADRDY should use explicit writes instead of read-modify-write.
I have also reworked the code to use explicit register writes where practical (instead of read-modify-write).
I have tested this on stm32h723. I don't have stm32l4, stm32g4, stm32h743, nor stm32h750 chips to test.
@D4SK , @adelyser, @mattthebaker, @bigtreetech - FYI.
-Kevin
Here are the two files if anyone need it:
STM32H7_MCU_FIX.zip (4.7 KB)
One file is located in /home/pi/klipper/src/stm32 and the other one in /home/pi/klipper/klippy/extras.
Thanks for your help!
2 Likes