추가 설치가 필요한가 봅니다. Arduino IDE 하단에 다음 메시지가 보여 클릭했습니다. 다음 메시지가 보이지 않으면 메뉴에서 툴 > 보드 > 보드 메니저를 선택한 후, 다음에 보이는 스크릿샷에 보이는 검색어를 입력하여 설치를 진행하면 됩니다.
보드 매니저에서 검색된 Arduino UNO R4 Boards 패키지를 설치했습니다.
설치 완료후 메뉴에서 보드 > Arduino Renesas UNO R4 Boards > Arduino UNO R4 WiFi를 선택할 수 있었습니다.
3. WiFiChatServer 예제 테스트 - 1차
메뉴의 파일 > 예제를 선택해보면 Arduino UNO R4 WiFi의 예제라는 항목이 보입니다. 그 중에 WiFiS3에 있는 WiFiChatServer를 선택해봅니다.
다음 코드가 불러와집니다. 코드를 보면 한글자를 수신받아 바로 다시 전송하도록 되어있습니다.
다음 2줄을 공유기의 SSID와 패스워드로 교체해줍니다.
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
예를 들어 다음처럼 바꾸면 됩니다.
char ssid[] = "SSID"; // your network SSID (name)
char pass[] = "PASSWORD"; // your network password (use for WPA, or use as key for WEP)
/* Chat Server A simple server that distributes any incoming messages to all connected clients. To use, telnet to your device's IP address and type. You can see the client's input in the serial monitor as well. This example is written for a network using WPA encryption. For WEP or WPA, change the WiFi.begin() call accordingly. Circuit: * Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and Uno WiFi Rev.2) created 18 Dec 2009 by David A. Mellis modified 31 May 2012 by Tom Igoe Find the full UNO R4 WiFi Network documentation here: https://docs.arduino.cc/tutorials/uno-r4-wifi/wifi-examples#wi-fi-chat-server */ #include <WiFiS3.h> #include "arduino_secrets.h" ///////please enter your sensitive data in the Secret tab/arduino_secrets.h char ssid[] = SECRET_SSID; // your network SSID (name) char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP) int keyIndex = 0; // your network key index number (needed only for WEP) int status = WL_IDLE_STATUS; WiFiServer server(23); boolean alreadyConnected = false; // whether or not the client was connected previously voidsetup() { //Initialize serial and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } // check for the WiFi module: if (WiFi.status() == WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); // don't continue while (true); } String fv = WiFi.firmwareVersion(); if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.println("Please upgrade the firmware"); } // attempt to connect to WiFi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); } // start the server: server.begin(); // you're connected now, so print out the status: printWifiStatus(); } voidloop() { // wait for a new client: WiFiClient client = server.available(); // when the client sends the first byte, say hello: if (client) { if (!alreadyConnected) { // clear out the input buffer: client.flush(); Serial.println("We have a new client"); client.println("Hello, client!"); alreadyConnected = true; } if (client.available() > 0) { // read the bytes incoming from the client: char thisChar = client.read(); // echo the bytes back to the client: server.write(thisChar); // echo the bytes to the server as well: Serial.write(thisChar); } } } voidprintWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your board'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"); }
Member discussion