Snippets

Grant Young AT command serial prompt

Created by Grant Young last modified
// NOTE: save this as a .ino file to open in the Arduino IDE
// This requires you to have the Arduino connected to the ESP8266 using digital pin
// 8 (Arduino Receive-->ESP8266 Transmit) and 9 (Arduino Transmit-->ESP8266 Receive)
// via a logic level converter (or equivalent) for 5v-based Arduinos
// 
// All it does is take the input from the Serial monitor window (type your AT command 
// in the text box, then press [Send]) and send it to the ESP, returning any response 
// from the ESP to the serial window.
// 
// The sendAT() method is simply an example of how you would send a command using
// the SoftwareSerial.println() method, and a bare-bones example of "listening" for
// the response.

#include <SoftwareSerial.h>

SoftwareSerial wifiSerial = SoftwareSerial(8,9);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("SETUP");
  
  wifiSerial.begin(9600);
  
}

void sendAT() {
  wifiSerial.println("AT");
  char a;
  while(wifiSerial.available() > 0) {
      a = wifiSerial.read();
      Serial.print(a);
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  while(Serial.available()) wifiSerial.write(Serial.read());
  while(wifiSerial.available()) Serial.write(wifiSerial.read());
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.