Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: Teensy + W5500 + Websocket server

  1. #1

    Teensy + W5500 + Websocket server

    I've been searching threads for anyone running a websocket server on a Teensy and I just see some dead threads from over a year ago.

    Is anyone doing this? Any code you can share? I'm trying to control some motor controllers with a Teensy and with motors, etc. Windows is too unreliable to use USB and C# Serial implementation is trash so I'd prefer to use Websocket. I'm doing it now with a RPI but I'd prefer the simplicity and reliability of a Teensy.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,813
    Let's talk about what a websocket example should look like. Maybe I'll write one....

    To get this conversation started, maybe you could explain to me what the non-Teensy side of the example should be?

  3. #3
    On the client side I'm connecting from Unity using a .NET library. I'm making websocket connection from sending data and another for receiving it. In the robotics application I have I'm connecting to a lot of different sensors. One websocket is for an IMU, another is encoders, roboclaw motor controller, OLED screens (robot eyes), WS2811B LEDs, dollar bill acceptor, and pressure sensors.

    But with all of these I find it best to have the websocket server be on the sensor side and have Unity make only client calls. Data is all ASCII text.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,813
    Ok, but let's talk about what an example published with the Ethernet library should look like?

    Kinda doesn't seem practical to distribute an example which requires someone to have Unity, dot net framework (presumably Windows only), and a very project specific setup.

  5. #5
    I think all the major programming languages already have client libraries for websockets. If you want to include a client example I would probably do it with Python. On the Teensy side one example should be for receiving commands, possibly commands to turn on Octo2811 LEDs, or even a single digitalWrite connected LED. Another example could be streaming data out of the websocket server on the Teensy. Just doing an analogRead and streaming to each connected client would be a good enough example.

    I've been using the Python websockets library for the server side on the RPI. But there's some sample Client code down the page a little. https://websockets.readthedocs.io/en/stable/intro.html

  6. #6
    I'm sure you could have found this easily enough yourself but it's a good reference. The RFC on Websockets. https://tools.ietf.org/html/rfc6455#page-14 and an Arduino websocket server that maybe could be used as a starting point. https://github.com/Links2004/arduinoWebSockets

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,813
    Yesterday I fixed bugs and tested this library. Seems to work fine, at least with the 1 very simple example and the public echo server.

    https://github.com/PaulStoffregen/Ar...ebsocketClient

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,813
    As far as a server example is concerned, I'm not planning to write such a thing (or library). But if anyone wants to contribute an example program....

  9. #9
    What ethernet chip did you use? W5500?

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,813
    W5500.

    Click image for larger version. 

Name:	DSC_0154_web.jpg 
Views:	30 
Size:	137.8 KB 
ID:	14245

  11. #11
    The Websocket library looks very promising.
    I does mention it does not support "Sec-Websocket-Key".
    Do you know if it is possible to add this option? I want to use an existing Websocket sever on nearlyfreespeech.net but it needs a sec key to be send too.

    It's all a bit new to me but would be great to hear how likely it is for this feature to make it in to the library.
    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •