free css templates
รายการสือการสอนของอาจารย์แต่ละท่านที่นำเสนอ

ชื่ออาจารย์ : นายศักดิ์ศรี เสนาลัย

สถานศึกษา : ข้าราชการเกษียน

แผนกวิชา : เทคโนโลยีสารสนเทศ

จังหวัด : มุกดาหาร



วิชาอาจารย์ นายศักดิ์ศรี เสนาลัย

ลำดับ

ชื่อวิชา

1- 1_BASIC_IOT_NETPIE_2020 17
2- 1_test_pid 8
3- 1_visual_foxpro 7
4- 1_การสร้างเว็บไซต์ด้วยMobirise 3
5- 1อบรมnodemcu_oit 8
6- 2อบรมnodemcu_oit 4
7- 3mqtt 5
8- A_WordPress 7
9- ARDUINO_BY_SAKSRI 6
10- basic_ROBOT 7
11- Car_Tracking 2
12- database 14
13- digital 30
14- esp32_Multi_Task 1
15- Firebase 4
16- internet_of_thing(IOT) 6
17- internet_of_thing(IOT2) 13
18- iot_nodemcu_wemos 3
19- JavaBasic 4
20- JSON 4
21- nodemcueps8266 7
22- php_mysql_and_NodeMCU_API 1
23- PYTHON 7
24- thunkable 5
25- VueJS 4
26- การเขียนโปรแกรมphp_mysql 29
27- การเขียนโปรแกรมคอมพิวเตอร์ 9
28- การเขียนโปรแกรมวินฟรอ์ม_database_dbf(visualfoxpro_by_saksri) 3
29- การเขียนโปรแกรมวินฟรอ์ม_database_mysql(visualfoxpro_by_saksri) 2
30- การเขียนโปรแกรมวินฟรอ์ม(visualfoxpro_by_saksri) 16
31- การเขียนโปรแกรมเว็บ2 22
32- การเรียนการสอนแบบออนไลน์ 2
33- ตัวอย่าง_PROJECT 5
34- ตัวอย่างการเขียนโปรแกรม 24
35- ปรับพื้นฐานการเขียนโปรแกรมด้วยภาษาphp 98
36- ระบบเขื่อข่ายคอมพิวเตอร์ 1
37- สร้างเว็บไซต์ด้วยPHPและฐานข้อมูลMySQL 5
38- สอนจาวา 30
39- สอนจาวา(java) 105
40- สอนจาวาGUI 23
41- สอนจาวาMysql 7
42- สอนทำเว็บ_PHP_Databases_Dreamweaver_Bootstrap 44
43- หุ่นยนต์เพื่ออุตสาหกรรม 13
44- หุ่นยนต์เพื่ออุตสาหกรรม2 3
45- หุ่นยนต์เพื่ออุตสาหกรรม3 5
46- หุ่นยนต์เพื่ออุตสาหกรรม4 2
47- เขียนเว็บด้วยHTML_CSS 2
48- เพลงคาราโอเกะ 52
49- โปรแกรมภาษาไพธอน 35
50- โรงงานอุตสาหกรรม 1

รายละเอียดd>1อบรมnodemcu_oit > download ตัวอย่างโปรแกรม


 download program-สำหรับทดลอง 

 

down program-สำหรับติดตั้งโปรแกรม 

 

 

 

 

 

 

 

drive.google.com/drive/folders/1Koxn2FvfimWihTMsUrnOCQPw8qqe-Fih

 

 

drive.google.com/drive/folders/1KiKpzTFXsvvNKk0_0olNNB8ZwWd0ONka

 

drive.google.com/drive/folders/15jVteoXRne4wioFkVcIBYTUQn6jxzRXD

รายละเอียดd>1อบรมnodemcu_oit > TCP Server และ TCP Client จาก thaieasyelec


 blog.thaieasyelec.com/getting-started-with-esp8266-nodemcu-ch3/

 

 

#include <ESP8266WiFi.h>
#define SERVER_PORT 8000            //ค่า port ที่ต้องการเชื่อมต่อ
IPAddress server_ip = {192,168,1,33};       //ค่า ip ของ Server (อย่าลืมแก้เป็น IP ของตัวเอง)
 
const char* ssid = "your ssid";         //ค่าของ SSID (อย่าลืมแก้เป็น ชื่อ SSID ของตัวเอง)
const char* password = "your password"; //ค่าของ SSID (อย่าลืมแก้เป็น password ของตัวเอง)
 
