Close

#9 The "perfect" version PCB finally arrives and works!

A project log for BW16 Stamp - Tiny 5GHz WiFi Dev Board

Super compact functional 5G Hz WiFi MCU in stamp size with power circuit, work out of the box

simonxiSimonXi 09/28/2022 at 11:030 Comments

Hooray! the latest "perfect" version has finally reached! 

I have tested with a few Arduino Graphic Libraries, but so far the one works the best is Adafruit ST7735 Library, as it supports a number of LCD drivers and sizes and come with a feature-rich API set.

The biggest change to the previous version is the change of 160x80 footprint and correcting the wrong slide switch connection. However, this lesson have ot be learnt the hard way-- it took me weeks before I can get my hand on the latest PCB. So, despite all the goods in open-source community, 

Always double check your code/parts after using any 3rd party libraries!

Anyway, I have ported the previous Wi-Fi Scanner project to this board, and let's watch a demo video together!

Here is the code used in the example,

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <WiFi.h>


#define TFT_CS         9
#define TFT_RST        6 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC         8

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
  Serial.begin(115200);
  Serial.print(F("Hello! ST77xx TFT Test"));

  // use this initializer (uncomment) if using a 0.96" 160x80 TFT:
  tft.initR(INITR_MINI160x80);  // Init ST7735S mini display
  tft.setRotation(1); // retate 90 degrees
  tft.setCursor(3,2);
  

  Serial.println("test filling screen");
  testFillScreen();

  tft.fillScreen(ST77XX_BLACK);
  tft.invertDisplay(true);
  
  tft.setTextColor(ST77XX_BLUE);
  tft.setTextSize(1);
  tft.println("Ameba WiFi Scanner        ");
  
  
  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
      Serial.println("WiFi shield not present");
      // don't continue:
      while (true);
  }

  // Print WiFi MAC address:
  printMacAddress();

  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();

  Serial.println("done");
  delay(1000);
}

void loop() {
  delay(100);
}


void testFillScreen() {
    tft.fillScreen(ST77XX_BLACK);
    delay(200);
    tft.fillScreen(ST77XX_RED);
    delay(200);
    tft.fillScreen(ST77XX_GREEN);
    delay(200);
    tft.fillScreen(ST77XX_BLUE);
    delay(200);
    tft.fillScreen(ST77XX_BLACK);
    delay(200);
}


void printMacAddress() {
    // the MAC address of your Wifi shield
    byte mac[6];

    tft.setCursor(tft.getCursorX()+3, tft.getCursorY());
    tft.setTextColor(ST77XX_GREEN);
    tft.setTextSize(1);
    tft.println("MAC Address:");
    // print your MAC address:
    WiFi.macAddress(mac);
    Serial.print("MAC: ");
    Serial.print(mac[0], HEX);
    tft.print(mac[0], HEX);
    tft.print(":");
    Serial.print(":");
    Serial.print(mac[1], HEX);
    tft.print(mac[1], HEX);
    tft.print(":");
    Serial.print(":");
    Serial.print(mac[2], HEX);
    tft.print(mac[2], HEX);
    tft.print(":");
    Serial.print(":");
    Serial.print(mac[3], HEX);
    tft.print(mac[3], HEX);
    tft.print(":");
    Serial.print(":");
    Serial.print(mac[4], HEX);
    tft.print(mac[4], HEX);
    tft.print(":");
    Serial.print(":");
    Serial.println(mac[5], HEX);
    tft.println(mac[5], HEX);
    tft.println();
}

void listNetworks() {
    // scan for nearby networks:
    Serial.println("** Scan Networks **");
    int numSsid = WiFi.scanNetworks();
    if (numSsid == -1) {
        Serial.println("Couldn't get a wifi connection");
        while (true);
    }

    tft.fillScreen(ST77XX_BLACK);
    // print the list of networks seen:
    Serial.print("number of available networks:");
    Serial.println(numSsid);
    tft.setCursor(3,2);
    tft.print("Number of WiFi found:");
    tft.println(numSsid);
    tft.println();

    // print the network number and name for each network found:
    for (int thisNet = 0; thisNet < numSsid; thisNet++) {
        Serial.print(thisNet);
        tft.print(thisNet);
        Serial.print(") ");
        tft.print(") ");
        Serial.print(WiFi.SSID(thisNet));
        tft.print(WiFi.SSID(thisNet));
        tft.print(" : ");
        Serial.print("\tSignal: ");
        Serial.print(WiFi.RSSI(thisNet));
        tft.print(WiFi.RSSI(thisNet));
        Serial.print(" dBm");
        tft.print(" dBm");
        Serial.print("\tEncryptionRaw: ");
        tft.print(", ");
        printEncryptionTypeEx(WiFi.encryptionTypeEx(thisNet));
        Serial.print("\tEncryption: ");
        printEncryptionType(WiFi.encryptionType(thisNet));
    }
}

void printEncryptionTypeEx(uint32_t thisType) {
    /*  Arduino wifi api use encryption type to mapping to security type.
    *  This function demonstrate how to get more richful information of security type.
    */
    switch (thisType) {
        case SECURITY_OPEN:
            Serial.print("Open");
            break;
        case SECURITY_WEP_PSK:
            Serial.print("WEP");
            break;
        case SECURITY_WPA_TKIP_PSK:
            Serial.print("WPA TKIP");
            break;
        case SECURITY_WPA_AES_PSK:
            Serial.print("WPA AES");
            break;
        case SECURITY_WPA2_AES_PSK:
            Serial.print("WPA2 AES");
            break;
        case SECURITY_WPA2_TKIP_PSK:
            Serial.print("WPA2 TKIP");
            break;
        case SECURITY_WPA2_MIXED_PSK:
            Serial.print("WPA2 Mixed");
            break;
        case SECURITY_WPA_WPA2_MIXED:
            Serial.print("WPA/WPA2 AES");
            break;
    }
}

void printEncryptionType(int thisType) {
    // read the encryption type and print out the name:
    switch (thisType) {
        case ENC_TYPE_WEP:
            Serial.println("WEP");
            tft.println("WEP");
            break;
        case ENC_TYPE_TKIP:
            Serial.println("WPA");
            tft.println("WPA");
            break;
        case ENC_TYPE_CCMP:
            Serial.println("WPA2");
            tft.println("WPA2");
            break;
        case ENC_TYPE_NONE:
            Serial.println("None");
            tft.println("None");
            break;
        case ENC_TYPE_AUTO:
            Serial.println("Auto");
            tft.println("Auto");
            break;
    }
}

Discussions