Heads up, usb-serial adapters and ESP8266

416 views
Skip to first unread message

Andy Kirby

unread,
May 8, 2016, 1:18:29 PM5/8/16
to sheffield-har...@googlegroups.com
Guys

Whilst up at Maker Fair UK this year I picked up a couple of inexpensive
serial to USB converters. Mainly to use one on the NoT Lamp Project I am
working on.

For quite a while now (Ever since maker fair in fact) I have been trying
tot get them to program the ESP8266-07 modules I am using without
success. Having used hacked cheap nokia data cables already (PL2502 etc)
I did not think they would be problematic.

I have tried all sorts of things and can not get them to work, they use
the HL-340 chip-set.

They are seen under Linux fine and work just fine at conventional baud
rates but odd speeds like 38400, 74880 and 76800 are a no-no. I did find
a data sheet for these devices and the baud rates listed here are no on
there, but all the usual culprits are.

It looks like the ESP's default connect speed is 74880 or thereabouts
but once connected the programmer turns the baud rate up to what is set
in the arduino IDE. Confusingly, being as this is a usual baud-rate it
all works fine if you could get it there. Unfortunately as the HL-340
wont do 74800 it is useless for programming the ESP8266.

I checked this out using a FTDI cable and the programming worked every
time, switching back to the HL-340 module it never worked. Interestingly
enough I had turned on the error stuff in the arduino status window and
there were errors coming up in there saying there was an error selecting
78400 baud. Even though the serial monitor window itself appeared to
have done the baud rate changes ok.

Another symptom to watch out for was setting the baud rates to the ESP
defaults and then resetting the ESP should have resulted in a string
printed in the serial monitor from the bootlog including current
programming mode. With the HL-340 this was just junk whatever the baud
rate was set for. whereas the FTDI worked fine.


The USB serial modules will still be useful, but not for this
application or any requiring the programming of an ESP8266.

Something to watch out for......

Kirbs

--
an...@kirbyand.co.uk
www.kirbyand.co.uk

James Muirhead

unread,
May 8, 2016, 7:05:52 PM5/8/16
to an...@kirbyand.co.uk, sheffield-har...@googlegroups.com
Isn't the HL-340 just a variant on the CH-340? Steve swears by the
CH-340 for programming the ESPs. I've not used the CH-340 for
programming ESPs myself, my ESP-01 programmer uses a Prolific 3203, I
think. Although am tempted to make one with the auto reset sometime!

- OJ.

Andy Kirby

unread,
May 8, 2016, 8:15:09 PM5/8/16
to sheffield-har...@googlegroups.com
Yup that was my understanding I have not located a datasheet for the
LH-340 yet this link to the CH-340 data sheet comes up all the time
though for the LH-340

https://www.olimex.com/Products/Breadboarding/BB-CH340T/resources/CH340DS1.PDF

Checkout section 5 for a list of supported baud rates.

On linux it does seem to be loading up the CH-340 kernel module for the
LH-340.

If someone has managed to get an LH-340 to work I will bring in one of
mine next time I am in and we could try it to see if they could get it
to work too. Might well just be a linux thing yet rather than an LH-340
thing.

This guy claims he has the HL340 working

https://vilimpoc.org/blog/
--
an...@kirbyand.co.uk
www.kirbyand.co.uk

Andy Kirby

unread,
May 8, 2016, 8:16:27 PM5/8/16
to sheffield-har...@googlegroups.com
Sorry that last should read CH340.

It appears to be a problem with the HL-340.

Andy Kirby

unread,
May 8, 2016, 8:31:37 PM5/8/16
to sheffield-har...@googlegroups.com
here's the relevant info from my workstation.

andy@minaj:~$ lsusb
Bus 004 Device 009: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 004 Device 023: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet
K-2024 Multimedia Keyboard
Bus 004 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 044: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial
adapter
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

andy@minaj:~$ lsmod | grep ch
ch341 13154 0
usbserial 28105 2 ch341,ftdi_sio
hid_logitech_dj 17245 0
lpc_ich 20768 0
mfd_core 12601 1 lpc_ich
shpchp 31121 0
mbcache 13082 1 ext4
hid 94034 4 hid_generic,usbhid,hid_logitech_dj
usbcore 154175 10
ch341,uvcvideo,usb_storage,usbserial,ehci_hcd,ehci_pci,usbhid,ftdi_sio,cdc_acm,xhci_hcd

It is seeing the serial/usb as an HL-340 and loading the ch341 module
for it. Which is about right from what I have been able to find out. But
it won;t do the unusual baud rates needed to work with the ESP8266. I
guess the question is whether it is a dodgy clone and the puker
CH340/LH340 does work....

