QTPy_ESP32S2_FactoryTest.ino
1 // SPDX-FileCopyrightText: 2021 Limor Fried for Adafruit Industries 2 // 3 // SPDX-License-Identifier: MIT 4 5 #include "WiFi.h" 6 #include <Adafruit_TestBed.h> 7 extern Adafruit_TestBed TB; 8 9 // the setup routine runs once when you press reset: 10 void setup() { 11 Serial.begin(115200); 12 13 // Set up QT port 14 Wire1.setPins(SDA1, SCL1); 15 16 // TestBed will handle the neopixel swirl for us 17 TB.neopixelPin = PIN_NEOPIXEL; 18 TB.neopixelNum = 1; 19 TB.begin(); 20 21 // Set WiFi to station mode and disconnect from an AP if it was previously connected 22 WiFi.mode(WIFI_STA); 23 WiFi.disconnect(); 24 } 25 26 // the loop routine runs over and over again forever: 27 uint8_t wheelColor=0; 28 void loop() { 29 if (wheelColor == 0) { 30 // Test I2C! 31 Serial.print("Default (pads) port "); 32 TB.theWire = &Wire; 33 TB.printI2CBusScan(); 34 Serial.print("Secondary (QT) port "); 35 TB.theWire = &Wire1; 36 TB.printI2CBusScan(); 37 38 // Test WiFi Scan! 39 // WiFi.scanNetworks will return the number of networks found 40 int n = WiFi.scanNetworks(); 41 Serial.print("WiFi AP scan done..."); 42 if (n == 0) { 43 Serial.println("no networks found"); 44 } else { 45 Serial.print(n); 46 Serial.println(" networks found"); 47 for (int i = 0; i < n; ++i) { 48 // Print SSID and RSSI for each network found 49 Serial.print(i + 1); 50 Serial.print(": "); 51 Serial.print(WiFi.SSID(i)); 52 Serial.print(" ("); 53 Serial.print(WiFi.RSSI(i)); 54 Serial.print(")"); 55 Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); 56 delay(10); 57 } 58 } 59 Serial.println(""); 60 } 61 62 TB.setColor(TB.Wheel(wheelColor++)); // swirl NeoPixel 63 64 delay(5); 65 }