B4R Question ESP8266 only works when I disconnect from the IDE

daveinhull

Active Member
Licensed User
Longtime User
Hi

Hope someone can point me in the right direction as this is my first look at using an ESP8266 board.

I purchased a XTVTX V3 Wireless Module ESAP8266 ESP-12F WIFI Development board from Amazon and have managed to download a simple flash LED program to it.
However, it only works when I disconnect it from the IDE and as soon as I connect it, it stops.
I think I've set the correct board (NodeMCU 1.0 (ESP-12E Module))

Has anyone some thoughts on what i might be doing wrong?

Thanks in advance
Dave
 

daveinhull

Active Member
Licensed User
Longtime User
Hi,

I've done a bit more research.
I used the Ardunio IDE to upload a sketch to flash the LED and output a message to the serial monitor (Serial.Println....) and it works without disconnecting anything.
But, as I mentioned it doesn't work when its connected to the B4R IDE, I have to disconnect it first.

What is the difference between the Ardunio Serial.println and the B4R Log.
Is there a serial.println in B4R?

Any thoughts?
Dave
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Hi,

Anyone got any thought son the paths I could take to find out what is happening.
I'm struggling in developing my cde with the log feature and I really don't want to go back to C in the Ardunio IDE :)

Thanks n advance
Dave
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Hi,

Any thoughts anyone?

However, in the meantime, coud you let me know about my two quesitons?
What is the difference between the Ardunio Serial.println and the B4R Log.
Is there a serial.println in B4R?

Thanks
Dave
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
It seems that the ESP8266's from XTVTX are of particularly poor quality. Only absolute low cost components are installed. Other forums talk about the same problems. Replacing the USB cable or installing a 100µF capacitor has helped to some extent. But this is not a problem solution.
Buy from a reasonable dealer not from Amazon. Don't waste your valuable time and destroy the XTVTX Amazon crap.
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Hi thetask,

:oops: Not quite the answer I was hoping for, but I guess one that I was suspecting :)

I did read somewhere in my search that another USB cable might work, but in truth I couldn't find much about this board, which may be suspect it wasn't used much and probably for the reasons you suggest!
I think I will invest in a better make, any suggestions, what and where?

Just one final quesiton then, for my own interest, but why did it work on the Ardunio IDE using the Serial.Writeln and not on the B4R IDE using Log? Any ideas?

Many thanks
Dave
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
Hi thetask,

:oops: Not quite the answer I was hoping for, but I guess one that I was suspecting :)

Which UART drivers do you have installed ?
These are the latest
www.wch.cn/download/CH341SER_EXE.html.
Which Windows Version do you have ?

Try this:
- close your IDE's
- connect your ESP through an USB 2.0 port.
- uninstall/ remove CH340/341 serial drivers.
- remove ESP board.
- reboot your PC
- install with admin right's the CH341 drivers ( with no ESP is connected)
- reboot your PC
- connect your ESP and have a look in the device manager and look for Errors
- in the Boardmanager try the "Generic ESP8266 Module"
- work with only one IDE opened.

Your question why it runs under the Arduino IDE,
can only be answered if we could compare the initialisation routines in the source code of the two IDEs.
 
Last edited:
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Hi thetask,

Thanks for the reference and guide, I'll give that all a go, although I'm tending to your first (maybe unwritter answer) which is just to scrap these cheapo boards and buy some decent ones :)

Cheers
Dave
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
What country are you from ?
I ask only to find a reasonable seller for you.
 
Last edited:
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Hi thetask,

The UK.
After you mentioned that you'd seen otherpeople taking (slating) thisd board I did a search and came across a forum with a thread in about the same device and how it wasn't working https://forum.micropython.org/viewtopic.php?f=16&t=12490
The guy said the same thing as you and he found another device, bought it (still from Amazon) and said it worked fine
Sorry about the logo, don't know how to just put a reference in without the pic!
Still fairly cheap, but I guess the seller isn't the most important thing, its the board itself, and he did say he had success with it.

However, any recommednations from you would be much appreciated.

Thanks
Dave

PS I did try numerous USB cables and all the same problem!
 
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
The company AZ Delevery is okay, this company also operates in Germany and have a good incoming goods inspection.
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Hello,

So I got 3 boards from AZ Delivery and this time the board works with the serial port connected, but I don't get anything back from the device using LOG("App Start") etc.

Have I got to set something else up to get messages back from the device?

Any help would be appreciated.

Thanks
Dave

