Lightburn triggers, possible to use say an ESP32 / arduino for fan and air control?

i’ve seen a few posts of people asking to do similar, but not seen if anyone’s figured this out.

I have a little omtech K40+ that uses a GRBL controller that talks to lightburn, but as it comes from the factory the air pump and exhaust fan run all the time the machine is powered up.

The controller on these machines is pretty much unknown it seems, i’ve seem pictures where they have evolved a little adding more outputs, and the one i have has 3 ext. outputs, 2 of which are in use but they seem to be used for the complicated interlock omtech uses on their machines (that needs you to press a reset button every time you’ve opened and closed the lid, which is extra annoying to say the least)

photo below showing my controller board with it’s 3 external outputs, and then the relay board they are switching.

:

As there are so many different GRBL controllers out there on the smaller laser cutters that use the GRBL method of control, i know it’s impossible to get lightburn to talk to all of them beyond the basic machine controls (axis moves and laser power)
So it would be easier if it was possible to use a second device to control the exhaust fan and air assist that people can add themselves.

say an arduino, ESP32 or similar, connected via usb to the computer that’s running lightburn, and when the G-code code is sent from the computer to the laser to run it, it can also send the signals to turn the extractor fan on and air assist pump etc to the board that controls those,

If an ESP32 board is used that could then also send signals to smart sockets to turn extractor fans on remotely as i have seen some people wanting to do.

:

in my case i want to have 2 speed extraction (i have a 3 speed centrifugal duct fan)

So the extraction fan would run at it’s lowest speed when the laser is powered up, but switches to high speed when it’s actually lasing to suck the smoke / fumes out,
then after a timer runs out after the laser has finished it’s program (which would simply be added to the arduino / ESP board code), the fan switches back to low speed to reduce that backflow of fumes you often get when the fan turns off.

or maybe even have the fan not start up until the laser is about to start working, run at full speed during the work, then switch to low speed from then on etc.

And likewise with air assist, it could be set up to start the air pump up whenever the machine is working like you do with the ruida controllers,
but it could switch the bypass solenoid on and off depending on if you have selected ‘air’ or not for that layer in lightburn.
so keeping low flow of air to keep the lens clear when engraving, then switch to full air when cutting, but not having the pump running all the time the machine is powered up.

And i’m sure people could come up with other things to control if lightburn could talk to an arduino / ESP type board as well as the laser cutters GRBL board?

I’m pretty confident this has been brought up before. I suggest you go to

And search for similar requests. Generally when you want Lightburn to drive multiple controllers with multiple connections, I think it’ makes it tough on developers.

Many of these suggestions have direct feedback from the development group…

:grinning_cat:

Interesting concept, have Lightburn talk to a second USB port where that controls some means of I/O.

The problem is that you have to write your Arduino (Raspberry Pi, Picaxe, BasicStamp, etc) source code to make it happen. And Lightburn would have to know what to send to that board. Unless a standard is established, there will be 100+ versions of that I/O controller board.

Maybe go down this path instead… If your controller controls an output with the M07 or M08 GCode Command, tap into that for the additional exhaust fan control. My S30 laser outputs 12vdc when I turn on Air Assist. That 12v feeds the air pump, but could also energize a 12vdc relay. That relay could switch the exhaust air fan on and off.

Would something work like this for you?

Aaaaand there’s timing involved, which depends on the G-Code command buffer size and suchlike in both controllers. Without a hardware-level handshake, there’s really no good way to synchronize two command streams.

1 Like

It needs to be an inherent part of the controller. Other than that, it’s known as a hack and becomes non-portable and more difficult to maintain/debug.

I’m sure this has come up before and I’m sure it didn’t make it because it’s very difficult to implement this type of tactic under most software architectures. To make changes like this without having a thought about it beforehand can be very difficult.

We all think we know how things work, but it’s different for everybody and unlikely it’s working the way you think. The beauty of these, it’s all invisible to the user.


I’m pretty sure if they could reasonably do this within Lightburn, they would have already.

I doubt the developers of Lightburn designed this to be a fan/compressor control software. So I think it’s really dependent on a controller with enough hardware and smarts to implement controlling a device.

:grinning_cat:

1 Like

Well… That did not go very far very fast.

I didn’t expect it to go far at all.. Sounds simple, but I know better.

Worked in a shop that the software had around 2 million lines of code. Very difficult to add things without breaking something else. Especially considering the scope of the request.

I think this is the origin of the simple saying fix one bug, a bunch more come to the funeral

:grinning_cat:

1 Like

My thinking would be be that lightburn could send out a ‘basic’ one way serial stream to an arduino.

You’d have a tick box to enable ‘arduino output’ in lightburn,
When that is selected it gives an extra ‘com port’ selection box like the one for the laser controller connection, and once the com port and speed it runs at is set up you could have it connect automatically to the arduino on that com port when lightburn starts,
similar to how the controller in the laser does.

Lightburn would need some extra code adding so that then when it sends certain G-codes to the lasers controller… say the M8 - air on command, it also sends a trigger over the serial stream for the arduino to ‘hear’,

After that it’s a seperate thing to configure the arduino that listens to the serial stream and how it does things in response to those commands from lightburn, and that would be upto other people and not the lightburn team.

i imagine there could be a timing issue as it’s likely the arduino serial stream would not be synched to the G-code mainstream perfectly, or running as fast as the GRBL controllers stream,
but it’s not like the arduino would be controlling anything really important like the lasers output that needs nanosecond precision,
so if it receives the ‘turn on fan’ code with 100ms of latency it’s not the end of the world.

After all, this is for a universal ‘lightburn’ ancillary output controller for automating the turning on and off of air pumps, fans, status lights and so on,

But it’s adding features to peoples laser cutters that are not available on their main laser controller (or are available, but no one knows how to access the commands, let alone connect to the relevant pins on the mcu on the lasers board)

And as this would add features not available with other laser controller programs it might help people decide to buy lightburn over using other programs.
this could even be an addon to the main lightburn program that you pay say 5 or 10 dollars for perhaps?
as not everyone wants it, ruida controller owners likely don’t need it, but the cheap laser cutter GRBL controller owners would likely find it useful to automate things they have to do manually now.

:

That serial stream from lightburn could be something like CSV’s, so
‘A0, B1, C0, D0, E0, F0, ;A1, B1, C0, D0, E0, F0 ;A1, B1, C0, D0, E1, F0, ;’ and so on,

A could be air pump, B = fan and so on,
when the number after the letter changes, the arduino does something… 0 being off, 1 being on.. so in the stream above, the fan is already on (B1) and the air pump turned on (A1) in the second repeat of the stream after the ‘;’ delimiter character,

The code that runs on the arduino would be a basic state machine,
It would be easy to provide a simple arduino sketch for people to load onto their arduino that controls a few pins, but as it’s an arduino sketch it can be very easily expanded on by the end user if they want (or by others who share their sketches)

The basic sketch handles starting the serial port and connecting to the computer, and once lightburn is running and the serial stream active, the arduino is just turning pins on and off when the relevant CSV changes in the serial stream,

.
So most of the time it sits there listening to the serial stream from lightburn doing nothing.

When there is an ‘M8’ trigger in that serial stream, the arduino takes a pin low and the air pump relay turns on,
when it receives an M9 trigger in the serial stream, it takes that pin high and the relay opens, air pump stops,

similar for extraction fan commands…
Not sure if there’s a G-code command for fan control, but there may be ‘starting job’ and ‘ending job’ G-codes?
and if not, maybe when the ‘laser fire’ command is sent to the GRBL board, the arduino’s stream gets a trigger and the code running on the arduino takes the extraction fan pin low to start the fan.

Then when the laser firing G-code goes off and thus the arduino’s serial stream changes to show the laser is no longer firing, a timer (running on the arduino of course) holds the fan pin low for longer than the time it would usually take to go between travel moves to the next part of a job and another ‘laser firing’ command is received that resets the timer etc.

If there has not been another ‘laser firing’ code, the arduino considers the job ‘finished’
then it starts a ‘run on’ timer to keep the fan on to clear the smoke after the job ends, and then when that run on timer expires it takes the fan pin high and the fan turns off / down to a low speed.

