I would like to make a connection from Arduino Uno to Microsoft SQL Server for storing student attendance records into a table from my database.

So, what is the best way to do that? I need a suggestion or useful references and links.

I have written a web application on Visual Studio using C# language. What Arduino does is getting fingerprint through sensor, then I would like to store the attendance records of a student into database. So the attendance records can be retrieved from database to the web application and display to teachers.

This is just for project purpose only and the connectivity between Visual & SQL Server using these two lines below:

SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=DESKTOP-H7KQUT1;Initial Catalog=SAOS1;Integrated Security=True";
  • It is highly doubtful you will ever get the Arduino to connect to Microsoft SQL Server. Create a Web API as a gateway between the Arduino and SQL using a protocol of your choosing (REST is common with plenty of examples around).
    – Majenko
    Commented Oct 18, 2018 at 15:30
  • @Majenko Hi, Majenko. Do you have any useful references? Cause I'm new to Arduino. Don't know which is the best one to me to establish connection between Arduino Uno & Microsoft SQL
    – Conard
    Commented Oct 18, 2018 at 15:38
  • No, I've never done it. You seem to already be au fait with C# and VS, so I'd guess you'd add it to your web app. Just create some URLs (however you'd do that) that accept data in some way and post them to the SQL server. Of course you'd need a network connection (WiFi, Ethernet, whatever).
    – Majenko
    Commented Oct 18, 2018 at 15:40

1 Answer 1


Using a layer between Arduino and MSSQL might give you the least headache. Would you like to do this on-premise or in the cloud?

For an easy cloud approach, look at AWS Lambda. Write a Lambda function that inserts into your MSSQL database, possibly running on AWS too. Your choice of Java, Node.js, C#, or Python. Hook it up with incoming MQTT messages from your Arduino. https://stackoverflow.com/questions/33165045/aws-lambda-and-sql-server-integration could help.

For a cloud-free approach, you could run your own local MQTT server (broker, to be exact, Mosquitto being the most popular), and have your C# subscribe as an MQTT client. When the Arduino publishes a fingerprint signature, your C# script can do the database work.

  • Hi Chris. I've been searching for tutorials about Mosquitto. But I didn't find any useful articles how to send data from Arduino to MSSQL using Mosquitto. Do you have any useful links or tutorials for me to do it?
    – Conard
    Commented Oct 19, 2018 at 14:53
  • Mosquitto is just a broker. Think of it more like a phone switch board. You write a piece of C# code that subscribes to a topic (think phone number). When your Arduino publishes information on that topic (dials that number), Mosquitto routes that to your C# client, invoking your code (phone rings). There is a nice intro to MQTT at HiveMQ.
    – ChrisH
    Commented Oct 23, 2018 at 17:59
  • Chris, how can I connect the arduino with mqtt broker or subscribe to the mqtt broker? Without using ethernet shield or wifi shield
    – Conard
    Commented Oct 30, 2018 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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