#include <SPI.h>
#include "WizFi250.h"
char ssid[] = "20133057"; // your network SSID (name)
char pass[] = "uw3845aa"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status
char server[] = "35b872ed.ngrok.io";
// Initialize the Ethernet client object
WiFiClient client;
void printWifiStatus();
void setup()
{
Serial.begin(115200);
WiFi.init();
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
// you're connected now, so print out the data
Serial.println("You're connected to the network");
printWifiStatus();
Serial.println();
Serial.println("Starting connection to server...");
// if you get a connection, report back via serial
if (client.connect(server, 80)) {
Serial.println("Connected to server");
// Make a HTTP request
client.println("GET /page.html HTTP/1.1");
client.println("Host: 35b872ed.ngrok.io");
client.println("Connection: close");
client.println();
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them
while (client.available()) {
char c = client.read();
Serial.write(c);
}
}
void printWifiStatus()
{
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
안녕하세요. 코드와 시리얼 모니터 출력 값 입니다.
ngrok를 통해서 임시적으로 웹브라우저를 열었고, 거기서 원하는 값을 시리얼 모니터로 출력했습니다.
여기서 출력한 값(빨간박스)을 저희가 the Day로 두고 이용하려는데
char c = client.read();
Serial.write(c);
char theDay;
theDay = c ;
Serial.println(theDay);
시리얼 모니터의 파란 박스 안의 내용이 전부 the Day로 입력이 됩니다.
빨간 박스안의 내용만 the Day로 받아오려면 어떻게 코드를 수정해야 할까요?
|