That same ‘job in progress’ trigger would be ideal for the air pump start and stop triggers too, with the M8 and M9 ones triggering the ‘full air pressure’ bypass solenoid for cutting layers.

:

As it’s up to the end user what they add to the arduino program for how it responds to the triggers in the serial stream this makes it extremely customisable,

if one person wants to flash a light outside the room saying ‘do not enter, laser in use’ they’d just add code to the arduino sketch that drives the pin the mosfets the light up sign is connected to high and low at the speed they want when the ‘job started’ code is received by the arduino.

If they want a push message sent to their alexa to say ‘your laser job is finished’ they’d add all the code needed on the arduino sketch that triggers when it hears the ‘job finished’ command etc (an ESP32 would be better used here for it’s wifi connectivity, where it can then talk to smart plugs to turn a fan on, or to home assistant and so on, but they can be programmed in the arduino IDE too, so are simple to write sketches for)

:

but as you can tell, software stuff is not my thing really, i’ve just used arduino’s to do things like this in the past,
one was to listen to a CSV serial stream from a bus driving simulator and turn pins on or off when it receives a 1 or a 0 for the relevant item.

This then turned lights on a vehicle dashboard on and off, moved gauges and displayed text on displays etc, and it was able to keep in sync very well so that the flashing indicator (turn signal) light on the dash matched the one on the computer screen.

so that’s how i’m imagining this working with lightburn, once a serial stream from lightburn is accessible the sky is the limit to what can be done with this.

“Alexa, is my laser on fire?” would be a nice feature.

Buy a controller that supports these operations directly, leaving everyone out of this quandary.


One way communications aren’t really communications as one side has no voice to determine it’s faulted, some other error condition, or simply not even there.

Arduino is handy, I have used a lot of them, however they are a quarter century old, doubt you’d use a home computer that old…? A mounted and working esp32 has many advantages over an Arduino and is about the same price and you usually get wifi and/or bluetooth as an bonus.


As I said, without a complete re-write of Lightburn, this isn’t likely to work without a lot of effort by a lot of people that have learned to find other options to control this stuff.

The Ruida has separate status signals, including a single off/on for air assist.

You’d get this done in your lifetime if you just found a different controller that supports these operations.

Haven’t looked into this for the MKS DLC32 V2.1 controller. It might be able to control some of these, don’t know.

Have fun…

:grinning_cat:

1 Like

i mentioned arduino’s as they are simple, cheap and easy to use, especially if it’s just listening to a serial stream and taking pins high or low,

but of course an ESP32 would be much better with it’s wifi, bluetooth and all other connection methods, and then it can talk to things like home assistant, or maybe even directly to smart plugs to turn the extraction fan on and off without even having to wire in a mains relay,
it could also turn smart bulbs on and off elsewhere to show the status of the laser (a ‘kids keep out, open diode laser in use’ sign perhaps).

maybe even turn the air pumps mains power on and off using another smart plug, tho some wiring would be needed for the high / low air flow solenoid, but it could almost be plug and play at this point.

:

Are one way comms for such simple control of things such a bad thing?
the serial stream and state machine sketch i used for my bus driving simulator rigs ran fine with that,
the serial streams delimited data is sent repeatedly over and over all the time,

So it’s not like there’s a single ‘turn on fan’ message that if missed the fan stays off, the serial stream part for the fan changes from 0 to 1, and stays on 1 until it’s time to turn the fan off, so the arduino will respond when it sees the value has changed, even if something causes it to stop reading the serial stream for a second or 2.

i’m sort of leaning towards something that in my head is easier to implement than a full 2 way comms that would take a re-write of lightburn,
but it seems that getting some sort of extra signals out of lightburn is very hard work, and that’s why it’s never been implemented even tho this subject pops up quite regularly.

Maybe something like memory hooks that read the G-code being sent to the laser cutter, and when it reads an M8 command, it changes the CSV for the air pump from 0 to 1.

:

