Hi,
We are from germany and total beginners in the programming of connections between a client and a server. We only have basic skills in c-programming.This semester every group have a big project in the university. Our task is to send measuring data (which will be readout by a sensor) from the arduino to the raspberry pi via wifi socket (TCP). The raspberry pi should store the data and display it. The diffult part for us is the socket-programming. We should use C as programming language.
We really need help, because our adviser/professor don't help us. In the moment we don't know what to do, because in the web we didn't find much information about socket-programming for our project, only basis stuff or things, that are too crazy for us to understand. It's also difficult to select the information, because many of them are about communication with Ethernet, webserver, UDP, additional shields and so on. Furthermore the commands in examples are often inapprehensible.
We will be grateful about any kind of help. Maybe someone have done similar things in the past. It would be awesome, if someone have code sources of similar projects (for example communication between two arduinos and so on).
kasimir69:
We should use C as programming language.
Do you mean plain C, or Arduino IDE C/C++ ? That makes a huge difference.
Is RPi programming also only allowed in C?
If not, I would probably just install a LAMP on the RPi, with a data base to save the data in, and some PHP scripts to store data into the DB and to read it back and display it in a nice web interface.
You can then run an HTTP client on the Arduino that sends POST requests containing sensor data to the server.
HTTP is built upon TCP, so I'm assuming that's allowed?
Another approach would be to use the WebSocket protocol. This is especially useful if you have to send the sensor data at a very high rate with low latency. It works great with the ESP8266, for example, but I'm not sure if it can run on an Uno ...
An explanation of the different protocols involved
Google Charts is great for displaying data in the browser
A great WebSocket library for Arduino
Installing a LAMP server on a Raspberry Pi (ignore the WordPress part)
Pieter
I think its Arduino IDE C/C++. I assume that the RPi programming is only allowed in C. We shouldn't use HTTP. We have the newer version of the arduino uno with a integrated ESP8266 shield, so it have wifi. Isn't it possible to build a direct socket connection between the arduino and the RPi.
TCP is part of the transport layer. You need an application layer protocol in order to communicate between the Arduino and the RPi, you can either use an existing protocol, like WebSocket or HTTP (which is basically just sending plain text through a TCP connection), or you have to write your own simple protocol (that's going to be quite simple since you have just one type of data to send).
You're probably going to have to use AT commands. The official AT instruction set by Espressif (the manufacturer of the ESP8266) contains everything you need to know to establish a TCP connection.
There are a lot of TCP client/server C examples available online that you can use on the RPi.
Pieter