Categories
ESP32 ESP8266 (ESP-01/01S) Microcontrollers

Reading Digital Signal (GPIO Pin)

GPIO pin can be used to read values off from sensor devices and monitor sensor data.

Serial console to display the read of the value from GND/3.3V pins of ESP8266

Requirements

  • Breadboard
  • Jumper wires
  • USB cable
  • ESP8266 D1 Wemos Mini
  • CH340 Driver (USB-UART)
  • Arduino IDE (ESP8266 Library / Board : Lolin D1 Mini)

Layout

D1 Wemos Mini (GPIO 5 – D1 and GND)

Arduino IDE Sketch Code

// Setup the GPIO 5 Pin
// D1 Wemos Mini pin GPIO5
 
int inputPin = 5;
int val = 0;

void setup() {
  // Setup the serial console baud speed
  Serial.begin(115200);
  pinMode(inputPin, INPUT);
}

void loop() {
  // Read the value off GPIO 5 Pin
  val = digitalRead(inputPin);

  // Display state of input pin
  Serial.println(val);
  delay(1000);
}
Arduino IDE’s Serial console output (reading from GND pin)

Resource

https://www.wemos.cc/en/latest/d1/d1_mini.html

https://arduino-esp8266.readthedocs.io/en/latest/