Friday, December 1, 2017

ESP8266 Servo Control from Website

I wanted a way to host a web site on the ESP8266 and control a Servo from that website. I had to search around for a bit and piece together a few bits of code, but it was pretty simple once I found the right combo.

The code is pretty straight forward. Enter your SSIS and your password. Set the int servoPin = to whatever pin you connected the servo data line to. Update the webPage line to style the web page like you want. I am going to mess around with some mobile frameworks to see if I can get it to build a good mobile looking site for me.

You can see where we are moving the servo if you find the Servo1.write() lines. You can tweak the angles to meet your needs. If you want to add a button just copy and paste the section that starts with server.on

Paste your new section above the line that says server.begin(). You will also need to add the button in your webpage+= line to add the new button: <a href=\"socket1On\"><button>UP</button> Make sure the ahref matches whatever you call the new button in the server on section.

Upload the script to the ESP and you should be rockin and rollin.

If you open the Serial Monitor you will see the IP address assigned to the ESP.


The main reason I wanted this servo functionality is because I saw the Paper Signals Google project. The voice thing is cool, but I just wanted a simple way to do the Arrow up and down. So I am going to print out the paper molds and try to assemble it this weekend.

The goal being I can have a web enabled Up Down arrow. When someone walks by my cube and gives me some lame idea I will click the down arrow. If they say something funny I will click the up arrow. The cool part is if this works well I can attach whatever symbol I want to it and move it around with the web enabled servo.

UPDATE:

Remote Boss Thumbs UP/DOWN

While planning the Paper Signals build I decided to make a remote Thumbs UP/DOWN for my boss. Now from his desk he can give me a Thumbs up or Thumbs down by hitting a web site from anywhere in the office.







I also baked in the Bootstrap Mobile framework into the web site hosted on the ESP, however Blogger was having a hard time displaying the code since it had several <script> tags. I have included the .INO file below that you can load up in Arduino IDE.


0 comments:

Post a Comment