arduino สามารถนำค่าของเซนเซอร์เข้า sql ได้ไหมครับ
Moderator: mindphp, ผู้ดูแลกระดาน
- dewhaha
- PHP Newbie
- โพสต์: 2
- ลงทะเบียนเมื่อ: 07/12/2022 11:51 pm
arduino สามารถนำค่าของเซนเซอร์เข้า sql ได้ไหมครับ
คือผมจะทำโปรเจคจบของ ปวช ครับ คิดว่าจะทำเซนเซอร์ที่ส่งค่าข้อมูลที่ได้ไปเก็บไว้ใน database ครับ แล้วอยากจะทำให้เปิดจากมือถือได้ด้วย ผมศึกษามาได้ประมาณนึง คือต้องเขียนโค้ดของรีเลย์ด้วยแล้วก็เขียนโค้ด สำหรับรับค่าและส่งค่าด้วยใช่ไหมครับ อยากถามทุกคนว่ามันมีแนวโน้มที่ทำได้ใช่ไหมครับ
- mindphp
- ผู้ดูแลระบบ MindPHP
- โพสต์: 41416
- ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
- ติดต่อ:
Re: arduino สามารถนำค่าของเซนเซอร์เข้า sql ได้ไหมครับ
ใช่ครับ หลังจากได้ค่าจาก รีเลย์แล้ว
ส่งค่า http แล้วใช้ php รับบันทึกลงฐานข้อมูลได้ครับ
ประมาณนี้
ส่วนการแสดงผลมือถือ ก็ใช้ php ดึงมาแสดงได้เลย หรือจะใช้ เป็น web service เพิ่มทำเป็น app แสดงผลก็ได้
ดูต่อที่นี่บทความเขียนไว้ดีเลยครับ ทำตาม step by step ได้ แต่บางขั้นตอนก็อ้อมไปหน่อย
https://arduinogetstarted.com/tutorials/arduino-mysql
ติดขัดขั้นตอนไหน สอบถามได้ โดยเอา Error ที่เจอ กับขั้นตอนที่ไปมาสอบถามได้
ส่งค่า http แล้วใช้ php รับบันทึกลงฐานข้อมูลได้ครับ
ประมาณนี้
โค้ด: เลือกทั้งหมด
/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/tutorials/arduino-mysql
*/
#include <SPI.h>
#include <Ethernet.h>
// replace the MAC address below by the MAC address printed on a sticker on the Arduino Shield 2
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetClient client;
int HTTP_PORT = 80;
String HTTP_METHOD = "GET";
char HOST_NAME[] = "192.168.0.26"; // change to your PC's IP address
String PATH_NAME = "/insert_temp.php";
String queryString = "?temperature=29.1";
void setup() {
Serial.begin(9600);
// initialize the Ethernet shield using DHCP:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to obtaining an IP address using DHCP");
while(true);
}
// connect to web server on port 80:
if(client.connect(HOST_NAME, HTTP_PORT)) {
// if connected:
Serial.println("Connected to server");
// make a HTTP request:
// send HTTP header
client.println(HTTP_METHOD + " " + PATH_NAME + queryString + " HTTP/1.1");
client.println("Host: " + String(HOST_NAME));
client.println("Connection: close");
client.println(); // end HTTP header
while(client.connected()) {
if(client.available()){
// read an incoming byte from the server and print it to serial monitor:
char c = client.read();
Serial.print(c);
}
}
// the server's disconnected, stop the client:
client.stop();
Serial.println();
Serial.println("disconnected");
} else {// if not connected:
Serial.println("connection failed");
}
}
void loop() {
}
ดูต่อที่นี่บทความเขียนไว้ดีเลยครับ ทำตาม step by step ได้ แต่บางขั้นตอนก็อ้อมไปหน่อย
https://arduinogetstarted.com/tutorials/arduino-mysql
ติดขัดขั้นตอนไหน สอบถามได้ โดยเอา Error ที่เจอ กับขั้นตอนที่ไปมาสอบถามได้
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
-
- Similar Topics
- ตอบกลับ
- แสดง
- โพสต์ล่าสุด
-
-
โพสต์ใหม่ ส่วนประกอบ Arduino UNO R3
โดย chaiyasitpraphut » 12/11/2019 2:42 pm » ใน IOT - Internet of things - 5 ตอบกลับ
- 47607 แสดง
-
โพสต์ล่าสุด โดย mindphp
26/10/2023 1:31 am
-
-
- 0 ตอบกลับ
- 5095 แสดง
-
โพสต์ล่าสุด โดย chayakan
12/12/2017 4:01 pm
-
-
โพสต์ใหม่ วิธีการทำให้ Arduino สื่อสารระหว่างกันแบบ I2C
โดย pataponnew » 04/05/2021 1:45 pm » ใน IOT - Internet of things - 0 ตอบกลับ
- 2442 แสดง
-
โพสต์ล่าสุด โดย pataponnew
04/05/2021 1:45 pm
-
-
-
โพสต์ใหม่ ความต่างระหว่าง Arduino vs Raspberry Pi
โดย yingphan.ch » 03/11/2021 10:12 am » ใน IOT - Internet of things - 0 ตอบกลับ
- 3763 แสดง
-
โพสต์ล่าสุด โดย yingphan.ch
03/11/2021 10:12 am
-
-
-
โพสต์ใหม่ การติดตั้ง Library บน Arduino IDE
โดย chayakan » 12/12/2017 5:34 pm » ใน IOT - Internet of things - 0 ตอบกลับ
- 3007 แสดง
-
โพสต์ล่าสุด โดย chayakan
12/12/2017 5:34 pm
-
-
-
โพสต์ใหม่ แนะนำบอร์ดไมโครคอนโทรเลอร์ Arduino(อาดุยโน่)
โดย bom_002 » 14/03/2017 12:06 pm » ใน Microsoft Office Knowledge & line & Etc - 2 ตอบกลับ
- 4115 แสดง
-
โพสต์ล่าสุด โดย mindphp
24/10/2023 4:16 pm
-
-
-
โพสต์ใหม่ แนะนำการใช้จอ LCD ร่วมกับ Arduino
โดย puopun.p » 09/07/2016 2:56 pm » ใน IOT - Internet of things - 0 ตอบกลับ
- 2637 แสดง
-
โพสต์ล่าสุด โดย puopun.p
09/07/2016 2:56 pm
-
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 50