# How to set up Marlin to use a heated chamber?

I have an infrared lamp I'd like to use to heat my chamber. Right now I don't have plans to install a cooling fan, but I will if I need to. This question pertains to Marlin (2.0, preferably) in combination with an MKS Gen L v1.0 board.

In the documentation for the thermal settings it specifies you can set a heater pin to be used to heat up the chamber. It says this variable is called the CHAMBER_HEATER_PIN but in Marlin 2.0's Configuration_adv.h file there is something called a HEATER_CHAMBER_PIN that has been commented out.

Secondly the Configuration.h file: there is something called an AUTO_POWER_CHAMBER_FAN. Is this meant for a fan used for cooling, or a fan used for cleaning out the chamber of particles? In either case, I probably don't want to have this fan always on, but only use it to cool the temperature the heater has been on too long.

So really there should be only 2-3 changes I need to make right:

• I need to specify an already present digital pin for
• the chamber heater
• the chamber cooler (fan)
• Turn thermal runway active.
• It needs to use the Marlin Chamber feature so that the readout temperature appears as "C:" in the arduino logs. This allows compatibility with octoprint
• Lastly I need to set an analog pin for the chamber thermistor

These are the things I can't fully figure out on my own. A detailed set of instructions or code snippets for a similar setup would be helpful

• what board is this using? – Trish Sep 12 '19 at 17:12
• MKS Gen V1.0. I would prefer Marlin 2.0 actually. I am going to update the question actually to specify that firmware. I would prefer to use the X-MAX or Y-MAX endstop as the heated chamber digital pin. And the thermistor can be the second extruder thermistor – K Mmmm Sep 12 '19 at 17:14
• a MKS Gen L 1.0? The board is relevent because you need to have some pins free, using the unused endstops could be an option, if the board can be retaught to do so. – Trish Sep 12 '19 at 18:04
• Yes I agree that there are a lot of other pins free on the Gen L. I want to use the max endstops though because they have a 3 wire slotted connection and won't come off the board when connected. They also have everything you need to activate a relay (5V, GND, D2). Im comfortable with activating new pins, it's just using the "Chamber" feature of Marlin that I specifically want to use because it is compatible with Octoprint. There doesn't seem to be any documentation on the web for it, except perhaps the answer to this question. – K Mmmm Sep 12 '19 at 19:24
• I tried to rework the question for easier readability. – Trish Sep 12 '19 at 19:49

Here is what I found to be the easiest solution. Please use this image for reference. I recommend doing these instructions once from source, since a lot of things can go wrong, then once everything works, go back and integrate them into your existing Marlin codebase.

1. Get some 5V relays to run the infrared lamps. These relays take in a 5V digital signal from an arduino pin. When the arduino activates these pins, the lamps will turn on. Get a cardboard box, line it with aluminum foil, and attach a lamp to the top of it using a lamp switch. One wire for the lightbulb goes to NO on the relay, the other goes to D-. One wire from 120V power goes to COM, the other also goes to D-. The yellow "jumper" on the relay boards I posted goes between HIGH and the middle pin. These are pins on the relay, not the MKS GEN board.

2. On the MKS GEN board, we will be using the X-MAX endstop as the digital pin to run the chamber. Wire the 5V pin on X-MAX to the D+ of the relay. Wire the GND pin to D- of the relay with the two other wires there. Wire pin D2 on the MKS GEN Board to IN on the relay. Bold means the pin is on the MKS GEN board.

3. Clone the Marlin-2.0 repo: git clone -b bugfix-2.0.x https://github.com/MarlinFirmware/Marlin.git

4. In Configuration.h, change TEMP_SENSOR_CHAMBER to 1 or 11 (depends on your thermistor, might be other values.) Since we will be using the board's second extruder thermistor as the thermistor in this example, change TEMP_SENSOR_1 to 0 for now.

#define TEMP_SENSOR_0 1
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_5 0
#define TEMP_SENSOR_BED 1
#define TEMP_SENSOR_CHAMBER 1

1. In the file src/pins/ramps/pins_RAMPS.h, add this line: #define TEMP_CHAMBER_PIN 15. Note that this is the thermistor slot usually used for a second extruder. If you're already using this thermistor for the second extruder and want to use a different analog pin, see this question. You'll need some resistors.

2. Also, around line 95 in pins_RAMPS.h, change X_MAX_PIN to use an unused pin. The number 4 is good. If you don't do this, your Chamber's digital Pin will be always "on" by default. You want it off by default, then activated by the Marlin code.

3. In Configuration_adv.h, change //#define HEATED_CHAMBER_PIN 44 to #define HEATER_CHAMBER_PIN 2 to use the X_MAX endstop's digital pin.