luc-github / ESP3D

FW for ESP8266/ESP8285/ESP32 used with 3D printer
GNU General Public License v3.0
1.73k stars 464 forks source link

Using with MKS TFT Wifi - Any Success? #249

Closed ZhuDaHai closed 5 years ago

ZhuDaHai commented 5 years ago

Issue #206 was closed back in March concerning using the MKS TFT Wifi board with this ESP3D firmware. I also have the MKS TFT28 display board and the MKS TFT Wifi board, and the default closed-source firmware from MKS is very limited. So I'd like to see if this could work. And so was wondering if you'd made any progress on this and/or if there was anything I could do to help. Thanks! P.S. As a side note, I updated the MKS TFT WIFI board with the ESP3D firmware, but now I cannot go back. I don't know why, but while I can load the original MksWifi.bin file and set the mks_config.txt file on the SD card to update, and it does appear to update, the MKS TFT WIFI board will not switch out of AP mode no matter what I try. Thoughts? Thanks!

luc-github commented 5 years ago

I have a module MKS TFT Wifi but did not have time to study / use it yet because busy with others projects - it is in 2.1 plan list but do not know when I can work on it

About your issue, I guess the bin is not enough may be some settings in EEPROM or SPIFFS was corrupted when flashed ESP3D - it is just a guess

luc-github commented 5 years ago

the best would be to dump the whole flash of working Module (not sure about size) and flash the full binary

ZhuDaHai commented 5 years ago

That worked! I flashed 'EraseFlash', then the stock MksWiFi.bin, then the mks_config.txt file and its back to stock. Thanks! I can go back and forth now while I test. Let me know if I can help with your firmware for the MKS TFT WiFi module. I'm a retired programmer of 30+ years. I don't know jack about this module, but I can still learn :) Maybe point me to the correct code block... Thanks again!

ZhuDaHai commented 5 years ago

I littered your code with LOG command at every ESP_SERIAL_OUT.readBytes command I could find, but nothing I added appeared in the log.txt file - just your stuff. So apparently I haven't a clue where to look. I did find these in the MKS TFT firmware. Maybe they'll help. Just wish I knew where to look for where that would be coming into your code:

at+netmode=%d
 at+dhcpc=%d
   at+wifi_conf=%s,auto,%s
   at+wifi_conf=%s,wpawpa2_aes,%s
    at+net_ip=%s,%s,%s
    at+net_dns=%s,8.8.8.8
 at+remotepro=tcp
  at+mode=server
    at+remoteport=8080
    at+uart=%d,8,n,1
  at+net_commit=1
   at+net_wanip=?
    at+wifi_ConState=?
    at+reconn=1
   at+dhcpd=%d
   at+dhcpd_ip=%s,%s,%s,%s
   at+dhcpd_dns=%s,8.8.8.8

P.S. those ending with ? appear to be queries to the Wifi module, while those with parameters (%s, %d) appear to be settings from the mks_config.txt being passed to the Wifi Module

luc-github commented 5 years ago

Yes as I suspected after few test MKS use AT commands - to query / set wifi parameters. ESP3D does not know AT commands, so it do not answer to any query send by MKSTF,T so TFT thinks there is no wifi.

Need to connect RX/ TX /GND to RX/GND of Serial to USB adapter to visualize the exchange on a Serial Monitor once the communication exchange is known - we can simulate the answers from ESP3D

ZhuDaHai commented 5 years ago

I understand ESP3D doesn't understand at+ commands. Does that mean they are not even read by ESP3D? Which part of the code would be receiving data from the LCD firmware? I thought SP_SERIAL_OUT.readBytes would do it. I guess I just don't get it. Sorry, just trying to help

luc-github commented 5 years ago

Yes ESP_SERIAL_OUT.readBytes just ignore the command as it does not know them need to code proper answer like: if it receive at+net_wanip=? it need to answer for example 192.168.1.4 but currently I do not know what command it could receive and what format it need to use to answer - it could be standard AT or custom AT

ZhuDaHai commented 5 years ago

Well, I got 'something', but it appears the data, parity and/or stop bits don't match. I believe the defaults in serial.begin() are 8N1. So I have no idea what the MKS TFT28 display is expecting:

BRIDGE::processFromSerial2TCP: ø þ?¨ÿ?¬ÿ?G} @@þ?¨ÿ?€ÿÿ?J”!@¤$ÿ?t&ÿ?

Hex:

f8 00 fe 3f a8 02 ff 3f ac 01 ff 3f 47 7d 20 40
40 8d fe 3f a8 02 ff 3f 80 ff ff 3f 4a 94 21 40
a4 24 ff 3f 74 26 ff 3f
luc-github commented 5 years ago

Ok I have some time and checked what TFT is requesting:

