Two way Ethernet socket communication Arduino

Ask, and ye shall receive.
FloppyTeam
Posts: 1
Joined: 10:09, 12 May 2014

Two way Ethernet socket communication Arduino

Postby FloppyTeam » 10:18, 12 May 2014

Hej.

We are using your sample code "Arduino LED On/Off TCP" from Evothings in our Cat Laser Turret Project
https://github.com/johnjun/DM2518-Project/

I was wondering if you have some suggestions on:
1. How to make the Arduino reply over the socket instead of Serial port. Got examples?
2. Use websockets instead of chrome Sockets so that the app works in all browsers.

Feel free to have a look at our repository. We're using these files for the communication between js and Arduino:

DM2518-Project / js / model / arduino.js + model.js
DM2518-Project / arduinoSketch / 20140510 / 20140510.ino (filename might change later on)

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: Two way Ethernet socket communication Arduino

Postby micke » 12:50, 13 May 2014

Hi!

To send data back from Arduino over TCP you can look at this code:

https://github.com/evothings/EvoThingsE ... -onoff-tcp
https://github.com/evothings/EvoThingsE ... tions.html
https://github.com/evothings/EvoThingsE ... arduino.js

This code is untested, and is being debugged now. Now code is planned to be pushed to Github when complete. But you can take the relevant parts of the code and add to your project to get going.

As for using websockets, they are not compatible with TCP sockets. What I would do is creating a websocket, connect to a server that just prints the raw data received, and send some sample data over the websocket to detect its format. You could do this in Arduino code. Just print whatever is sent to the TCP socket. (It is always TCP at the low level, but websockets add some protocol data, possibly using HTTP, I am not familiar with the details.) Another alternative is to read the websocket specification and use that to write the code that parses websocket requests. Best would be to do both. I however usually find it beneficial to inspect the actual data sent to understand the format used.

Regards, Micke


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 43 guests