DEV Community

Esther mueni
Esther mueni

Posted on

Getting started with Esp-12F

Alt Text
Esp-12F is a miniature WiFi Module present in the market. It is used to establish a wireless network connection for microcontrollers or processors. Esp-12F is based on the ESP8266 module, with built-in 32Mbit Flash, in the small SMD22 package.

There are many ways of programming Esp-12F module. Some include:

  • Using a dedicated programmer board
  • using NodeMCU
  • using a dedicated USB-to-Serial adapter
  • using a witty cloud development board

For this tutorial, I am using a dedicated USB-to-Serial adapter to program the Esp-12F module via Arduino IDE.

Requirements

Esp-12f
USB-to-serial FTDI(YP-05)
Esp-12F breakout board
A couple of jumper wires

Connecting the Devices

To make connection with Esp-12F module easier, I am using a breakout board.

Alt Text

I am connecting the devices as shown below:

Alt Text

Running the first program

The code I am using to get started with the Esp-12F module is a WiFi scan code. This program will scan all the WiFi networks within reach of the module.

Before running the code, I am installing FTDI drivers in my laptop. The documentation provided in the website provides a clear guide on the installation process. I am installing the divers to enable my Arduino IDE to read the FTDI as a COM port.

Once the installation is complete, I am uploading the code shown below for WiFi Scan. If the connection was correct and the code runs successfully, the Serial Monitor should display the WiFi networks within reach.

#include "ESP8266WiFi.h"
#define BLINK_PERIOD 250
long lastBlinkMillis;
boolean ledState;

#define SCAN_PERIOD 5000
long lastScanMillis;

void setup()
 {
  Serial.begin(115200);
  Serial.println();

  pinMode(LED_BUILTIN, OUTPUT);

  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
}

void loop()
{
  long currentMillis = millis();

  // blink LED
  if (currentMillis - lastBlinkMillis > BLINK_PERIOD)
  {
    digitalWrite(LED_BUILTIN, ledState);
    ledState = !ledState;
    lastBlinkMillis = currentMillis;
  }

  // trigger Wi-Fi network scan
  if (currentMillis - lastScanMillis > SCAN_PERIOD)
  {
    WiFi.scanNetworks(true);
    Serial.print("\nScan start ... ");
    lastScanMillis = currentMillis;
  }

  // print out Wi-Fi network scan result upon completion
  int n = WiFi.scanComplete();
  if(n >= 0)
  {
    Serial.printf("%d network(s) found\n", n);
    for (int i = 0; i < n; i++)
    {
      Serial.printf("%d: %s, Ch:%d (%ddBm) %s\n", i+1, WiFi.SSID(i).c_str(), WiFi.channel(i), WiFi.RSSI(i), WiFi.encryptionType(i) == ENC_TYPE_NONE ? "open" : "");
    }
    WiFi.scanDelete();
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)