0

I am using Arduino UNO. I want to store arduino sensor value to SQL Database, from that Database i want to show that values which was stored in Database Table to user thorough ASP.NET Web Browser. Also I am using ethernet shield. I have found this method done by PHP, but I want to do this in C#. How can I do that?

1 Answers1

1

Depends on what you want to do...

If you want to run a C# application on Arduino, and your Arduino has an ARM Cortex processor, then you stand a chance. If it has an Intel Quark (x86-32) or an Atmel AVR (8-bit), then you're out of luck.

So in case you have an ARM-processor, you need to download Visual Studio 2017 (Community edition - free). Then you need to install .NET Core 2.0 preview. From there, you can compile a standalone Linux-binary targetting ARM. The result should run, if your Arduino can sport a Linux distro. However, I doubt you will find a version of linux that fits in 32K - but if you do, you could probably compile it and upload it to the Arduino.

If what you mean is "How can you get the sensor data from Arduino", then you can either use System.IO.Ports, or you can use the C# Arduino USB drivere here: https://github.com/christophediericx/ArduinoDriver

Next, you need a relational or NoSQL database to store sensor information. Since you're probably a just-starting windows-user, I'd recommend you download sql-server express, and SQL-server management studio Express. If you're not a fan of Microsoft, you can also use PostgreSQL, or SQLite, if you don't want to install anything. Firebird would also be a nice embedded database. If you'd have an extreme high write-frequency, and need multiple computers to store the results, you should use Cassandra (NoSQL) - However, Cassandra is not for beginners, and neither is PostgreSQL, SQLite or Firebird. So I recommend you use SQL-Server Management Studio and SQL-Server Express.

If you also install SQL-Server-data-services, you could also use ReportingService to output your measurements, which has the added benefit of easy filtering, and multiple output formats (HTML, Excel, PDF, PowerPoint, Word, TIFF, Graphs, XML, CSV), without much work on your own. Then you don't need any ASP.NET application.

If however, you want to output the data in your own database table, you need the SQL-Server ADO.NET driver (System.Data.SqlClient) to access the SQL-Server express database. For PostgreSQL, you'd need the PostgreSQL-ADO.NET driver (Npgsql), and for SQLite you'd need System.Data.SQLite.

You can output the table in ASP.NET web forms with DataGridView, and do DataBind in the Page_Load event. Or you could use the more modern ASP.NET Core framework, to write a REST-service, and display the table with JavaScript and AJAX/JSON (use a JavaScript-grid like HandsonTable or SlickGrid). You'd need to serialize the data to JSON using Newtonsoft.JSON.

Or you could display the table in real-time with web-sockets and a web-sockets real-time DataGrid.

Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442