ESP32 to SQL Server.

Thread Starter

Pushkar1

Joined Apr 5, 2021
212
I want to send sensor data taken by ESP32 to SQL Server. I have Arduino IDE and SQL server running on my PC. I don't understand how to connect ESP32 to a Microsoft SQL Server for database connection. I've been searching on Google for a long time but haven't found any useful information yet. May be someone can help me.

warm regards
Pushkar
 

Yaakov

Joined Jan 27, 2019
3,492
You are probably going to need to use some sort of middleware on the PC, possibly a C# script.

SQL is pretty heavy stuff for an MCU, using MQTT as a lightweight way to publish your data and a C# script subscribed on the PC might work pretty well.

MQTT is a publish-suscribe broker designed for sensor data, Mosquitto is a very popular F/OSS implementation.

I can't help with MSQL or C# since I don't use either of them, sorry.
 

Thread Starter

Pushkar1

Joined Apr 5, 2021
212
MQTT is a publish-suscribe broker designed for sensor data, Mosquitto is a very popular F/OSS implementation.

I can't help with MSQL or C# since I don't use either of them, sorry.
Have you worked with MQTT? I don't know much about it. I will ask you any specific question after reading about it on internet
 

Yaakov

Joined Jan 27, 2019
3,492
I am going to suggest you look at Node-Red: https://nodered.org/ as your middleware. It works really well and has ”nodes” (plug-ins) for an amazing array of things, I do see MSSQL nodes.

It will not only work for this but give you something to rely on for many other projests.
 

Yaakov

Joined Jan 27, 2019
3,492
I see many examples on the internet that raspberry pi is required to use MQTT. but i have only esp32 and esp8266
The MQTT broker (e.g.: Mosquito) runs on an external host. In this case it would be your PC. Look ar Docker to make this easier, though you’ll have to learn the basics of it, it will let you run many things more easily. Alternatively, check out Virtual Box and run aLinux distribution in. VM under Windows.

However you do it, it will be ESP32 <—> MQTT <—> connector <—> MSSQL

Node-Red would be a really good option for the connector but it could be a C# program instead.
 

Thread Starter

Pushkar1

Joined Apr 5, 2021
212
However you do it, it will be ESP32 <—> MQTT <—> connector <—> MSSQL
i think i got it, node-red will receive sensor readings from ESP32 using the MQTT communication protocol. node-red running on PC. Node-red will read and write to mssql database
 

Yaakov

Joined Jan 27, 2019
3,492
i think i got it, node-red will receive sensor readings from ESP32 using the MQTT communication protocol. node-red running on PC. Node-red will read and write to mssql database
That's correct. Except the MQTT border is a separate piece, BUT, there is an MQTT broker node for Node-Red so you don't really need the Mosquito worker. broker [EDIT: spellcheck error]1631102647956.png
 
Last edited:
Top