at+netmode=2
at+dhcpc=1
at+wifi_conf=NETGEAR_2GEXT_OFFICE2,auto,blabla
at+net_ip=192.168.1.240,255.255.255.0,192.168.1.1
at+net_dns=192.168.3.1,8.8.8.8
at+remotepro=tcp
at+mode=server
at+remoteport=8080
at+uart=115200,8,n,1
at+net_commit=1
at+net_wanip=?
at+net_wanip=?
at+net_wanip=?
at+net_wanip=?
luc-github commented 5 years ago

This is the doc for the wifi module HLK-RM04 user manual.pdf

luc-github commented 5 years ago

But my TTF screen seems not communicating well with the WiFi module the TX seems OK but not RX
I can see the above command sent by TFT

Modules communicated once got connected and right IP, then no more (Only got exception) so hard to continue

ZhuDaHai commented 5 years ago

Thanks for the updates! I plan on working on it this weekend and let you know if I make any progress or not.

luc-github commented 5 years ago

Hi any update on this ?

luc-github commented 5 years ago

My MKS TFT seems not well communicate and no update for a while I close topic - feel free to re-open if any update

luc-github commented 5 years ago

I have ordered a new MKS TFT a v4 this time,I hope this time it will work https://www.aliexpress.com/item/MKS-TFT32-v4-0-touch-screen-MKS-Slot-module-extended-SD-card-reader-splash-lcds-touching/32946735899.html

Valcob commented 5 years ago

just posting in case it may help. So it looks like the MKS WIFI has 2 UARTs setup for communication the one is a normal one UART0 setup on pin TX(label on the wifipcb) goes to RX0(IO3 of the ESP12s) and RX(label on the wifipcb) goes to TX0(IO01 of the ESP12s) and another one UART1 is on TX(mainboard <-> IO0 wifiboard) goes to IO0(ES12s) RX(mainboard <-> IO1 wifiboard) goes to IO4(ESP12s) looks like sw serial here.

So on UART0 when just wifi is connected to usbToSerial converter is image on RX pin of the wifipcb; on TX is nothing , and on UART1 is some rubbish
image

And when connected to main board which is and MKS TFT 3.5 I have this on UART0 from RX wifiboard image the two black rectangles are SSID and pass and at the same time the responses are from the TX pin on wifiboard image

And while still connected to main board on UART1 TX pin of the main board image

And for UART1 RX pin of the main board image with something being continuously written also played with baud rates to get something useful but with no luck

If there is something I can help I would be glad to do so.

luc-github commented 5 years ago

@Valcob interresting what FW version do you have and what settings for wifi ? I just got my MKS TFT32_L V4.0 looks like it has the latest FW 3.03

connector Aux1

? ? ? ?
TX RX GND +5V

connector WiFI

RST RX TX NC
TX RX GND VCC

Connector SD

CS DI
GND V
CLK GND
DO CD

Can you clarify which TX/RX you mentioned ? Thank you Note: I did not connected any WiFi yet - I have the HKL and the ESP

MKS WIFI TFT V1.0

IOO IO1 GND VCC
RST RXD TXD NC

MKS HLK-WIFI V1.1

ES NC GND VCC
TX RX GND VCC
Valcob commented 5 years ago

@luc-github so WIFI pcb is MKS wifi module, TFT is MKS TFT 3.5 with 1.0.2 firmware connector used is WIFI image image

luc-github commented 5 years ago

Ok - will enable WiFi and see if it is better than my previous board MKS TFT32_L V2.0 which did not communicated well

luc-github commented 5 years ago

Ok using MKS TFT WIFI and updating with latest FW it seems working and now I even have a webserver which I did not have before image

Communication with board according config is 250000 and I can see the M105 on Arduino serial so my previous issues were FW and not hardware ...

image

I will dump the MKS WIFI firmware to have a backup - just in case

Valcob commented 5 years ago

can you please share your config for tft ?

#########  Printer type setting  ##################################

#mainboard firmware setting(marlin:1; repetier:2; smoothie:3)
>cfg_firmware_type:1

#machine setting (Normal:1; Delta:2)
>cfg_machine_type:1

#baud rate (9600:1; 57600:2; 115200:3; 250000:4)
>cfg_baud_rate:3
luc-github commented 5 years ago

But I cannot do any telnet action, I have tried different port and connection failed I connected to 192.168.1.25:8080 - connection is accepted but no effect /feedback of any command Here my file : CONFIG.txt

luc-github commented 5 years ago

So I am not sure using wifi bridge is working or need additional setting

Valcob commented 5 years ago