WiFiServer server(SERVER_PORT); //สร้าง object server และกำหนด port ที่ต้องการเชื่อมต่อกับ server
WiFiClient client;              //สร้าง object client
 
void setup() 
{
    Serial.begin(115200);       //เปิดใช้ Serial
    WiFi.begin(ssid, password); //เชื่อมต่อกับ AP
   
     while (WiFi.status() != WL_CONNECTED)  //รอการเชื่อมต่อ
    {
            delay(500);
            Serial.print(".");
    }
   
    Serial.println("");
    Serial.println("WiFi connected");  
    Serial.println("IP address: "); 
    Serial.println(WiFi.localIP()); //แสดงหมายเลข IP
 
    Serial.println("Connect TCP Server");
    while (!client.connect(server_ip,SERVER_PORT)) //เชื่อมต่อกับ Server
    {
            Serial.print(".");
            delay(100);
    } 
    Serial.println("Success"); 
ESP.wdtDisable();  //ปิด watch dog Timer
}
 
void loop() 
{
    while(client.available())   //ตรวจเช็ตว่ามี Data ส่งมาจาก Server หรือไม่
    {
            uint8_t  data =client.read();  //อ่าน Data จาก Buffer
            Serial.write(data); //แสดงผล Data ทาง Serial
    }
               client.println("Hello");     //ส่งค่าที่ได้รับกลับไปยัง Server
               delay(1000);
}
 
 
 

 
#include <ESP8266WiFi.h>
#define SERVER_PORT 8000    //กำหนด Port ใช้งาน
const char* ssid = "stk";       //กำหนด SSID
const char* password = "stk123456"; //กำหนด Password
WiFiServer server(SERVER_PORT); //สร้าง object server และกำหนด port
 
void setup() 
{
            Serial.begin(115200);   //เปิดใช้ Serial
    Serial.println("");
            Serial.println("");
            WiFi.begin(ssid, password); //เชื่อมต่อกับ AP
     while (WiFi.status() != WL_CONNECTED)  //รอการเชื่อมต่อ
    {
            delay(500);
            Serial.print(".");
    }
            Serial.println("WiFi connected");   //แสดงข้อความเชื่อมต่อสำเร็จ  
    Serial.println("IP address: "); 
    Serial.println(WiFi.localIP());     //แสดงหมายเลข IP
            server.begin();             //เริ่มต้นทำงาน TCP Server
            Serial.println("Server started");       //แสดงข้อความ server เริ่มทำงาน 
ESP.wdtDisable();            //ปิด watch dog Timer
}
 
void loop() 
{
        WiFiClient client = server.available();  //รอรับ การเชื่อมต่อจาก Client
        if (client)         //ตรวจเช็คว่ามี Client เชื่อมต่อเข้ามาหรือไม่
        {
            Serial.println("new client");   //แสดงข้อความว่ามี Client เชื่อมต่อเข้ามา
            while(1)        //วนรอบตลอด
            {
                    while(client.available())   //ตรวจเช็ตว่ามี Data ส่งมาจาก Client  หรือไม่
                    {
                            uint8_t data =client.read();  //อ่าน Data จาก Buffer
                            Serial.write(data); //แสดงผล Data ทาง Serial
                    }
                    if(server.hasClient())  //ตรวจเช็คว่ายังมี  Client เชื่อมต่ออยู่หรือไม่ 
                    {
                        return;         //ถ้าไม่มีให้ออกจาก ลูป ไปเริ่มต้นรอรับ Client ใหม่
                 }
            }
        
     } 
}
 

รายละเอียดd>1อบรมnodemcu_oit > บทความ ARDUINO จาก myarduino


 บทความ ARDUINO

 Arduino เบื่้องต้น แบบระเอียด 

  • #66 สอนใช้งาน Arduino ขยายขา Analog Input และ Analog Output PCF8591
  • #67 สอนใช้งาน Arduino ขยายขา Analog Input และ Digital Input Multiplexer 74HC4051



บทความ ESP8266 NodeMCU

 

Arduino เบื่้องต้น

รายละเอียดd>1อบรมnodemcu_oit > nextion


รายละเอียดd>1อบรมnodemcu_oit > wifimanager esp8266 การใช้


