Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pySerial to send gcode

This may be a bit of a long shot but I can't figure out the problem here. I'm trying to build an interface on my laptop using tkinter and pySerial to control my 3D-printer. I've got a function that contains this piece of code (Yes, I imported time and serial):

ser = serial.Serial('COM3', 115200)
time.sleep(2)
ser.write(str.encode("G28\r\n"))
time.sleep(1)
ser.close()

This sends the gcode "G28" to the 8bit mainboard of my 3d printer (Ender3), which makes it home. This is very hit and miss however. One time it works, the other it doens't. When it doesn't, it seems to reset/restart the printer. Anyone have a clue what could cause this?

like image 590
Nick Avatar asked Sep 04 '26 20:09

Nick


1 Answers

I have found the problem. Arduino and similar 8bit boards reset when running 'ser.close()'. Removing that line fixed it.

like image 74
Nick Avatar answered Sep 09 '26 00:09

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!