I´m working on a Python script that reads out four DS18B20 sensors, which are mounted in the four vertikal aluminium extrusions on the corners to get a arithmetic mean for the frame temperature.
I´ve added a additional MCU temperature sensor to klipper like this:
If i change the value in the “frame” file, klipper shows me the right temperature. But if I run the script, klipper don´t refresh the value.
Here is my script:
#!/usr/bin/env python
#coding=utf-8
import os, time, sys
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
file_path = 'frame'
sys.stdout = open(file_path, "w")
sensorcount = 4
sensors = ['28-0621b2312f10', '28-0120426e687f', '28-0621b245c0cf', '28-0120428c8a85'];
temp_sum = 0;
sensorpath = '/sys/bus/w1/devices/'
sensorfile = '/w1_slave'
def callsensor(sensor):
f = open(sensorpath + sensor + sensorfile, 'r')
lines = f.readlines()
f.close()
if lines[0].strip() [-3:] != 'YES':
sys.exit('Fehler bei Sensor ' + sensor)
temp_line = lines[1].find('t=')
if temp_line != -1:
temp_output = lines[1].strip() [temp_line+2:]
t= in temp_output schreiben
return temp_output
for i in range(0, sensorcount):
s = sensors[i]
temp_sum = temp_sum + int(callsensor(s))
temp_arr = int(temp_sum/sensorcount)
print(temp_arr)
sys.exit()
It´s working well, but klipper doesn´t update the temp value.
I think it´s caused by the truncation before the write of the file from python.
I know that i can implement the four sensors in klipper directly, but not the arithmetic mean. I just want one value for the frame, so i can wait for the frame to get on temperature before the print starts.
I noticed the ‘temperature_combined’ feature popup this weekend and tried it out on my Voron 0
This turns the processor fan in the back of the machine when either of the processors get hot.
Works well thanks.
#####################################################################
# Temperature Sensors
#####################################################################
[temperature_sensor SKR_Pico]
sensor_type: temperature_mcu
[temperature_sensor Raspberry_Pi]
sensor_type: temperature_host
#####################################################################
# Processor Fan Control
#####################################################################
[temperature_fan processors_maximum]
pin: gpio20 # the fan control pin (must be a mosfet or a pwm fan)
control: watermark # the type of hysteresis we are using
max_delta: 3.0 # fan turns on/off at 3° over/under target_temp
sensor_type: temperature_combined # new temperature type
sensor_list: temperature_sensor SKR_Pico, temperature_sensor Raspberry_Pi
combination_method: max # use the maximum reading of the sensors
maximum_deviation: 999.9 # we don't care about the difference in temperature
max_temp: 85 # just the valid temperature ranges
min_temp: 0
target_temp: 57.0 # the initial target temperature for the fan
max_speed: 1.0
min_speed: 0.3