/ Factory_Tests / Feather_ESP32_V2_FactoryTest / Feather_ESP32_V2_FactoryTest.ino
Feather_ESP32_V2_FactoryTest.ino
 1  // SPDX-FileCopyrightText: 2022 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  #define NEOPIXEL_I2C_POWER 2
10  #define NEOPIXEL_PIN 0
11  
12  // the setup routine runs once when you press reset:
13  void setup() {
14    Serial.begin(115200);
15  
16    // turn on the QT port and NeoPixel
17    pinMode(NEOPIXEL_I2C_POWER, OUTPUT);
18    digitalWrite(NEOPIXEL_I2C_POWER, HIGH);
19    
20    // TestBed will handle the neopixel swirl for us
21    TB.neopixelPin = NEOPIXEL_PIN;
22    TB.neopixelNum = 1;
23    TB.begin();
24    TB.setColor(0xFF0000); 
25    delay(50);
26    TB.setColor(0x00FF00); 
27    delay(50);
28    TB.setColor(0x0000FF); 
29  
30    // Set WiFi to station mode and disconnect from an AP if it was previously connected
31    WiFi.mode(WIFI_STA);
32    WiFi.disconnect();
33  }
34  
35  // the loop routine runs over and over again forever:
36  uint8_t wheelColor=0;
37  void loop() {
38    if (wheelColor == 0) {
39      // Test I2C!
40      Serial.print("I2C port ");
41      TB.theWire = &Wire;
42      TB.printI2CBusScan();
43  
44      // Test WiFi Scan!
45      // WiFi.scanNetworks will return the number of networks found
46      int n = WiFi.scanNetworks();
47      Serial.print("WiFi AP scan done...");
48      if (n == 0) {
49          Serial.println("no networks found");
50      } else {
51          Serial.print(n);
52          Serial.println(" networks found");
53          for (int i = 0; i < n; ++i) {
54              // Print SSID and RSSI for each network found
55              Serial.print(i + 1);
56              Serial.print(": ");
57              Serial.print(WiFi.SSID(i));
58              Serial.print(" (");
59              Serial.print(WiFi.RSSI(i));
60              Serial.print(")");
61              Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
62              delay(10);
63          }
64      }
65      Serial.println("");
66    }
67  
68    TB.setColor(TB.Wheel(wheelColor++)); // swirl NeoPixel
69  
70    delay(5);
71  }