Using the Arduino AJAX Webcam to Monitor and Control Your 3D Printer


It’s a simple idea. Just modify the source code from our Arduino IP Webcam project page and add an additional set of AJAX response lines that toggle a couple IO pins on the Arduino. You can have these pins go directly to some headers on your 3D printer and/or to an inline power-switch tail that you can toggle in the event of a problem. All the while monitoring your 3D printer visually with a live image feed from anywhere on the World Wide Web.

Heck, while you’re at it, you might as well add some remote controlled lighting, and a relay shield. Your only limit is your imagination RAM. Check out this simple user interface:


The “Printer control” buttons sends a simple HTTP request in the backround that the Arduino server listens for.  Such “commands” can also be executed via appending the appropriate pre-programmed AJAX phrase at the end of the URL like this: http://yourarduinosip:port/?pwr

To add some level of protection, you can also add a basic HTML+JavaScript password prompt that blocks unwanted control over your printer.


Once the Arduino receives the request, it will complete the desired action and return some form of a response to indicate that all was successful.

Here is an example of what the Arduino server may listen for. In this case it is looking for the string “?pwr” after the main URL (http://yourarduinosip:port/?pwr).

//AJAX request line for toggling printer's power relay
if (strstr(clientline, "GET /?pwr") != 0) {
  code200(client);               //give client a responce header
  if (is1 == 0) {                //if relay is off, turn it on
    digitalWrite(relay1, HIGH);
    is1 = 1;                     
  else {                         //if relay is on, turn it off
    digitalWrite(relay1, LOW);
    is1 = 0;
  client.print(F("done."));      //tell client we are done

All you’ll need to do is copy the code above over to the appropriate place in the example sketch (see project page), declare/edit your variables, then edit or add a new button in the example HTML file.

If you are new to HTML or Javascript, head on over to and tinker with some of their examples. It’s easier then you might think.

Give it a try and share your results!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.