netpie.gitbooks.io/nodemcu-esp8266-on-netpie/content/lab-6.html

 

รายละเอียดd>1อบรมnodemcu_oit > การเรียกใช้เวลามาตรฐาน NTP


 

 

 

การเรียกใช้เวลามาตรฐาน NTP



การดึงค่าเวลามาตรฐานสากลจากอินเตอร์เน็ต จะดึงจาก Server ที่ให้บริการโพรโทคอล NTP โดย NTP Server มีอยู่ด้วยกันหลายที่  

คำว่า "NTP” จาก https://www.thaicert.or.th/papers/technical/2014/pa2014te002.html  ได้อธิบายความหมายของ ว่า  NTP หรือที่ย่อมาจากคำว่า Network Time Protocol เป็นโพรโทคอลสำหรับการเทียบเวลามาตรฐานและตั้งค่าเวลาบนเครื่องคอมพิวเตอร์นั้นๆผ่านระบบเครือข่าย ส่วนใหญ่ถูกนำมาใช้ในองค์กรเพื่อช่วยทำให้เวลาในเครื่องคอมพิวเตอร์หรือเครื่องแม่ข่ายนั้นมีค่าตรงกัน โดยรูปแบบการทำงานนั้นแบ่งเป็น ส่วนหลักๆคืออุปกรณ์ที่ให้บริการเทียบเวลา (NTP Server) กับเครื่องคอมพิวเตอร์หรืออุปกรณ์ที่ต้องการเทียบเวลา (NTP Client)  โดยโพรโทคอล NTP นั้นเชื่อมต่อผ่านทางระบบเครือข่ายด้วยโพรโทคอล UDP ผ่านพอร์ต 123 (โพรโทคอล UDP มีความรวดเร็วในการรับส่งข้อมูลแต่ก็มีข้อเสียตรงที่โพรโทคอล UDP ไม่มีการตรวจสอบความถูกต้องของข้อมูลที่รับส่งกันอยู่เหมือน TCP)”

วัตถุประสงค์

ใช้ ESP8266 NodeMCU สร้าง Station  เพื่อดึงค่าเวลามาตรฐานจาก  NTP Server  แล้วแสดงผลทาง Serial monitor   

 

อุปกรณ์

  1. ESP8266 NodeMCU
  2. บอร์ดทดลอง (Breadboard)

ตัวอย่างโปรแกรม  ใช้ไลบรารี Time.h  และใช้ ฟังก์ชั่นมาตรฐาน localtime() or gmtime() and the struct tm. เพื่อดึงค่าเป็น วัน-เดือน-ปี ชม- นาที และ วินาที  ค่าที่ดึงได้นี้จะเป็นตัวเลข  ใช้การแปลงจากตัวเลขวัน ตัวเลขเดือน  ให้เป็นชื่อเดือน  ชื่อวัน  ส่วนปี ค.ศ. เปลี่ยนเป็นปี พ.ศ.


โปรแกรม time_ntp3.ino

 

#include <ESP8266WiFi.h>

#include <Time.h>

 

const char* ssid = "TOT";  //  your network SSID (name)

const char* password = "0815610067";       // your network password

const String month_name[12] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

const String day_name[7] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

 

int timezone = 7 * 3600; //ตั้งค่า TimeZone ตามเวลาประเทศไทย

int dst = 0; //กำหนดค่า Date Swing Time

 

void setup()

{

  Serial.begin(115200);

  Serial.setDebugOutput(true);

 

  WiFi.mode(WIFI_STA); //เชื่อมต่อ Wifi

  WiFi.begin(ssid, password);

  Serial.println(" Connecting to WiFi");

  while (WiFi.status() != WL_CONNECTED)

  {

  Serial.print("*");

  delay(1000);

  }

  configTime(timezone, dst, "pool.ntp.org", "time.nist.gov"); //ดึงเวลาจาก Server

  Serial.println(" Loading time");

  while (!time(nullptr)) {

     Serial.print("*");

    delay(1000);

  }

  Serial.println("");

}

 

void loop()