I know the ‘solution’ is to buy a ruida controller, but last time i looked they cost about half as much as i paid for my little K40+ laser cutter, and for some people with cheaper machines and diode lasers, a ruida controller would cost more than their machine.

So i was thinking of a cheaper way to do this, and it would also help make lightburn stand out from other laser controlling software if it can give your machine functions it does not have due to it being too cheap to warrant a controller that has built in outputs for extraction fan and air pump.

There could be things people want to control other than the air pump and extraction fan that more expensive machines have but the cheap little machines that use these GRBL controllers don’t do.
and i can imagine the CNC people may want things like this too,

;

I’m wondering if perhaps there is a way to listen in to the G-code stream, i’m sure i saw something aimed at the CNC guys, a little box that you plug between the computer and machine and it listens to the G-code stream then sends out signals that you can do what you want with… say turn on or off mist or flood coolant, dust extraction and so on.

But of course i can’t find it now, and i wonder if it might introduce latency into the G-code signal as it’s ‘breaking into’ the usb cable to access the G-code data stream.

Thinking more on this… i wonder if there’s some way for another program on the computer to read what’s being sent to and displayed in the lightburn ‘console’ window?

as that’s showing what is being sent to the laser controller, so if it could read what’s sent to or displayed in the console window, it could then interpret certain codes and do other things with it.

I know this could be done with something that reads the text in a certain part of the screen, as that’s been done before with driving simulators to read on screen ‘HUD’ text showing stuff like speed, pressures etc and send a serial stream to an arduino to move real gauges to match.

A better way to do this would be to intercept the data that’s sent to the console window,
then send a copy of the data to a file that is updated in real time elsewhere on the computer for another program to read and act on specific messages it sees,

i wonder if lightburn has a logging feature of the console messages that could be read in real time as they are appearing in the console window?

@ednisley already pointed out you will have a syncronization problem. You have no way to stop the stream so you can perform an auxillary operation, then continue. Capturing a USB stream is already done. Controlling it, not so much.

how bad are we talking for a synchronization?

i imagine there’s a small delay from lightburn sending the G-code command and it arriving at the lasers controller, i guess if it goes into a buffer in the controller there will be issues,

i’m thinking of controlling an air pump, air pump valve and extraction fans, so unless the delay was like 1 second is it going to be that bad?

but i’m also not sure about needing to ‘stop the stream’
the serial stream to an arduino / ESP32 would just be repeating what it see’s in the console window, so when it see’s M8 in the console, it takes a pin low and the air pump starts up / bypass solenoid opens,
then when M9 is seen in the console window, the arduino takes the pin high and the pump stops,

Exactly what we’ve been saying. :grin:

Old School Arduino controllers buffered about 128 bytes of G-Code, but contemporary 32-bit controllers have tens to hundreds of kB of RAM, enough to swallow all the G-Code for an entire program that may then run for tens of minutes.

While the program is running, the controller gives no hint as to which G-Code instruction it’s executing. In fact, it doesn’t even tell you when it’s finished.

Which is why I said there’s no way to synchronize two controllers without a hardware handshake. Of course, if the main controller had a controllable output bit or two, you wouldn’t need the additional controller. :grin:

ahh right,

so… what is shown in the lightburn console window,
is that live as the laser cutter is executing it, or is it showing what is being sent to the laser cutter from lightburn in a buffer, and then it’s up to the lasers controller to wait for the current G-code line to finish before it moves on to the next one.

Say if it was finishing up an engraving layer and about to switch to a cutting layer where you want the air on, would the console window show the M8 command before the laser cutter would actually execute that command?

i can’t test this as my laser cutter does not respond to the air on / off M8 / M9 commands,

:

For other things like turning the extraction fan on and off when a job starts and ends, that could be something that is added to the start and end G-code that lightburn can add when you start a job,
but of course the arduino / ESP32 would need to be able to get those commands, ideally without having to be fed the entire G-code stream,
which is why i was hoping of a way to maybe monitor the console window in real time on the computer, when when the G-code we want to look out for shows up, it sends the command to the arduino / ESP32 to do it’s thing.

i was also thinking of something like when the frame button is pressed, it could start up the extractor fan on low speed, as when i start framing the workpiece i am getting ready to start a job… and my fan takes a few seconds to get upto speed.

