My Nodemcu don't run my code

Hi, i want to create a simple wireless switch control for tasmota.
To my nodemcu, will be a button attached to GPIO 14 (D5), when pulled LOW, should connect to the main tasmota device via http command.
Im not an expert in C++ programming. I created this code:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>

const int ledPin = 2;
const int ButtonPin = 14;
const char* ssid = "MY SSID";
const char* psw = "MY PASSWORD";
const char* url = "http://TASMOTA_IP/cm?cmnd=POWER%20TOGGLE";

void setup() {
Serial.println("TASMOTA REMOTE TOGGLE");
Serial.println("Serial Debug comm started successfully");
WiFi.begin(ssid, psw);
Serial.println("Started connection attempt to values specified in IDE");
while (WiFi.status() != WL_CONNECTED) {
void loop() {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);
int buttonstate = digitalRead(ButtonPin);
  if (buttonstate == LOW) {
    WiFiClient client;
    Serial.println("BUTTON PRESSED- attempted a client connection to URL specified in IDE-----");
    client.connect(url, 80);


This is my Platformio.ini:

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps = 
monitor_port =

when uploading the code via the upload function, it flashes successfully, but the ESP don’t run it.
Instead of showing normally serial output, it shows only unrecognized and crazy symbols…

What I’m doin’ wrong??
Thank you for your help!!!


Do you notice anything? :slight_smile: (Hint)

Tried to change the baud rate matching the one set up in the code, but nothing changes.

Is it hung in a boot loop or a boot error? Set monitor_speed = 74880 and start the serial monitor again and press the reset button. What’s the output of the bootloader?