Arduino Uno for $2, NodeMCU for $3, RPi for $5... please let this trend continue. A year or two, and we'll basically have computronium - simple dev boards powerful and cheap enough to just tile your house with them.
I've recently figured out that there's no point in designing your own PCB for placing sensors at home, when you can get an Arduino and an ESP8266 for $5; add power (and some ~$0 of voltage regulation) and you have a base station. Or just buy NodeMCU for $3 and skip on wiring Arduino and ESP8266 together.
I realise how silly this question may seem but here we go:
If I get an ESP8266, I can have something that run code, sit on my home network wirelessly and use it to do things like report on sensor inputs? Am I missing some larger expense that would be required as this seems very cheap compared to other options I've seen.
The cost is $4 for a NodeMCU, $2 for the sensors, $1 for a breadboard to stick them on, and $1 for a microUSB cable to power them from. You can power the sensors from the NodeMCU's Vin, since that's the 5V from the USB.
I have done exactly this, it sends values to an MQTT server on my NAS every second or so, which the NAS then adds to Graphite and plots them in Grafana. It also has some logic to act on these values and send commands back, like turning lights on and off, etc.
I can write up the sensor setup I have at home, if you want. It has motion, temperature, humidity, light sensors and IR/RF remotes for controlling devices, and a burglar alarm.
Great, I'll give it a shot tomorrow. I also have a mini-ecosystem of Python scripts to communicate with the sensors over serial and to read values, etc. I'll post that as well.
Man, I spent all day yesterday trying to reimplement the sensor for the ESP8266, as I thought it would be better to have it report over MQTT, but the damn thing keeps crashing in seconds. I literally cannot keep it working for more than a few seconds, no matter what I do.
I'm pretty disheartened, I'll try some more and either succeed or go back to an Arduino over serial... Do you have any experience with making it not crash?
Sadly, my ESP8266 experience is only about to start next week, I'm still abroad. But from the experiences of some of my friends, consider replacing the firmware on the ESP - some units were apparently sold with buggy one that made the module crash after short time.
Yeah, I've tried flashing the Arduino firmware (I think it gets flashed every time regardless). I'll keep trying and let you know, thanks!
By the way, if you don't want to keep checking the comments, you can follow me on Twitter at @stavros and experience my frustration first-hand. I'll be posting about it there.
I'm using HN Notify, so I generally get replies straight to my inbox (except some weird bug once that made the service not work for me for like a month or two). But yeah, maybe Twitter is a better place to have real-time updates. Will be following. Thanks :).
The nodemcu is definitely the sweet spot. It saves you the trouble of power management, is breadboard friendly, and integrates the programmer. It's way easier to work with than the base ESP-01.
The only other part needed to get this running is a programming cable. The ESP8266 does not have a USB port but a serial one, so you need an adapter to connect and programm it.
e.g.:
https://www.sparkfun.com/products/12977
Just be careful not to connect the 5V VCC to the ESP8266, it will probably kill it.
The SparkFun ESP8266 Thing Dev Board [0] has a USB-to-serial so you can use a micro USB cable. They're obviously more expensive but ESP8266 breakout boards like SparkFun's Things and Adafruit's Huzzah are more breadboard-friendly an generally easier to work with.
You need to run it on 3.3v which means 3.3v versions of your sensore or external level shifting. You've got limited IO compared to, say, Arduino.
But of you've got 3.3v sensors - yeah - all you need is an ESP8266 and some way of providing 3.3v. (And probably some pulldown/up resistors and decoupling caps...)
I'm pretty sure the digital I/O on the ESP8266 is actually 5V tolerant according to the datasheet, though this isn't widely advertised and there's some inaccurate information drifting around from back when the specs weren't fully known. (The same isn't true of some official Arduino boards which should not be exposed to 5V on the I/O pins.) It's a very nice little chip.
While I agree completely with what you're saying, I think it's almost unfair to be comparing this to an Arduino or NodeMCU - this is orders of magnitude more powerful.
At this price point, for many projects it doesn't matter; you can now use Raspberry Pi as a throwaway SOC for powering little stuff. I wouldn't, for example, put an $35 RPi 2 in charge of a bunch of sensors over my doors, but with $5 RPi it is an option.
EDIT:
And given the power, you can start offloading computation on what would otherwise be "dumb" control/data acquisition units. Hell, with that much compute you can start running serious DSP on it, which opens some additional use cases.
The only case where it matters for me is that this runs Linux, which means that I'll have an extra computer to secure against intruders. An Arduino can't do as much damage to the rest of the network if it gets hacked.
However, you can get very far with the built-in real-time capabilities. If your software stack can deal with occasional jitter in sensor updates (and normally you have to take that into account), you can compile a stock kernel with PREEMPT_RT and can use C to build software that has to do IO every 1ms. In POSIX. That is huge.
What would be a real-time OS? I'd be interested in hooking up a bunch of independent boards that could interact with each other, and have as quick as a response to sensors as possible... Do you have any advice as to where to start with this type of project?
Sensor latency will be measured in milliseconds in Linux. A real time OS is more necessary when you have feedback loops, inverted pendelum problems, bitbanging protocols, etc. Not being a real time OS just means that when you say "ping me in X time" it might ping you in X +- Y. Y tends to be too big for critical applications, but generally small enough that it won't matter.
As a programmer who used to like taking things apart and playing with solder in school seeing these kinds of things fill me with enthusiasm and joy - and then I remember I need a wired power supply or a battery and suddenly enthusiasm is gone :( I wish we had wireless power transfer - for these kinds of things losses wouldn't even matter.
Yeah, powering stuff sucks. With ESP8266 you've pretty much eliminated the need for a data line for home automation, but you still need a power line.
My current solution (to be deployed in a week or two, after I get home): $2 Chinese fast charger with 4 USB ports (2x 2A, 2x 1A). I had a chance to test them personally before buying; they're decent enough for the task and cheap enough to buy a bunch. You can then use either an Arduino ($2-3 with USB cable) and ESP8266, or NodeMCU + $3 USB cable.
The price on Aliexpress is stunningly high though; I bought it for something like $2-$3 in person. I guess this is one of those cases (I've noticed a few), where Chinese just leave the same price numeric value but change the unit from CNY to USD.
I meant Chinese clones. Arduino is Open Hardware, it's perfectly legal (that's kind of a point of Open Hardware movement). It's equivalent in form and function to the genuine Arduino made in Italy.
I'm speculating, rather sooner than later, the foundation will let people (read Chinese) clone Pi Zero at will ala Arduino way.
They can't even have a profit margin with that price point. So why not open-source it anyway to let go of the burden of manufacturing? That would be a great boost for the Raspberry platform.
Just because Broadcom won't sell them doesn't mean the factory won't make some more. This is China, they have a pretty liberal (and one could argue: more reasonable) approach to issues of intellectual property :).
Or at least it used to be so; sadly, in the last few years the US was pressuring Chinese government to crack down on it. Anyway, you can read more about this phenomenon here: [0].
Oh, and one more thing. It may not apply to RPi in terms of cloning it because it's still quite a niche product, but in general, they actually recycle electronics here. Like, seriously, when you throw away your smartphone, it'll likely end up in China for desoldering. So will your laptop. The amount of desoldered components and especially ICs available for sale is staggering. I have no data for this, but I'm pretty sure people here are making small-scale production runs out of recycled ICs. So Broadcom may not sell you their chip, but the lady on the first floor of SEG building in Shenzhen just might.
BTW., I love how they recycle components so much, and how it leads to interesting situations sometimes. For instance, I recently got my phone fixed - $15 and 15 minutes of waiting was all it took to get the front half of Galaxy S4 replaced with a brand new part (screen + touch surface + glass + box) and to get a new camera (electronics, lens and all). The equivalent repair at home would cost me around $240 and would take a few days. The secret of such cheap and fast repair? They took the broken parts from me. They'll regain 90% of value of that repair by simply replacing broken subcomponents in their own time, and then pushing the fixed modules back onto the market.
"So Broadcom may not sell you their chip, but the lady on the first floor of SEG building in Shenzhen just might."
And she will also happily affix a holographic "genuine" sticker to the part and package it in "original" "tamper proof" packaging. Just like brand new!
I've recently figured out that there's no point in designing your own PCB for placing sensors at home, when you can get an Arduino and an ESP8266 for $5; add power (and some ~$0 of voltage regulation) and you have a base station. Or just buy NodeMCU for $3 and skip on wiring Arduino and ESP8266 together.