Hi, I would transmit ESP8266-01 serial.println messages to Arduino in order to output them on serial monitor and/or execute code depending on the message arrivated to Arduino. I tried with
#include <SoftwareSerial.h> //Including the AltSoftSerial library
SoftwareSerial esp (8,9);
void setup() {
Serial.begin(9600);
esp.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(esp.read());
}
and
#include <AltSoftSerial.h> //Including the AltSoftSerial library
AltSoftSerial esp;
void setup() {
Serial.begin(9600);
esp.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(esp.read());
}
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
/* Set these to your desired credentials. */
const char *ssid = "APOG";
const char *password = "98761234";
ESP8266WebServer server(80);
/* Just a little test message. Go to http://192.168.4.1 in a web browser
connected to this access point to see it.
*/
void handleRoot() {
server.send(200, "text/html", "<h1>You are connected</h1>");
}
void setup() {
delay(1000);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
// server.on("/genericArgs", handleGenericArgs); //Associate the handler function to the path
server.on("/specificArgs", handleSpecificArg); //Associate the handler function to the path
server.begin(); //Start the server
Serial.println("Server listening");
}
void loop() {
server.handleClient();
}
void handleSpecificArg() {
String message = "";
if (server.arg("Temperature")== ""){ //Parameter not found
message = "Temperature Argument not found";
}else{ //Parameter found
message = "Temperature Argument = ";
message += server.arg("Temperature"); //Gets the value of the query parameter
}
server.send(200, "text/plain", message); //Returns the HTTP response
Serial.println(message);
}
I tried to connect the esp to pc via USB adaptor and it prints!
I also tried to edit the baud rate to 115200 without success...!
It's definitely not going to work if you have the ESP8266 configured to run at 115200 but the other board running at 9600. The baud rates must match. Also, SoftwareSerial library won't work reliably at 115200 so 9600 is a safe rate to get things working.
void loop() {
// put your main code here, to run repeatedly:
Serial.println(esp.read());
}
You get -1 because you are reading the serial port even if there is nothing in the buffer. The serial read function returns -1 for an empty receive buffer. To check if there is something in the buffer to read use the available() function.