B4R Question NodeMCU ESP8266 ESP12F - cannot upload the sketch - CH340G drivers

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi everybody,

after a long period I decided to play again with B4R and I faced a problem.

I have bought (and received) this module
Geekcreit® Mini NodeMCU ESP8266 WIFI Development Board Based On ESP-12F

I have updated the library of ESP8266 to 2.5.2 and B4R in version 3.0.0.
In B4R I have this settings:

upload_2019-12-13_16-51-20.png


upload_2019-12-13_16-52-30.png



I run the sketch. Everything looks to compile fine but when it tries to install the sketch nothing happens (the red led on the board stays constantly on - no blinking as the arduinos) and I get the following log error.

B4R Version: 3.00
Parsing code. (0.00s)
Building folders structure. (0.01s)
Compiling code. (0.00s)
Building project (0.02s)
Compiling & deploying Ino project (NodeMCU 1.0 (ESP-12E Module) - COM1) Error
Loading configuration...
Initializing packages...
.
.
.
.
.
Preparing boards...
Verifying...
Uploading...
esptool.py v2.6
2.6
esptool.py v2.6
Serial port COM1
Connecting........_____....._____....._____....._____....._____....._____.....____Traceback (most recent call last):
File "C:\Users\Nikos\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py", line 25, in <module>
esptool.main(fakeargs)
File "C:/Users/Nikos/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 2653, in main
esp.connect(args.before)
File "C:/Users/Nikos/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py", line 468, 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
_
An error occurred while uploading the sketch
DEBUG StatusLogger Stopping LoggerContext[name=af3868, org.apache.logging.log4j.core.LoggerContext@10ab13f]
DEBUG StatusLogger Stopping LoggerContext[name=af3868, org.apache.logging.log4j.core.LoggerContext@10ab13f]...
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868]
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868,component=StatusLogger]
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868,component=ContextSelector]
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=af3868,component=Loggers,name=]
TRACE StatusLogger Unregistering 2 MBeans: [org.apache.logging.log4j2:type=af3868,component=Appenders,name=RollingFile, org.apache.logging.log4j2:type=af3868,component=Appenders,name=Console]
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=af3868,component=AsyncAppenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=af3868,component=AsyncLoggerRingBuffer'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=af3868,component=Loggers,name=*,subtype=RingBuffer'
TRACE StatusLogger Stopping XmlConfiguration[location=jar:file:/C:/B4X/Tools/B4R/arduino-1.8.10/lib/pde.jar!/log4j2.xml]...
TRACE StatusLogger XmlConfiguration notified 2 ReliabilityStrategies that config will be stopped.
TRACE StatusLogger XmlConfiguration stopping 1 LoggerConfigs.
TRACE StatusLogger XmlConfiguration stopping root LoggerConfig.
TRACE StatusLogger XmlConfiguration notifying ReliabilityStrategies that appenders will be stopped.
TRACE StatusLogger XmlConfiguration stopping remaining Appenders.
DEBUG StatusLogger Shutting down RollingFileManager C:\Users\Nikos\AppData\Local\Arduino15/logs/application.log
DEBUG StatusLogger Shutting down RollingFileManager C:\Users\Nikos\AppData\Local\Arduino15/logs/application.log
DEBUG StatusLogger All asynchronous threads have terminated
DEBUG StatusLogger RollingFileManager shutdown completed with status true
DEBUG StatusLogger Shut down RollingFileManager C:\Users\Nikos\AppData\Local\Arduino15/logs/application.log, all resources released: true
DEBUG StatusLogger Appender RollingFile stopped with status true
DEBUG StatusLogger Shutting down OutputStreamManager SYSTEM_ERR.false.false
DEBUG StatusLogger Shut down OutputStreamManager SYSTEM_ERR.false.false, all resources released: true
DEBUG StatusLogger Appender Console stopped with status true
TRACE StatusLogger XmlConfiguration stopped 2 remaining Appenders.
TRACE StatusLogger XmlConfiguration cleaning Appenders from 2 LoggerConfigs.
DEBUG StatusLogger Stopped XmlConfiguration[location=jar:file:/C:/B4X/Tools/B4R/arduino-1.8.10/lib/pde.jar!/log4j2.xml] OK
DEBUG StatusLogger Stopped LoggerContext[name=af3868, org.apache.logging.log4j.core.LoggerContext@10ab13f] with status true

