HttpResponse = httpHeader + content + " " // There is a bug in this code: the last character of "content" is not sent, I cheated by adding this extra space HttpHeader +="Connection: close\r\n\r\n" HttpHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/html charset=UTF-8\r\n" Void sendHTTPResponse(int connectionId, String content) * Description: Function that sends HTTP 200, HTML UTF-8 response The esp has data so display its output to the serial windowĬhar c = esp8266.read() // read the next character. If(secondNumber>=0 & secondNumber millis()) Int pinNumber = (esp8266.read()-48) // get first number i.e. the ASCII decimal value and 0 (the first decimal number) starts at 48Įsp8266.find("pin=") // advance cursor to "pin=" Int connectionId = esp8266.read()-48 // subtract 48 because the read() function returns get the connection id so that we can then disconnect If(esp8266.available()) // check if the esp is sending a messageĭelay(1000) // wait for the serial buffer to fill up (read all the serial data) SendCommand("AT+CIPSERVER=1,80\r\n",1000,DEBUG) // turn on server on port 80 SendCommand("AT+CIPMUX=1\r\n",1000,DEBUG) // configure for multiple connections SendCommand("AT+CIFSR\r\n",1000,DEBUG) // get ip address SendCommand("AT+CWMODE=1\r\n",1000,DEBUG) // configure as access point SendCommand("AT+RST\r\n",2000,DEBUG) // reset module and the RX line from the esp to the Arduino's pin 3Įsp8266.begin(9600) // your esp's baud rate might be different This means that you need to connect the TX line from the esp to the Arduino's pin 2 SoftwareSerial esp8266(18,19) // make RX Arduino line is pin 2, make TX Arduino line is pin 3. Im trying to connect wifi module to my MEGA 2560 board.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |