ESP 8266-01

Computers and stuff like that

ESP 8266-01

Postby Doug Coulter » Fri Nov 18, 2016 12:55 pm

While I don't intend to use these for the "fancy" projects, I got a few and it turns out they'll be just fine for a few of the "dumber" things I want to do, like a bunch of the "smart homestead" stuff, which isn't really rocket science - mostly acquiring some data, or switching some relay. The "big thinking" can be done anywhere on the network that is handy...but with "things" all over the place, some simple wifi is kind of nice, and that many fewer wires or ethernet switch ports.
The particular -01 modules I got were these: https://www.amazon.com/Makerfire-ESP826 ... op?ie=UTF8
While I'm sure you can find them cheaper elsewhere (after a looong boat ride), these are fine and already cost the least of any part of a project using them...or nearly enough.

These have 1 megabyte flash, unlike the newer modules that have 4. No biggie. The wireless stuff eats about a quarter meg, and you'd be hard pressed to add more then 16 or 32k more for a reasonable use of these. So, plenty. I'm using a 1 meg, using the arduino ide and the adaruit github library add on, with "generic module" type and it works fine.
I built a programmerloosely based on this guy's post - which turns out to work nicely, though I added a couple features to make it more like Adafruit's Huzzah - the two button thing is nicer than moving parts on and off a proto board (I despise those anyway and use them up so I won't have them in the way when I want to do something actually-serious, weird, I know). To make my programmer work with one of these perma-proto boards that are like the push-in type but with solder, I used my bandsaw to cut the end off an old raspi stacking header (extra long leads) and bent them to go onto opposite sides of the strip board.
I wired up 6 pins worth of stakes to accept either an FTDI cable or a console cable (either one is 3.3v compatible).
100_3125.JPG
Having to offset things to avoid those strips makes this a lot bigger than it needed to be, but I gor rid of one of those nasty boards...


If you're getting medium tricky, this link is helpful. You can change the uart pins to gpio's when your sketch is running, and still be able to reprogram the thing when it's in upload mode. 4 IOs instead of the usual two. http://www.esp8266.com/wiki/doku.php?id ... llocations

The only thing that could be called a "trick" here is how I did the button for gpio-0. It is a button to ground. The other pin of the button goes through a 330 ohm resistor to the actual gpio pin, just in case you have a sketch in there that was forcing that pin high and you forgot to hit the reset button first. I didn't really want to use two red leds - I wanted different colors, but I always use red for reset (a mnemonic thing), and the gpio-0 pin has an interesting property - when things are "Ready for upload" it pulses that pin low at a low duty cycle. For the life of me I couldn't get a yellow or green LED to light up enough with that 330 ohm (and another one in series with V+ because the button DOES short to ground) to see in that mode.

To add support for these to the arduino ide, you basically:
Enter http://arduino.esp8266.com/stable/packa ... index.json into Additional Board Manager URLs field in the Arduino v1.6.4+ preferences.
I am using the "generic" for these and the 1MB settings, and they work fine.

Basically, you hit the reset button, then the gpio-0 button, release the reset one, then the gpio one. If the device sees gpio-0 low coming out of reset it goes into "load me" mode, regardless of what was in there already - your last sketch or, ugh, AT or Lua. Either of which you can flash back in there if you're into auto-flagellation.

I intend to use Adafruit's Huzzah for anything more complex than switching power or looking at a sensor or two here and there. I'm using Adafruit's Feather Huzzah for development, since it's so simple and no button pressing at all to try a new sketch. While compilatoin is a little slow on the raspi-3 I'm using for this, backing its world up is tons simpler and faster than most other things.

I tend to buy at least the first few of any of this class of stuff from Adafruit and I believe for good reasons.
1. It works almost 100% of the time
2. They spend time and money writing code to make it all as easy as possible. While I'm not one of the kewl kids with the new languages, c(++) works fine for me, as does perl.
3. In the event #1 isn't true, they have actual customer service. Like all places, their first assumption has to be that you're an idiot, as 99,9xxx% of their requests are from...well, people who didn't RFTA or check. But once they find out you're OK - very nice and helpful. And when I find a bug in their code and inform them - it gets implemented right now on their github.

OK, if you're going to use a metric cubic gazillion of something, there are other options (but I might call Ada too). But isn't your time worth something? And theirs?

One of the reasons I bother posting on what is my own board, when a local pi or something could (and does, using PHPBB too) take notes for me is that my time is worth something. This is an offsite backup...as well as its other functions.

So, out of all those hours of searching and finding what works, I now have one simple post that "does it all" for this module type. One probablem with searching (especially linux stuff) is you might spend hours getting the wrong answer, or what would have been the right one but for some other version and things have changed - and that right answer was so simple it doesn't stick in the mind much better than the 1000 wrong ones. Then a year later you need to know it again....so adding "metadata" like this is actually reducing the entropy of my life, and I hope the reader's too.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: ESP 8266-01

Postby Doug Coulter » Sun Nov 20, 2016 5:03 pm

As promised, here is a kind-of schematic I drew. Not in the pure old form, but as close to the physical reality of what I built as I could while not cheating too much. I used the truly old-skool cut and tape (I ate all my library paste decades ago) of an image of the ESP board - this is all just as you'd see it if it were sitting on your desk, built. I also added stakes to 3.3v power, ground, and both of the "GPIOs" in case I'd want to try something right here, or put a scope on something.
Note that I used an adjustable 3 terminal regulator from the 5v on the serial cable (this works with either type as long as the data signals are 3.3v compatible), and it's a bit of overkill, also not producing exactly 3.3v but closer to 3.39v. If I were just ordering all the parts instead of building this out of my junkbox and stuff left over from spurious "uP Starter kits" - I'd have used a proper low dropout and probably lower current fixed regulator instead. You run whatcha brung as we said in drag racing.

Note, most sketches won't run while in this jig. For one thing, the pin GPIO2 toggles like crazy during downloads, and that's likely to confuse an SPI or I2C device to the point of needing a power cycle to actually work. I did get a sketch using the DHT-22 temp/humidity sensor to kind of work, but this particular sensor is a little flakey - it's been wired to power backwards and got quite hot before I realized it. Though, it seems all DHT-22's are a little flakey, and many of the libraries that drive them have provisions for when they return something "NAN" or not a number. Which this one does now and then, but I will try with one I haven't half-fried soon.

Some trickery mentioned in one of the links above will let you also use the RX and TX pins as GPIO 1 and 3. They will revert duing programming to RX and TX just fine, but things will be a little confusing till you unplug this from the jig and put it in your real hardware setup. This is from the link above:
pin_functions.png
Pins can be re-mapped according to this
(but I haven't tried this yet - YMMV)

So, here's the jig schematic. I used all the "safety resistors". To use this, one holds down the GPIO0 button and then presses the reset button, and only after releasing the reset button, release the GPIO0 button. EG, if it sees GPIO0 low coming out of reset, it goes into "boot load" mode. You do this button press cycle just before pushing the on-screen "upload sketch" button in the arudino IDE. This is the same as the Adafruit Huzzah board without the fancy Feather add-ons.
In dim enough light you can see the GPIO0 led light up a little when it's in the "waiting for sketch" mode...I can barely see it here with the room lights on...a little tweaking here and there might help (or just a more-efficient led).
ESPJig.jpg
Schematic for the ESP programming/test jig


Note this build is between what I call "research grade" - only has to work a few times, and production grade - works forever and is effortless. That's engineering for ya. You try and hit the sweet spot for total hours spent on it - too fussy wastes man-hours as R Heinlein said. So does not fussy enough. The big "trick" if any is that I cut up some stacking header to make a socket for this so it isn't hanging loose on a bunch of kludge wires, easy to miswire on every use. I just added buttons while at it. While not mentioned in the link above that I more or less copied, power cycling, depending on how you do it, drives most PC's a little nuts - they don't like USB serial ports coming and going, and assuming the unplug might have been a glitch, tend to assign a new port ID ( at leas in linux and windows) when you replug the thing...which in turn your arduino IDE will be confused by. That was the main driving force behind adding the buttons like in the Adafruit Huzzah. At any rate, the thing works, and for reasonable length runs, it'll be "production grade" enough. I'll do most of my dev work on a fancier board, and test with that - then program these for cases where up to 4 pins of IO is all I'll need...
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Digital

Who is online

Users browsing this forum: No registered users and 3 guests