ESP 8266 Wi-Fi Repeater with Mesh Networking
github.com
github.com
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.
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...
https://www.aliexpress.com/wholesale?SearchText=wemos+d1+min...
Thought I could compete against all the nodeemcu boards.
Once I looked into amazon fullfillment, the margins went way out and I wouldn't make anything... And lose money if didn't sell quickly.
All my gifts were bought from Amazon, mostly for the speed of shipping and arrival. But I may just look closer at aliexpress or banggood to see what they have.
Thank you for sharing the link!
I bought 30 latest revision d1 mini plus a few other shields, payed AliExpress premium express shipping.
The express shipping came out to 20$ (you can play with quantities to maximize items for bulk shipping price from same seller... Like remove one d1 mini to add 4 components to keep shipping price the same or add a few d1 mini till price changes and go back down 1 quantity, it's tiered.).
Item arrived to Canada within 10 days (came DHL).
This was back in November.
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).
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!
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.
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?
Although that degree of caution is more or less warranted when dealing with lead solder in paste form, I have to admit. That crap gets everywhere.
Exactly.
Fumbling around with a soldering iron and some leaded solder a little bit, few times a decade, won't give you cancer or any poisoning. Safety considerations are aimed at people doing lots of soldering, because at this point the amount of flux fumes they might breathe in (or risk of ingesting lead) becomes a possible risk.
(And to be honest, I believe most of this safety advice is aimed not at DIY people, and not even at people who occasionally have to solder something at work, but to have a stick that will prevent employers in soldering shops from creating very unhealthy conditions for their workers.)
You have to breath it or ingest it for it be dangerous. In soldering it does not get anywhere near hot enough to vaporize, so really all you have to worry about is ingestion.
As long as you either don't touch the solder, or are careful after touching it to not touch anything that may find its way into you until you can thoroughly wash whatever parts of you touched the lead (or were touched by parts of you that touched the lead), you should be OK.
The biggest health risk during soldering is going to come from the flux. It's the flux burning that produces the smoke you see and smell during soldering.
Here's a document from LBNL on safe soldering practices that goes into the components of solder (leaded and lead-free) and their dangers: http://www2.lbl.gov/ehs/ih/pdf/safeSolderingFinal.pdf
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).
See discussion here: https://hackaday.com/2016/07/28/ask-hackaday-is-the-esp8266-... and official reply on Facebook (of all places): https://www.facebook.com/groups/1499045113679103/permalink/1...
> Teo Swee Ann i can reply officially here: it is 5V tolerant at the IO. while the supply voltage is at 3.3V.
It used to be the case that people were unsure if the logic pins were 5V tolerant or not due to ambiguity in the datasheet and the consensus was to be cautious, but it has since been officially confirmed that they are tolerant. Some other devices (e.g. relays, some MOSFET gates) might require a 5V output level to trigger, in which case you will need a level shifter/transistor, but 5V inputs to the pins are fine (and most digital devices that work at 5V logic levels will be fine with 3.3V logical high due to the way TTL levels are defined).
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.
See this ongoing issue on github: https://github.com/espressif/arduino-esp32/issues/653
Unless you need Bluetooth, most people are going with the cheaper board
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?
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.
https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-gu...
A bit better at scaling than particle in my opinion, not that that really matters for little diy one off projects though.
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..
The 800x600 module is perhaps the better size, for €46, but this is just for me to experiment with. I have no particular use for the paper, I'm just impressed that it is suddenly "cheap".
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...
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.
https://www.amazon.ca/Aoyue-Benchtop-Solder-Smoke-Absorber/d...
and stick with lead when I get the chance....I'll be sure to do it in well ventilated area.
Me: I use leaded solder, I have a fan, I don't lick my fingers (while soldering).
http://www.militaryaerospace.com/articles/print/volume-16/is...
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
I'm super excited about 3dhubs! I didn't know such service existed. Wonder what the pricing is like.
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.
One can, of course, build their own boards which requires soldering.
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.
From there on I transitioned to more DIY things like the ESP over time, buying cheap stuff from AliExpress.
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.
Works great with mqtt, and one of biggest IoT home automation communities.
I use about 20 wemos d1 mini boards off AliExpress (esp8266 board) with various sensors
What I have to figure out forexample how to power this thing with semi-prolonged burst say through a cap. I was looking at the specs briefly it's like below 300mA but 3. Something volts for "load draw"
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.
Are you using some small SMD package or a breakout board?
One thing to keep in mind. Your fire insurance might not cover that.
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.
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
It's only a matter of time before it's easier and cheaper to get any kind of networked devices onto a carrier network than the users wifi. The implications are kinda scary though: does this mean it's only a matter of time before the majority of personal devices talk to their users with a telco/govement middle man network?
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.
Reliability is going to be the hard part.
so 15 pounds in CAD is ~ $25
so 15 pounds for 500mb/month in Canada...
Gonna be hard to beat that, cost-wise, with anything reliable and covering a large area.
Specifically mention of two Ubiquiti M900 (~$130 each) for line-of-sight internet from home.
Related discussions:
- 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.
Unfortunately, the ringer was too high-voltage to make work, and the Arduino wouldn't fit inside the phone unless I took out the ringer. Maybe the new PCB will fit, I'll have to try it out. Maybe I'll send you the next prototype unit as a gift, if I ever complete it (or, if you're ever in Greece, drop me a line and we can build it together!).
> the ringer was too high-voltage to make work
But they don't use a lot of current. It's about 90V AC iirc to make it properly ring, and 20 Hz, you could do that with a switched capacitor network or, alternatively, by using a step up transformer (will be a bit heavier). Ugly solution would be to re-wind the coil so it works on a lower voltage and drive it directly.
I loved your LEGO sorter, by the way, it was very large-scale and a very interesting project, well done. I greatly enjoyed reading the writeup. Do you still use it?
Paid work has been absolutely insane the 2nd half of 2017, we are barely managing to recover before the next all-out job is landed so unfortunately no time to mess around with other stuff. I have a few more fun projects lined up, one of which has to be ready for next summer so I will definitely be making some time for play besides more work. Can't complain though.
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.
Don't forget censorship… :)
>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).
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.)
Staying awake 10% of the time seems like a decent improvement on staying awake all the time.
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...