Monday, May 21, 2018

One Cheap Arduino Nano Clone-o Plus one Cheap 1.8" TFT Display = An Entire Sunday!




Who can resist Amazon Prime Points?

Who can resist a cheap TFT display?  (I couldn't)

A million and one uses--as I develop my skills with Analog DIY and Digital hybrids I can justify all of this right?  (right???).

My goal this time: to design a simple DVM I can incorporate into audio gear. OF COURSE I can buy a DVM for like 25 cents that will probably work better.  And OF COURSE I already have  DVMs already. So why not stash one in my studio and use that.

(Answer: what fun would that be?)

Along the way, getting TFT displays going is an unfamiliar process for me, having never worked with a small display like this.....as well as understanding more about DACs, ADCs, and in general,  creating semi-precision applications--usually I just throw op amps at things and hope they work?

Anyway: these clones appealed due to their super low price ($6.50 US on a good day?), good online visibility and online .h libraries already written, like the Adafruit 7735 library

So just fire up an Arduino Nano clone, wire up the TFT, load in the Adafruit test sketch, and go?

Nope--Not that fast!

Here is the pix of my first Arduino clone….


I discovered the clones are.... "diff'rent".

To wit: some clone Arduinos don't use an FTDI USB chip you find in real Arduinos--the clono cuts corneros and uses cheaper USB chips.

So the drivers you have in your PC, used by the Arduino IDE to talk to a "real" Arduino chip, may not work with the clone board.

How this manifests: It's like you never hooked the Arduino up via USB at all--there is literally no USB port for the IDE to use to upload code to the board.

This is a first world problem.....

OK what to do: go to the Internet of course.

Turns out you can flip over the clone board and read the chipset used for USB, and google that to get the driver online?

But for my Nano clone, someone had scraped off the chip designation.  NICE!!!

From research online: this is the chip used to control USB on Clono-nanos but who scraped off the damn chip designation?

So I did what every tech does: I had to guess. Trial and error? I **hate** trial and error when fixing things!  From more reading: most clone Arduinos use CH340 USB chips.  The SOC layout of the USB chip looked like a CH340-CH341 so maybe that's what it is?  Just get the driver and go?

Driver is here  PLLUNNKKK!!!

(WARNING do not use this driver!  I took out the hyper link above!  It crashed my Mac!)

WTF???  I am using a Mac Sierra.  the chip's mfgr site says to use USB V1.3 for Mac. I downloaded that driver from the .cn site that will not be named and poof!  OS crashed.  mac unbootable. Yes, Elmo, the driver downloaded from the .cn vendor messed up an otherwise working Mac and made it unusable.  And maybe installed a keystroke reader and god only knows what else? VERY VERY NICE!

Forturnately I fix computers for a living so getting the Mac back wasn't that hard....the whole command + R thing.

Then a thorough anti-virus/anti malware pass. I  removed the butt driver and the Mac booted fine and appears to be secure again.

Back to square one--I still have the initial issue--how do I talk to the Arduino Clone?

Turns out--you need to get "the patched driver" for CH340/Mac OS sierra after removing the butt driver.

Time wasted: about an hour.  Arrg!

Now--with the right driver--now at least I can see Arduino no name-o Clone-o Nan-o and upload my code to it.  (OK no more o's)

Marvey. how do I wire the TFT?  How do I send proof of concept test code to it?

Trial and error pretty much? This time I felt it couldn't be avoided....

The TFT 1.8" device is a no-name unit with zero documentation. No links to the vendor's site. No vendor name silkscreened on the PCB I can use to track down  the pin-out designations.

And the pins' legends didn't seem to match anything to do with SPI or MOSI really, but a few still said MOSI?  So this must be SPI-ish? Hello?

I could go on and on.  But here is the last complaint: There was a QR code on the bag it came in, would that be a link to the mfgr's website maybe? With setup details? but someone covered it up with a "made in China" sticker that I couldn't remove.  ARRRG!


The best link I could find, with pins that closely matched (but didn't exactly match) what I got on amazon, is here.

My OCD kicked in and I was determined to get this to work.  Who needs to do laundry?

After about 2 more hours I got this pin combo to work:

LED+  > hook to 3.3 V on the Nano clone board.
LED-  > GND (GND by the 6 pin header on the nano, not the GND down towards the other side of the board--the other GND on the nano clone didn't work)
CS  > CS
SCLK > SCK
MOSI > SDA (you knew that right?)
AO > DC (you knew that one too?)
Reset  > reset
VCC > 5V
GND > GND by 6 pin header.  There were 2 GND pins on the clone arduino Nano but as just mentioned one of the #@$ things didn't work (it looked like it had been soldered correctly).

There were other pins on the cheapo 1.8" TFT--some with very similar names--including one that tauntingly said "MOSI" that wasn't used at all when making the thing work.



(And of course the pin silkscreens on the TFT were on its underside, not the top.  So I had to write down a mirror image of how the pins are marked to figure it out.)

Once I got some life out of the board  I then modified the sample code provided by Adafruit with these pins and names:


#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

//how to wire from cheap-ass H340 based USB nano.
//vcc to 5v
//gnd to gnd by 6 pin header
//LED+ to 3.3 V
//LED- to GND by 6 pin header


#define cs    4  //there are 2 cs pins, don't use cs pin by the //LED+, wrong cs pin, but you knew that
#define sclk  5  // sck on TFT board
#define mosi  6  // sda connect on board, but you knew that
                     
#define dc    7 // ao connect on board, you knew that as well
#define rst   8 // reset, not 'rest'
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, mosi, sclk, rst);


And it works!

The takeaway here: the super cheap .cn clones may not be worth it.  Stick to things (like TFT displays) that are well documented and offer at least support on a user forum.

it took me an entire Sunday to get the proof of concept you see here working, and I think if I just bought "the real deal" it might have only taken me a couple of hours.  What is my time worth, really?



As long as I am throwing stones: I am also pretty disappointed with Adafruit's GFX documentation. that's the library used to get graphics going on the board.

I thought since Adafruit is after hobbyist business (?) they would provide endless docs and code examples online, but I couldn't find their GFX tutorial at all, and their library documentation is powerfully short on useful examples (I couldn't find any). I guess it's way better than nothing, but their PDF needs to at least have working code examples in it. Just my two cents.


UPDATE (5-24-18): Makerfocus, who read my less than favorable Amazon review of their Arduino clone's lack of drivers and scraped off SOC chip, contacted me several times to make sure I was OK.  I should have had the common sense to Amazon message them as soon as I had issues with their driver vs. just assuming no one was out there and no one was willing to help.

They were not only helpful and enthusiastic, I would venture to say they were downright sweet and kindhearted about making sure I had a fix. Really!!! I will do business with these guys again...and I  have to remember all the time that the folks at the other end of the great global keyboard are humans, except for United's AI phone service?, trying to make a living, to stay sane and safe and get on with things--it's so easy to forget with this massive impersonal, loving and hateful system we all rely on, accurately called the "interweb", that we are DEVO....oh nevermind!

UPDATE (1-25-19): Tried to get the CH340 driver working on a Lenovo Windows 10 system for the first time, to program a Makerfocus Nano clone at work. At first the driver appeared in devmgmt.msc ("device manager") but nevertheless the IDE wouldn't recognize the clono-nano. Then upon trying to uninstall and reinstall the driver, it wouldn't work at all, the installer throwing up a cryptic message along the lines of "you can't install it, it's already installed".  I gave up on this whole process after an hour of trying--I got Linux and Mac to work, but not W10--2 out of 3 ain't bad?


1 comment:

  1. Same trouble here, tryed everything. Contacted the seller, and they sent me more stuff that didn't work for me. Super sad ):

    ReplyDelete

Rotary Encoder Expermenter's Board: Improving the Hardware

Quick one this time....I have posted a few projects lately that incorporated a Raspberry Pi Pico, rotary encoder, and .96" OLED:  here ...