| Electronics > Projects, Designs, and Technical Stuff |
| Arduino to PC wifi communication method - Any ideas? |
| (1/1) |
| balage:
Hi, I am planning to create one or more Arduino based data acquisition devices. I bought an Arduino MKR WiFi. I understand the basic examples, but all of them are working with publishing data on HTTP. The Arduino based device should collect data, and only upon the request of the computer based software (will be a LabVIEW VI) the arduino sends all the stored data to the computer. The readout time period can be between a few seconds and a minute. The Arduino can be a server and can connect to a wifi AP. What kind of communication should I use? I have not much clue about network communication things, sorry.ű Thanks, |
| rstofer:
I couldn't find a concise document on how to use the device. In general, I would prefer to use a TCP connection (Berkeley Socket) and set the board as a server waiting for a connection from a client (the PC in this case). Sockets are nice because they allow you to connect to your own host for development/debugging. You do this by writing a bit of code for the server and starting it. This code looks for a connection request at the host IP address and some socketport number which you pick. Then you write a bit of client code that establishes a connection to the IP address and port. https://www.paulgriffiths.net/program/c/sockets.php The web server examples provided for the board are a start in the right direction because they set up a socket at a port (usually 80 or 8080, sometimes elsewhere) and accept a connection for a single transaction. But that's because the HTTP protocol doesn't want to deal with persistent connections. There is code here for making socket connections: http://www.linuxhowtos.org/C_C++/socket.htm |
| balage:
Arduino is nice because prototyping is fast, but it also hides low-level things from the user. So in the background there must be TCP socket connection, but who knows. I have found the read() function that can be used to receive raw data. https://www.arduino.cc/en/Reference/WiFiNINAClientRead Thanks for your interpretation! |
| Navigation |
| Message Index |