Page 190 - MDP2022-2
P. 190

*  @author  hanse  (im763741@gmail.com)
              *  @version  1.0
              *  @date  2022-10-20
              *
              *  @copyright  Copyright  (c)  2022
              *
              */
            #include  <ESP8266WiFi.h>
            #include  <PubSubClient.h>
            #include  <string.h>


            const  char  *ssid  =  "project_two";
            const  char  *password  =  "11111111";
            const  char  *mqtt_server  =  "192.168.0.100";


            WiFiClient  espClient;
            PubSubClient  client(espClient);
            unsigned  long  lastMsg  =  0;
            #define  MSG_BUFFER_SIZE  (50)
            char  msg[MSG_BUFFER_SIZE];
            char  to_arduino_msg[MSG_BUFFER_SIZE];
            int  value  =  0;
            int  AT_Step  =  0;


            void  setup_wifi()
            {
                delay(10);
                //  We  start  by  connecting  to  a  WiFi  network


                Serial.println();
                Serial.print("Connecting  to  ");
                Serial.println(ssid);


                WiFi.mode(WIFI_STA);
                WiFi.begin(ssid,  password);


                while  (WiFi.status()  !=  WL_CONNECTED)
                {
                    delay(500);
                    Serial.print(".");
                }


                randomSeed(micros());


                Serial.println("");
   185   186   187   188   189   190   191   192   193   194   195