29 lines
1.1 KiB
C++
29 lines
1.1 KiB
C++
// Pins
|
|
// Arduino pin 2 (RX) to ESP8266 TX
|
|
// Arduino pin 3 to voltage divider then to ESP8266 RX
|
|
// Connect GND from the Arduiono to GND on the ESP8266
|
|
// Pull ESP8266 CH_PD HIGH
|
|
#include <SoftwareSerial.h>
|
|
SoftwareSerial ESPserial(3, 2); // RX | TX
|
|
void setup()
|
|
{
|
|
Serial.begin(9600); // communication with the host computer
|
|
// Start the software serial for communication with the ESP8266
|
|
ESPserial.begin(9600);
|
|
Serial.println("");
|
|
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
|
|
Serial.println("Ready");
|
|
Serial.println("");
|
|
}
|
|
void loop()
|
|
{
|
|
// listen for communication from the ESP8266 and then write it to the serial monitor
|
|
while ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
|
|
// listen for user input and send it to the ESP8266
|
|
while( Serial.available() ) { ESPserial.write( Serial.read() ); }
|
|
|
|
String json = "/json.htm?type=command¶m=udevice&idx=892&nvalue=0&svalue=0;0;0;0;510;0";
|
|
ESPserial.print(json);
|
|
delay(10000);
|
|
}
|