but if it’s already running at low speed before the job starts, it takes a fraction of a second to ramp up to full speed when the laser starts firing and producing smoke that needs sucking out…

something i notice on youtube videos of people with big boys laser cutters with ruida controllers have, the laser cutter is filling with smoke for a couple of seconds as their fan spools up because it’s only triggered to start up when the laser starts working,
then it gets to full speed and sucks all the smoke out but by that time some sensitive materials have had some smoke settle on them at the beginning of the cut.

I think that’s where i read about people adding start and end G-code to lightburn, so when they start a job, it sends makes the laser start the job then pause for a second or 2, allowing the fan to spool up, air compressor to start etc, then it runs the actual job,
So having a way to pre-start the extraction may be helpfull even to ruida controller owners?

Ruida controllers don’t use G-Code, but (some) can add delays so the exhaust air blower gets up to speed and clears the fumes at the end:

My KT332N controller has delay settings for both assist air and the exhaust blower, but I use a manual control for the latter. My version of Sadler’s dual-flow assist air plumbing works fine, with the controller set for 1 second on/off delays.

The G-Code commands originally controlling coolant flow have been repurposed for assist air, some controllers have additional (hardware) outputs that can control exhaust blowers (or other things), and all of them have programmable delays. G-Code dates back to the beginning of the CNC machinery era and, believe me, G-Code has capabilities lasers never touch.

If the controller you’re using lacks hardware outputs for your purposes, because the manufacturer has cost-optimized them out of existence in a specific machine, then you need a controller that meets your needs. Configuring that for a specific laser machine it was never intended to control will present a challenge educational opportunity, but will be more straightforward than trying to work around the limitations built into specific hardware.

Doh!.. that’s my adhd mixing things up about how ruida controller work, i thought they could still use the start and end scripts thing that’s in lightburn, but i guess that only shows up when you are using a GRBL controller,

:

i know the solution is to remove the board from my brand new omtech K40+ and replace it with one that can turn outputs on and off from G-code commands, but it’s kind of annoying that we have to do that when the board works with lightburn,

and i know it’s my fault for not doing more research before i bought this thing, i saw that it runs with lightburn straight out of the box and that helped me choose it over a cheaper K40 that i’d need to replace the controller board on just to get lightburn to talk to it, then replace the gantry, mirrors, head, tube mounts etc (and in a way i wish i’d done that, as i’d have done Russ Saddlers K40 extreme mods, but i bought this little laser to use for a year or so until i can get a larger one (something like an omtech 747, or maybe a russ spec laser, and that will have a ruida controller)

What is even more annoying, my board has 3 aux outputs:

But from what i can tell they are used with triggers from the lid switch interlock board to lock the laser out if you lift the lid, making you press the reset button on the laser before it will reset after closing the lid.

Of course there is no info i can find about this board, so it’s very likely those 3 aux outputs could be repurposed to trigger from G-code commands, but without knowing how to change the firmware running on the board we can’t do that,

as you can see from the photo above of my boards 3 aux outputs, i have one free, but i can’t find anything that triggers it yet,
the other 2 go to the relay board that cuts power to the mains relays feeding the HV psu and exhaust fan, but they only seem to trigger when the lid switches are opened.

How good are you at programming? One option is to use a Raspberry Pi as a catch and throw device in the middle of the USB path. That way you can test for specific GCode commands and insert your own commands or use them as a trigger for performing another functions.

What you want to do can be done with some work. We are trying to illustrate just how much work it can be. You have to decide whether you can tolerate manual control or must have automatic operation.

EX1 is an output, but EX2 seems more an input. The circuitry behind those three pins may not be able to do what you want, even if you could tweak the firmware.

There is a large difference between “works with LightBurn” and “doesn’t do this other thing I think it should”. :yin_yang:

IMO, you should spend a year using the machine you have to learn about lasering things, which will teach you about the practicalities and give you a better idea of what you want in your next machine.

I confidently predict: manually turning on the exhaust fan will not be the most annoying task you must deal with. :grin:

1 Like