-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Nov 15, 2016 at 05:07 PM
-- Server version: 10.1.16-MariaDB
-- PHP Version: 5.6.24
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `tutor`
--
-- --------------------------------------------------------
--
-- Table structure for table `esp8266`
--
CREATE TABLE `esp8266` (
`id` int(11) NOT NULL,
`temp` int(11) NOT NULL,
`day` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `esp8266`
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `esp8266`
--
ALTER TABLE `esp8266`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `esp8266`
--
ALTER TABLE `esp8266`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1;
#include
#include
#include
#include
ESP8266WiFiMulti WiFiMulti;
void setup() {
Serial.begin(115200);
for (uint8_t t = 4; t > 0; t--) {
Serial.printf("[SETUP] WAIT %d...\n", t);
Serial.flush();
delay(1000);
}
WiFiMulti.addAP("wifi_ssid", "wifi_password"); // ssid , password
randomSeed(50);
}
void loop() {
if ((WiFiMulti.run() == WL_CONNECTED)) {
HTTPClient http;
int temp = random(25,35);
String url = "http://192.168.1.39/nodemcu/esp8266mysql/add.php?temp="+String(temp);
Serial.println(url);
http.begin(url); //HTTP
int httpCode = http.GET();
if (httpCode > 0) {
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
if (httpCode == HTTP_CODE_OK) {
String payload = http.getString();
Serial.println(payload);
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
delay(3000);
}
ArduinoAll ขาย Arduino ซื้อ Arduino ทุกอย่าง เปลี่ยนชื่อเป็น AllNewStep