Seriell Monito

I want to do 2 sketches in one.
The first sketch counts a button and shows at the seriell monitor.
The second sketch can send a text to my smartphone.

I don´t know how to put in the text of the seriell monitor into the field, who is showed on my mobile.

Can someone help me?

Sketch1:

const int buttonPin = 0;
//pin0 ist digital3
const int ledPin = 13;

// Variables will change:
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}

void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
buttonPushCounter++;
Serial.println("");
Serial.print(" “);
Serial.println(buttonPushCounter);
} else {
Serial.println(”");
}
delay(50);
}
lastButtonState = buttonState;
if (buttonPushCounter % 4 == 0) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}

}

Sketch2:

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

#ifndef STASSID
#define STASSID “FRITZ!Box 7490”
#define STAPSK “password”
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
digitalWrite(led, 1);
server.send(200, “text/plain”, “here will be the text on the smartphone.”);
digitalWrite(led, 0);
}

void handleNotFound() {
digitalWrite(led, 1);
String message = “File Not Found\n\n”;
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? “GET” : “POST”;
message += "\nArguments: ";
message += server.args();
message += “\n”;
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + “\n”;
}
server.send(404, “text/plain”, message);
digitalWrite(led, 0);
}

void setup(void) {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");

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

if (MDNS.begin(“esp8266”)) {
Serial.println(“MDNS responder started”);
}

server.on("/", handleRoot);

server.on("/inline", {
server.send(200, “text/plain”, “this works as well”);
});

server.onNotFound(handleNotFound);

server.begin();
Serial.println(“HTTP server started”);
}

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

I hope that someone can help me
Jonas

To make it easy for people to help you please modify your post and use the code button </>
codeButton.png

so your code looks like this and is easy to copy to a text editor. See How to use the Forum

Your code is too long for me to study quickly without copying to my text editor. The text editor shows line numbers, identifies matching brackets and allows me to search for things like all instances of a particular variable or function.

Also please use the AutoFormat tool to indent your code for easier reading.

This Simple Merge Demo may help.

...R