[HELP] Error uploading data nodemcu

Hi all,

in this case i use 4 pins in my nodemcu for communicate to arduino, i use pin D2, D3 and D5,D6. But the trouble is when i put up pin D2,D3 its always error the program wont uploaded into my nodemcu, but when i release pin D2,D3 and i upload the program and then the program installed correctly then i put up the pin D2,D3 again (when the program has been uploaded) and its no error with the program.

my serial pin
ARDUINO NODEMCU
PIN 2 D2
PIN 3 D3
PIN 5 D5
PIN 6 D6
GROUND GROUND

here's the message for error

Sketch uses 278252 bytes (26%) of program storage space. Maximum is 1044464 bytes.
Global variables use 28152 bytes (34%) of dynamic memory, leaving 53768 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.8
Serial port COM6
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
  File "C:\Users\Home\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3/tools/upload.py", line 65, in <module>
    esptool.main(cmdline)
  File "C:/Users/Home/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 2890, in main
    esp.connect(args.before)
  File "C:/Users/Home/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/tools/esptool\esptool.py", line 483, in connect
    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

_

and here's my nodemcu code

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>

const char* ssid = "#####";
const char* password = "#####";
const char* host = "#####";
const int httpPort = 80;
WiFiClient client;

SoftwareSerial s(D6, D5);
SoftwareSerial s1(D3, D2);
int counter0;
int counter1;

String request_string;
HTTPClient http;


void setup() {
  s.begin(9600);
  s1.begin(9600);
  Serial.begin(9600);
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  Serial.println("Wifi connected");
  Serial.println("IP adress: ");
  Serial.println(WiFi.localIP());
  Serial.println("NesMask: ");
  Serial.println(WiFi.subnetMask());
  Serial.println("Getway: ");
  Serial.println(WiFi.gatewayIP());
  //End

}

void loop() {

  if (s.available() ) {
    counter0 = s.read();
    Serial.println();
    Serial.print("Reader0 menerima data ");
    Serial.println();
    Serial.print("Counter 0 = ");
    Serial.print(counter0);
    Serial.println();
    koneksi_database();
    delay(1000);
 } else  if (s1.available() ) {
    counter1 = s1.read();
    Serial.println();
    Serial.print("Reader1 menerima data ");
    Serial.println();
    Serial.print("Counter 1 = ");
    Serial.print(counter1);
    Serial.println();
    koneksi_database();
    delay(1000);
  }

}

void koneksi_database() {
  if (!client.connect(host, 80)) {
    Serial.println("Gagal Konek");
    return;
  }

  client.print("GET /rfid/index.php?data1=");
  client.print(counter0);
  client.print("&data2=");
  client.print(counter1);
  client.print(" HTTP/1.1");
  client.println();
  client.println("Host: #####");
  client.println("Connection: close");
  client.println();
  Serial.print("Mengirim data ke database");
  Serial.println();
  Serial.print("Reader 0 = ");
  Serial.println(counter0);
  Serial.println();
  Serial.print("Reader 1 = ");
  Serial.println(counter1);
  Serial.println();
  client.stop();

}

anyway sorry for my bad english :smiley:

The state of pin 2 at power up will affect the boot mode. See this page.

i tried change into pin D4 and D3, but the problem is still same :confused:

Did you put a pull-up on pin 2?

groundFungus:
Did you put a pull-up on pin 2?

yes i pull up pin 2 so the serial pin like this

ARDUINO NODEMCU
PIN 3 D3
PIN 4 D4
PIN 5 D5
PIN 6 D6
GROUND GROUND