Tuesday, May 2, 2017

Speaker controller version 2, part 1

I had a request to build one of the speaker controllers that I've posted about before, but the request was for an 8 zone controller rather than a 4 zone controller like I'd done previously. This led me down an entirely different path, which has been very interesting.

I started with one of these:

ESP8266 ESP-01 Microcontroller for Arduino


These are tiny wifi controllers that stand on their own, no need for a shield or a separate Arduino. They come in a package of 4 for about $15. They are completely programmable from the Arduino IDE and fully support the Arduino libraries. Unlike Arduino, there are very few pins for controlling things, but it turns out that's okay.

I also found this nice looking project box on Amazon for about $19:


The other essential piece of this is an MCP23017, which is an I2C port expander, meaning the two output pins on the ESP-01 can be connected to this to get 16 pins. These come 5 in a package for about $24


As in my previous version of the speaker controller, I used the SainSmart 8 channel relay module, but two of them to be able to run 8 zones (8 zones, 2 speakers per zone, means 16 relays, one per speaker). These run about $10 each on Amazon.

Here is the whole thing assembled on a breadboard. The Arduino is not part of this project.


From left to right:

2 SainSmart 8 channel relays
MCP23017
Flash button
Reset button
ESP-01

Unlike Arduino, this is programmed with a TTL serial cable, not USB. I use a nice one from Adafruit:


An important thing to note is the ESP-01 runs at 3.3V, using the usual 5V from a USB cable will fry it. This one has 3.3V on the RX line already, so no problems. In the picture, the black wire is ground, the white is RX, the green is TX and the red is 5V power. I didn't use the red wire at all for this project.

Here is the whole thing soldered to a prototype board:


The MCP23017 is on the left, with pins added to connect the relays. The two pins at the bottom are to connect the serial programming cable. There are 4 pins at the top, two are for 3.3V, which turns out is not enough to run the relays, and the other two are ground pins for the relay boards. Top right is the ESP-01, and on the very right is the power converter. The button on the bottom right is the reset button and the button on the center top is the flash button.

Here's a shot of the underside. I thought my soldering skills are not very good, but actually, this came out quite nice.


Lots of tiny wires soldered by using a magnifying glass. I took this picture before I added pins for the serial cable. I thought the pins were long enough on the ESP-01 to attach the cable, but they weren't, so I needed the extra pins.

Here are a few shots of everything in the box:

The relays and circuit board are attached with heavy duty double stick tape.

I'm not too pleased with this, I got a little off on drilling holes, so the connectors don't line up as nicely as they should. On the right is the power connector.

I put a small styrofoam block under the circuit board.

The programming for this is quite a bit different than my previous version. The ESP-01 is capable of running as an access point, which makes it easy to connect to the local network, plus it supports over-the-air updates. I also added the ability to change the names of the zones via a configuration page.

I'll cover operation and programming in separate posts.



1 comment:

Mario said...

Hi can't get the code to verify? any thoughts?

Arduino/ESP01RelayServer/ESP01RelayServer.ino:44:65: fatal error: "ArduinoJson.h": No such file or directory
#include <"ArduinoJson.h"> // read/write config file
^
compilation terminated.
exit status 1
Error compiling for board Generic ESP8266 Module.