14. Networking and communications¶
This week I worked on defining my interface.
Useful links:¶
Manufacturer of the ESP8266 with OLED display integrated: HELTEC
You`ll find the Wireless Stick description here
Code Example¶
Use the three backticks to separate code.
// Set ledPin according to the request //digitalWrite(ledPin, value); // Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // do not forget this one client.println("<!DOCTYPE HTML>"); client.println("<html>"); /* * int shouldertwist = 1150; int shouldery = 1300; int elbowy = 1430; int wristy = 2150; int wristtwist = 1450; int griper = 1800; */ client.print("My position is: "); client.print(shouldertwist); client.print(", "); client.print(shouldery); client.print(", "); client.print(elbowy); client.print(", "); client.print(wristy); client.print(", "); client.print(wristtwist); client.print(", "); client.print(griper); client.println("."); u8g2.clearBuffer(); u8g2.setFont(u8g2_font_6x12_mr); u8g2.drawStr(0, 7, "My position is:"); u8g2.setCursor(0, 24); u8g2.print(shouldertwist); u8g2.print(", "); u8g2.print(shouldery); u8g2.print(", "); u8g2.print(elbowy); u8g2.setCursor(0, 32); u8g2.print(wristy); u8g2.print(", "); u8g2.print(wristtwist); u8g2.print(", "); u8g2.print(griper); u8g2.sendBuffer(); if(value == 2) { client.print(" Initial Position"); } else{ if(value == 3){ client.print(" Connection OK"); } else { if(value == 4){ client.print("blink8"); } else { if(value == 70){ client.print("Full Vertical"); } else { client.print(" #"); } } } } /* client.println("<a href=\"/LED=ON\"\"><center><button>Turn On </button></a>"); client.println("<a href=\"/LED=Blink4\"\"><button>Blink4 </button></a>"); client.println("<a href=\"/LED=Blink8\"\"><button>Blink8 </button></a>"); client.println("<a href=\"/LED=OFF\"\"><button>Turn Off </button></center></a><br />"); client.println("<a href=\"/FUNCION A EJECUTAR\"\"><center><button>TITULO DEL BOTON</button></a>"); */ client.println("<p><b><h1><center>Numeric Control of the Robotic Arm</center></h1></b></p>"); client.println("<h4><p><left>José Luis Martínez.</left></p></h4>"); client.println("<a href=\"/INITIALPOSITION\"\"><p><center><button>INITIAL POSITION</button></a>"); client.println("<a href=\"/LED=Blink8\"\"><button>Test Connection </button></a>"); client.println("<a href=\"/FULLVERTICAL\"\"><button>FULL VERTICAL</button></center><p></a>"); client.println("<p><b><h5><center>SHOULDER TWIST (#27)</center></h5></b></p>"); client.println("<a href=\"/LEFT1\"\"><center><button>LEFT 1 </button></a>"); client.println("<a href=\"/LEFT2\"\"><button>LEFT 2 </button></a>"); client.println("<a href=\"/LEFT5\"\"><button>LEFT 5 </button></a>"); client.println("<a href=\"/LEFT7\"\"><button>LEFT 10 </button></a>"); client.println("<a href=\"/LEFT8\"\"><button>LEFT 20 </button></a>"); client.println("<a href=\"/LEFT45\"\"><button>LEFT 45 </button></a>"); client.println("<a href=\"/RIGHT45\"\"><button>RIGHT 45</button></a>"); client.println("<a href=\"/RIGHT8\"\"><button>RIGHT 20</button></a>"); client.println("<a href=\"/RIGHT7\"\"><button>RIGHT 10</button></a>"); client.println("<a href=\"/RIGHT5\"\"><button>RIGHT 5 </button></a>"); client.println("<a href=\"/RIGHT2\"\"><button>RIGHT 2 </button></a>"); client.println("<a href=\"/RIGHT1\"\"><button>RIGHT 1 </button></center></a><br />"); client.println("<p><b><h5><center>SHOULDER Y (#31)</center></h5></b></p>"); client.println("<a href=\"/SYUP1\"\"><center><button>UP 1 </button></a>"); client.println("<a href=\"/SYUP2\"\"><button>UP 2 </button></a>"); client.println("<a href=\"/SYUP5\"\"><button>UP 5 </button></a>"); client.println("<a href=\"/SYUP7\"\"><button>UP 10 </button></a>"); client.println("<a href=\"/SYUP8\"\"><button>UP 20 </button></a>"); client.println("<a href=\"/SYUP45\"\"><button>UP 45 </button></a>"); client.println("<a href=\"/SYDOWN45\"\"><button>DOWN 45</button></a>"); client.println("<a href=\"/SYDOWN8\"\"><button>DOWN 20</button></a>"); client.println("<a href=\"/SYDOWN7\"\"><button>DOWN 10</button></a>"); client.println("<a href=\"/SYDOWN5\"\"><button>DOWN 5 </button></a>"); client.println("<a href=\"/SYDOWN2\"\"><button>DOWN 2 </button></a>"); client.println("<a href=\"/SYDOWN1\"\"><button>DOWN 1 </button></center></a><br />"); client.println("<p><b><h5><center>ELBOW Y (#3)</center></h5></b></p>"); client.println("<a href=\"/EYUP1\"\"><center><button>UP 1 </button></a>"); client.println("<a href=\"/EYUP2\"\"><button>UP 2 </button></a>"); client.println("<a href=\"/EYUP5\"\"><button>UP 5 </button></a>"); client.println("<a href=\"/EYUP7\"\"><button>UP 10 </button></a>"); client.println("<a href=\"/EYUP8\"\"><button>UP 20 </button></a>"); client.println("<a href=\"/EYUP45\"\"><button>UP 45 </button></a>"); client.println("<a href=\"/EYDOWN45\"\"><button>DOWN 45</button></a>"); client.println("<a href=\"/EYDOWN8\"\"><button>DOWN 20</button></a>"); client.println("<a href=\"/EYDOWN7\"\"><button>DOWN 10</button></a>"); client.println("<a href=\"/EYDOWN5\"\"><button>DOWN 5 </button></a>"); client.println("<a href=\"/EYDOWN2\"\"><button>DOWN 2 </button></a>"); client.println("<a href=\"/EYDOWN1\"\"><button>DOWN 1 </button></center></a><br />"); client.println("<p><b><h5><center>WRIST Y (#7)</center></h5></b></p>"); client.println("<a href=\"/WYUP1\"\"><center><button>UP 1 </button></a>"); client.println("<a href=\"/WYUP2\"\"><button>UP 2 </button></a>"); client.println("<a href=\"/WYUP5\"\"><button>UP 5 </button></a>"); client.println("<a href=\"/WYUP70\"\"><button>UP 10 </button></a>"); client.println("<a href=\"/WYUP8\"\"><button>UP 20 </button></a>"); client.println("<a href=\"/WYUP45\"\"><button>UP 45 </button></a>"); client.println("<a href=\"/WYDOWN45\"\"><button>DOWN 45</button></a>"); client.println("<a href=\"/WYDOWN8\"\"><button>DOWN 20</button></a>"); client.println("<a href=\"/WYDOWN7\"\"><button>DOWN 10</button></a>"); client.println("<a href=\"/WYDOWN5\"\"><button>DOWN 5 </button></a>"); client.println("<a href=\"/WYDOWN2\"\"><button>DOWN 2 </button></a>"); client.println("<a href=\"/WYDOWN1\"\"><button>DOWN 1 </button></center></a><br />"); client.println("<p><b><h5><center>WRIST TWIST (#11)</center></h5></b></p>"); client.println("<a href=\"/WTFA\"\"><center><button>Wrist Twist Full AntiClock </button></a>"); client.println("<a href=\"/WTC\"\"><button>Wrist Twist Center </button></a>"); client.println("<a href=\"/WTFC\"\"><button>Wrist Twist Full Clock </button></center></a><br />"); client.println("<p><b><h5><center>GRIP (#15)</center></h5></b></p>"); client.println("<a href=\"/GO\"\"><center><button>Grip Open</button </button></a>"); client.println("<a href=\"/GMO\"\"><button>Grip Mid Open </button></a>"); client.println("<a href=\"/GC\"\"><button>Grip Close </button></center></a><br />"); client.println("</html>"); /* client.println("<p><center><button onclick=\"window.location.href='http://192.168.1.17/H'\"> LEFT 1 </button><button onclick=\"window.location.href='http://192.168.1.17/0'\"> LEFT 2 </button><button onclick=\"window.location.href='http://192.168.1.17/G'\"> LEFT 5 </button><button onclick=\"window.location.href='http://192.168.1.17/F'\"> LEFT 10 </button><button onclick=\"window.location.href='http://192.168.1.17/3'\"> LEFT 20 </button><button onclick=\"window.location.href='http://192.168.1.17/E'\"> LEFT 45 </button><button onclick=\"window.location.href='http://192.168.1.17/D'\"> RIGHT 45 </button><button onclick=\"window.location.href='http://192.168.1.17/2'\"> RIGHT 20 </button><button onclick=\"window.location.href='http://192.168.1.17/C'\"> RIGHT 10 </button><button onclick=\"window.location.href='http://192.168.1.17/B'\"> RIGHT 5 </button><button onclick=\"window.location.href='http://192.168.1.17/1'\"> RIGHT 2 </button><button onclick=\"window.location.href='http://192.168.1.17/A'\"> RIGHT 1 </button></center></p>"); client.println("<p><center><button onclick=\"window.location.href='http://192.168.1.17/I'\"> UP 1 </button><button onclick=\"window.location.href='http://192.168.1.17/4'\"> UP 2 </button><button onclick=\"window.location.href='http://192.168.1.17/J'\"> UP 5 </button><button onclick=\"window.location.href='http://192.168.1.17/K'\"> UP 10 </button><button onclick=\"window.location.href='http://192.168.1.17/6'\"> UP 20 </button><button onclick=\"window.location.href='http://192.168.1.17/L'\"> UP 45 </button><button onclick=\"window.location.href='http://192.168.1.17/M'\"> DOWN 45 </button><button onclick=\"window.location.href='http://192.168.1.17/7'\"> DOWN 20 </button><button onclick=\"window.location.href='http://192.168.1.17/N'\"> DOWN 10 </button><button onclick=\"window.location.href='http://192.168.1.17/O'\"> DOWN 5 </button><button onclick=\"window.location.href='http://192.168.1.17/5'\"> DOWN 2 </button><button onclick=\"window.location.href='http://192.168.1.17/P'\"> DOWN 1 </button></center></p>"); client.println("<p><center><button onclick=\"window.location.href='http://192.168.1.17/X'\"> UP 1 </button><button onclick=\"window.location.href='http://192.168.1.17/9'\"> UP 2 </button><button onclick=\"window.location.href='http://192.168.1.17/W'\"> UP 5 </button><button onclick=\"window.location.href='http://192.168.1.17/V'\"> UP 10 </button><button onclick=\"window.location.href='http://192.168.1.17/n'\"> UP 20 </button><button onclick=\"window.location.href='http://192.168.1.17/U'\"> UP 45 </button><button onclick=\"window.location.href='http://192.168.1.17/T'\"> DOWN 45 </button><button onclick=\"window.location.href='http://192.168.1.17/m'\"> DOWN 20 </button><button onclick=\"window.location.href='http://192.168.1.17/S'\"> DOWN 10 </button><button onclick=\"window.location.href='http://192.168.1.17/R'\"> DOWN 5 </button><button onclick=\"window.location.href='http://192.168.1.17/8'\"> DOWN 2 </button><button onclick=\"window.location.href='http://192.168.1.17/Q'\"> DOWN 1 </button></center></p>"); client.println("<p><center><button onclick=\"window.location.href='http://192.168.1.17/f'\"> Up 1 </button><button onclick=\"window.location.href='http://192.168.1.17/p'\"> UP 2 </button><button onclick=\"window.location.href='http://192.168.1.17/e'\"> UP 5 </button><button onclick=\"window.location.href='http://192.168.1.17/d'\"> UP 10 </button><button onclick=\"window.location.href='http://192.168.1.17/r'\"> UP 20 </button><button onclick=\"window.location.href='http://192.168.1.17/c'\"> UP 45 </button><button onclick=\"window.location.href='http://192.168.1.17/b'\"> DOWN 45 </button><button onclick=\"window.location.href='http://192.168.1.17/q'\"> DOWN 20 </button><button onclick=\"window.location.href='http://192.168.1.17/a'\"> DOWN 10 </button><button onclick=\"window.location.href='http://192.168.1.17/Z'\"> DOWN 5 </button><button onclick=\"window.location.href='http://192.168.1.17/o'\"> DOWN 2 </button><button onclick=\"window.location.href='http://192.168.1.17/Y'\"> DOWN 1 </button></center></p>"); client.println("<p><center><button onclick=\"window.location.href='http://192.168.1.17/g'\">Wrist Twist Full AntiClock</button><button onclick=\"window.location.href='http://192.168.1.17/h'\">Wrist Twist Center</button><button onclick=\"window.location.href='http://192.168.1.17/i'\">Wrist Twist Full Clock</button></center></p>")); client.println("<p><center><button onclick=\"window.location.href='http://192.168.1.17/j'\">Grip Open</button><button onclick=\"window.location.href='http://192.168.1.17/k'\">Grip Mid Open</button><button onclick=\"window.location.href='http://192.168.1.17/l'\">Grip Close</button></center></p>")); */
Gallery¶
This is the ESP8266 wirelees stick used:
Here you`ll see the ESP8266 wireless stick broadcasting the I.P. address where the interface/web page is hosted:
And this is my interface: