// 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>SoftwareSerialwifiSerial=SoftwareSerial(8,9);voidsetup(){// put your setup code here, to run once:Serial.begin(9600);Serial.println("SETUP");wifiSerial.begin(9600);}voidsendAT(){wifiSerial.println("AT");chara;while(wifiSerial.available()>0){a=wifiSerial.read();Serial.print(a);}}voidloop(){// put your main code here, to run repeatedly:while(Serial.available())wifiSerial.write(Serial.read());while(wifiSerial.available())Serial.write(wifiSerial.read());}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.