Categories

EMIS-1 Test Code Wifi

WIKI:

EMIS (Energy Monitoring IoT Sensors), SDK Kit is based on an Espressif ESP32 WROOM, which incorporated 2.4GHz Wireless.

This code simply communicates with the 2.4GHz Wireless and scans for available Access Point or Router networks.

Example Arduino code below.

/*
Dave Williams, DitroniX 2019-2022 (ditronix.net)
EMIS-1 Energy Monitoring IoT Sensors v1.0
Features include ESP32 GTIL RS232 RS485 MODBUS RELAY EEPROM OPTO CT Clamp Current Voltage
PCA v1.00 – Test Code Firmware v1 – 2nd September 2022

Simplified Board Bring Up Test – Wifi Scan
.
Remember!
– Set the BOARD to ESP32 DEV Module (or similar).
– You can also set the BAUD rate up to 921600 to speed up flashing.
– The SDK does NOT need external power to flash. It will take Power from the USB 5V.
.
Note that in the default state, upon first power up and during reset, the Green LED will be partially lit.� Once programmed and the GPIO defined, the Green LED will go off after power up.
.
The purpose of this test code is to cycle through the various main functions of the board as part of bring up testing.
.
This test code is OPEN SOURCE and although is is not intended for real world use, it may be freely used, or modified as needed.
It is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/

#include <WiFi.h>

WiFiClient client; // Initialize the client library

void setup() {

// Stabalise
delay(250);

// Initialize UART:
Serial.begin(115200, SERIAL_8N1); //115200
while (!Serial);

// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
}

void loop() {

Serial.println(“ESP32 WiFi MAC \t ” + WiFi.macAddress());
Serial.println(“Scanning for Access Points or Routers. Please wait….”);
delay(100);

// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.print(“Scan Complete. “);
if (n == 0) {
Serial.println(“No Access Points or Routers Found.”);
} else {
Serial.print(n);
Serial.println(” Access Points or Routers Found.”);
Serial.println(“”);

for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(“: \t”);
Serial.print(WiFi.SSID(i));
Serial.print(” (“);
Serial.print(WiFi.RSSI(i));
Serial.print(“)”);
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? ” ” : “*”);
delay(100);
}
}
Serial.println(“”);
}

Leave a Reply

This site uses User Verification plugin to reduce spam. See how your comment data is processed.
0

Cart Summary (Discounts shown at checkout)

    Product Price Quantity Subtotal

Basket totals

Subtotal £0.00
Total £0.00