luizalaquini / esp-cnc

ESP8266's code for connection between server and CNC machine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP CNC

GitHub GitHub repo size GitHub language count GitHub top language GitHub followers

Usage

We are using this code in NodeMCU v3 to communicate our CNC with an online server.

Technologies

  • C++
  • Arduino IDE

Behavior

The esp was programmed with the arduino IDE and has some files. The file esp-cnc.ino is the main one, which has setup and loop structure and simply initializes wi-fi and socket.io and keeps checking if the internet connection is active (trying to reconnect if there is a problem).

The wifi.cpp file is where we enter the name and password of the wifi network that the esp must connect and also where is the logic for making this connection via the library.

The socketio file manages the websocket connection to the server. It is in him that the server URL is placed, along with the default port 80 for HTTP communication and with the path "/socket.io/?EIO=4", necessary for the connection to work. This file also handles the events received by the server, calling the handleEvent function from the gcode.cpp file. This function makes an initial treatment of the received data, verifying if the event received was called “gcode” and sending it to the sendGcode function if be. sendGcode divides the received string with strtok and sends each command separately. As soon as it sends a command, it waits 250ms and stays sending the character “?” which makes the arduino return to the current position of the CNC. When the CNC finishes executing the command, esp sends the next one, repeating the process until the commands are finished.

Developers

About

ESP8266's code for connection between server and CNC machine.

License:MIT License


Languages

Language:C++ 87.9%Language:C 6.8%Language:Python 2.2%Language:Shell 1.6%Language:JavaScript 0.8%Language:HTML 0.6%