I am working on a project where I need to wirelessly send and receive CAN-FD frames between two Arduino UNO WiFi Rev2 boards. My current setup is an access point (raspberry pi 5) creating a closed network which my arduinos are both connected to. I was planning to send the CAN-FD data as a string.

I have successfully got my access point up and running and my two arduinos can connect to it just fine. I am trying to use the WiFiNINA library to communicate over the network but I am having trouble with this. I am a networking noob so I am trying to build off of examples from the WiFiNINA library and KayPebble's WebSocket_WiFiRev2 example (https://docs.arduino.cc/tutorials/communication/wifi-nina-examples/#examples and https://github.com/KayPebble/WebSocket_WiFiRev2) My problem is that I can't figure out how to transform what I see from the websocket examples, which seem to all be set up for communicating bidirectionally with a local html site, into bidirectional communication between two arduinos. I've been reading through the WiFiNINA library documentation to try and come up with something but I am stuck. There is one example for sending and receiving a string as a UDP packet, but I don't think I can use UDP packets reliably for CAN messages, I have heard UDP can get jumbled.

All this is to ask, how do I use websockets (if that's what WiFiNINA is using) to send and read data between two arduinos? I am hoping someone could explain the basic steps or pseudocode for this kind of communication. My problem is not that I am running into errors, but that I don't understand how to network these things. Are websockets the right method to use for this? I am lost. Any insight is much appreciated.

  • 1
    – Juraj
    Commented Jul 9 at 12:26
  • I don't think a server/client set up will work for my project because both arduinos need to be able to send and read data, not just send or just read. Unless that's possible with a server/client configuration?
    – newbie
    Commented Jul 9 at 12:32
  • You don't need the overhead of WebSockets for sending strings: a TCP connection will do just fine. Once the connection is established, it's simply a bidirectional data pipe, similar to a serial link. Like a serial link, it's full duplex, so both Arduinos can write to that pipe whenever they like. Commented Jul 9 at 13:18
  • 1
    that forum thread is based on my SE answer linked in the first comment here. did you read it?
    – Juraj
    Commented Jul 9 at 15:41
  • 1
    "Do you just keep the connection open and don't close it until you want to stop talking?" yes. is it not what you want? web sockets do the same just wrapped into HTTP initialization.
    – Juraj
    Commented Jul 10 at 9:04


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.