ESP8266 control panel upgrade

While writing the article on multiplexing the esp’s inputs I came up with the idea of PWMing all the outputs at once by interrupting the path to ground with an n-FET.  That’s actually not a bad idea, and I have an extra input on the analog MUX that I can use for a light sensor so I can even have auto-dimming.  This is to describe how I did that.

play spot the difference!

With much difficulty and frustration.  That’s how I did it.  If you hadn’t figured it out yet I wrote the intro to this piece before actually preforming the task.  The main problem is that for some reason I couldn’t get input 0 of the analog mux to do anything.  As I think about describing my problem here I also may have the solution… fuck.  The problem is that any input to that input was pulled very very low to the point of pulling more than an amp at a half a volt.  I swapped the chip but it continued to happen.  What I didn’t do was check for a little solder bridge (would have to be very little) to ground which could be what caused the pull down and uselessness of that input.  In order to get around this I added another control line for the mux to use the other inputs.  An act I now realize could have been to move s0 to s2 and tie s0 high so I had to use the other bank of inputs…I was having a good night until I go to write it down, I swear.

So, with a cadmium sulfide cell acting as half a resistor divider I can read the local light level.  That information could be used to dim the LEDs if I had that ability.  It turns out that when I wired the LEDs I tied them all to the same ground wire, one not shared by any other things.  I decided to break the ground wire just before it hit the ground plane and stuck a 2n7000 FET with pull down resistor on it.  This is called “low side drive“, a technique I have paired with individual”high side drive” pins coming from the ‘595.  Since the shift register can only update all of the LEDs at once I decided that PWM through SPI is more convoluted than I want to write code for.  The reason I want dimming is so if I mount this on a wall in a room of my house I can have the LEDs not be obtrusive while still being visible.  That means all I need is to dim them at once so I spend an extra output to control the brightness of all the LEDs at once.

That sums up all the hardware changes I made, if you take a look at the code you will find that I have put in a lot more commands, I have moved some things out to functions, and that I have defined masks for reading/writing bits rather than having hard-coded sequences.  I rather like my new code, but one thing I’m going to move toward is having many topics on each device. The problem with defining the topics now is that if I don’t know where I’m going to put things or how I want them to interact then I can’t design a system.  The problem I face as being not-a-programmer is that I don’t know a good way to parse the payload of a message.  What I have right now is to have a lot of verbatim answers or an’else’ which I use for numbers.  First: I should move to a switch/case structure, and second I could stand to parse a smaller part of the payload making my code more versatile.  I’m not going to do the second one,I will instead move to a lot of topics which contain ‘/’ symbols so it looks like a hierarchy even though it isn’t.

here is the bit of code I updated.

here are the pictures (again).

here is my hub for all things esp8266.

Advertisements

Tags:

3 Responses to “ESP8266 control panel upgrade”

  1. Intro to my ESP8266 adventures | Evan's Techie-Blog Says:

    […] Wall control panel v2 […]

  2. ESP8266 control panel (input muxing) | Evan's Techie-Blog Says:

    […] So, now let’s deal with the outputs for these panels.  The white LEDs I just explained, how I set them up to be driven with 3.3v, but we also have 2 red LEDs.  The red LEDs had both positive terminals wired together and apparently used low side drive to switch them, I decided to make all the outputs on this project high side drive so I unwired the LEDs and rewired them with resistors that make them pleasing to look at at 3.3v (as I do more projects I care less and less what amperage my lights are, they just need to be ‘pleasing’ and ‘not going to burn out’.  Since these LEDs are driven over shift registers I can’t use the hardware PWM to control the brightness, it’s important to choose a light leven that is comfortable because it will be hard to dim (although one could low side drive the common light ground to dim them all as one). […]

  3. ESP8266 control panel upgrade | Electronics Infoline Says:

    […] More info at Evan’s Techie blog. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: