Using a DS18B20 Connected to Raspberry Pi to Give Chamber Temperature

What is the problem?

I cannot find a way to use my connected and functioning DS18B20 sensor to provide chamber temp on the temperature screen.

What did you already try to solve it?

I've installed several plugins that will use this sensor to display the temp elsewhere, but not on the graph and not from the "chamber temp" drop down. I've read through about 20 different tutorials and have not been able to find away to setup where the chamber temp is read from.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, what kind of hardware precisely, ...)

1.6.1, Prusa MK3S, Bondtech Prusa w/Mosquito Hotend Firmware

Hello @NoHelmet !

Additional temperatures are not supported by OctoPrint.
There are some requests already and attempts (Temperature Tab Replacement), but it's not working yet.

1 Like

Thanks for the quick response. Where is OctoPrint currently trying to read the chamber temp from? If I knew that I could possibly tweak a plugin to send it where it's being looked for. I understand that klipper may have a workaround, but I haven't tried that yet.

It gets the information from what's reported by your firmware. That's where my plotly temp graph plugin would allow a single file plugin to graph additional data not reported by the firmware. An exmple is in the repo here. It's just an example of getting fan speed response from Marlin and adding it to the graph. It does work BTW @Ewald_Ikemann, I just decided against merging it into core OctoPrint.

2 Likes

I actually have the plotly temp graph installed, but I'm not able to configure it to read from the sensor connected to the pi. If I had it output the temp to the printer via gcode could I get it read back in the plotly graph?

How are you interfacing with the sensor? I assume gpio, which if you can find an example python script that will work to read the data I could possibly assist getting that to work with the graph.

I can get you that. Give me a bit, I'm not home at the moment.

I believe Marlin has an option to read chamber temperature but I don't know what sensors are supported. Also appears to have the option of controlling chamber temperature.

@NoHelmet
Just out of configuration.h :

//===========================================================================
//============================= Thermal Settings ============================
//===========================================================================
// @section temperature
/**
 * --NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
 *
 * Temperature sensors available:
 *
 *    -5 : PT100 / PT1000 with MAX31865 (only for sensors 0-1)
 *    -3 : thermocouple with MAX31855 (only for sensors 0-1)
 *    -2 : thermocouple with MAX6675 (only for sensors 0-1)
 *    -4 : thermocouple with AD8495
 *    -1 : thermocouple with AD595
 *     0 : not used
 *     1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
 *   331 : (3.3V scaled thermistor 1 table for MEGA)
 *   332 : (3.3V scaled thermistor 1 table for DUE)
 *     2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
 *   202 : 200k thermistor - Copymaster 3D
 *     3 : Mendel-parts thermistor (4.7k pullup)
 *     4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
 *     5 : 100K thermistor - ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan, J-Head, and E3D) (4.7k pullup)
 *   501 : 100K Zonestar (Tronxy X3A) Thermistor
 *   502 : 100K Zonestar Thermistor used by hot bed in Zonestar Průša P802M
 *   512 : 100k RPW-Ultra hotend thermistor (4.7k pullup)
 *     6 : 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
 *     7 : 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
 *    71 : 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
 *     8 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
 *     9 : 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
 *    10 : 100k RS thermistor 198-961 (4.7k pullup)
 *    11 : 100k beta 3950 1% thermistor (Used in Keenovo AC silicone mats and most Wanhao i3 machines) (4.7k pullup)
 *    12 : 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
 *    13 : 100k Hisens 3950  1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
 *    15 : 100k thermistor calibration for JGAurora A5 hotend
 *    18 : ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327
 *    20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage.
 *         NOTES: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21.
 *    21 : Pt100 with circuit in the Ultimainboard V2.x with 3.3v ADC reference voltage (STM32, LPC176x....) and 5V INA826 amplifier board supply.
 *         NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C.
 *    22 : 100k (hotend) with 4.7k pullup to 3.3V and 220R to analog input (as in GTM32 Pro vB)
 *    23 : 100k (bed) with 4.7k pullup to 3.3v and 220R to analog input (as in GTM32 Pro vB)
 *    30 : Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K / B3950 (4.7k pullup)
 *   201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x
 *    60 : 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
 *    61 : 100k Formbot / Vivedino 3950 350C thermistor 4.7k pullup
 *    66 : 4.7M High Temperature thermistor from Dyze Design
 *    67 : 450C thermistor from SliceEngineering
 *    70 : the 100K thermistor found in the bq Hephestos 2
 *    75 : 100k Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor
 *    99 : 100k thermistor with a 10K pull-up resistor (found on some Wanhao i3 machines)
 *
 *       1k ohm pullup tables - This is atypical, and requires changing out the 4.7k pullup for 1k.
 *                              (but gives greater accuracy and more stable PID)
 *    51 : 100k thermistor - EPCOS (1k pullup)
 *    52 : 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
 *    55 : 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup)
 *
 *  1047 : Pt1000 with 4k7 pullup (E3D)
 *  1010 : Pt1000 with 1k pullup (non standard)
 *   147 : Pt100 with 4k7 pullup
 *   110 : Pt100 with 1k pullup (non standard)
 *
 *  1000 : Custom - Specify parameters in Configuration_adv.h
 *
 *         Use these for Testing or Development purposes. NEVER for production machine.
 *   998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below.
 *   999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below.
 */
#define TEMP_SENSOR_0 61
#define TEMP_SENSOR_1 61
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_6 0
#define TEMP_SENSOR_7 0
#define TEMP_SENSOR_BED 11
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
#define TEMP_SENSOR_COOLER 0
#define TEMP_SENSOR_REDUNDANT 0

The DS18B20 is not included. But you may use a spare heatbed or hotend thermistor.

DS18B20 uses digital interface (see https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) while Marlin expects analog input that itself will convert to digital data.

You could grab any of the "standard" 100k thermistors (termistor 100k - Buy termistor 100k with free shipping on AliExpress) and connect to ADC capable ports on Marlin board.

Yes, I am using gpio. The python script for giving temp back to the SSH terminal is:

import os
import glob
import time

os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')

base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'

def read_temp_raw():
f = open(device_file, 'r')
lines = f.readlines()
f.close()
return lines

def read_temp():
lines = read_temp_raw()
while lines[0].strip()[-3:] != 'YES':
time.sleep(0.2)
lines = read_temp_raw()
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
temp_c = float(temp_string) / 1000.0
temp_f = temp_c * 9.0 / 5.0 + 32.0
return temp_c, temp_f

while True:
print(read_temp())
time.sleep(1)

I really only need the Celsius readout. It would be nice to be able to utilize it to control heat/fan, but I believe I can tackle that from a different direction.

Thanks.

formatting on that code can make a big difference. Can you share the whole file itself? It doesn't look like it would be difficult to work out.

Here's a first stab based on what you shared. You may need to adjust the tabbing and such in the while loop, etc. Hopefully this gets you started in the right direction.

You should be able to copy/paste the URL below into Plugin Manager > Get More > ...from URL to install.

https://gist.github.com/jneilliii/177d0fae0e285c82762ec96b2fbfff8b/raw/790f1fc4645ab230c29ca0159d2068e60b6777c1/DS18B20%2520Plotly%2520Temp%2520Graph%2520Integration.py

Thank you very much. I've got a pretty long print going but I'll give it a shot when it gets done.

OK, so I got it installed. It's showing the chamber setpoint on the graph, but not the actual reading. If I force the plugin I'm using to read the temp to export it in G code, the graph changes from the setpoint to 1 degree. Not sure exactly what's up.

without having one of those it's hard for me to figure out what could be not working. there's probably better ways to do it as well using Rpi.GPI) or perephery (probably better option) instead of system commands and looping waiting on responses.

Not sure if Circuit Python modules are available in regular python venv or not, but there's possibly the ability to use this and it seems you have to do something special possibly for what looks like a similar solution here (search the page for DS18B20).

any helping log/debug entries?
regarding the issue, maybe a permission issue? (reading directly from hardware)

I'm not sure. It's been so long since I actually did any coding that I'm practically useless. I'm going to try setting up klipper as I think there's a built in integration for this sensor.

@NoHelmet I think I found your solution with the TopTemp plugin.

Bringing this back to life...

I presume since I have a hyperpixel4 attached to my RPi, I cannot attach a DS18B20 sensor to the GPIO pin?