[HN Gopher] A Beginner's Guide to the ESP8266 (2017)
___________________________________________________________________
A Beginner's Guide to the ESP8266 (2017)
Author : davikr
Score : 232 points
Date : 2024-04-25 01:03 UTC (21 hours ago)
(HTM) web link (tttapa.github.io)
(TXT) w3m dump (tttapa.github.io)
| paul_funyun wrote:
| A useful gizmo but bang for your buck seems esp32 is the way to
| go
| jareklupinski wrote:
| i reach for an esp8266 for the same reasons i try to design a 2
| layer pcb instead of 4 layer: the challenge
|
| and maybe just maybe if i have to make a thousand, i'll be
| ahead of the game
| connicpu wrote:
| I mean, if it's for a task where I know my program will fit in
| 512K flash and 80K ram, then an ESP8266 is still cheaper. One
| of those is powering my DIY thermostat right now :)
| peterhadlaw wrote:
| Any resources on how you made your diy thermostat? :)
| connicpu wrote:
| If you've done any basic electronics before it would be
| relatively straightforward. I didn't follow any specific
| guides, just spent a lot of time reading the datasheets for
| components that sounded like they might work. My ESP8266 is
| connected to a GPIO expansion board from Adafruit over I2C,
| which controls 3 TRIACs through TRIAC opto-isolators. HVAC
| control wires use 24VAC so TRIACs are the silent option for
| switching, although relays would have probably worked just
| as well. After that I just programmed the ESP8266 in
| Arduino to listen to the MQTT broker on my network to send
| the values from its temperature probe (also an I2C board
| from Adafruit) and receive commands. It also has a basic
| thermostat mode programmed in if it stops receiving
| commands for too long.
| pantalaimon wrote:
| Unfortunately it relies on an outdated GCC 5 toolchain that
| will never get an update
| LeafItAlone wrote:
| I have to imagine that in most hobby (as in, one off) use
| cases the $1-$2 difference makes no real difference.
|
| And at one point (years ago) I was able to buy ESP32s for
| practically the same price on Aliexpress.
| reaperman wrote:
| Biggest advantage of the ESP32 for me is that it can connect to
| WiFi networks with enterprise encryption with X.509
| certificates. ESP8266 doesn't have the CPU horsepower to manage
| this.
| throwup238 wrote:
| The other big advantage is nonvolatile storage. The ESP32 can
| store the state of modules between restarts.
| jes5199 wrote:
| I've used both, and I'm actually more productive with the
| ESP8266 because it is so limited - I can usually squeeze in a
| minimal implementation of one or two things and that's it. With
| the ESP32 there's always other options, and it means I have to
| make more decisions, so I end up getting bogged down in
| irrelevant stuff
| eternityforest wrote:
| ESPHome completely solves that for me.
| sircastor wrote:
| The ESP32 line is the natural progression. Specifically the
| ESP32-C3 is the successor to the 8266.
| weinzierl wrote:
| The ESP32-C is a RISC-V, unlike the others.
| pantalaimon wrote:
| All the new ESP32 parts are RISC-V
| weinzierl wrote:
| Isn't the C3 the only one so far?
| pantalaimon wrote:
| ESP32-C2, ESP32-C5, ESP32-C6, ESP32-H2, ESP32-H4 and
| ESP32-P4 are also RISC-V. Xtensa are ESP8266, ESP32,
| ESP32-S2 and ESP32-S3.
| yau8edq12i wrote:
| If you're looking for a "successor" for the ESP8266, then
| it's clearly the ESP8684, part of the C2 line - even
| Espressif says so.
| 3abiton wrote:
| It totally depends on the usecase, but I find that esp32 is so
| powerful, it's not power efficient. Al lot of IoT application
| run on batteries with a single task usually, and this where
| ESP8266 shines.
| cranium wrote:
| The ESP32 has series tailored for different purposes:
| https://www.espressif.com/en/products/socs (eg. the ESP32-H
| is for low-powered applications). I don't know how it fares
| against the ESP8266 in power consumption but as a hobbyist I
| would pick an appropriate ESP32-XX first and only look at
| alternatives if it's really lacking.
|
| See also: https://products.espressif.com/#/product-comparison
| mavamaarten wrote:
| It's almost problematic how many variants there are these
| days. I'm sure they all have their particular application
| but I sure don't know the difference anymore without
| spending a lot of time comparing. I feel like a few years
| ago you just went for an Esp8266 with x amount of flash. I
| thought the only difference was that and the form factor,
| but I might just have been oblivious of all variants back
| then.
| HeyLaughingBoy wrote:
| I used to work for an engineering services company, and
| by default, our quotes would include a minimum of 40
| hours just for finding and sourcing appropriate
| components.
|
| Even for an experienced EE, it can be ridiculously time
| consuming. And it's one of those "hidden tasks" that has
| to be done but is rarely explicitly accounted for.
| GuB-42 wrote:
| This guide is from 2017, before the ESP32 essentially took
| over.
| krish98sai wrote:
| Very clean guide. I wish I had something like this when I
| attempted to make my Roomba "smarter":
| https://github.com/krish98sai/smart-roomba
| chaosprint wrote:
| esp32 s3 or c6 can be better to get started with:
|
| https://gist.github.com/sekcompsci/2bf39e715d5fe47579fa184fa...
| bahmboo wrote:
| (2017)
| devsda wrote:
| This is a good and extensive guide.
|
| Most guides out there work with dev boards that are powered by
| usb. It's great to see a section dedicated to power them with
| alternatives like LM-1117.
|
| I'm still hoping to find a guide dedicated to power management of
| espxxx boards that includes guides for powering them with a range
| of sources like coin cells, aa, lithium, 9v, 12v batteries etc
| along with a primer on different features (like sleep modes) and
| their impact on power consumption to maintain the battery life.
|
| I always see mentions of all these interesting diy projects but
| not how they are powered. So, its difficult to get a complete
| picture of the maintenance needed and their usefulness in the
| long term.
| 2Gkashmiri wrote:
| I have an esp8266 hooked up to a solar inverter. it used to
| have problems with not getting enough power so i hooked up a
| power bank between the inverter and the esp. if the power from
| solar gets out, the power bank (10k mah on paper, must be less)
| can run it for around 36 hours on full charge.
| YugyDugan wrote:
| That's like your nan being frustrated that there isn't a single
| definitive guide to buying a laptop.
|
| There are so many factors that it's a near-impossible task. And
| even if you somehow managed to do so, it would already be
| obsolete by the time you stopped typing.
|
| The datasheet (for each of the ESPxx, regulator, etc) will
| specify power consumption in different states. But sadly
| there's a lot of misleading amateurish pseudoscience in
| Arduino-land so you're best to ignore everything else (which
| would even include a guide like this, for example).
| TeMPOraL wrote:
| How to read that info from the sheet? Problem: I have my
| NodeMCU gizmo with sensors and stuff, that works while
| powered via USB charger. I want to make it portable and
| powered by AAA batteries. How do I do it? I feel that my nan
| would've had an easier time figuring out on her own what
| laptop to buy.
| stavros wrote:
| Connect two AAA batteries to the 3v3 rail.
| YugyDugan wrote:
| That's not what it's designed for. That's like asking how
| to run your iPhone on AAAs.
|
| The hobbyist solution would be to find some obscure product
| on AliExpress with a holder for 2xAAAs and a 5V boost
| regulator with a USB connector. It's janky and inefficient,
| but that'll power your board, or your iPhone.
|
| The 'proper' solution would be to then take this prototype
| to an optimised design in your ECAD software of choice,
| integrating a AAA holder and choosing an appropriate
| regulator, and having some PCBs assembled.
|
| I'm not sure what else you could want. If the latter sounds
| daunting to you, it would be very easy for even an
| inexperienced EE on Fiverr to whip up for you.
| devsda wrote:
| I think there's some misunderstanding on the expectations.
| Documenting a combination of all the available peripherals,
| boards and power sources is virtually impossible but that is
| not what I meant.
|
| Given a power source and board with defined power
| requirements (e.g. say 3.3v upto 150mA) if we can easily find
| what commonly available components are needed and how to wire
| them up (with tradeoffs) is sufficient.
|
| Here's an excellent video that touches lightly on what I
| meant. https://m.youtube.com/watch?v=heD1zw3bMhw .
|
| PS: If you find the video format of tutorials useful for
| learning about electronics, Andreas Spiess and Great scott
| channels on youtube have very good content that is helpful
| for beginners.
| YugyDugan wrote:
| If you're this new to electronics though, you're better off
| buying a hobbyist development board like any of those
| suggested in the guide. You don't need to concern yourself
| with this. Just plug in the USB cable.
|
| If you're designing your own board, you would simply enter
| 3.3v and >150mA into the parametric search on Mouser, Digi-
| Key, TI, etc and pick whatever part takes your fancy.
|
| This is so simple that there isn't any need for a guide.
| The datasheet for whatever regulator you choose will tell
| you the recommended input capacitance, output capacitance,
| inductance, any configuration resistors, etc.
|
| Same goes for battery charger ICs, which can be just as
| simple or far more advanced, and there are new devices
| being announced all the time for everything from tiny
| energy harvesting applications to USB PD, which is what I
| mean when I say it'll be obsolete by the time it's
| announced.
|
| It's daunting at first but you need to take the plunge:
| find a part that interests you on Mouser, integrate it into
| a design according to its datasheet, and order some PCBs.
| You'll be amazed how accessible it is.
| HeyLaughingBoy wrote:
| > misleading amateurish pseudoscience in Arduino-land
|
| Drives me crazy just how much people don't realize that they
| don't know and are just spouting unfounded assumptions.
| zippox wrote:
| I always see these low prices (<$5) on articles and comments but
| this doesn't seem the be the case for the boards people actually
| recommend. Are people buying on aliexpress or other cheap
| alternatives?
| yjftsjthsd-h wrote:
| Aliexpress is probably cheaper, but TBH I just order them on
| Amazon. If you buy a bundle of like 6 then the unit cost gets
| around... I would have said $6, but I might be misremembering.
| Of course, for the number I've used, ~$4 and ~$6 are equivalent
| so YMMV.
| regularfry wrote:
| Right now I can see knock-off D1 mini clones on Amazon for
| about PS2.40 each. Real Wemos boards are about PS4 each in
| bulk.
| kube-system wrote:
| $1.10 US on eBay: https://www.ebay.com/itm/314750044526
| danieldk wrote:
| Wemos D1 Mini is about 5 Euro from many local sellers here.
| It's a great little board (if you have the official ones, don't
| know about clones).
| smilespray wrote:
| If you liked the D1 Mini, you can now get the excellent S2
| Mini with an ESP32 S2 microcontroller for $2.50 on eBay. I
| just ordered a 10-pack for my HomeKit projects.
|
| https://www.wemos.cc/en/latest/s2/s2_mini.html
| otherme123 wrote:
| To get less than 5EUR you usually have to buy more than one,
| like here: https://www.az-delivery.de/products/nodemcu-lua-
| amica-v2-mod....
| 3D30497420 wrote:
| As an aside, I've bought a bunch of AZ-Delivery products and
| have been very happy with them.
| mft_ wrote:
| I've got three from AliExpress that were all EUR2-3 (I pushed
| the boat out for a USB-C model most recently) and they're all
| working perfectly so far.
| dvh wrote:
| Is there a wifi module with smaller power consumption?
| BenjiWiebe wrote:
| This isn't really answering your question, but Wi-Fi isn't a
| very power efficient protocol.
| defanor wrote:
| Strange to see an overview of network protocols in the guide, and
| a web server in the SDK: they are very generic, do not seem like
| any of that should be specific to ESP8266.
|
| Edit: Removed two points of the comment that were wrong (as
| mentioned in a reply).
| zargon wrote:
| The introduction is quite clear that the guide uses Arduino,
| and using C is a possible alternative, among other options, not
| covered in the guide. It mentions several of the options in
| that same paragraph that you complain about it not mentioning.
| defanor wrote:
| Indeed, both are mentioned in the "programming" section,
| which I have either misread or skimmed over.
|
| Edit: The options in the same paragraph are for different
| languages though (I saw those), but nevertheless it also
| mentions that they exist in general, including those for C.
| Well, it only mentions the official SDK for C, but hinting at
| more options still.
| Perz1val wrote:
| I recently got mine out of the stash of "things for future
| projects" and I wanted to program it using PlatformIO and the
| RTOS SDK, but that's terribly outdated, with parts of that stack
| newer and it just doesn't work. Should I use the Arduino
| framework? That's boring, I did that already with arduino boards.
| Or maybe I should install the official Espressif toolchain and
| try the RTOS framework there? It is a bit dated, but I guess if
| the hardware didn't change, the software doesn't have to either.
| If anyone wants to give a recommendation, I want to make a system
| that listens to an endpoint (EC2 atm) and sends wake on lan
| packets to my devices that join a VPN after booting, so I can
| access them from anywhere.
| agys wrote:
| I go with PlatformIO and Arduino as framework (#include
| <Arduino.h> on top of the main.cpp file) for all my ESP32
| projects... All the library dependencies are managed through
| the platformio.ini file. Works perfectly!
| Perz1val wrote:
| Yeah, that's probably what I'll do, but I wanted to try RTOS
| framework
| wdfx wrote:
| I've been building a MIDI device using PlatformIO with ESP-
| IDF: https://bitbucket.org/doughammond/fourays/src/master/fir
| mwar...
|
| I used this combination because I found USB device support in
| Arduino framework lacking flexibility.
| vineyardmike wrote:
| If you really want to quickly build, you can try ESPHome. Less
| learning, but way easier. They also make it possible to insert
| your own C into that code too.
| 037 wrote:
| For the ESP32, an hero is in the process of adding LVGL[1] to
| ESPHome[2][3]. You can try it out now:
| https://github.com/esphome/esphome/pull/6363
|
| Here's the (very good!) preview documentation: https://deploy-
| preview-3678--esphome.netlify.app/components/...
|
| This is such a game-changer for me that I'll be using the ESP32
| over the ESP8266 for any projects involving displays from now on.
|
| [1]: https://lvgl.io/
|
| [2]: https://esphome.io/
|
| [3]: ESPHome on HN yesterday (500+ points):
| https://news.ycombinator.com/item?id=40138228
| zyberzero wrote:
| This is amazing! Thanks for the tip. My ESP32 dev board with a
| display is in the hands of Fedex right now, so this is perfect
| timing :)
| nayuki wrote:
| "An hero" means something unexpected:
| https://en.wiktionary.org/wiki/an_hero ,
| https://knowyourmeme.com/memes/an-hero
| 037 wrote:
| Oh, sorry, thanks for pointing that out!
| gkhartman wrote:
| This is great news! I recently discovered LVGL and was thinking
| that it would be great to have in a esphome module. I currently
| have a few of the small i2c OLED displays going, but they are
| quite limited.
|
| Many thanks to those working on it. Can't wait to try the
| preview.
| antirez wrote:
| I spent the latest three or four months doing embedded
| programming. After using extensively the ESP8266 and ESP32, now
| I'm quite certain I prefer big times the RP2040 (that is, the
| Raspberry Pico processor, but you can find it in different non-
| Raspberry produced development boards). The reasons are easy to
| summarize:
|
| 1. Vastly superior C SDK, and even the MicroPython support
| appears to have an edge.
|
| 2. Fantastic documentation, even if in PDF form, which makes a
| bit less accessible for us and especially for LLMs training data
| crawlers. In general LLMs know a great deal more about ESP stuff
| than the RP2040.
|
| 3. Almost every RP2040 can be overclocked to 400Mhz and work
| stable, and I could say basically _every_ RP2040 can be stable at
| 350Mhz, so when comparing performances, account for this.
|
| 4. Very smart hardware capabilities: state machines for
| programmable pins (PIOs), great DMA support, hardware
| interpolators.
|
| 5. High quality hardware, and if you don't need the version with
| wireless, the cost is still quite reasonable. 3/4 euros/dollars
| per piece.
|
| 6. When you need the "W" one, the wireless chip the Pico uses has
| its own ARM processor, so you continue to have the two RP2040
| cores spare for your application.
|
| 7. Memory mapped flash with execute in place. You can read from
| 0x1000000+offset just deferencing a pointer and that's it, you
| access your flash.
|
| 8. More GPIOs available.
|
| The big disadvantage of the RP2040:
|
| No SPI RAM support. At this point many ESP32 boards have built-in
| SPI and this makes memory a lot less a scarse resource.
|
| To familiarize with the ESP family is useful since they are
| everywhere and are extremely cheap for what they offer. But
| still, I would start basically any new project where I have
| choice with the RP2040.
| dandy23 wrote:
| It uses a lot of power for embedded apps though. Not often you
| need all that performance either.
| antirez wrote:
| You can downclock the Pico as you can overclock it in order
| to reduce power usage. By default AFAIK it already more or
| less matches the ESP32 power usage, and downclocking it
| should be able to reach the one of the ESP8266, likely, but
| I'm not sure.
| dandy23 wrote:
| The RP2040 doesn't have a good low power sleep mode. It
| uses several hundred uA in sleep and dormant mode versus
| the ESP8266 which uses only 20uA in deep sleep.
|
| This makes a huge difference for sensor systems etc. A
| pico/RP2040 cannot be powered by a battery for very long.
| antirez wrote:
| I never tried to explore the Pico deep sleep indeed. I
| used it with esp32 with great results even if the wake
| time of 200 ms does not make certain applications viable.
| Thanks for the point.
| unwind wrote:
| Why do you feel that LLMs knowing less is a good thing?
|
| I would add "no on-board flash" as a big negative, at least to
| me it makes it less of a "true" microcontroller.
| antirez wrote:
| Never said that it's a good thing that LLMs know less. It's a
| negative thing and I suspect it's like that because of good
| documentation in PDF format. So you usually need a lot less
| help in forums, and the doc itself is less discoverable.
|
| The Pico has 2MB to 16MB on board flash with XIP in all the
| configurations AFAIK.
| unwind wrote:
| Okay, that is how your second list item:
|
| _Fantastic documentation, even if in PDF form, which makes
| a bit less accessible for us and especially for LLMs
| training data crawlers. In general LLMs know a great deal
| more about ESP stuff than the RP2040._
|
| came across to me, as if the entire item was a reason why
| you prefer the RP2040-based systems.
|
| And I meant that the microcontroller itself (the RP2040
| chip) lacks built-in flash. I realize it's on the boards
| instead, that is the thing I personally don't like since
| you can never have a single-chip solution.
| jsheard wrote:
| > Almost every RP2040 can be overclocked to 400Mhz and work
| stable
|
| If you're playing with overclocking the RP2040 it's good to
| know that the flash chip might not be able to keep up with
| those higher clocks though, which leads to inscrutable crashes,
| and of course the official documentation doesn't endorse
| overclocking so they don't tell you how to work around that.
| The flash runs on a configurable clock divider defaulting to 4,
| so if you're running the CPU at double the nominal clock you
| can raise the divider to 8 to keep the flash running at its
| original speed.
| antirez wrote:
| What I do here (https://github.com/antirez/zx2040/) is: stay
| overclocked when not accessing the flash, downclock when
| accessing the flash via memory map, return back to the higher
| clock. Works without issues. I find this method to work more
| reliably than dividing the clock in practice. Maybe I did
| something wrong dividing the clock so it was not stable, but
| the system I described really works flawlessy.
| regularfry wrote:
| Personally I'd like the option to give up a core for
| wifi/bluetooth. The pico boards are a little ungainly, and
| having an rp2040 plus radio in a single package would be nice.
| dr_dshiv wrote:
| My 14 year old has gotten so into arduino this year. ChatGPT was
| a game changer for him.
|
| He is using a pair of ESP32s with cameras to make a "mom
| detector" so he has more time to switch tabs.
| roughsquare wrote:
| Why not have it switch tabs automatically?
| amelius wrote:
| Is the Arduino IDE the best way to program these chips? Is there
| something more "professional", for Linux? Anyone programming with
| just CLI tools and without Arduino libs?
| iamds wrote:
| VSCode with the platformIO plugin is pretty good
| HankB99 wrote:
| Last time I looked, I thought that VSCode/PlatformIO
| supported both the ESP libraries (ESP-IDF) directly as well
| as the Arduino libraries (which I think are based on ESP-
| IDF.)
|
| My personal preference is to use the Espressif libraries
| rather than Arduino libraries, but I used to program micro-
| controllers for a living so I'm more comfortable with that
| development environment.
| zik wrote:
| Sure. I use the ESP32 (rather than the older ESP8266 mentioned
| here) and I program in C and the ESP API [1]. The provided
| software has a lot of features and is pretty nice to work with.
| There's also a vscode plugin which makes configuring and
| programming the device a breeze.
|
| [1] https://docs.espressif.com/projects/esp-
| idf/en/stable/esp32/...
| amelius wrote:
| Thanks. Aside, that looks a lot more developer-friendly than
| many other vendor-provided tools/frameworks I've seen in the
| past. I hope the others follow suit.
| dotnet00 wrote:
| It's pretty cool how cheap and capable microcontroller dev boards
| are these days, I just have a stash of two-three dozen esp8266's,
| esp32s and rp2040s laying around, convenient to just be able to
| grab one whenever something I'm tinkering with could use some
| intelligence.
___________________________________________________________________
(page generated 2024-04-25 23:01 UTC)