Wakeup with no radio

dev board WeMos D1 Mini
chip ESP8266
features wakeup no radio

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Buy the components

Code

Download code wakeup-with-no-radio.ino
#include <ESP8266WiFi.h>

// Edit "secret" ssid and password below
const char* ssid = "secret";
const char* password = "secret";
int count = 0;

void setup() {
  pinMode(2, OUTPUT); // GPIO02 on ESP-12 module is linked to on-board LED

  Serial.begin(115200);
  delay(10);

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    count++;
    Serial.print(".");

    if (count > 20) {
      Serial.println("WiFi connection failed");
      break;
    }
  }

  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("");
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());

    pinMode(LED_BUILTIN, OUTPUT);
  }
}

void loop() {
  if (WiFi.status() == WL_CONNECTED) {
    digitalWrite(2, HIGH);
    Serial.println(WiFi.localIP());
    delay(1000);
    digitalWrite(2, LOW);
    delay(1000);
  }

  Serial.println("Deep sleeping for 5 seconds...");
  ESP.deepSleep(5000000, WAKE_RFCAL);
  // Vary the parameters to test WiFi Connectivity
  // WAKE_RF_DEFAULT: WiFi connection is successful
  // WAKE_RFCAL: WiFi connection is successful
  // WAKE_NO_RFCAL: WiFi connection is successful
  // WAKE_RF_DISABLED: WiFi connection should fail
}

Makefile

BOARD?=esp8266com:esp8266:d1_mini
PORT?=/dev/cu.wchusbserial1410
BUILD=build
# Arduino CLI version 0.14.0 is used.

.PHONY: default lint all flash clean

default: lint all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./

flash:
	arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD)

clean:
	rm -r build

Description

Wakeup from deep sleep with various options to turn on / off the radio.

In ESP8266, there are four options and params:

  1. [WAKE_RF_DEFAULT] deepsleepsetoption(0): Radio calibration after deep-sleep wake up depends on init data byte 108.
  2. [WAKE_RFCAL] deepsleepsetoption(1): Radio calibration is done after deep-sleep wake up; this increases the current consumption.
  3. [WAKE_NO_RFCAL] deepsleepsetoption(2): No radio calibration after deep-sleep wake up; this reduces the current consumption.
  4. [WAKE_RF_DISABLED] deepsleepsetoption(4): Disable RF after deep-sleep wake up, just like modem sleep; this has the least current consumption; the device is not able to transmit or receive data after wake up.

References