(Full Error Log)

The code I run was copied from the forum and it is the following:

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private wifi As ESP8266WiFi
    Private server As WiFiServerSocket
    Private astream As AsyncStreams
    '    Private ser As B4RSerializator
End Sub

Private Sub AppStart
    Serial1.Initialize(57600)
    Log("AppStart")
    RunNative( "SetIP" , Null )' STATIC IP 192.168.1.6 ---> code #if C
    'ACCESS POINT
    If wifi.StartAccessPoint2("NFAccessPointESP","12345678") Then ' Router SSID e Passw.
        Log("Connected Access Point")
        Log("Module ESP-12 IP: ", wifi.LocalIp)
    Else
        Log("Failed to connect")
        Return
    End If

    server.Initialize(51042, "server_NewConnection")
    server.Listen
End Sub

Sub Server_NewConnection (NewSocket As WiFiSocket)
    Log("Client connected")
 
    astream.Initialize(NewSocket.Stream, "astream_NewData", "astream_Error")
End Sub

Sub AStream_NewData (Buffer() As Byte)
 
End Sub

Sub AStream_Error
    Log("Error")
    server.Listen
End Sub

'STATIC IP (Replace with desired IP)
#if C
  void SetIP(B4R::Object* o) {
  IPAddress ip(192, 168, 1, 50);  // (Replace with desired IP)
  IPAddress gateway(192, 168, 1, 1);
  IPAddress subnet(255, 255, 255, 0);
  WiFi.config(ip, gateway, subnet);
  }
#end if

When I also try to update the com ports I see only COM1 again.

Any suggestion will be highly appreciated.
 
Last edited:

hatzisn

Well-Known Member
Licensed User
Longtime User
Hi XorAndOr, I tried to install the driver as I downloaded it from here:
https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all

The result is that I get a "Install failure" error.

I tried uninstalling it and then installing it and I 've got a successful uninstallation and then a successful installation message that said "The installation was successful. The driver was pre-installed. I tried to upload the sketch and the problem persists.

I tried also removing the board and reconnecting it and then I also tried to remove the board from the USB and refresh the COM Ports and the COM1 was still there so I suppose it has to do with the Printer or the camera.

Anything else I am missing here?
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
1.8.10. I think this has to do with windows though...
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
1) check using Arduino IDE when it works then use B4R

2) Unconect any other circuit added to your ESP, reconnect just after uploaded the firmware.

3) somewhere in Windows you can change manually the port com maybe com1 is already used.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
@f0raster0
1) check using Arduino IDE when it works then use B4R
2) Unconect any other circuit added to your ESP, reconnect just after uploaded the firmware.
3) somewhere in Windows you can change manually the port com maybe com1 is already used.

Thank you @f0raster0 for answering... Here is what I've done.
In 1) The only port see I see is COM1
In 2) I tried it without connecting anything
The 3) looks promising and I will try it asap (Win10).

@XorAndOr
try to change usb cable,
maybe the one you use has only 2 wires for charging the phone (+ -),
while here we need 4 wires (Vcc data+ data- Gnd),
I'm sorry I don't know anything else to advise you

I suppose the cable is a data cable because I use the same to upload in my Android Phone the apps I create in B4A.
If it doesn't work with the advice if @f0raster0 then I suppose it has to be either a driver problem (probably not) or
a broken CH340G. Thank you anyway @XorAndOr for your time.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
I had no luck with the communication of CH340G with the computer. Probably a broken IC.
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Definitely a CH340G Problem. I downloaded the latest drivers from the site of WCH and nothing happened:
Here are the drivers: http://www.wch.cn/download/CH341SER_EXE.html

Though, when I inserted an arduino clone with the same chip it was recognized and a port appeared:

upload_2019-12-17_18-38-57.png


Bad luck... Or bad cable? (The arduino clone is connected with another cable)
I suppose since I am able to upload applications to my Android Phone with the other cable it has Data+ & Data-. Right?

I also tried changing the com number with no luck...
 
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Thanks for answering thetahsk. The driver is installed correctly (see previous message)... I suppose I had bad luck in the board I received.
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
the driver can be installed but could not be the right driver..

if wrong with board..start checking with a multimeter power

Are you using Anrduino IDE?
 
Upvote 0
Top