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.
https://github.com/esp8266/Arduino