also can you share what wifi binary you are using I cant get a normal output(M105) for some reason (

luc-github commented 5 years ago

I use the one present in https://github.com/makerbase-mks/MKS-TFT

luc-github commented 5 years ago

Version 3.03, the latest

luc-github commented 5 years ago

Looks like they build a cura plugin. Will check it https://github.com/makerbase-mks/Software/blob/master/MKS%20Plugin/MKS%20Plugin3.5↑.rar

Valcob commented 5 years ago

yeah I saw that too and it works I can confirm image

luc-github commented 5 years ago

So cura can send commands using wifi So hope to see in plugin code how to do

luc-github commented 5 years ago

Ok I was able to bridge RX/TX wire and I saw the communication at 115200 baud same as you @Valcob but when checking wires to see which wire is mandatory. the VCC was disconnected and after reconnect fully the MKS TFT WIFI - I loose the wifi connection - but same wifi module was working on other TFT so I have applied the config file again but still not success I could recover only after flashing again the 3.03 FW which means the FW can easily get corrupted

Valcob commented 5 years ago

Yeah have the same issue with the FW the text on UI buttons is gone and it doesn't matter if I reflash the config or both config and TFT bin :(

luc-github commented 5 years ago

I have dumped the MKS WIFI FW so actually the MKS WIFI module is like this: I needed to put IO0 to GND to connect, so IO0 is GPIO0 and I need to connect my Serial adapter RX -> WIFI RX (which is TX) and TX -> WIFI TX (which is RX) IO1 is GPIO4 - verified with multimeter like all others pins

GPIOO GPIO4 GND VCC
RST TXD RXD NC

not sure what GPIO4 is used for

I did not flash back to verify yet, but as I was able to dump the FW. there is no reason flash the dump won't work

luc-github commented 5 years ago

if you want to try, the command to dump esp8266 FW is like this : esptool.py --port COM59 --baud 115200 read_flash 0x00000 0x400000 backpack.bin under windows and esptool.py --port /dev/ttyUSB0 --baud 115200 read_flash 0x00000 0x400000 backpack.bin under linux/OSX change port number according your machine

Valcob commented 5 years ago

@luc-github please be aware that the dump has your wifi creds ;)

luc-github commented 5 years ago

It is test network so it is ok

jamesarm97 commented 5 years ago

Not sure if this helps, it is the "protocol" used when connecting to the ESP over TCP but don't know if it is the same that goes out the serial port. The ESP may just be passing the data straight through to the TFT or may be interpreting it and sending other data. http://osoyoo.com/wp-content/uploads/2016/07/MKS-TFT-Protocol.pdf (using the standard Wifi module with ESP, not the HK module)

luc-github commented 5 years ago

Thank you for sharing -interresting indeed, I was wondering what 997 and 998 commands stand for MKS-TFT-Protocol.pdf

IrishMoss commented 5 years ago

yeah I saw that too and it works I can confirm image Just curious, have you been able to get this plugin working in cura 4.0?

Edit: for anyone interested, there's a modified version of this plugin that works on cura 4.0 https://github.com/makerbase-mks/Software/issues/10

luc-github commented 5 years ago

I have sent email to MKS team (github one) to get help on protocol, let see what they answer.

luc-github commented 5 years ago

I was able to dump communication between TFT and MKS-HLKWIFI module (not esp based) and between TFT and MKS wifi TFT (ESP based) 1 - both use different protocols : MKS-HLKWIFI use at commands MKS -WIFI-TFT use binary and text commands

2 - they use differents pins for RX/TX which means we cannot use MKS-HLKWIFI protocol with MKS-WIFI-TFT module, but MKS-HLKWIFI should be easily replaced by any ESP module

3 - MKS-HLKWIFI protocol looks easy but slower to connect than MKS-WIFI-TFT protocol 4 - Once connected, MKS-HLKWIFI protocol is quiet, only commands are bridged, unlike MKS-WIFI-TFT which is pretty verbose 5 - I was not able to use MKS-WIFI-TFT as a bridge, unlike the MKS-HLKWIFI, I suspect it is only to be used on specific cloud server when MKS-HLKWIFI as no restriction.

Next step will be to add the MKS-HLKWIFI protocol support in ESP3D and test with a standard esp8266.

here the MKS-HLKWIFI communication for reference

