Search code examples
httparduinotcp

HTTP vs TCP/IP, send data to a web server


I'm currently working on a project where I need to use an Arduino Nano (http://arduino.cc/en/Main/arduinoBoardNano) to send data from a temperature sensor to a web server.

At first I thought it would be easy, since there are so many great libraries out there to help with POST/GET etc. However, my professor just told me that I need to send data to the server using TCP/IP, and as I understand it POST and GET are HTTP methods.

Could someone explain to me the difference between HTTP and TCP/IP? Specifically as it relates to sending data to a web server. I'm looking for an answer that isn't too technical (I'm pretty new to all of this).


Solution

  • HTTP is a protocol used mostly for browsing the internet (IE, Firefox, etc). It rides on top of TCP which provides a reliable link between two computers (if packet get lost - it is re-transmitted). TCP itself rides on top of IP, which provides unified addressing to communicate between computers. TCP/IP is a basis for internet and 99% of other networks.

    Basically it means if you are communicating HTTP, you are doing it with TCP/IP underneath (but I am sure this is not what your professor meant).

    Arduino Nano is not supporting all of those, so you need something in between, which will translate Nano signaling to TCP/HTTP communication.

    Some of your options are:

    1. Communicating with Nano over Serial and making PC translate your Serial protocol to HTTP/TCP.
    2. Switch Nano with some other Arduino board which supports Ethernet/Wifi shield extension (Uno/Mega), or choosing a custom board which contains Ethernet by itself.
    3. Using another Arduino (Uno/Mega) with Ethernet shield as an additional board which communicates with Nano over Serial or with the help of RF modules (I personally implemented this option in past).
    4. Another unusual option is to attach Nano to your Android smartphone using Audio cable and to use soft-modem library. (https://code.google.com/p/arms22/issues/detail?id=2), which contains implementation for Android and write an application for Android

    Web server you mentioned supports HTTP only by definition, so if you want to communicate over TCP, you will need to use some TCP server.

    One of the existing web services to provide graphs for visualizing Sensor data is https://xively.com/, its API is based on REST which rides on top of HTTP. But it is not the only one.