Author Topic: Wifi connection first test ..  (Read 2165 times)

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Wifi connection first test ..
« on: June 30, 2017, 01:11:50 PM »
This might take me a day or two so will edit this post as I go..

Adding wifi, there are many ways to do this but this is the version I am going with. I have been using ESP8266's for a few years now so I get this is going to look confusing if you have never heard of them .. will try to make it as simple as possible.

These guys have recently brought out a 32 bit version so these have dropped in price, I am using one of these basically..

https://www.aliexpress.com/item/Free-Shipping-Lua-Nodemcu-ESP-12F-WIFI-Network-Development-Board-Module-Based-ESP8266/32740698081.html

So what follows is how I go adding wifi using one of these Node MCU ESP8266 4MB modules.

First things first .. plug module into USB (micro usb)
download one of the TGZ's at https://github.com/jeelabs/esp-link/releases I used the 3.0.14 version (last stable)

Follow instructions in flashing.md you will need a flashing tool, grab the one here .. https://espressif.com/en/support/download/other-tools
I am not sure if that is the one I am using, if so .. then in configuration set the filenames and addresses as required according to flashing.md .. the addresses autofilled for me anyway.
Change options to a 4MB flash if that is what you have, hit "flash" and wait a minute..

You can open a terminal window to the com port the ESP is using at 115k and check debug info. Mine said .. (the number is a millisecond time stamp)

Code: [Select]
111> Flash config restore *FAILED*                                           
   111> CONN led=0                                                             
   111> SER led=14                                                             
   113> Wifi init, mode=AP                                                     
   115> Wifi uses DHCP, hostname=esp-link                                       
   119> "ip": "0.0.0.0"                                                         
   121> "netmask": "0.0.0.0"                                                   
   124> "gateway": "0.0.0.0"                                                   
   126> "hostname": "<null>"                                                   
   129> sleep enable,type: 2                                                   
   132> Httpd init, conn=0x3fff3820                                             
   135> No user file system found!                                             
   138> Serbridge pins: reset=12 isp=13 swap=0                                 
   151> Reset cause: 6=external                                                 
   151> exccause=0 epc1=0x0 epc2=0x0 epc3=0x0 excvaddr=0x0 depc=0x0             
   151> Flash map 4MB:512/512, manuf 0xE0 chip 0x4016                           
   156> ** esp-link v3.0.14-g963ffbb: ready, heap=21368                         
   161> SNTP timesource set to us.pool.ntp.org with offset 0                   
   166> initializing user application                                           
   169> Waiting for work to do...                                               
   172> mode : softAP(a2:20:a6:0d:d2:1a)                                       
   176> add if1                                                                 
   178> dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)   
   186> bcn 100                                                                 
 15132> Wifi check: mode=AP status=255                                         


Then using an ipad or tablet/phone open the new wifi you will have (mine was called ESP_0DD21A) then open the browser and connect to 192.168.4.1

debug now reports

Code: [Select]
581578> add 1                                                                   
581578> aid 1                                                                   
581578> station: 1c:ab:a7:b3:cf:1c join, AID = 1                               
581579> Wifi AP: station 1c:ab:a7:b3:cf:1c joined, AID = 1                     
605137> HTTP GET /: 302, 21ms, h=18904                                         
605242> HTTP GET /home.html: 200, 31ms, h=18904                                 
605737> HTTP GET /style.css: 200, 37ms, h=14848                                 
605751> HTTP GET /ui.js: 200, 51ms, h=16544                                     
605755> HTTP GET /pure.css: 200, 56ms, h=18184                                 
605799> HTTP GET /favicon.ico: 200, 64ms, h=18904                               
606248> HTTP GET /menu: 200, 42ms, h=16728                                     
606249> HTTP GET /wifi/info: 200, 42ms, h=16920                                 
606249> HTTP GET /system/info: 200, 42ms, h=17120                               
606262> HTTP GET /pins: 200, 54ms, h=18032                                     
                           
and ipad now has an open page to configuration..

open "wifi station" page

where it says "wifi association", select the switch to "STA+AP_mode to scan" link

scan and select the wifi network you want to use ..

note the IP address it tells you up top after it has connected and rebooted.

You can now connect back to your normal wifi and browse to the IP it gave you above, mine was 192.168.1.105

You are now connected back to the device via your wifi and it has disabled its own wifi server. (now ins STA mode, station instead of STA+AP)


