/ Factory_Tests / QTPy_ESP32C3_FactoryTest / QTPy_ESP32C3_FactoryTest.ino
QTPy_ESP32C3_FactoryTest.ino
 1  // SPDX-FileCopyrightText: 2022 Limor Fried for Adafruit Industries
 2  //
 3  // SPDX-License-Identifier: MIT
 4  
 5  #include <Arduino.h>
 6  #include <Adafruit_NeoPixel.h>
 7  #include "Adafruit_TestBed.h"
 8  #include <WiFi.h>
 9  extern Adafruit_TestBed TB;
10  
11  #define PIN_NEOPIXEL 2
12  
13  void setup() {
14    Serial.begin(115200);
15    //while (! Serial) delay(10);
16  
17    Serial.println("QT Py ESP32 C3!");
18  
19    TB.neopixelPin = PIN_NEOPIXEL;
20    TB.neopixelNum = 1; 
21    TB.begin();
22    TB.setColor(0xFF0000);
23    delay(50);
24    TB.setColor(0x00FF00);
25    delay(50);
26    TB.setColor(0x0000FF);
27    delay(50);
28  }
29  
30  uint8_t j = 0;
31  
32  void loop() {  
33    TB.setColor(TB.Wheel(j++));
34    delay(10);
35  
36    if (j == 255) {
37      TB.setColor(GREEN);
38      Serial.println("scan start");
39      // WiFi.scanNetworks will return the number of networks found
40      int n = WiFi.scanNetworks();
41      Serial.println("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  }