ความรู้แน่น ฟรีสำหรับชุมชน ArduinoAll ที่นี่เท่านั้น

ฟรีและดีที่สุด คอร์สอบรม Arduino + NodeMCU
ทำเพื่อแบ่งปัน ห้ามนำไปจำหน่าย หรือเก็บเงินค่าเรียน
  !!!


  


AllNewStep รับประกันคุณภาพทุกชิ้น วันจันทร์-ศุกร์แจ้งชำระสินค้าก่อน 14.00 จัดส่งทันทีวันนี้ค่ะ

กรุงเทพ /ภาคกลาง ได้พรุ่งนี้


*** สินค้าทุกชิ้น ถ้าสามารถทำรายการสั่งซื้อได้ แสดงว่ามีครบทุกรายการค่ะ *** 

พิมพ์ค้นหาบทความ หัวข้อกระทู้ และสินค้าในเว็บ AllNewStep ได้ที่นี่
QUOTE 

แล้วจะใส่ชื่อwifi กับรหัสยังไงครับ

โอ๊ก อภิสิทธิ์ เกตุแก้ว

แล้วจะใส่ชื่อwifi กับรหัสยังไงครับ

#include <Software

Serial.h>

#include <SerialESP8266wifi.h>

 

#define sw_serial_rx_pin 4 //  Connect this pin to TX on the esp8266

#define sw_serial_tx_pin 6 //  Connect this pin to RX on the esp8266

#define esp8266_reset_pin 5 // Connect this pin to CH_PD on the esp8266, not reset. (let reset be unconnected)

 

SoftwareSerial swSerial(sw_serial_rx_pin, sw_serial_tx_pin);

 

// the last parameter sets the local echo option for the ESP8266 module..

SerialESP8266wifi wifi(swSerial, swSerial, esp8266_reset_pin, Serial);//adding Serial enabled local echo and wifi debug

 

String inputString;

boolean stringComplete = false;

unsigned long nextPing = 0;

 

int smokeA0 = 0;

 

int sensorThres = 400;  //ตั้ง ค่าความหนาของตวัน แก๊ส ก๊าซที่ 100

 

void setup() {

inputString.reserve(20);

  swSerial.begin(9600);

  Serial.begin(9600);

  while (!Serial)

    ;

  Serial.println("Starting wifi");

 

  wifi.setTransportToTCP();// this is also default

  // wifi.setTransportToUDP();//Will use UDP when connecting to server, default is TCP

 

  wifi.endSendWithNewline(true); // Will end all transmissions with a newline and carrage return ie println.. default is true

 

  wifi.begin();

 

  //Turn on local ap and server (TCP)

  wifi.startLocalAPAndServer("MY_CONFIG_AP", "password", "5", "2121");

 

  wifi.connectToAP("wifissid", "wifipass");

  wifi.connectToServer("192.168.0.28", "2121");

  wifi.send(SERVER, "ESP8266 test app started");

 

int smokeA0 = 0;

 

int sensorThres = 400;  //ตั้ง ค่าความหนาของตวัน แก๊ส ก๊าซที่ 100

 

  

}

 

void loop() {

 

int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");

  Serial.println(analogSensor); 

 

  delay(100);

 

 

  //Make sure the esp8266 is started..

  if (!wifi.isStarted())

    wifi.begin();

 

  //Send what you typed in the arduino console to the server

  static char buf[20];

  if (stringComplete) {

    inputString.toCharArray(buf, sizeof buf);

    wifi.send(SERVER, buf);

    inputString = "";

    stringComplete = false;

  }

 

  //Send a ping once in a while..

  if (millis() > nextPing) {

    wifi.send(SERVER, "Ping ping..");

    nextPing = millis() + 10000;

  }

 

  //Listen for incoming messages and echo back, will wait until a message is received, or max 6000ms..

  WifiMessage in = wifi.listenForIncomingMessage(6000);

  if (in.hasData) {

    if (in.channel == SERVER)

      Serial.println("Message from the server:");

    else

      Serial.println("Message a local client:");

    Serial.println(in.message);

    //Echo back;

    wifi.send(in.channel, "Echo:", false);

    wifi.send(in.channel, in.message);

    nextPing = millis() + 10000;

  }

 

  //If you want do disconnect from the server use:

  // wifi.disconnectFromServer();

 

}

 

//Listen for serial input from the console

void serialEvent() {

  while (Serial.available()) {

    char inChar = (char)Serial.read();

    inputString += inChar;

    if (inChar == '\n') {

      stringComplete = true;

    }

  }

}

 

QUOTE 
ความคิดเห็นที่ #1
เจ้าของร้าน

มีแนะนำการใช้งาน Arduino ESP8266 ที่หน้าเว็บ ลองเล่นดูนะครับ

QUOTE 
ความคิดเห็นที่ #2
โอ๊ก อภิสิทธิ์ เกตุแก้ว

มันขึ้น  error  แก้ไง

 

QUOTE 
ความคิดเห็นที่ #3
เจ้าของร้าน

ถามทีละกระทู้จะได้มีรายละเอียดเดียวกันครับ

บอร์ด Arduino ทางร้านเช็คให้ละเอียดก่อนส่งแล้ว จะต้องใช้งานได้ทุกชิ้น

สาเหตุที่อัพโหลดไม่ได้ เพราะยังคอมไพล์ไม่ผ่านเลย เช็คไลบารีตามที่ได้แนะนำไปแล้วครับ

แสดงความคิดเห็นที่ 1-3 จากทั้งหมด 3 ความคิดเห็น
ขาย ARDUINO
คุณภาพ อันดับ 1

ได้รับรางวัลร้านยอดเยี่ยม
ตั้งแต่ปี 2558
ขาย Arduino
วีดีโอสอน Arduino

สอน esp8266

สอน Arduino IoT
สอน Arduino แบบเร็ว

สอน NodeMCU

อุปกรณ์ Arduino

MEMBER ZONE

พูดคุย-สอบถาม