Just a bit more info.
I've set the board type to NodeMCU 1.0 (ESP-12E Module)
If I set the board rate to 74880 (!!!) I get this on start and reset
<<<<Start>>>>
tail 4
chksum 0xc9
csum 0xc9
v00043460
~ld
<<<Pressing Reset>>>
���������������������������������������������������������������
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 3460, room 16
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4
tail 4
chksum 0xc9
csum 0xc9
v00043460
~ld
 
Last edited:
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
Dave I don't have a spare ESP8266 to do some testing for you and I don't know if this is of any use, but in my ESP8266 projects when I wanted to write to the serial port I used code like this:

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private astream As AsyncStreams 

End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    astream.Initialize(Serial1.Stream, "astream_NewData", "astream_Error")

End Sub

Sub sendData(tmp as String)
    astream.Write(tmp.GetBytes)
End Sub

This replaced code like:

B4X:
Serial.begin(115200);

Serial.println(" ");

when I was initially using the Arduino IDE.

UPDATE: I've dug out one of my ESP8266 projects and I don't think the above reference to AsyncStreams is relevant because when I look back into my code I see I've some simple log() statements which indeed show up in the IDE Logs tab.

Best of luck in your search for a solution.
 
Last edited:
Upvote 0

thetahsk

Active Member
Licensed User
Longtime User
Hello,

So I got 3 boards from AZ Delivery and this time the board works with the serial port connected, but I don't get anything back from the device using LOG("App Start") etc.

I've set the board type to NodeMCU 1.0 (ESP-12E Module)
1657596710803.png


I think you bought a D1 mini board. That's why you have to put the same board in the board selector.

Log without delay function:
Sub Process_Globals
    Public Serial1 As Serial
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    On(0)
End Sub

Private Sub On (t As Byte)
    Log("on")
    CallSubPlus("Off",2000,0)
End Sub

Private Sub Off(t As Byte)
    Log("off")
    CallSubPlus("On",2000,0)
End Sub
 
Upvote 0

daveinhull

Active Member
Licensed User
Longtime User
Thanks both,

@bdunkleysmith, thanks for the code which was what I was looking for using my old boards as I knew writing to the serial port worked when I moved the the standard Ardunio IDE. I'll give you code a test so I have it available.

@thetahsk, yes it was the D1 mini and that was exactly how I initially set the board to and it ran the code (I could see from the LED flashing as programmed) but no messages from Log.
I've just tried your code and it works after some random characters
********************* PROGRAM STARTING ****************
rll�r$�n �l�b|���rb�b�nnlnnbbp�$blrlp�n0 �l� bn�n��b��nn'l�l`�nn$`nr���n rr�`p�n� r�<bbn�nb��nn'l`�nn$`nr���n rl`r��n rl`� �l`��n�`AppStart
on
off
on
off
on

If I add another log statement after the AppStart statement and before you call to On ....
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    Log ("My Start")
    On(0)
End Sub
I get the following, but the log screen goes crazy and flashes like mad for a while then goes steady.
rll�r$�n �l�b|���rb�b�nnlnnbbp�$blrlp�n� �l� bn�n��b��nn'l�l`�nn$`nr���n rr�`p�n� r�bbn�nb��nn'l`�nn$`nr���n rl`r��n rl`� �l`��n�`AppStart
My Start
on
off
on
off
on
off
on

Does this sound like a driver problem?
Why am I getting the random characters - not a probem, just interested?

If I add a delay before using Log it still throughout the random text, but then the screen works fine.
B4X:
Private Sub AppStart
    Serial1.Initialize(115200)
    Delay (3000)
    Log("AppStart")
    Log ("My Start")
    On(0)
End Sub
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
@daveinhull I get that "garbage" when the ESP8266 is reset too, but I just ignore it which works for my application.

A bit of Googling comes up with this explanation:

It's a start up message from the espressif bootloader and is at 74880 baud.

This is because the the ESP8266 boot ROM runs at 74880 Baud.

Many people complain at the 'choice' of 74880; well there is a technical reason for it.

On reset, ESP8266 hardware default baud rate depends on the crystal choice. With a 40MHz crystal you get 115200bps. With a 26MHz crystal you get proportionally less, 74880bps (115200*26/40). Almost everyone (including Espressif) ships hardware with a 26MHz crystal, so almost everyone gets 74880bps by default.

I think you've actually seen that because you refer in post #16 to setting board rate to 74880.
 
Upvote 0
Top