You will not see debugging on the terminal any longer..
Code: [Select]
903711> Scan done: found 2 APs                                                 
903711> bss1: Lounge2 (-53)                                                     
903711> bss2: no_free_lunch (-83)                                               
904437> GET scan: cgiData=0 noAps=2                                             
904446> GET scan: cgiData=1 noAps=2                                             
904450> HTTP GET /wifi/scan: 200, 18ms, h=17616                                 
904498> HTTP GET /wifi/icons.png: 200, 12ms, h=17616                           
915801> Wifi check: mode=AP+STA status=0                                       
915801> Enabling/continuing uart log                                           
924513> HTTP POST /wifi/scan: 200, 9ms, h=17584                                 
924711> Starting a scan                                                         
926835> Wifi try to connect to AP Lounge2 pw *******                     
926838> scandone                                                               
926838> Scan done: found 2 APs                                                 
926838> bss1: Lounge2 (-55)                                                     
926838> bss2: no_free_lunch (-87)                                               
926842> HTTP POST /wifi/connect: 200, 31ms, h=17592                             
927574> GET scan: cgiData=0 noAps=2                                             
927578> GET scan: cgiData=1 noAps=2                                             
927581> HTTP GET /wifi/scan: 200, 12ms, h=17616                                 
927835> Wifi changing association                                               
930101> scandone                                                               
930501> switch to channel 6                                                     
930503> state: 0 -> 2 (b0)                                                     
930505> state: 2 -> 3 (0)                                                       
930506> state: 3 -> 5 (10)                                                     
930507> add 0                                                                   
930507> aid 3                                                                   
930507>                                                                         
930507> connected with Lounge2, channel 6                                       
930635> dhcp client start...                                                   
930636> cnt                                                                     
930637> Wifi connected to ssid Lounge2, ch 6                                   
930911> HTTP GET /wifi/connstatus: 200, 8ms, h=17144                           
931724> ip:192.168.1.105,mask:255.255.255.0,gw:192.168.1.1                     
931725> Wifi got ip:192.168.1.105,mask:255.255.255.0,gw:192.168.1.1             
931727> host_name = esp-link                                                   
931729> server_name = _http._tcp.local                                         
931955> HTTP GET /wifi/connstatus: 200, 16ms, h=16808                           
947765> HTTP POST /wifi/scan: 200, 7ms, h=16792                                 
947962> Starting a scan                                                         
948812> GET scan: cgiData=0 noAps=2                                             
948815> HTTP GET /wifi/scan: 200, 8ms, h=16744                                 
950091> scandone                                                               
950092> Scan done: found 2 APs                                                 
950092> bss1: Lounge2 (-55)                                                     
950092> bss2: no_free_lunch (-87)                                               
950864> GET scan: cgiData=0 noAps=2                                             
950867> GET scan: cgiData=1 noAps=2                                             
950872> HTTP GET /wifi/scan: 200, 13ms, h=16808                                 
971106> HTTP POST /wifi/scan: 200, 9ms, h=16792                                 
971304> Starting a scan                                                         
972156> GET scan: cgiData=0 noAps=2                                             
972159> HTTP GET /wifi/scan: 200, 7ms, h=16744                                 
973279> GET scan: cgiData=0 noAps=2                                             
973433> scandone                                                               
973433> Scan done: found 2 APs                                                 
973434> bss1: Lounge2 (-53)                                                     
973434> bss2: no_free_lunch (-88)                                               
973981> HTTP GET /wifi/scan: 200, 708ms, h=16808                               
975028> GET scan: cgiData=0 noAps=2                                             
975032> GET scan: cgiData=1 noAps=2                                             
975037> HTTP GET /wifi/scan: 200, 15ms, h=16808                                 
987974> Wifi check: mode=AP+STA status=5                                       
987975> Wifi got IP. Going into STA mode..                                     
987975> station: 1c:ab:a7:b3:cf:1c leave, AID = 1                               
987978> rm 1                                                                   
987979> bcn 0                                                                   
987980> del if1                                                                 
987982> pm open,type:2 0                                                       
987984> mode : sta(a0:20:a6:0d:d2:1a)                                           
988108> Turning OFF uart log                                                   
                             

I turned off the ipad and opened the page on the PC instead  .. photo 1

I suggest setting your router to configure this device as a static IP.

for my router, I go to DHCP clients list, copy the MAC address, then address reservations, paste the MAC address and the current IP and hit "enable" and now esp-link (can change name later) will always be the same IP.

At this point I disconnected the esp from USB and wired it to the Mana SE bluetooth port.
5v (pin closest to drivers) to Vin
Gnd to gnd
Tx - Tx
Rx - RX

I know the serial looks counterintuitive but that is the way the pins are marked on the mana se, so tx is tx of the FTDI chip and Rx of the nano..

The 5v on this port comes from the onboard regulator of the mana SE so there is no power when the power switch is off and the nano is powered. More on this later .. the nano will need to be swapped to this power also.

Turned power switch on and make sure you can still connect to the esp-link board...

Then open the uC console page and type "$$" in "console entry" and send it .. you should see the grbl data echoed back.. photo 2
congrats, hardware is done, you are well on the way ..

