-->
Page 1 of 1

Serial communication with Arduino Nano & ESP-12 not working

PostPosted: Mon Feb 27, 2017 7:51 pm
by mietzekotze
Hey guys,

I hope you can help me. I'm trying to make a web-controlled TV remote. For this I want to connect an IR LED to an Arduino Nano and connect it to an ESP-12 for the wifi access.

Both of the boards are supposed to communicate via software serial, thats the code I have set up for this

The modified "HelloServer"-Example code for the ESP:
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <SoftwareSerial.h>
#include <WiFiManager.h>

ESP8266WebServer server(80);
SoftwareSerial arduino(14, 12); // RX, TX

void handleRoot() {
  server.send(200, "text/plain", "hello from esp8266!");
}

void handleNotFound(){
  server.send(200, "text/plain", "not found"); 
}

void handleData(){
  String message = "";
 
  if(server.hasArg("code")){
    message += server.arg("code");
    arduino.println(message); 
  } else {
    message += "No valid parameter given";
  }

  server.send(200, "text/plain", message);
}

void setup(void){
  Serial.begin(4800);

  WiFiManager wifiManager;
  wifiManager.autoConnect("AutoConnectAP");
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  if (MDNS.begin("esp8266.local")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);

  server.on("/data", handleData);

  server.onNotFound(handleNotFound);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();
}


and this one for the Arduino Nano:

Code: Select all#include <SoftwareSerial.h>
#include <IRremote.h>

SoftwareSerial esp(4, 5); // RX, TX
IRsend irsend;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(4800);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  esp.begin(4800);
  Serial.println("Let's go");
}

void loop() { // run over and over
  if (esp.available()) {
    Serial.println(esp.read());
  }
}


The problem is that on the serial monitor I only receive weird readings like this:

Code: Select allLet's go
130
255
72
255
133
255
26
146
255
4
255
237
9
255
0
29
127
84
168
255
145
93
40
255
16
0
255
85
170
255
85
141
253
85
171
255
17
84
255
170
255
85
141
85
74
84
89
247
93
170
255
170
255
84
213
255
65
255
85
255
92
255
170
255
141
170
255
85
76
86
255
85
85
255
93
81
255
85
92
85
29
93
84
255
170
16
160
255
92
253
93
85
255
17
178
254
85
84
255
92



Does someone know what my mistake is?

I hope you can help me!

Kind regards