• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Send gcode via ESP32 to Duet wifi.

Scheduled Pinned Locked Moved
Tuning and tweaking
6
30
1.9k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    AverageUser
    last edited by 12 Dec 2019, 10:49

    Is it possible to send gcode from a ESP32 Controller to the Duet Wifi? I need a little kickstart here becuase I dont know where to begin. Thx a lot for your help.

    1 Reply Last reply Reply Quote 0
    • ?
      A Former User
      last edited by 12 Dec 2019, 10:56

      you can enable telnet and send it over wifi or connect to the paneldue serial port. there are a few posts on the forum that show how to do it.

      1 Reply Last reply Reply Quote 0
      • undefined
        AverageUser
        last edited by 12 Dec 2019, 11:04

        Yeah I would like to send it over wifi, but with an ESP32. And that is the problem. I dont know where to start. A simple example would save my life ...

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User
          last edited by 12 Dec 2019, 11:08

          there are examples in the arduino ide even
          https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientBasic/WiFiClientBasic.ino

          1 Reply Last reply Reply Quote 1
          • undefined
            AverageUser
            last edited by AverageUser 12 Dec 2019, 11:45 12 Dec 2019, 11:35

            Ohh I know how to make http POST/GET requests with the wifi.h. But how do i channel it to the duet wifi? Do i have to type in the IP-Address of the Duet wifi as the destination for the http request?!?

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User
              last edited by 12 Dec 2019, 11:46

              Use the IP address of the Duet.

              But instead of HTTP requests you can enable telnet and connect to the telnet port and send GCODE directly instead of dealing with the DWC API

              undefined 1 Reply Last reply 13 Dec 2019, 14:06 Reply Quote 0
              • ?
                A Former User
                last edited by 12 Dec 2019, 13:13

                i just want a simple led to turn on, when i press a button on the esp32... and it has to be via wlan

                in that case the easiest is probably to stick with HTTP towards the IP of your Duet.

                first you'll need to set up means to turn your led on and off; by means of a fan output M106 or a gpio M42 (<- click links to learn more)

                Then simply sent the HTTP request to run the GCODE needed to turn the LED on.

                to use Fan2 output
                client.print("GET /rr_gcode?gcode=M106%20P2%20S1 HTTP/1.0\n\n");
                or to use M42 with the same Fan2 outut (but not as a fan)
                client.print("GET /rr_gcode?gcode=M42%20P22%20S1 HTTP/1.0\n\n");

                1 Reply Last reply Reply Quote 2
                • undefined
                  AverageUser
                  last edited by 12 Dec 2019, 14:56

                  Thank you very much!!!!

                  1 Reply Last reply Reply Quote 0
                  • ?
                    A Former User
                    last edited by 12 Dec 2019, 15:08

                    simple ESP32 code to send g-code to duet

                    #include <WiFi.h>
                    #include <WiFiClient.h>
                    #include <ESPmDNS.h>
                    const int led = 5;
                    const char* ssid = "ccc";
                    const char* password = "pass";
                    //const char* host = "192.168.1.115";
                    const char* host = "ender5.local.lan";
                    const int port = 23;
                    int l = 0;
                    int potValue = 0;
                    WiFiClient client;
                    int sendGcode(char * gcode){
                    unsigned long timeout;
                    int ret;
                    ret = 1;
                    client.print( String(gcode) + "\r\n" );
                    timeout = millis();
                    while (client.available() == 0) {
                    if (millis() - timeout > 5000) break;
                    }
                    while(client.available()) {
                    String line = client.readStringUntil('\r');
                    Serial.print(line);
                    if (line.startsWith("ok")) ret = 0;
                    if (line.startsWith("\nok")) ret = 0;
                    if (line.startsWith("\r\nok")) ret = 0;
                    }
                    return(ret);
                    }
                    void setup()
                    {
                    pinMode(led, OUTPUT);
                    digitalWrite(led, 0);
                    Serial.begin(115200);
                    delay(10);
                    Serial.print("Connecting to ");
                    Serial.println(ssid);
                    WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
                    WiFi.mode(WIFI_AP);
                    if (MDNS.begin("pendantDue")) {
                    Serial.println("MDNS responder started");
                    }
                    WiFi.begin(ssid, password);
                    while (WiFi.status() != WL_CONNECTED) {
                    delay(500);
                    Serial.print(".");
                    }
                    Serial.println("WiFi connected");
                    Serial.print("IP address: ");
                    Serial.println(WiFi.localIP());
                    delay(1000);
                    Serial.print("connecting to ");
                    Serial.print(host);
                    Serial.print(":");
                    Serial.println(port);
                    if (!client.connect(host, port)) {
                    Serial.println("connection failed");
                    while(1){
                    digitalWrite(led, 0);
                    delay(500);
                    digitalWrite(led, 1);
                    delay(500);
                    }
                    return;
                    }
                    Serial.print("CONNECTED to ");
                    Serial.print(host);
                    Serial.print(":");
                    Serial.println(port);
                    }
                    void loop()
                    {
                    delay(5000);
                    sendGcode("M115");
                    }
                    undefined 1 Reply Last reply 12 Dec 2019, 15:10 Reply Quote 2
                    • undefined
                      AverageUser @A Former User
                      last edited by 12 Dec 2019, 15:10

                      @smece thx a lot.. that really saves me from wandering through github and places in the internet where my mind is not suited for. ^^ (smece-- funny name. means garbage in croatian language)

                      ? 1 Reply Last reply 12 Dec 2019, 15:14 Reply Quote 0
                      • ?
                        A Former User @AverageUser
                        last edited by A Former User 12 Dec 2019, 15:32 12 Dec 2019, 15:14

                        @flipil said in Send gcode via ESP32 to Duet wifi.:

                        smece-- funny name. means garbage in croatian language)

                        znači i kod nas na istoku πŸ™‚

                        thx a lot.. that really saves me from wandering

                        you are welcome, I started making a pendant for duet with esp32 so that's the initial test how to talk to it πŸ˜„

                        note that if you don't close the connection client.stop(); it can "block" as it looks like duet is listening only with one or two threads ... you might want to change to open connection to send gcode and immediately close if you don't plan to send many commads

                        1 Reply Last reply Reply Quote 1
                        • undefined
                          AverageUser
                          last edited by 13 Dec 2019, 13:18

                          Hvala ti puno smece πŸ˜„ spasio si mi zivot. πŸ˜„

                          1 Reply Last reply Reply Quote 0
                          • undefined
                            Danal @A Former User
                            last edited by Danal 13 Dec 2019, 14:06

                            @bearer said in Send gcode via ESP32 to Duet wifi.:

                            But instead of HTTP requests you can enable telnet and connect to the telnet port and send GCODE directly instead of dealing with the DWC API

                            Just note for the future: Telnet is going away in Duet/RepRap V3 firmware.

                            For that matter, so are RR_whatever HTTP calls. Moving to websocket.

                            Delta / Kossel printer fanatic

                            ? ? 2 Replies Last reply 13 Dec 2019, 16:41 Reply Quote 0
                            • ?
                              A Former User @Danal
                              last edited by 13 Dec 2019, 16:41

                              @Danal said in Send gcode via ESP32 to Duet wifi.:

                              For that matter, so are RR_whatever HTTP calls. Moving to websocket.

                              WHY oh WHY ?!

                              adding websocket is ok, but removing telnet ?!?!?! why ?

                              1 Reply Last reply Reply Quote 0
                              • undefined
                                Danal
                                last edited by 13 Dec 2019, 17:15

                                That was pretty much my question to DC42. Perhaps if we both asked nicely, he'd reconsider.

                                Delta / Kossel printer fanatic

                                T3P3Tonyundefined 1 Reply Last reply 13 Dec 2019, 23:01 Reply Quote 0
                                • T3P3Tonyundefined
                                  T3P3Tony administrators @Danal
                                  last edited by 13 Dec 2019, 23:01

                                  @Danal @smece on Duet 3 you have all the connection options of whatever SBC you use. So SSH into it if you wish.

                                  www.duet3d.com

                                  ? 1 Reply Last reply 14 Dec 2019, 01:33 Reply Quote 0
                                  • ?
                                    A Former User @T3P3Tony
                                    last edited by 14 Dec 2019, 01:33

                                    @T3P3Tony said in Send gcode via ESP32 to Duet wifi.:

                                    @Danal @smece on Duet 3 you have all the connection options of whatever SBC you use. So SSH into it if you wish.

                                    so telnet is not going away?

                                    1 Reply Last reply Reply Quote 0
                                    • ?
                                      A Former User
                                      last edited by 14 Dec 2019, 01:45

                                      @smece said in Send gcode via ESP32 to Duet wifi.:

                                      so telnet is not going away?

                                      with respect to Duet 3 + SBC telnet is already gone, unless you cobble together something like socat and the command line client

                                      ? 1 Reply Last reply 14 Dec 2019, 05:28 Reply Quote 0
                                      • ?
                                        A Former User @A Former User
                                        last edited by 14 Dec 2019, 05:28

                                        @bearer said in Send gcode via ESP32 to Duet wifi.:

                                        with respect to Duet 3 + SBC telnet is already gone

                                        dunno what's SBC but I'm running RRF3 on Duet2Eth and telnet is still here

                                        ? 1 Reply Last reply 14 Dec 2019, 08:10 Reply Quote 0
                                        • ?
                                          A Former User @A Former User
                                          last edited by 14 Dec 2019, 08:10

                                          @smece said in Send gcode via ESP32 to Duet wifi.:

                                          dunno what's SBC but I'm running RRF3 on Duet2Eth and telnet is still here

                                          Duet 3 as in 3rd generation hardware not firmware, and SBC refers to a single board computer like the raspberry pi.

                                          ? 1 Reply Last reply 14 Dec 2019, 09:35 Reply Quote 0
                                          4 out of 30
                                          • First post
                                            4/30
                                            Last post
                                          Unless otherwise noted, all forum content is licensed under CC-BY-SA