(maybe: Note to self check nodemcu for resistive divider on both rx and tx pins, a brief glance shows a 470R to the sub chip but none to the ESP12 module, the ESP may have only a divider on the RX from memory, which is fine, the nano 5v Tx is going to the esp rx line)

next step likely not needed so spoiled for the moment..
[spoiler]
Next step, we have a functioning wifi device that can talk to the laser via serial, we need PC side software so things like T2 think they are talking to a serial port when in reality it is going out over wifi.
So for this step I am using Com0Com .. you want the signed version available here http://pete.akeo.ie/2011/07/com0com-signed-drivers.html google "com0com signed" for alternate copys.

instructions ..  http://com0com.sourceforge.net/doc/UsingCom0com.pdf

Opened com0com setup and I used virtual pair 0, click on "use ports class" for the 2 entrys if not already ticked, hit apply and you should see a driver installation message and a new com port will appear. mine is COM19 and COM20..

(note to self, not sure com0com is required yet)
[/spoiler] .. doh, no spoilers..

We need Com2Tcp .. I used this version http://www.astrogeeks.com/AstroGeeks/COM2TCP/download.html (made me nervous so used an online virus scanner and had one 1/57 false positives), I will let you know if my PC explodes (by using my ipad)

once installed it opens a little window up top left, set the com port to an unused one if not already filled in, mine is COM4, set IP to the esp link device and port to 23.

this then connected ..

opened a realterm window and opened com4 at 115k, typed $$ and got the grbl data back .. good sign.

close realterm .. open T2 and connect to the chosen comport..

odd, right click on home is not resetting the XY to 0. Y always sets to 32 or 72 ?? latency issue ?

"display grbl parameters" however is working.

loaded the TEXT_COLOURS.dxf and set laser to 200, preview frame looked ok, hit go..

etched the letters on some ply well except for one glitch .. it stopped a couple of times at the start of one letter and tried burning a hole straight through my ply for a few seconds, so I am guessing
that we are not getting the throughput grbl needs ?

but .. it is working over wifi..

tomorrow will power the nano from 5v and unplug the cable I think, though this stopping and burning issue might be a deal breaker, may try bluetooth tomorrow and see if any better..

edit: as Zax moted below, enable dynamic laser power, this will turn off the laser if buffer emptys (off or compile time minimmum ?) .. disable fast status.


-----------------------------------------------------

day 2 ..

Did some research, removed the nano and soldered the jumper underneath on my board, this connects the nano 5v regulator output with the onboard 5v supply and means the nano no longer needs USB power, not sure if all Manas have this jumper..  (photo3 .. it has been soldered)

Turned on power, open Com2TCP, hit connect, open T2, connect to com4 and off it went.

Disabled fast status, position is still reported incorrectly though,the odd thing though I can open the console in the browser and see that WCO is being correctly reported, T2 machine position is correct at all times, it just seems to have a problem reading the WCO parameter. In fact X pos stays at 0 and Y pos which is displayed is the machine position.



from console ..

<Idle|MPos:105.000,-45.000,0.000|Bf:15,128|FS:0,0>
<Idle|MPos:105.000,-45.000,0.000|Bf:15,128|FS:0,0|WCO:100.000,-50.000,0.000>
<Idle|MPos:105.000,-45.000,0.000|Bf:15,128|FS:0,0|Ov:100,100,100>
<Idle|MPos:105.000,-45.000,0.000|Bf:15,128|FS:0,0>


T2 is reporting ..
 machine pos 105.0 and -45.0
work pos 0.0 and -45.0 (should be 5,5 from above values  I think)

no big deal, setting the work pos works, just the reported work value is incorrect.

Anyway, all good, I could now put the laser in another room of the house if I so desired, which I dont right this minute.. this was more an experiment for the plasma cutter in future since moving my PC to the shed is not an option and neither is moving my plasma cutter into the house..





« Last Edit: July 01, 2017, 03:50:32 AM by Stonemull »
A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #1 on: June 30, 2017, 01:25:23 PM »
Disable "Fast Status" in the settings, that will reduce the bandwidth.

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Re: Wifi connection first test ..
« Reply #2 on: June 30, 2017, 01:26:59 PM »
roger, will do tomorrow.

seems grbl could do with an option to turn off the laser when the buffer emptys. not looked, maybe it has one..

A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #3 on: June 30, 2017, 01:27:48 PM »
Enable "Dynamic Laser Power" in the settings  ;D