Kirbs

Andy Kirby

unread,
May 8, 2016, 8:37:48 PM5/8/16
to sheffield-har...@googlegroups.com
bit o google-ing

http://www.oomipood.ee/drivers/ch341a_programmer/CH341_chip.pdf

The ch341 chip does seem to support the unusual baud rates.

James Muirhead

unread,
May 8, 2016, 8:53:57 PM5/8/16
to an...@kirbyand.co.uk, sheffield-har...@googlegroups.com
My CH340 seems to come up the same....
james@5-pound ~ $ lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 004: ID 046d:c046 Logitech, Inc. RX1000 Laser Mouse
Bus 002 Device 003: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 002 Device 002: ID 05e3:0610 Genesys Logic, Inc. 4-port hub
Bus 002 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

james@5-pound /etc/udev/rules.d $ lsmod | grep ch
ch341                  13720  0
usbserial              38902  1 ch341
lpc_ich                16864  0
shpchp                 32128  0

However, mine seems to work just fine after adding a suitable UDEV rule for it (programming a ESP-01 in my lunch box dev kit). Maybe you just got a couple from a dodgy batch, or yes, a dodgy clone!

Will bring in my kit tomorrow (today now, Mon 2016-05-09).

- OJ.


On 09/05/16 01:31, Andy Kirby wrote:

Andy Kirby

unread,
May 8, 2016, 9:01:34 PM5/8/16
to James Muirhead, sheffield-har...@googlegroups.com
Bum, wont be in tomorrow

Having just got back from being away for a week or so were sorting ourselves out ready for the week.

I will bring mine in when in next (Probably going to be Friday or Saturday)

Am beginning to suspect a dodgy clone of a clone. the HL is supposed to be a clone of the CH.

I did not add a udev rule it just worked-ish. Or at least looked to work enough to waste a lot of time. Do you have a copy of the udev rule ??

Kirbs

James Muirhead

unread,
May 8, 2016, 9:05:25 PM5/8/16
to an...@kirbyand.co.uk, sheffield-har...@googlegroups.com
Enjoy... I just keep a bash script in my /home/james/Dropbox/Arduino/
folder which'll auto create it. Same for Digispark & TinyISP, as well as
a whole bunch of pinout images.

- OJ.
43-CH340.rules

James Muirhead

unread,
May 8, 2016, 9:08:07 PM5/8/16
to an...@kirbyand.co.uk, sheffield-har...@googlegroups.com
Sorry, is it this Friday / Saturday you mean (13/14)? Or the following
Fri/Sat (20/21)?

- OJ

Andy Kirby

unread,
May 8, 2016, 9:10:32 PM5/8/16
to sheffield-har...@googlegroups.com
this fri/sat.

thnx for the rules, there's nothing in there that should cause it to
load differently...... /me scratches head.
--
an...@kirbyand.co.uk
www.kirbyand.co.uk

James Muirhead

unread,
May 8, 2016, 9:24:43 PM5/8/16
to an...@kirbyand.co.uk, sheffield-har...@googlegroups.com
Gdgd, we need to talk about a certain wiring diagram on Fri or
Sat!!! ;-)

As for the rules file, I've never written anything particularly
complex... They're basically just there to get different chipsets to
work with dialout group and therefore Arduino IDE.

Anyhow, must sleep, see you Friday / Saturday.

- OJ

PS - Sorted normalizing of audio tracks for pirc. And transitioned pirc
onto Jessie. Oh, and if you could see to stopping wintermute from
kicking pirc out of #events, that'd be a huge help.

Andy Kirby

unread,
May 9, 2016, 6:52:05 AM5/9/16
to sheffield-har...@googlegroups.com
Yes, had read previous emails, well done sir.
--
an...@kirbyand.co.uk
www.kirbyand.co.uk

James Muirhead

unread,
May 9, 2016, 2:31:57 PM5/9/16
to Sheffield Hackspace, an...@kirbyand.co.uk
Have tested my CH340 on the Debian machines at Portland. Programs just fine.

Duff batch!

- OJ

Andy Kirby

unread,
May 9, 2016, 4:53:08 PM5/9/16
to James Muirhead, Sheffield Hackspace
Yup looks like it, ordered a few CH340G's form ali express today the ones with the RTS and DTR broken out for reset etc.

Hopefully these will be better these other two flaky ones I have will be fine with arduino or atmega chips, just no good for ESP8266's.

Kirbs






On 09/05/16 19:31, James Muirhead wrote:
> Have tested my CH340 on the Debian machines at Portland. Programs > just fine. > > Duff batch! > > - OJ

Reply all
Reply to author
Forward
0 new messages