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+


Posted 2016-02-07T21:23:27.297

Reputation: 2 231


G4 P60000 as explained here:

– Lars Pötter – 2016-02-07T21:39:03.737

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 – 2016-02-07T21:44:57.287

@LarsPötter That should be an answer, not a comment! – Tom van der Zanden – 2016-02-07T21:52:47.733

@LarsPötter thanks, if you post your comment as an answer I'll accept it – Nir – 2016-02-07T22:02:20.720

@TormodHaugene - I wrote the entire back story as to why I'm looking for this, if you have a better solution I'm open to trying it – Nir – 2016-02-07T22:04:28.917

@Nir, I believe I answered that previous question. It's getting late now, but I can have a look at it tomorrow, if you like! :-) – Tormod Haugene – 2016-02-07T22:05:36.203

@Nir, could you post the code in start.gcode that you are currently using? I believe ´M109 S{print_temperature}´ is the command you are looking for, as was posted in the previous question. Did that work?

– Tormod Haugene – 2016-02-08T07:26:35.527

@TormodHaugene - yes, M 109 works, everything works perfectly for PLA but ABS doesn't stick to the bed, if I pre-heat the hotend (and remove the M 109) the ABS does stick to the bed - so my working assumption (that I have to test) is that it takes a little bit of extra time for the heat to make it from the thermistor to the tip of the nozzle – Nir – 2016-02-08T07:36:25.650

1@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 – 2016-02-08T07:39:21.423



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.

Lars Pötter

Posted 2016-02-07T21:23:27.297

Reputation: 1 471

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 – 2019-05-28T06:55:09.390

so the P actually behaving like the S parameter (seconds instead of milliseconds). Can you also put that information into here:

– Lars Pötter – 2019-05-28T20:49:51.850

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 – 2018-03-01T19:57:39.130


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.

Tormod Haugene

Posted 2016-02-07T21:23:27.297

Reputation: 3 919


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.

Fernando Baltazar

Posted 2016-02-07T21:23:27.297

Reputation: 1 280