#Arduino #MySQL#node_red_sql
@makersgroup
To send Arduino data to the database you don't need any wifi devices like eas8266, nodemcu, or Wifi shield LAN. You just follow the video and all is done quickly.
Node red installation guide:- • Node-RED Installation Guide for Compu...
The Arduino Code:-
int Humidity=0;
int Temprature=0;
int Light=0;
void setup() {
Serial.begin(9600);
Serial.println(F("DHTxx Unified Sensor Example"));
}
void loop() {
Temprature=random(20,40);
Humidity=random(80,120);
Light=random(100,160);
Serial.print("{\"Hum\":");
Serial.print(Humidity);
Serial.print(",\"Temp\":");
Serial.print(Temprature);
Serial.print(",\"Li\":");
Serial.print(Light);
Serial.println("}");
delay(2000);
}
The JSON code, to import the project:-
[
{
"id": "c73516050e9670c4",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "8c0759f2b73c30ef",
"type": "serial in",
"z": "c73516050e9670c4",
"name": "",
"serial": "632ce51bae434d89",
"x": 150,
"y": 140,
"wires": [
[
"78c9b7023caae7d3"
]
]
},
{
"id": "78c9b7023caae7d3",
"type": "json",
"z": "c73516050e9670c4",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 250,
"y": 200,
"wires": [
[
"7fe478bfb80dde25"
]
]
},
{
"id": "7fe478bfb80dde25",
"type": "function",
"z": "c73516050e9670c4",
"name": "",
"func": "var value=JSON.parse(JSON.stringify(msg.payload));\nvalue=msg;\nvar sensor1 = msg.payload.Li;\nvar sensor2 = msg.payload.Temp;\nvar sensor3 = msg.payload.Hum;\nmsg.payload = [sensor1, sensor2, sensor3];\nmsg.topic = 'INSERT INTO sensordata(Humidity, Temprature, Light) VALUES (?,?,?);';\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 260,
"wires": [
[
"4aebfc352c4acb8b"
]
]
},
{
"id": "4aebfc352c4acb8b",
"type": "mysql",
"z": "c73516050e9670c4",
"mydb": "a8c399d7db9657e5",
"name": "",
"x": 510,
"y": 200,
"wires": [
[]
]
},
{
"id": "632ce51bae434d89",
"type": "serial-port",
"serialport": "COM4",
"serialbaud": "9600",
"databits": "8",
"parity": "none",
"stopbits": "1",
"waitfor": "",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "\\n",
"bin": "false",
"out": "char",
"addchar": "",
"responsetimeout": "10000"
},
{
"id": "a8c399d7db9657e5",
"type": "MySQLdatabase",
"name": "",
"host": "127.0.0.1",
"port": "3306",
"db": "test",
"tz": "",
"charset": "UTF8"
}
]
Watch video 🔴How to send sensor Data from Arduino UNO to MySQL Server(PHPMYADMIN) Offline (No internet)? online without registration, duration hours minute second in high quality. This video was added by user Makers Group 01 January 1970, don't forget to share it with your friends and acquaintances, it has been viewed on our site 42,68 once and liked it lik people.