I found a lot of methods on the internet and I was wondering whats the best method to send data from sensors connected to Arduino to mysql database in wamp server continuously ?

share|improve this question

closed as primarily opinion-based by jfpoilpret, Anonymous Penguin May 23 '15 at 20:14

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 2 down vote accepted

There is no absolute "best" way, there is only the way that "works best for your situation".

In a nutshell, the different methods that I can think of, and their pros and cons, are:

  • Simple HTTP GET with parameters

Quick to implement, light weight, but not very secure or robust. Perfectly fine for things like "send the temperature once a minute" etc, but crafting very long GET requests with lots of parameters can severely impact on both your RAM and your sanity.

  • HTTP POST request

Like the GET request it's fairly simple to implement, but needs more RAM since you need to know the size of the data you're sending first so you can send a Content-length header. You can send much more that way though, assuming you have the resources for it.

  • SOAP

This is basically HTTP POST but with a specially XML formatted body. It has the advantage that it's a standard protocol for transferring data and commands around the place, so there are plenty of resources to help you. The main problem is crafting the XML at the Arduino side.

  • Custom TCP

Connect to a special port to communicate with your own software. You define all of the protocol, but you have to write all (or most) of the software too. This can be more like a serial connection to your computer but through the network. Good for sending larger amounts of data, such as images from a camera, etc.

  • Custom UDP

If you want to send lots of small values very frequently this is probably the best bet. Harder to implement than most of the others, but the light-weight nature of UDP means you can send data much more rapidly. Of course, with UDP, you run the risk of losing packets since it's very much a "fire and forget" protocol - you send a packet and hope it gets there. Fine if you don't mind missing the odd bit of data, say for higher speed temperature logging. Of course, you have to write the server side software yourself, but there's plenty of resources to help you with that online.

So it's really not a case of "best" but "most suitable". Define what the data is and how often you want to send it, then think about how complex you are willing to get with your programming.

Nine times out of ten a simple HTTP GET request fits the bill.

share|improve this answer
    
thank you @Majenko my project consists of sending LM35, LDR, PIR motion data along with the status of couple led and switches so what's the most suitable way for me ? – Ghassen Charai May 21 '15 at 12:48
    
That depends how often you want to send. Some of it you would want to send periodically (temperature) but others you can send only when they change state. GET is probably easiest, but use different GET calls for the different types of data. – Majenko May 21 '15 at 12:53
    
I am new to arduino so I would guess that I have to send temperature data every 1 min and the stat of switch and led every 1 seconde. – Ghassen Charai May 21 '15 at 14:42
    
No, you would send temperature as fast as you want to (every minute is fine) but you only need to send the state of the button when someone presses the button. – Majenko May 21 '15 at 15:03
    
okay that seems right so what method should I use ? @Majenko – Ghassen Charai May 21 '15 at 15:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.