I have created a weather station on ESP8266 NodeMCU which has a web interface with logs. I've connected DHT22 on ESP8266 NodeMCU and a BMP180 on an Arduino Uno. Arduino Uno sends pressure to the ESP8266 NodeMCU via serial communication and ESP8266 logs all data it has received from Arduino Uno. The problem is that when I access the logs sometimes I get good output such as 1022.23 hPa, but sometimes the browser asks me to download the logs and when i open it I get garbage output like LLɂҢ˘rš‚Ň’ŞŇŠĘŇŠŠrŞÂŇŠ‚’šr’˘ţ. This is the code of serial communication:

#include <SoftwareSerial.h>
#include <ESP8266WebServer.h>

ESP8266WebServer server(80);
SoftwareSerial s(D6, D5);

String logs = "";

void logFunc(String logstring) {
  logs += logstring + "\n";

void setup() {
server.on("/logs", handleLogs);

void loop(){
if (s.available() > 0)
    serial = s.readString();
    logFunc(serial); //function for logging
void handleLogs() {
  server.send(200, "text/plain", logs);

What could be the cause and how can I fix it?

  • Are you sure that the Uno is sending the right data? – Majenko Apr 11 at 12:03
  • Yes, I was getting clear output when I was reading the output on the Serial Monitor. – Janko Pjer Apr 11 at 12:38
  • this can't compile – Juraj Apr 11 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.