491 points · by rcarmo · 8y ago · 165 comments
For instance, I have one rigged up across a zone valve on my mom's "dumb" furnace and it's now smart furnace that heats the house up before she wakes up and controls the temperature to whatever tolerance she wants. I have another one running the stepper motor that turns the screw of my $30 DIY star-tracking camera mount. Another is hooked up to a thermocouple that transmits readings from wherever through a MQTT server to processing equipment to characterize oven temperatures, water heaters, or anything else you want to measure. I have other ones hooked to reed sensors that tell my security system when things get opened or closed.
The possibilities with this kind of cheap SoC are nearly endless. I love how many fun ideas become really practical (as in, "Ooh, I could set this up right now using my drawer of ESPs! Here I go...") with this kind of thing.
However for those that don't have a background other than simple programming experience, I strongly recommend paying g more for a platform with good infrastructure. For example , I'm really impressed with particle.io.
Board costs are <$20 but come with cloud infrastructure and lots of examples and documentation. For those that value time over money I recommend them.
But I started getting interested in "hardware" about this time last year. Soldering was a bit fiddly since I'd only rarely done it in the past, but the programming side was pretty simple to handle. I found tutorials which were very beginner, even non-programmer, friendly.
Of course it helps that I've programmed in C for 20+ years, and I can still do assembly-stuff if I must, but I don't think it is unreasonable for a complete beginner to do useful/fun things given enough willpower.
The only downside for me is ordering kit from AliExpress which takes ~1 month to arrive to me. I'm currently waiting on some E-Paper, which I was recently surprised to discover is very affordable..
But I have limited knowledge on embedded programming. Hope someone can shed some material programming esp8266 from scratch. Thank you!
It doesn't get any easier than an ESP8266 and Micropython. https://docs.micropython.org/en/latest/esp8266/esp8266/tutor...
https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-gu...
Those days are over. The new chips come with a high level language like python, pip. You can program it like you would with a digital ocean box but with a lot more constraints in hardware.
I haven't done any soldering but I don't see why that should turn people off. I mean I am worried about the toxic fumes but I'm sure theres way to mitigate that.
The whole point of having my own chip and programming it is the experience itself. Particle.io does not make sense to me as it seems to be another commercialization via platforming of this space which might make sense in enterprise but for the hobbyist, I doubt it.
as others have said, those days are over. micropython with esp8266 is insanely easy[2].
1. https://www.thingiverse.com/thing:1128026 2. https://docs.micropython.org/en/latest/esp8266
Any programming language available for MS-DOS back in the PCW 1512 is doable in a ESP32.
Programming can be low-level like we used to do in Assembly, or high level Turbo Basic, Turbo Pascal, Modula-2, C, C++ style.
So far I've got an Alexa controlled IR transmitter that controls my TV, an LED board showing the current bitcoin price, the temperature outside and the status of the local highway and I've got some led strips controlled by Alexa.
I haven't coded for years and it was a lot of fun.
One can, of course, build their own boards which requires soldering.
From there on I transitioned to more DIY things like the ESP over time, buying cheap stuff from AliExpress.
A bit better at scaling than particle in my opinion, not that that really matters for little diy one off projects though.
If you are into home automation, look into Sonoff stuff. It uses these chips but comes nicely packaged into several different form factors. You can run open source firmware on them.
Plain Arduino (AVR) boards don’t have a ton of advantage over the ESP8266 and ESP32 chips. So I’d honestly mostly skip them except if you want a ton of GPIO pins or if you want to use the Uno form factor with the shields. Having Wi-Fi is such a huge thing that I think it outweighs the other considerations. Good luck!
What do you mean?
> the amount of lead is harmless for DIY solderers.
To date, the FDA, CDC, and the WHO state that "no amount of lead is harmless". It's just that we can't get a sensitive enough handle on the neurological effects to determine a good metric for it.
On another note, does anyone know if the Respro masks are suitable for protection against lead (+ the stuff with lead) inhalation while soldering? The "techno" mask has a HEP-A filter and a charcoal mesh, which I would have thought would be enough for most of the lead particulate?
I would say that the Arduino advantage is that it's truly out of the box. ESP8266 is close, but it's not that easy.
If you want an easy IoT dev board, I will always recommend the Particle Photon (no affiliation). It's $20 and has really great documentation. It will do OTA updates out of the box once you've set it up on your network using a smartphone. It's a separate IDE (cloud based, or you can get an offline one), but you still use Wiring and they've retained the setup() / loop() constructs. I have had some issues with devices not connecting to networks using the chip antenna, so you probably need the external one.
Other minor issues - most ESP boards are not FCC/CE compliant. They're just fake stamps on the EM shield. Some of the boards are, but you need to be careful if you're trying to build a product or worry about interference. The Photon, on the other hand, is certified (and they also certified it with a suitable external antenna).
Yes there are loads of other breakout boards that suck but I found Wemos ones to be great.
Adafruit Huzzah https://www.adafruit.com/product/2471
NodeMCU is good, there's a ton on ebay.
https://www.aliexpress.com/store/group/WeMos/1331105_2571030...
https://m.aliexpress.com/s/item/32765214054.html?spm=a2g0n.s...
https://m.aliexpress.com/s/item/32454217006.html?spm=a2g0n.s...
The soldering iron is the only thing I got state-side. I went with one that has temperature control so I can do lead-free solder.
I believe that the other two sleep modes (modem sleep and light sleep) support waking on GPIO activity, but they don't save as much power.
Modem sleep just disables WiFi between DTIM beacon intervals. In this sleep it draws between about 15 mA and 16 mA current average, depending on the DTIM beacon interval.
Light sleep is like modem sleep, but also turns off the system clock. That gets you down to an average of between 0.5 mA and 2 mA, depending ton the DTIM beacon interval.
In deep sleep, everything is off except the real time clock. That cuts current down to around 0.02 mA.
Two of the sensors I have don't fit in well with that kind of deep sleep.
One is a cup anemometer. It briefly closes a switch once per revolution. Wind speed = rotation rate times a constant. If I just wanted to check the average wind speed every so often, it would be fine--the ESP8266 could wake up and stay awake for a few resolutions to get the speed, send it, and go back to sleep.
It could be hooked up to reset the ESP8266 each time the switch closes, but in high wind that could generate resets so fast that the ESP8266 would not have time to connect to WiFi and send data.
Also, I'd like to get more information on wind gusts, and so really want to record the time of each switch closure.
The other is a tipping rain gauge. It briefly closes a switch for every 0.01" of rain. That one probably could be used directly with the ESP8266 by making it generate a reset on each switch closure. I don't think my area ever gets rain intense enough to make those resets happen fast enough to cause problems.
What I'm thinking of do is relegating the ESP8266 to just dealing with WiFi, and using something like an ATiny84 to handle the sensors.
The ATiny84 and ESP8266 can be connected via I2C or SPI or similar. The ESP8266 can then spend most of its time in deep sleep, being woken every so often by the RTC. When it wakes it can get the accumulated data from the ATiny84 and upload it.
https://taoofmac.com/space/blog/2017/11/05/2130
There are hacks to trigger wake with auxiliary circuitry, but it would be nicer (if more demanding in terms of current) to monitor a GPIO pin.
Your idea to offline sensor handling to an ATTiny is perfect. I'd use
https://www.microchip.com/wwwproducts/en/ATtiny85
as it has timer/counter.
https://www.aliexpress.com/wholesale?SearchText=wemos+d1+min...
https://hackaday.io/project/28527-solved-esp8266-powered-by-...
[0] https://www.aliexpress.com/item/10pcs-3-7V-260mAh-Lipo-Batte...
[1] https://www.aliexpress.com/item/5pcs-Ultra-mini-DC-3-7V-4-5V...
I've used them for kids lights, a chicken coop door controller, remote temperature monitor, and garage door controller. It's nice as a software person to be able to control and monitor real world things exactly how I'd like too.
I did my prototyping on the much nicer (more features added out of the box) esp8266 Huzzah from adafruit. Once I got the code and everything working, I bought a bunch of the cheap ones + the sensors and then went to town. You can manage a fleet of them with the mongoose os stack https://mongoose-os.com/ (note that the fleet management of 40+ sensors is a paid service, but all of the libs otherwise are free and oss).
It's worked very well in my experience, even just as a fun experiment to say that I could.
[0] Javascript is in quotes because it's not a fully compliant javascript engine.
There are also lua implementations that run on a variety of microcontrollers.
Maybe give ~anything else~ one of those a try instead.
But I did try out lua and quite enjoyed it (lua being another of my preferred languages), and never really felt the need to tryout micropython. How is performance with micropython? and how does it differ from "regular" python?
See this ongoing issue on github: https://github.com/espressif/arduino-esp32/issues/653
I had a project in mind of making a smart poster that was open buttons on a flat piece of paper that you shorted with your finger with an id. You'd bind this button to a server event and it would be powered by ambient rf signals.
Gotta read up on this.
One thing to keep in mind. Your fire insurance might not cover that.
Are you using some small SMD package or a breakout board?
The reason being is that I have lots of Internet connected devices which watch over me whilst I'm in the house, being Quadriplegic it's much more comforting to have a computer watch over my health and do things for me than it is to have a potentially tired, angry and/or bored person doing it. However, that bubble ends as soon as I pass out of Wi-Fi range.
So obviously I would like to extend coverage to cover my smalltown, but everything I've seen so far has been prohibitively expensive. It wouldn't need to have a massive amount of bandwidth available as it would be just me using it, but it would need to be fairly cheap and as near to 100% reliable as possible.
Any insights, questions, comments? TIA
Edited To Add: I've just measured it using Google Earth and I need to cover a circle with an area of about one square kilometre.
Specifically mention of two Ubiquiti M900 (~$130 each) for line-of-sight internet from home.
Related discussions:
They are(were) deploying wifi mesh networks on the cheap in Slovenia. They've covered entire towns that did not have internet access in the past (mesh network in the town + string of directed antenna to get an uplink from a bigger town). Routers they used cost in the range of 15€ each, but the last time I talked to them they had trouble supplying new routers.
The alternative would be a small battery-powered 4G hotspot like the Huawei E5573CS-322.
I would rather avoid a 4G hotspot attached to my wheelchair for a couple of reasons, chief among them is the data costs would be really high. If I were to extend my home Wi-Fi network I've already paid for my Internet connection, I'm just making my home Wi-Fi network WAY BIGGER than it was intended to be. :-)
Espressif also have a shorter distance but lower power option that uses WiFi tech called ESP-Now that is worth looking at: http://espressif.com/en/products/software/esp-now/overview
Reliability is going to be the hard part.
Gonna be hard to beat that, cost-wise, with anything reliable and covering a large area.
- Throughput is not stellar (less than 1 mbit/s in a realistic setup);
- This is not a real IEEE 802.11s mesh, but rather some clever mechanism on how a node can select an "uplink".
Here's the smallest breakout for the ESP8266 that I know of, one I made: https://github.com/skorokithakis/tiny-ESP8266-breakout
You'll need to connect a 2-3 resistors to the ESP to get it to boot, and that breakout makes it easy. Or you can buy a WeMos D1 mini, which has a USB to serial adapter on it as well, and makes things much easier.
https://www.makerfol.io/project/3VanQzA-the-bus-stop-bus/bui...
The alternative would be to have all the resistors and capacitors floating in the case, so it's much more tidy. Plus it's very fun to route.
The mesh-like standards it does have currently are mainly focused on home automation, and they only cared about developing those because Bluetooth was becoming the de-factor standard for IoT, and now 6LoWPAN seems to be taking over.
802.11ax promised 5x the range of 802.11n in theory, but implementers will go up to 2x, at most, likely preferring to focus on increased performance/bandwidth instead.
I think it would be really cool if we could have a Wi-Fi standard that would go through buildings over 1 mile even at 1Mbps speeds. And I think we now have the technology and know-how for how to deal with interference from similar Wi-Fi emitters.
It would be nice if something like this was made by the Wi-Fi Alliance because then we could all have that capability in our phones within 5 years after release. Think how much that would help in cases of disaster: earthquakes, tsunamis, hurricanes, wars, and so on.
>go through buildings over 1 mile even at 1Mbps speeds
That sounds like a nightmare. WiFi is already nearly unusuable in high density situations. A recent trip to help a friend living in a medium density part of a large city showed ~100 access points, using the lousy WiFi antenna on my smartphone. Even every single 5GHz channel (which really doesnt travel well through objects) was taken, usually twice or more, including all the DFS channels. Mind you, this was inside.
I cant begin to imagine how unusable WiFi (and its related unlicenced spectrum) would become if had 5x the range. Even in low-density suburban areas, 2.4GHz is crowded to the point of degraded performance (although 5GHz is pretty clear for now).
Don't forget censorship… :)
Where I usually struggle is making it all small and robust enough. Does anyone know of any products which integrate power supply (mains or battery) and the esp8266 into a small, cheap enclosed product. The best candidate I have found so far would be the Sonoff products.
You can't put repeater into sleep mode[#], and in active AP+STA mode ESP8266 takes 70mA @3.3v, which is 3-4 times lower than best purpose-made wifi repeaters, but will still drain 3000mA*h battery in couple of days.
[#] ...unless whole sensor network has scheduled "data upload" internals, something like 1-minute window twice a day. But even that is going to be very tricky due to notoriously poor precision of ESP's real-time clock - see for example https://github.com/micropython/micropython/issues/2724
Indeed. Periodic clock resync is a must here. Better from external NTP though, as neighbours have their clock badly drifting as well.
> If you wake up and nobody else seems to be awake, go into degraded mode where you continually listen for the next scheduled interval.
That'll defeat the purpose completely. Here's why:
- "Listen" consumes full 70mA;
- "wake up and no neighbours awake" will happen very, very often. Let's take simplest example of two nodes with drifting clock. When they both wake up (each by local clock), inevitably one will wake up first. That node will discover there's no neighbours awake. I a mesh, statistically this will happen to 1/N nodes each wake-up, where N is average number of neighbours. If we tighten requirement from "anybody awake" to "enough nodes awake to reach uplink" (so to make use of external NTP) probability of "not enough neighbours awake" even will come close to 100% on each wakeup.
Slightly better approach would be - when each node wakes up, it stays awake for long enough to cover worst-case all neighbour's clock drift. Average clock drift seem to be +/-2%. Let's say +/-5% would be worst case. That means, all nodes have to be awake 10% of the time just to re-sync clock so that next wake-up will be not worse off than current one.
And staying awake 10% of the time means average power draw of 70mA * 10% = 7mA, which is pretty darn high (3 weeks on a 3000mA*h Lithium cell. Even less if there is payload data transmitted on this mesh.)
If they are cheap enough and self configuring then we could just plug them in to any available electrical outlet and go. Put a couple in your house and put a couple in your parent's/sister's/cousin's house. Talk to your neighbors and have them plug a couple in. Head to the local taco place and have them plug a couple in. It shouldn't be hard to get everyone on board: "Plug this in and get free {libre|beer} Internet access!"
I'm curious about the challenges b/c I've been wanting to try to get a more long-distance mesh going with Lora. Some of the newer chips are incredibly affordable:
https://www.cnx-software.com/2017/10/13/this-ttgo-board-comb...
Also, ESP8266's official SDK doesn't support IPv6.
Strict uplink-downlink hierarchy still stays regardless of whether "manual uplink" or "mesh" mode is in use. Each repeater doing Source NAT still stays. Lack of "sideways" connectivity still stays (unless you configure manual DNAT which is incompatible with "mesh" mode to begin with).
I.e., if you have 3 of those ESP8266 repeaters with two clients connected to different repeaters, there is no (easy) way to have those two clients talk to each other. Let's say this is our network diagram:
{The Internet}----[Cloud Server]
|
[Wired AP]----[Local Server]
|
[ESP8266-R1]
| |
[ESP8266-R2] [ESP8266-R3]
| |
[Clinet 1] [Client 2]
...then, we have two options how to make Client 1 and Client 2 talk to each other:- each client talks to the same server (local or cloud) and server takes care of passing the message;
or
- we configure static destination NAT (option portmap add) on both ESP8266-R2 and ESP8266-R3, and disable "mesh" mode (i.e. manually configure uplinks for all 3 repeaters);
...and arranging 1000 of those in a single string and routing a single packet through that is better avoided. "Mesh" mode helps a lot with this, by selecting shorter path to the internet and bringing topology closer to a tree, where possible.
On the other hand, L2 bridge of WiFi station to anything else (including STA<->AP bridge for a repeater operation) is quite messy: it needs special "4addr mode" packets which are only sent in "WDS" mode, which should be enabled on corresponding uplink AP. And WDS is universally disabled out-of-the box. Many cheaper routers don't have WDS at all. Plus, there are different incompatible flavours of WDS. Finally, there is question of WDS/4addr mode support on ESP8266 itself - in theory, there is some support in SDK, but I haven't seen any working application code doing it.
Some in-depth discussion of WDS with diagrams:
https://wiki.openwrt.org/doc/howto/clientmode
https://www.dd-wrt.com/wiki/index.php/WDS#Note_about_WDS_and...
It is ESP8266 and can be programmed without grahical IDE, using only GCC toolchain and Lua?
So, why so slow?
TL;DR: Too little RAM on ESP8266.
WiFi is half-duplex, i.e. in basic scenario (no MIMO; all stations close enough that each can hear at least some other), only one node can transmit at a time. [CSMA/CA] protocol is used to enforce this limitation. This protocol is susceptible to [Hidden node problem], which absolutely will be present for wifi repeater. Meaning that data in a single burst is transmitted fast, but any switch-over of who's transmitting is going to be really slow, with collisions, pauses, etc. In turn, that means that to achieve any decent throughput, WiFi repeater should buffer as much data as possible to minimize number of transmitter switch-overs. And that requites RAM - say to buffer half-second data burst at 54Mbps you'll need 3.5MB of RAM. Alas, ESP8266 only has 96KB of data RAM, out of which just 32KB is used as packet buffer with standard SDK.
[CSMA/CA] https://en.wikipedia.org/wiki/CSMA/CA
[Hidden node problem] https://en.wikipedia.org/wiki/Hidden_node_problem
https://medium.com/@iungo/iungo-global-wifi-networks-is-abou...