[TFT]   at+netmode=2\r\n
[WIFI MODULE]   at+netmode=2\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+dhcpc=1\r\n
[WIFI MODULE]   at+dhcpc=1\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+wifi_conf=YOURSSID,auto,YOURPASSWORD\r\n
[WIFI MODULE]   at+wifi_conf=YOURSSID,auto,YOURPASSWORD\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+net_ip=192.168.3.100,255.255.255.0,192.168.3.1\r\n
[WIFI MODULE]   at+net_ip=192.168.3.100,255.255.255.0,192.168.3.1\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+net_dns=192.168.3.1,8.8.8.8\r\n
[WIFI MODULE]   at+net_dns=192.168.3.1,8.8.8.8\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+remotepro=tcp\r\n
[WIFI MODULE]   at+remotepro=tcp\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+mode=server\r\n
[WIFI MODULE]   at+mode=server\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+remoteport=8080\r\n
[WIFI MODULE]   at+remoteport=8080\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+uart=115200,8,n,1\r\n
[WIFI MODULE]   at+uart=115200,8,n,1\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n
[TFT]   at+net_commit=1\r\n
[WIFI MODULE]   at+net_commit=1\r
[WIFI MODULE]   \r
[WIFI MODULE]   \r\n
[TFT]   at+net_wanip=?\r\n
[WIFI MODULE]   at+net_wanip=?\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   192.168.1.59,255.255.255.0,192.168.1.1\r\n
...
[TFT]   at+net_wanip=?\r\n
[WIFI MODULE]   at+net_wanip=?\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   192.168.1.59,255.255.255.0,192.168.1.1\r\n
[TFT]   at+wifi_ConState=?\r\n
[WIFI MODULE]   at+wifi_ConState=?\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   Connected\r\n
[TFT]   at+reconn=1\r\n
[WIFI MODULE]   at+reconn=1\r
[WIFI MODULE]   \r\n
[WIFI MODULE]   ok\r\n

so it should be easy to reproduce in theory

EDIT: I do not plan to have a support of at commands, just echo them, end back ok and give connected if ESP8266 is connected, I do not plan to support ESP3D wifi configuration using mks_config.txt and corresponding at commands as ESP3D already have configuration commands and webUI

luc-github commented 5 years ago

Support of MKS TFT is now added : https://github.com/luc-github/ESP3D/commit/1d7b3ff83f72d5bc5cc8bc0a525ceda4f2333c02

need to enable

//MKS TFT WIFI support see Wiki for wiring
//#define MKS_TFT_FEATURE

because it is disabled by default boot is slow due to TFT Firmware, it start from disconnected to exception then go to connected like standard MKS-HLKWIFI module, bridge is working - I did not checked web UI yet but it should be ok based on telnet tests I did

I have used a nodemcu connected according :

NC NC NC NC
TX RX GND VCC

if someone could confirm it is working - it would be great Correct IP is displayed - SSID is the one from mks_config.txt not from ESP3D as no way to send such info as far I know

luc-github commented 5 years ago

OK tested with webUI and some features do not work due to MKS TFT FW filter some commands what does not work so far: 1 - positions display M114 does not reach printer so cannot get position 2 - smoothieware may have issue as console commands are filtered (not tested yet) 3 - Printer configuration is not working as M500/M503 etc .. commands are blocked

not sure if this can be handled, may be push issue about filer in MKS as issue with some commands like M114

limited commands seems same as the one described above : MKS-TFT-Protocol.pdf

luc-github commented 5 years ago

Close with limitation due to tft fw

ETE-Design commented 4 years ago

So it is possible to make ESP3D work on MKS TFT2.8 with Wifi module? Can you then make some sort of autodetect, so it only show working stuff on the GUI? And is it possible to print direct from Cura with ESP3D Also, is it just to plug the ESP Module direct in the Screen, or do I need to rewire?

AnHardt commented 4 years ago

Likeliy not The Cure, but cura could be possible. (too slow ;-) )

ETE-Design commented 4 years ago

And how to connect it to Arduino Uno to flash it? Have looked at the video - but can't figure it out...

atsage commented 4 years ago

@luc-github Any news on this? I got one of these modules a while ago and just now getting around to using it. It's pretty horrible on stock firmware and ESP3D would be a huge upgrade.

luc-github commented 4 years ago

It is working but with limitations as I wrote above

atsage commented 4 years ago

Thanks, I thought you meant that you meant nothing worked due to firmware limitations. I'm planning on using Marlin, so the only things that won't work are positions display and printer configuration? If so I'll give it a shot. I'm planning on only using the control panel and sd card panel.

slm4996 commented 4 years ago

Good day, I have successfully flashed ESP3D on the MKS WiFi Robin V1.0 module (https://www.aliexpress.com/item/32816882694.html) used by the Robin Mini board: robin_mini However after enabling MKS_TFT_FEATURE the printer does not see the module as active, and as such is ignoring the commands sent. This module normally runs similiar to the MKS TFT WiFi module in that it opens a wifi to serial bbridge on :8080.

Output from the stock firmware on the TX pin to the printer board is as follows: Mordor <SanitizedWifiPassword>www.baizhon12345678f' HJNLMuserCS1.0.2_180327⸮⸮ M27 M997 M115 ⸮⸮

Maybe this module outputs different responses to the board to tell it that it is connected?

I am fairly new at this ESP stuff, but with a little guidance I am willing to gather any information needed to assist in getting this to work. @luc-github if you are willing to assist, how can I best proceed?

Edit: The firmware is a Marlin 2.x variant, source available here: https://github.com/makerbase-mks/MKS-Robin/tree/master/MKS%20Robin%20Mini