In this video, I'm going to show you how
to use Raspberry Pi and Windows 10 IOT
core to collect telemetry data from a
plant and send it to a SQL server
database that is either on-premise or in
the cloud. Okay, so this is the setup that
I have here. I've got my raspberry pi
that is running a UWP application
generating telemetry data from this
temperature and humidity sensor via
it's one wire protocol. And also from
this potentiometer via the Modbus TCP
protocol. Okay so, let us begin by
creating our database and preparing our
SQL server instance to accept remote
connections. Okay, so the first thing that
we need to do is to change our secure
server authentication to mixed-mode, and
then we create our database.
And then add a new login.
And then from here, we must give our user permission to write to the database,
set it as DB owner. And then we create a
table for storing our sensor data.
So, here's our temperature data
with a decimal data type, humidity and
our Modbus data, and then we let SQL
server generate the date time by
default.
okay so, I've successfully created our
database and then the next step is to
configure SQL server to accept remote
connections. Close the management studio.
And open the SQL server configuration
manager and then under SQL server
network configuration, select protocols
for SQL Server Express. And then make
sure that tcp/ip is enabled, and then
right-click tcp/ip and select properties.
Select IP addresses, and then scroll down
to IPAll, make sure TCP dynamic ports is
blank and then set your tcp port to 1433.
Apply and then restart your SQL
server service. Okay so, we already have
our UWP app that is basically
generating telemetry data from Modbus
and temperature and humidity sensors. so we are going to send that data to our
remote SQL Server database. Now, because Windows 10 IOT core is not a full OS, it
doesn't automatically have access to
some resources. So we must enable
necessary capabilities to communicate
with an external enterprise application
such as SQL Server. Okay and then from here, we go to our C# file and then
I'll put these declarations here. So here I am creating a new SQL server connection, and
then I am building my connection string.
And then from there, I add my method for
logging the data to the SQL server.
Creating a new SQL command and then
executing it. And then here, right after
generating my telemetry data I call the
method to log that data to the SQL
Server. And then here on my database I'll
execute a quick script,
so my table is currently empty. Okay,
and then I deploy. And then now, if I
select everything from sensor data,
you can see our sensor data coming
through. So you see our Modbus data is
at 29, if I turn down the pot we're now
getting 21. Now, if I want my data sent to
a cloud-based server instead, I'll go to
my Azure Portal, SQL databases and then I
create a new SQL database.
Okay, my server has been successfully
deployed. So, I'll go to the resource. So,
I'll get my database connection strings
copied. And then, I'll go to my set server
firewall, to allow my internet gateway device
to connect to the server on the cloud. So,
that I can connect my Raspberry Pi and
my PC to the server on the cloud. And
then I go back to my SQL server
management studio to connect to the
database in the cloud. so I've
successfully connected to my SQL
server database in the cloud. And then,
from here I go into my Demo DB in the
cloud. And then I create my sensor data
table, and then I go back to my UWP
application to update my connection
string.
And then I deploy. And then we go to
SQL server management studio to see if
our data is going to our database in the
cloud. And there we've got our data going
into our SQL server database in the
cloud. Thanks for watching, if you've got
any thought at all on this video, I'd
love to hear about it in the comments
section below. And if you found the video
useful, please share it with your
connections. And don't forget to
subscribe to the channel to get more
videos like this.
