# Is there a G-code for waiting?

My printer has an auto-leveling feature that works by touching the build plate with the tip of the nozzle.

I started using a BuildTak surface and BuildTak is damaged when you push a hot nozzle into it.

So I edited the start G-code to run the auto-leveling before heating up the hotend

But ABS doesn't stick to the build surface unless I pre-heat the hotend and wait about a minute.

So now I'm looking for a G-code command to put at the end of the start G-code that will make the printer wait a minute before printing

The sequence I'm looking for is:

• Heat up the bed
• Auto level
• Raise the hotend a little bit so it doesn't touch the build plate
• Heat up the hotend
• Wait a minute (that's the only part that is missing, everything else works)
• Start printing

Any way to insert a delay into the G-code?

I'm using Cura to slice/print, my printer is Robo3D R1+

• G4 P60000 as explained here:reprap.org/wiki/Gcode#G4:_Dwell – Lars Pötter Feb 7 '16 at 21:39
• Hi, @Nir! So, you want to set hotend temperature, and wait until it is warm before printing (at the end of start.gcode)? I generally doubt you really need to explicitly set a delay - it is basically a hack to overcome (not fix) the problem! – Tormod Haugene Feb 7 '16 at 21:44
• @LarsPötter That should be an answer, not a comment! – Tom van der Zanden Feb 7 '16 at 21:52
• @LarsPötter thanks, if you post your comment as an answer I'll accept it – Nir Feb 7 '16 at 22:02
• @Nir, Oh, I see. In that case, you are probably right that adding a delay or "Dwell" (with G4) is the way to go. :-) – Tormod Haugene Feb 8 '16 at 7:39

The G-code to delay is G4.

G4 P60000 will wait for one minute. The P is in milliseconds. Some firmware also accept a S Parameter that has the seconds. So, if supported, G4 S60 would do the same thing.

The details for this and all other G-codes are documented here.

• In my end-G-code, I shut off the hot end, and wait several minutes before shutting off the fan. I was getting communications timeout errors and the fan would never actually shut off from the code (using Monoprice Select Mini with Octoprint). If this occurs for you before the print, it will not print at all. I resolved it by simply breaking it up unto a series of shorter delays. – mbmcavoy Mar 1 '18 at 19:57
• For cncjs, the command is G4 P0.5 for half a second, for example. i.e. it's a float, not an int. – Gavin Simpson May 28 '19 at 6:55
• so the P actually behaving like the S parameter (seconds instead of milliseconds). Can you also put that information into here: reprap.org/wiki/G-code#G4:_Dwell – Lars Pötter May 28 '19 at 20:49

An alternative solution to using a hard delay with the G4 dwell command, is to increase the time that the temperature set with M109 has to be held before it continues with the next command.

In Marlin, this setting is named TEMP_RESIDENCY_TIME, and can be found around line 150 in Configuration.h. By default, this is set to 5 seconds, which looks like:

// Actual temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 5  // (seconds)


If increasing this setting solves your exact problem, I cannot say, but it could be worth looking into.

I´m using this code for my prints.

    G29 ; Autonivel
M190 S35 ; set bed temperature
G1 Z4 F240 ; lift nozzle
M109 S195 ; wait for temperature to be reached
G21 ; set units to millimeters
G90 ; use absolute coordinates
M82 ; use absolute distances for extrusion
M104 S210 ; set temperature
G92 E0
G1 E-1.5000 F1800
G1 Z0.225 F240


On M190 S35, the nozzle is still on the low position (1.2mm), then goes to 4mm then waits for the extruder temperature Ex. 195°C; when the extruder reach the 195°C for 10 seconds then the printers starts to print going the nozzle to 0.22mm while the nozzle reach the second temperature of 210°C. On This time its allow me to clean the nozzle and normalize the temperatures for a good prints.

Note: To avoid the nozzle stays many time on low position (1.2mm) normally I preheat the bed at 35°C. some times to heat the bed takes a longer time than heating the nozzle. This is the main reason that I prefer to preheat the printer.