Friday, March 25, 2016

3.3v (or: how to not fry your esp8266)

[question]
That all sounds great, makes a lot of sense. One more question - http://www.electrodragon.com/product/water-drop-rain-sensor/ says that it uses 5v, but the HUZZAH doesn't have a 5v pin and all the GPIO pins come with dire warnings on https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/pinouts about them not being 5v "compatible". I take this to mean something will melt, explode, or otherwise make me unhappy.

What happens if I just throw 3.3v at the water sensor board? Will give me 3.3v back, or will it not work or explode or something?

[answer]
Ok, took me a bit but I just checked the demo board I made, and I connected the water sensor to the +3v for it's vcc, and it works fine.  Some sensors (eg: the ultrasonic one I demoed) do require a 5v vcc* to work correctly.  Many, however, work fine on 3.3v.  Sometimes the sensor will outright state "5v only" or "3.3v only" or (in some cases) "3.3v and 5v".  Some will state "TTL Logic" <-- this almost always means: "will work with logic levels from 2.7v to 5v for the "on" state"

Yes, 5v isn't good for a microcontroller that uses a 3.3v logic signal to indicate a "high" (ON, or 1) state.  Thinking of voltage as pressure in a hose (a useful, if not entirely accurate, analogy).  A valve that's rated for 3.3v psi might burst/fail/leak if you hit it with 5psi.  Bit of a stretch for the real world, but you get the idea...tiny circuits that are spec'ed to deal with 3.3v may burn up @ 5v.

Using the above ultrasonic sensor, for example, I had to feed the sensor 5v for it to work right, but the signal pin also put 5v out.  That would have very likely damaged the input on the esp8266.  I wound up using a voltage divider to bring the 5v down to 3.3v.   (voltage divider quick tutorial: https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-raspberry-pi )

Here's a bit of irony for you...my in-laws came by last night to borrow a pair of fans from us ... to dry out their garage floor ... where the water heater had been leaking.  I described the demo'ed water sensor and they immediately asked where they could buy one ...

OH...and before I forget...for *this* particular application, I'd recommend adding the email widget to your app and a call to Blynk.email in your arduino code.  (http://docs.blynk.cc/#widgets-notifications-email)  So instead of only having it notify an application (that may or may not be running) on your phone, you should wind up with a text message that will be sure to pop up and be noticed.

We do this by sending the email message to your cell carrier's "email to text" gateway. (list: http://www.digitaltrends.com/mobile/how-to-send-e-mail-to-sms-text)

Heck, have the huzzah send the email to *several* people just to be sure!

Cheers!

(*vcc == "this is where the positive supply voltage gets connected")

No comments:

Post a Comment