Skip to main content
added 38 characters in body; edited title
Source Link
Aurora0001
  • 18.5k
  • 13
  • 54
  • 169

Connect cncCNC machine to AWS IOTIoT

iI want to connect my cncCNC machine with aws iotAWS IoT within a system that contains a robotic arm and sensor ,the cnc. The CNC machine is connected to a laptop and runs with a pythonPython code  . so iI want to use mqttMQTT to make cnc asthe CNC machine a publisher and subscriber but iI don't know how to do that ,here. Here is the cnc pythonCNC Python code.

import serial
import time

# Open grbl serial port
s = serial.Serial('COM3',9600)

# Open g-code file
f = open('grbl.gcode.txt','r');

# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2)   # Wait for grbl to initialize 
s.flushInput()  # Flush startup text in serial input

# Stream g-code to grbl
for line in f:
    l = line.strip() # Strip all EOL characters for consistency
    print 'Sending: ' + l,
    s.write(l + '\n') # Send g-code block to grbl
    grbl_out = s.readline() # Wait for grbl response with carriage return
    print ' : ' + grbl_out.strip()

# Wait here until grbl is finished to close serial port and file.
raw_input("  Press <Enter> to exit and disable grbl.") 

# Close file and serial port
f.close()
s.close()  
import serial
import time

# Open grbl serial port
s = serial.Serial('COM3',9600)

# Open g-code file
f = open('grbl.gcode.txt','r');

# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2)   # Wait for grbl to initialize 
s.flushInput()  # Flush startup text in serial input

# Stream g-code to grbl
for line in f:
    l = line.strip() # Strip all EOL characters for consistency
    print 'Sending: ' + l,
    s.write(l + '\n') # Send g-code block to grbl
    grbl_out = s.readline() # Wait for grbl response with carriage return
    print ' : ' + grbl_out.strip()

# Wait here until grbl is finished to close serial port and file.
raw_input("  Press <Enter> to exit and disable grbl.") 

# Close file and serial port
f.close()
s.close()  

Connect cnc machine to AWS IOT

i want to connect my cnc machine with aws iot within a system contains a robotic arm and sensor ,the cnc machine is connected to laptop and runs with a python code  . so i want to use mqtt to make cnc as a publisher and subscriber but i don't know how to do that ,here is the cnc python code.

import serial
import time

# Open grbl serial port
s = serial.Serial('COM3',9600)

# Open g-code file
f = open('grbl.gcode.txt','r');

# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2)   # Wait for grbl to initialize 
s.flushInput()  # Flush startup text in serial input

# Stream g-code to grbl
for line in f:
    l = line.strip() # Strip all EOL characters for consistency
    print 'Sending: ' + l,
    s.write(l + '\n') # Send g-code block to grbl
    grbl_out = s.readline() # Wait for grbl response with carriage return
    print ' : ' + grbl_out.strip()

# Wait here until grbl is finished to close serial port and file.
raw_input("  Press <Enter> to exit and disable grbl.") 

# Close file and serial port
f.close()
s.close()  

Connect CNC machine to AWS IoT

I want to connect my CNC machine with AWS IoT within a system that contains a robotic arm and sensor. The CNC machine is connected to a laptop and runs with Python code. I want to use MQTT to make the CNC machine a publisher and subscriber but I don't know how to do that. Here is the CNC Python code.

import serial
import time

# Open grbl serial port
s = serial.Serial('COM3',9600)

# Open g-code file
f = open('grbl.gcode.txt','r');

# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2)   # Wait for grbl to initialize 
s.flushInput()  # Flush startup text in serial input

# Stream g-code to grbl
for line in f:
    l = line.strip() # Strip all EOL characters for consistency
    print 'Sending: ' + l,
    s.write(l + '\n') # Send g-code block to grbl
    grbl_out = s.readline() # Wait for grbl response with carriage return
    print ' : ' + grbl_out.strip()

# Wait here until grbl is finished to close serial port and file.
raw_input("  Press <Enter> to exit and disable grbl.") 

# Close file and serial port
f.close()
s.close()  
Source Link

Connect cnc machine to AWS IOT

i want to connect my cnc machine with aws iot within a system contains a robotic arm and sensor ,the cnc machine is connected to laptop and runs with a python code . so i want to use mqtt to make cnc as a publisher and subscriber but i don't know how to do that ,here is the cnc python code.

import serial
import time

# Open grbl serial port
s = serial.Serial('COM3',9600)

# Open g-code file
f = open('grbl.gcode.txt','r');

# Wake up grbl
s.write("\r\n\r\n")
time.sleep(2)   # Wait for grbl to initialize 
s.flushInput()  # Flush startup text in serial input

# Stream g-code to grbl
for line in f:
    l = line.strip() # Strip all EOL characters for consistency
    print 'Sending: ' + l,
    s.write(l + '\n') # Send g-code block to grbl
    grbl_out = s.readline() # Wait for grbl response with carriage return
    print ' : ' + grbl_out.strip()

# Wait here until grbl is finished to close serial port and file.
raw_input("  Press <Enter> to exit and disable grbl.") 

# Close file and serial port
f.close()
s.close()