{

   //แสดงเวลาปัจจุบัน

   time_t now = time(nullptr);

   struct tm* p_tm = localtime(&now);

   Serial.print(p_tm->tm_hour);

   Serial.print(":");

   Serial.print(p_tm->tm_min);

   Serial.print(":");

   Serial.print(p_tm->tm_sec);

 

   Serial.print(" / ");

   Serial.print(day_name[(p_tm->tm_wday)]);

   Serial.print("/");

   Serial.print(p_tm->tm_mday);

   Serial.print(" / ");

   Serial.print(month_name[(p_tm->tm_mon)]);

   Serial.print(" / ");

   Serial.print(p_tm->tm_year + 2443);

   Serial.println("");

 

   delay(1000);

}


ความหมาย

1.         configTime  จาก https://github.com/esp8266/Arduino/blob/9913e5210779d2f3c4197760d6813270dbba6232/cores/esp8266/time.c#L58    มีรายละเอียดดังนี้

 

void configTime(int timezone, int daylightOffset_sec, const char* server1, const char* server2, const char* server3)

{

    sntp_stop();

     

    setServer(0, server1);

    setServer(1, server2);

    setServer(2, server3);

     

    sntp_set_timezone(timezone/3600);

    sntp_set_daylight(daylightOffset_sec);

    sntp_init();

}

 

(1)     timezone  ของกรุงเทพเป็น GMT+7  จึงเท่ากับ 7 * 3600

int timezone = 7 * 3600;
ถ้าเป็น San Francisco TimeZone เป็น GMT-7
int timezone = -7 * 3600;

(2)     ค่า 

(3)     server สามารถกำหนด Server ได้ตั้งแต่ 1 ถึง 3 ที่  เช่นถ้าต้องการใช้ NTP Server ของไทยที่มีอยู่หลายแห่งเช่น

Name:    ntp.ku.ac.th

Address:  158.108.212.149

Name:    itoml.live.rmutt.ac.th

Address:  203.158.111.32

Name:    time1.nimt.or.th

Address:  203.185.69.60

Name:    fw.eng.ku.ac.th

Address:  158.108.32.17

Name:    delta.cpe.ku.ac.th

Address:  158.108.32.3

Name:    time2.nimt.or.th

Address:  203.185.69.59

Name:    ilm.live.rmutt.ac.th

Address:  203.158.118.3

Name:   time.navy.mi.th 

Address: 118.175.67.83

Name:    time3.nimt.or.th

Address:  203.185.69.56

Name:    time.uni.net.th

Address:  202.28.18.72

Name:    clock.nectec.or.th

Address:  202.44.204.114

 

 ตัวอย่าง  configTime(timezone, dst,  "time.navy.mi.th");

 2.         โครงสร้างของตัวแปร tm มีดังนี้ 

struct tm {

   int tm_sec;       // วินาที,  มีค่าตั้งแต่ 0 ถึง 59

   int tm_min;      // นาทีมีค่าตั้งแต่ 0 ถึง 59

   int tm_hour;     // ชั่วโมงมีค่าตั้งแต่ 0 ถึง 23

   int tm_mday;   // วันที่มีค่าตั้งแต่ 1 ถึง 31

   int tm_mon;     // เดือนมีค่าตั้งแต่ 0 ถึง 11

   int tm_year;      // ปีคริสศักราช ตั้งแต่ 1900

   int tm_wday;    // วันมีค่าตั้งแต่ 0 ถึง 6 

   int tm_yday;     // วันใน 1 ปีมีค่าตั้งแต่ 0 ถึง 365

   int tm_isdst;     // daylight saving time  

};

        วิธีการเรียกใช้ดูจากตัวอย่างในโปรแกรม

 

 

 การทดสอบ

1.         เมื่อแปลและ Upload ลงไปบน ESP8266 NodeMCU    ให้เปิด Serial Monitor   (อย่าลืมใช้ Baud Rate 115200)  ผลลัพธ์ควรได้ทำนองนี้




 
 
 
Comments

รายละเอียดd>1อบรมnodemcu_oit > การเชื่อมต่อ NodeMCU/ESP8266 กับ NETPIE ด้วย ESP8266 microgear


รายละเอียดd>1อบรมnodemcu_oit > การใช้ WiFiManager กับ ESP8266 (Nodemcu) | WiFiManager with ESP8266


รายละเอียดd>1อบรมnodemcu_oit > webUB.com (เว็บยูบี.คอม) หมู่บ้าน INIZIO หมู่ที่ 1 ถ.เลียบคลองสาม ต.คลองสาม อ.คลองหลวง จ.ปทุมธานี


 webUB.com (เว็บยูบี.คอม)