Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By jlawton
#93787 So in order to get websocket Wi-Fi working on my CNC engraver, I got an ESP-01 board containing a ESP8266 and I tried to build the "websocket" sketch on Arduino following exactly the instructions on https://lasergrbl.com/usage/wifi-with-esp8266/.
Unfortunately it did not compile and as I do not have a lot of experience with this codebase, I'm unsure what to do about it. What I've posted below are the error messages, can anyone tell me how to fix them?

webserver:90:34: error: 'WStype_t' has not been declared
90 | void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght)
| ^~~~~~~~
webserver:162:6: error: redefinition of 'void setup()'
162 | void setup()
| ^~~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\sketch_mar01a.ino:1:6: note: 'void setup()' previously defined here
1 | void setup() {
| ^~~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\webserver.ino: In function 'void setup()':
webserver:169:37: error: cannot convert '<unresolved overloaded function type>' to 'WebSocketsServerCore::WebSocketServerEvent' {aka 'std::function<void(unsigned char, WStype_t, unsigned char*, unsigned int)>'}
169 | webSocket.onEvent(webSocketEvent);
| ^
In file included from C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\webserver.ino:5:
C:\Users\New\Documents\Arduino\libraries\WebSockets\src/WebSocketsServer.h:50:39: note: initializing argument 1 of 'void WebSocketsServerCore::onEvent(WebSocketsServerCore::WebSocketServerEvent)'
50 | void onEvent(WebSocketServerEvent cbEvent);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\webserver.ino: At global scope:
webserver:180:6: error: redefinition of 'void loop()'
180 | void loop()
| ^~~~
C:\Users\New\AppData\Local\Temp\untitled457104433.tmp\sketch_mar01a\sketch_mar01a.ino:6:6: note: 'void loop()' previously defined here
6 | void loop() {
| ^~~~
exit status 1
'WStype_t' has not been declared

Thank you in advance!
User avatar
By Inq720
#93797 Its not clear to me where you are on the learning curve.
  1. I did a quick look at that link and if they're recommending an ESP01 for a first timer, that's really bad advice. The fact that they also require you to wire up components to program it is also years old or foolish. There are cheap programmers where you can just plug them in. Or better yet, just use a WeMos or NodeMCU board.
  2. Have you fully installed the Core ESP8266 libraries. Since most of your errors are looking for something not available, this is my guess. - It's been a long time since I first did this, but this tutorial seems about right - https://www.instructables.com/Setting-Up-the-Arduino-IDE-to-Program-ESP8266/
  3. Once you do that, there are basic Examples build-in to the IDE using File/Examples to make sure your environment / board is working for you. Surprisingly, I just checked the list and I didn't see a WebSocket example.
  4. After that, your example off that website of yours might just compile.
  5. If still not, you'll need to post your Sketch. It might be far easier for us to see the problem from the code than these errors.

Good luck