Many of my projects are meant for autonomous deployment (set it and forget it). But for some of the projects I've been working on, I'd like to have some sort of real time control and/ or monitoring. And if I'd like to join the Internet of Things Party (IOTP), I need to incorporate some sort of wireless component to my work. So thanks to my friends down at Acrobotic Inc, I was introduced to the ESP8266 ESP-12E development board. This is a little dev board similar in layout to the Arduino Pro Mini, but with wireless capability. The ESP also has an on-board USB -> Serial converter, so while not as power stingy for long-term deployments, it has the added bonus of not requiring a special download cable. The ESP board can be programed using the Arduino IDE, but it's not a straight forward process getting the IDE to talk to the ESP. Luckily for me the folks down at Acrobotic have great customer service, and Cisco and Sonia are really helpful when it comes to project guidance. They put together a great tutorial to get you up and running with the ESP board here. Controlling/ talking to the ESP board is the tricky part, so for this post I'll keep the project simple and just use the example of controlling a 110v relay. But keep in mind being able to control an Arduino board over a wireless network really opens up what you can do with this kind of technology, and acts as your official invitation to the IOTP where all the cool kids are hanging out. Equipment List: Board- I used the ESP8266 ESP-12E, though there are other ESP boards out there on the market that are similar. Relay- I used a four channel relay board I picked up at Acrobotic as well. You don't need 4 channels for this project, but it's nice to have the option to control up to 4 different pieces of equipment. Computer- You will need a computer connected to a wireless network to control the relay. Equipment to control- In this project I just used an ordinary desk lamp plugged into a power strip as my equipment to control. But anything that plugs into power (and is not sensitive to being rapidly unplugged) can be used. The Set Up: A relay is a simple switch that can be turned on and off. It can either be configured as "Normally On" or "Normally Off"- meaning it's "Normal" resting state is either allowing electricity to flow through, or not. The relay requires an active signal from your board to flip the switch from it's "Normal" position. So if your device is going to spend most of it's life powered down, and only occasionally being powered on, you would want to configure your relay as "Normally Off". Conversely, if your device spends most of it's time in the on position, then you will want to configure your relay as "Normally On". The relay requires active power to work against it's "Normal" state, so it's important to configure your relay properly ahead of time so as to avoid needlessly overworking it. And a quick disclaimer on my part- most of my projects deal with low voltage DC current. The example provided below uses 110V AC current, so please be careful whenever you work with this kind of electricity (AKA- don't attempt this at home). As usual, the relay GND and VCC attach to the board GND and 3.3v. I'm using Digital Pin 2 as my signal to the Relay. As can be seen in the video below I have cut the insulation on the power strip cord (unplug power strip from wall outlet first!) to access the red and black wires. With the wires exposed I left the black wire untouched and cut the red wire in half. The red wire on the side of the plug (Plug End) attaches to the "C" screw terminal on the relay. The red wire on the side of power strip (Power Strip End) attaches to the "NO" or Normally Open screw terminal of the relay. Configured as above, I have now set up a power interrupt for my desk lamp that is controlled by the relay. Pin Layout: ESP 3.3v -> Relay VCC ESP GND -> Relay GND ESP D2 -> Relay IN4 Plug End BLK -> Power Strip End BLK Plug End RED -> Relay C Relay NO (Normally Open) -> Power Strip End RED The Code- For this project I'm using the aRest library to set up a simple ON/ OFF button in a web browser window that can control my relay setup. To use the below code you will need to enter the name of the wireless network as well as your password. After the code is loaded up on the ESP board, you will need to open up the Arduino Serial Monitor to find the IP address the ESP board is using. Once you have the IP address from the serial monitor, just paste it into your browsers address bar. The IP address will now open up a web page containing a simple ON/OFF button interface for your ESP board. Note that while this example only has one set of ON/OFF buttons, you can adjust the code and add more buttons (which is nice as we are using a 4way relay).
0 Comments
|
AuthorAn electronics enthusiast looking for a place to gather his thoughts, ideas, diagrams, and code Archives
October 2016
Categories |