Cheap-O firmware configuration

This is a bit about how to set up and adjust the Marlin firmware to use my Cheap-O end stop sensor correctly.


File: Configuration.h


For my Cheap-O endstop you don’t need the internal pull-up that can be activated in the firmware.

To disable the pull-up resistors you can comment them out like this


But if you are using mechanical switches on the other axis, and only got two wires connected to the NO and C pin on those, you will still need the pull-up for those. If you got mechanical switches as endstops elsewhere, you can instead disable the pull-up for just the Z axis by commenting this line out instead. (which can be found a few lines lower than the previous mentioned line.



For the Cheap-O sensor to work correctly it must be inverted too. You do that with this line.

const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.

File: Configuration_adv.h

Home retract

The next thing we need to change is how much Z is lifting before touching down again on the homing procedure.

This is needs to be tweaked because the sensor got build in hysteresis and therefor need a bit more movement before changing it’s state.
The line you need to find is this


and it must be changed from 1mm to 2mm.


This makes the firmware lift the Z axis 2mm, after touching down first time, before touching down a second time.

Advanced configuration

Do not continue if you are not 100% sure of what you are doing yet.

Manual adjusting Z height in firmware

If you are having problems adjusting your Z0 (zero) height by hand you can adjust it in the firmware.

To do this you first need to uncomment


Which can be found in Configuration.h.

This enables the ability to offset the different zero points.

The next thing we need to do is to define how much we want to offset the Z0 point. To change that you need to find this line.


Which can be found just a few lines lower than the line enabling the function.

Now when we have found the line we need, and also enabled the function, the offset should be easy to offset, but remember it is the opposite of what you put in.



This will set Z0 1mm above the point the sensor got triggered at, so when you tell your printer to go to Z0 it will move down 1mm! If you scroll back up to the top of this page, you can see that this sensor got plenty of air between the trigger point and the pcb, so 1mm (and even a bit more) would not be a problem, but if you use a mechanical switch you got way less room to work with.

Also notice, if you do this wrong, or got less clearance than you think you got, you will crash your hotend into the printbed, because you tell it is is somewhere else, and if that is wrong it will do something wrong too. So if you are not 100% sure what you are doing yet don’t touch this, and instead adjust the height mechanically, or try tweaking the first layer height in Slic3er if that is what you are using. (This setting can be found under “Printer Settings > General > Z offset:”, this is safer to use since your printer still wont go below the Z0 height you set when you mounted and adjusted the sensor)

Leave a Comment