Arduino To SQL Server

usamakhan18 picture usamakhan18 · Jul 12, 2017 · Viewed 11.6k times · Source

Anyone who can Help me, Please tell me How to send ultrasonic detection readings from Arduino to SQL Server using Ethernet Cable? Need Code or Helping material or Link. I don't want to send it by using any Wifi module to Arduino just by using Ethernet Cable.

Answer

MBurnham picture MBurnham · Jul 12, 2017

If you want to send it to sql server using the arduino, you have one of two options. (And I think really only one)

For both, you will need to write Arduino code that can talk to an external server.

You can find info on that here

Next, you will need to decide if you want to send it directly to a SQL Server, or if you want to send it to a RESTful Web API, and have that API write the data to SQL Server.

The first option will require you to write your own implementation for TDS over TCP. TDS is the protocol SQL Server uses to send and recieve database queries.

You can find info on SQL Server and the TDS protocol here

This option will be a lot of work, and I am not sure that you will have enough room on the arduino to fit all of the code that would be required for even just a dirty, minimal implementation. Nevermind a reliable, quick, and safe one.

Your other option would be to implement a way to send HTTP Requests over TCP using the arduino. This would allow you to talk to a Web-based REST API. The API would act as a middle man, taking HTTP GET or POST Requests from the arduino, and translating them to SQL Server by means of some database driver.

As far as implementing HTTP with the arduino, you can do that with precreated libaries, like this

As far as what you would use for an API, that can be any Server Side programming language. I personally recomend using ASP.NET to create the API, and ADO.NET to talk to the database. There is lots of documentation all over the net on both of these subjects. A good place to start would be here for a Web API and here for information on ADO.NET