(I know, I have a setting for everything)

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Re: Wifi connection first test ..
« Reply #4 on: June 30, 2017, 01:36:58 PM »
of course, that'll work hey.
A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #5 on: June 30, 2017, 01:43:18 PM »
If the laser stops it will automatically go to 0 power and prevent the hole in your waste board or worse dining room table.

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Re: Wifi connection first test ..
« Reply #6 on: July 01, 2017, 03:51:18 AM »
updated first post with todays results
A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #7 on: July 01, 2017, 04:35:56 AM »
Without fast status you only get an update to workpiece coordinates every second or so but it should still update.

So I think maybe you have an offset programmed in Grbl.

Use Clear Grbl Positions (in the Machine menu) to check.

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Re: Wifi connection first test ..
« Reply #8 on: July 01, 2017, 04:50:08 AM »
I have no offsets that I know of, its wierd though.

I just etched an image but I had the Y steps incorrect, everything went fine and T2 went 'ding'. I noticed steps were wrong so set them correctly, moved a bit and re etched the same image without leaving the laser control.
This time the image was the correct size and completed (I think) the progress bar was at 100% but there was no ding, T2 would not respond, I hit "Reset uC" in the web console window, I figured it will not do anything anyway since the reset line is not connected, next I hit the the big red button in T2, I get the grbl sign on message ??

Then I noticed the work coordinates have changed .. so I jogged and sure enough the work position is now displaying correctly.

This is the debug window in T2 .. from when I hit the button.

Sending Aborted
M03 S0
M05
Grbl 1.1f ['$' for help]
$$
G91G01X5F2000
G91G01Y-5F2000
G91G01Y-5F2000
G92X0Y0
Origin Set (Home)
G91G01Y5F2000
G91G01X5F2000


So I am thinking that maybe T2 needs that initial connection reboot for some reason, is there a sync there somewhere ?
I might connect up the reset line and see if it makes any difference.
A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #9 on: July 01, 2017, 05:15:54 AM »
Does your connection have some buffering or is it direct?

There should be no sync. T2Laser sends commands and looks for the "ok" response to know it was executed, and requests the machine status to update coordinates. It isn't trying to sync a status request to a response, it just deals with the received data based on what it gets.

If it doesn't finish (ding) but shows 100% sent, that means an "ok" was lost and it thinks Grbl is still processing. You can try low buffer mode which will prevent it filling Grbl's RX buffer and instead send individual commands and wait for their acknowledgement but this will likely make the pausing worse.

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Re: Wifi connection first test ..
« Reply #10 on: July 01, 2017, 05:55:16 AM »
There has to be buffering just for the nature of serial to TCP, com2TCP it would wait a certain time collecting serial data till there was a gap is my guess. It could wait for a cr/lf perhaps and also send when it has a packet but usual method would be to wait for a gap. Then the esp-link probably does the same at the other end for the grbl responses.

looking at the console if I send a '?' it takes about 2 seconds before I get the response.

A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #11 on: July 01, 2017, 06:01:38 AM »
That's quite a bit of lag but shouldn't present any problems providing nothing get's lost.

Since you were able to successfully send a job it sounds like the solution is viable.

Stonemull

  • Hero Member
  • *****
  • Posts: 889
    • View Profile
Re: Wifi connection first test ..
« Reply #12 on: July 01, 2017, 06:16:24 AM »
Yeh it seems to work, I have now connected up a reset line .. cause GPIO5 is of course D1 on a nodeMCU, I need to restart com2TCP after each power on or there is no comms despite it saying COM4 is fine.
What I have found is T2 will not give correct work position until I reset the nano with the console button, once that is done, then it works fine.

What I suspect is happening is that T2 sends commands and is getting an 'ok' response from several commands previously due to lag, maybe the reset and grbl reset message allows it to to sync, perhaps just the 2 second delay as grbl initialises even ?

A3 Eleksmaker 2500mW
Solidoodle V2 Pro
Wanhao I3+ touch
Hacked Roland DXY-880
CNC3018 engraver
CNC Plasma (work in progress)

Zax

  • T2Laser
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6244
    • View Profile
    • T2Laser
Re: Wifi connection first test ..
« Reply #13 on: July 01, 2017, 06:27:59 AM »
That could be, but it should still receive the most recent status string and update even if there's a lag.

Can you send a soft reset (left click the red button) to get it in sync?

ggallant571

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2407
    • View Profile
Re: Wifi connection first test ..
« Reply #14 on: July 01, 2017, 06:38:57 AM »
I suspect it would be safer to transmit packets of gcode and let the remote node buffer and interface with the laser controller. To use with existing host software (T2 & company) the remote would need to emulate the expected response and reply as if the command were completed successfully.

Would also be nice if the remote node or the embedded  gcode interpreter (GRBL) could detect stalled data transmissions conditions and force the laser off.

I really like this concept. With it and a big battery the laser etcher/cutter could be easily moved outside when working with nasty materials. Keep us posted!!
SARCASM - Just one more service we offer here.