This is a quick tutorial on how to set up a simple web controlled relay using Adafruit’s Huzzah ESP8266 board and Adafruit’s Latching Relay Featherwing.  When you are done you will be able to open a web page while on your local network (on your phone, on your laptop, on anything with a browser) and turn lights plugged into the wall on or off. 

95% of this is pieced together from other places online, but when I was piecing I couldn’t quite find it all in one place.  Hence this blog post.  The entire process is pretty easy as these things go.

In order to make this work you need 1) something connected to your home network that hosts the website and turns inputs on the website into action, and 2) something to translate that “action” into power going on or off.  That’s the Huzzah ESP8266 board and the Latching Relay Featherwing, respectively.

Practically, you will need:

  • An ESP8266 breakout board (I used the Adafruit Huzzah because I knew it would be well documented)
  • A USB to TTL serial cable (I used the Adafruit one too) to program the Huzzah.  Note that it will also power the board during development.

  • Some LEDs to turn on (I grabbed these).  
  • Some wires, a breadboard, and a soldering iron will also help

For the purposes of this project you could use pretty much anything that uses a moderate amount of electricity as the thing that is turned on (you are just creating a remote controlled switch).  The most appealing features of the LEDs I chose were 1) that they plugged into the wall instead of being battery powered (relevant to the long term use I have in mind), and 2) that it was easy to access the power cord downstream from the power adapter so that the loads were less dangerous.

Programming

I very much recommend using the Adafruit tutorial for setting up the Huzzah.  Once you’ve successfully blinked a light with the Arduino IDE come back here.

The code is taken from this post, which is also a great post about using the ESP8266 boards as simple web servers.  The only thing I added as the CSS styling, which I’ll get to in a second.

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

// Replace with your network credentials
const char* ssid = “YOUR_SSID”;
const char* password = “YOUR_WIFI_PASSWORD”;

ESP8266WebServer server(80);   //instantiate server at port 80 (http port)

String page = “”;
int LEDUnsetPin = 0;
int LEDSetPin = 2;
void setup(void){
 //the HTML of the web page
 //don’t forget you need estapes (") around the quotes
 page = “<style>  .button{    background-color:red;    color:blue;    border-radius: 8px;    padding: 12px 24px;  }</style><h1>Simple NodeMCU Web Server</h1><p>    <a href="LEDOn"><button class="button">ON</button></a>    &nbsp;    <a href="LEDOff"><button>OFF</button></a></p>”;
 //make the LED pins output and initially turned off
 pinMode(LEDUnsetPin, OUTPUT);
 digitalWrite(LEDUnsetPin, LOW);
 pinMode(LEDSetPin, OUTPUT);
 digitalWrite(LEDSetPin, LOW);

 delay(1000);
 Serial.begin(115200);
 WiFi.begin(ssid, password); //begin WiFi connection
 Serial.println(“”);

 // Wait for connection
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(“.”);
 }
 Serial.println(“”);
 Serial.print(“Connected to ”);
 Serial.println(ssid);
 Serial.print(“IP address: ”);
 Serial.println(WiFi.localIP());

 server.on(“/”, [](){
   server.send(200, “text/html”, page);
 });

 //turn on the on pin and turn off the off pin
 server.on(“/LEDOn”, [](){
   server.send(200, “text/html”, page);
   digitalWrite(LEDUnsetPin, LOW);
   digitalWrite(LEDSetPin, HIGH);
   delay(1000);
 });

 //turn off the on pin and turn on the off pin
 server.on(“/LEDOff”, [](){
   server.send(200, “text/html”, page);
   digitalWrite(LEDUnsetPin, HIGH);
   digitalWrite(LEDSetPin, LOW);
   delay(1000);
 });
 server.begin();
 Serial.println(“Web server started!”);
}

void loop(void){
 server.handleClient();
}

Make sure to replace “YOUR_SSID” and “YOUR_WIFI_PASSWORD” with your wifi network ssid and wifi password.

As I noted above, the only modification I made to the code was to add styling to the server.  The code above isn’t the final styling - it is just a first cut to verify that the way I thought styling would work was the way that styling actually worked.

The “page=“ part of the code is the HTML for the webpage you will visit with your browser to control the lights. It may look more familiar once it is converted from a string into a more standard layout (apologies - tumblr is very bad with tabs but this may be a bit better):

<style>  .button{   

background-color:red;   

 color:blue;    

border-radius: 8px;    

padding: 12px 24px;  

}

</style>

<h1>Simple NodeMCU Web Server</h1>

<p>    <a href="LEDOn"><button class="button">ON</button></a>    &nbsp;    <a href="LEDOff"><button>OFF</button></a></p>

The links to LEDOn and LEDOff trigger the server.on functions further down in the code.  Since the latching relay has two pins, each function turns off and turns on the appropriate pins on the relay so that the relay is either open or closed.  If you were using a non-latching relay there would only be one pin that was either HIGH or LOW as necessary.  Those pins were defined in LEDUnsetPin and LEDSetPin at the start of the code.

The nice thing about mapping LEDUnsetPin and LEDSetPin to pins 0 and 2 is that those pins are also mapped to leds on the Huzzah board.  That means that you can test the sketch to make sure it works by just seeing if the lights turn from blue to red.  Of course, to do that you’ll need to go to the webpage that the Huzzah is hosing.

Finding the Huzzah on the Network

In theory the serial monitor in the Arduino IDE will return a message with your Huzzah’s IP address.  I found that to be a somewhat unreliable action.  Instead, I just went to the connected devices section of my router and looked for it in the table.  Once all of this is set up I’ll use the router to assign the Huzzah a static IP address so it is easy to find.  For the development period I just track it down in the router every time.

Once you have the IP address (probably some variation of 192.168.1.X) you can just type it into your browser.  If everything is going well you’ll see the webpage with two buttons (one with ugly styling):

image

Clicking on or off will turn on a red or blue LED on the Huzzah.  If that is happening things are working out just fine so far.

Hooking up the Relay

Now that the Huzzah is connected to your network, serving up a web page, and responding to clicks on that web page, it is time to connect the Huzzah to the relay.  

Note that I’ve been having problems uploading scripts to the Huzzah when it is connected to the relay.  That means it is probably best to have the final version of the code loaded into the Huzzah before you solder it all together (obviously you can breadboard it to your heart’s content).

There are four connections between the Huzzah and the relay to  make this work.  Unfortunately fritzing does not have the latching relay featherwing in its library, so we’re stuck with my description and this picture:

Fortunately there are only four connections so words should be able to get us most of the way.

  • Connect the GND pin on the huzzah to the GND pin on the relay
  • Connect the 3V pin on the huzzah to the 3V pin on the relay
  • Connect the #2 pin on the huzzah to the SET pin on the relay
  • Connect the #0 pin on the huzzah to the UNSET pin on the relay

Once you have that up and running try controlling it all with the webpage again.  If things are working every time you click a button on the webpage you will switch the LED on the huzzah and hear a nice click from the relay.

Connecting the Relay to the Lights

The last step is to make that click impact something you care about.  Cut the live wire on the LED power cable (obvious notes about electricity plugs into walls apply - make sure you know what you are doing and take appropriate precautions) and plug it into the “COM” and “NO” ports on the relay.  Plug the lights into an outlet.  

At this point if everything is working when you click a button on the webpage you should get

  1. An LED switch on the huzzah
  2. A satisfying click on the relay
  3. Lights on or off

And that’s pretty much it.  At some point you’ll need to switch the power for the huzzah/relay from the computer you are using for debugging to a real power supply.  I haven’t done that yet but will update when I do.

image

Because, why not, it appears that we have arrived at round 4 of Just 3D Print vs The World.  In this round, Just 3D Print is bringing a new lawsuit* (it lost the last one) against the media company 3DR Holdings for reporting on Just 3D Print’s shenanigans.  The tl;dr version of this round is that Just 3D Print has brought no new evidence to the table and its claims this time seem just as big of a waste of time in Round 4 as they did in Round 3.  There do not appear to be any good reasons left to continue this lawsuit, although there are potentially one or two bad ones (see below).

The deep background is here, but at this point the short version is: Just 3D Print downloaded hundreds of models from Thingivese and, in violation of their licenses, started selling 3D prints of the models on eBay. This resulted in pushback from the community and media coverage. After the models were removed from eBay, Just 3D Print commenced a number of lawsuits against media outlets that covered the drama.  The lawsuits claimed that the negative coverage cost Just 3D Print  a $100,000,000 business.  Courts that addressed the merits of Just 3D Print’s claims have all ruled against Just 3D Print.  Courts came to this conclusion because, among other things, we are in America and reporting on public behavior and having opinions about public controversies is not illegal.

3DR Holdings owns websites like 3DPrint.com and 3DPrintingIndustry.com.  Just 3D Print sued 3DR for its coverage of the dispute.  Just 3D Print claimed that 3DR defamed Just 3D Print by reporting on the controversy surrounding the Thingverse/eBay models and that the defamation caused Just 3D Print damage (mostly in the form of lost business opportunities and sales). In Round 3 of this dispute, a court found that 3DR did not defame Just 3D Print because 1) 3DR’s post was not defamatory, and 2) even if they were defamatory, Just 3D Print failed to prove that 3DR’s actions were in any way related to any harm experienced by Just 3D Print.  The court did not need to determine if any copyright infringement actually occurred in the underlying dispute in order to reach this conclusion.

That original case was in Philadelphia Municipal Court and was resolved in August of 2017.  As best as I can tell, Municipal Court appears to be the local equivalent of small claims court.** In October of 2017 Just 3D Print filed a new case against 3DR in the Court of Common Pleas, which appears to be the PA civil court. According to the Municipal Court’s website anyone involved in a case in Municipal Court can appeal the decision to the Court of Common Pleas for a trial de novo.  De novo means that the Court of Common Pleas will reexamine the facts of the case itself instead of just relying on the factual conclusions of the Municipal Court.  Again according to the Municipal Court’s website, less than 3% of cases in Municipal Court are appealed up to the more formal Court of Common Pleas.

The New Complaint

The original complaint in Municipal Court by Just 3D Print is short enough to easily reproduce here:

ON FEBRUARY 21, 2016 THE PLAINTIFF STATES THE DEFENDANT PUBLISHED AN ARTICLE ON LINE (PLEASE SEE ATTACHED EXHIBIT). THE PLAINTIFF STATES THAT THE ARTICLE CONTAINED FALSE AND DEFAMATORY IN NATURE INFORMATION. DUE TO THIS ARTICLE, THAT PLAINTIFF’S COMPANY LOST PROJECTED REVENUE IN EXCESS OF

$100,000,000.00. THE PLAINTIFF HAS CONTACTED THE DEFENDANT VIA MAIL TO ATTEMPT TO RESOLVE THIS MATTER TO NO AVAIL. THE PLAINTIFF IS AWARE OF OUR JURISDICTIONAL LIMIT OF $12,000.00 AND FORFEITS ANY AND ALL MONIES OVER THIS AMOUNT. THE PLAINTIFF NOW SEEKS A JUDGMENT IN THE AMOUNT OF $12000.00 PLUS COURT COSTS.

The new complaint makes essentially the same sets of claims in full-blown-civil-complaint form, which means that it is long enough that I’ll just link to it here.  Once again, Just 3D Print claims that 3DR’s articles about Just 3D Print’s antics cost it a thriving business.  As a result, Just 3D Print is asking the court to award it $150,000 in damages ($50,000 each for defamation, unfair trade practices, and tortuous interference. All three of these claims are attempts to show that the same original reporting caused trouble for Just 3D Print under slightly different legal theories).

Is There Anything New Here?

I could spend another few thousand words working through these claims, talking about the procedural fights they contain and why the entire case  may be dismissed without a substantive decision by the court because Just 3D Print may have failed to follow various administrative rules, but my and your life is finite so I won’t. This is basically another round of the same dance that we saw in Round 3 moved to a slightly larger court.  That means that the post outlining Round 3 takes care of most of the substance.

At this point I have no idea what purpose this case is serving.  It does seem to be effective at wasting a lot of people’s time.  It is also starting to develop the characteristics of the types of cases that are brought to intimidate critics and find scapegoats for the failure of stupid business ideas.  Without even getting to the question of if there was copyright infringement or not, two courts have already concluded that the reporting in question here is not the type of behavior that can trigger defamation.  Just 3D Print does not appear to have found any new evidence to call that basic conclusion into question or any substantive reason why those courts are incorrect.

Even if a court came to a different conclusion – a change that would strike me as unreasonable without some sort of unexpected additional evidence – in the Round 3 post I explained why 1) there does not actually seem to be a link between any of the reporting in question and the models being taken down by eBay, which is nominally how the harm was caused, and 2) if the public facts are correct it is pretty clear to me that Just 3D Print did infringe on a number of copyrights.  Oh, also, $100,000,000 in lost business opportunities?

Why Does This Matter?

In the previous post I wrote that I’ve been following this case because

“we are still in a formative time in the context of 3D printing, copyright, and Creative Commons licensing. While there is some ambiguity, there isn’t total ambiguity.  Throwing settled areas of copyright law into question does not help work towards a solution for the complicated stuff. When there are legitimate disagreements about the intersection of 3D printing, copyright, and Creative Commons licenses, they are important to explore. But if someone is bringing dubious claims into a discussion it is important to identify them as such as quickly as possible.”

That’s still true.  However at this point it seems like this case is also evolving into an example of someone trying to use the legal system to discourage criticism they do not like, or to suppress discussions of events they wish were not widely discussed.  Just 3D Print has every right to bring these cases if it believes that it has been wronged. Similarly I – and 3DR and anyone else for that matter – has every right to report on Just 3D Print’s antics and to clearly state that they think that Just 3D Print is abusing the legal system to harass a critic and pass the blame.  Which I’ll do now: I believe that Just 3D Print is abusing the legal system to harass a critic and pass the blame for the failure of its incredibly ill conceived business onto anyone else.

To the extent that there is a Round 5 of this case (and boy do I hope there is not), my guess that it will finally move beyond the copyright questions – the answers to those are pretty clear.  Instead, any Round 5 will likely be about Just 3D Print trying to find new ways to harass critics and justify its bad behavior via lawsuit. That’s something I wouldn’t usually write about here, but I guess at this point I’m in for a penny, in for a pound.

As always, I’ll update this post if and when there is additional information.  If you have such information, contact me however you please.


* This new round was brought to my attention by the team at All3dp.com.  You can read their coverage here. Also, because it is always a good practice when writing about lawsuits, here’s a link to Just 3D Print’s complaint and amended complaint, as well as 3DRs responses.

**This seems like a good place to reiterate once again that I am in no way an expert in Pennsylvania law or the structure of its courts.  Like anything I write in relation to this case, this post is my personal best understanding and opinion but should not be confused with a statement of legal fact.  It also isn’t legal advice.  I’ll update this post as the inevitable errors emerge.


Sad face image courtesy of Loubie.

Update: If you think unlocking 3D printers (or other types of things like video game consoles, airplane black boxes) is important, please consider donating to organizations like Public Knowledge. They do the real, often behind the scenes heavy legal lifting that makes it possible to push the Copyright Office to make these types of things possible.

Today I filed the latest petition in the US Copyright Office’s review of the rules that govern unlocking 3D printing (this is part of a larger review that happens every three years concerning breaking DRM on all sorts of things).  After reading the record that informed the creation of the rules in 2015, I now believe that the evidence put forward to justify part of the rule does not actually exist.

For those of you playing along at home, at the end of October the Copyright Office renewed the existing rule that allowed people to unlock their 3D printers and use whatever consumables they want with them.  However, that rule is burdened by a significant exception that threatens to eat the rule. Today’s filing is a request that the Copyright Office drop the exception.

A charitable reading of the exception suggests that it was motivated by a fear that people might unlock their 3D printer, use third party (and sub-standard) material in their printer, create something highly regulated like an airplane part or medical implant, and then have that part fail because no one realized that it failed to meet the standards.  Unfortunately, the language that the Copyright Office chose to address this concern was so broad as to basically include every 3D printer. 

Specifically, it said it did not apply to a printer that “produces goods or materials for use in commerce the physical production of which is subject to legal or regulatory oversight.”  Needless to say, this is pretty broad.

My petition today asks the Copyright Office to drop this qualifying language for two main reasons.  First, the language itself is ridiculously broad and ends up blocking many users and uses that are unrelated to the underlying concern.

Second, and more importantly, there is not any actual evidence that the concern is real. My petition (and it is only about 7 pages long) outlines the history of the concern that unlocking 3d printing could create faulty medical devices or make airplanes fall out of the sky.  These concerns were originally raised by Stratasys and then further discussed by the Copyright Office.  However, they do not appear to have been actually documented anywhere.

In the recommendation to include the qualifying language, the Copyright Office pointed to a letter from the FDA that is represented as raising concerns about unlocked 3D printers creating harmful medical devices.  Unfortunately, if you actually read the letter (which is only 5 pages) it does not raise any of those concerns. 

As a result, the Copyright Office has severely restricted the usefulness of its exemption in order to address a concern that, as far as the record is concerned, does not exist. 

As a final point, even if unlocking 3D printers did create problems with medical devices, or airline safety, or anything else, the Copyright Office is poorly positioned to address those concerns.  Neither the proponents nor opponents of a Copyright Office rule are well positioned to argue the merits of medical device safety regulation.  Even if they were, the Copyright Office is poorly positioned to weigh their respective arguments.

Ultimately my petition asks the Copyright Office to focus on the copyright aspects of this decision.  To the extent that there is no copyright-related reason to limit the scope of the exemption, the exemption should not be limited.  If there are non-copyright-related impacts of the decision, the Copyright Office should let the other parts of the Government worry about those.

If you are convinced by this argument, you can submit comments in favor of my petition here by March 14, 2018.  If you think my argument is dumb, you can submit a comment to that effect in the same place on the same timeline.

Good news from the US Copyright Office.  Three years ago I petitioned the US Copyright Office asking it to confirm that using unapproved print material in a 3D printer did not violate US copyright law.  The Copyright Office granted the petition (with some important caveats).  However, the process driving the entire enterprise requires that petitions be renewed every three years.  Earlier this year I petitioned for a renewal, and last week that renewal was granted.  

That isn’t quite the end of it, but before I explain next steps I want to pause for a second and mention how the Copyright Office went about the process this time around.

This process is usually known as the Section 1201 Exemption Proceedings (or something similar) because they are technically requests under 17 USC 1201 for exemptions to the law that prohibits circumventing technical measures designed to prevent unauthorized reproductions of copyright-protected works. In english, participants are asking the Copyright Office to state that breaking DRM for a specific purpose does not violate the law that makes it illegal to break DRM.  The law creates a process for people to make these requests, and requires the Copyright Office to revisit the issue every three years.

This allows for new issues to be introduced to the process and old issues to drift out of memory.  It also creates something of a burden for exemption requests that are still relevant.  Three years ago professors who want to show short clips of movies in their classes needed to break DVD DRM in order to pull those clips from the larger works.  Those professors still need that capability today and therefore need to re-petition every three years.

Historically, the US Copyright Office has placed the burden on the petitioners to re-prove that the exemption is still necessary.  Since in most cases the people requesting these exemptions are represented by law school clinics or public interest organizations (Public Knowledge participates in this process every time around), this created a significant burden with no real corresponding value.  After all, the petitions were granted three years ago - if nothing has changed they should probably be renewed.

This time around the Copyright Office decided to change the process. For the first time, if an exemption already existed the burden was on the opponents to the exemption to prove why it was no longer relevant. The process for asking for a renewal was essentially a three sentence application, forcing opponents to decide if they wanted to take the time to fight the renewal.

The notice that came out last week showed the dramatic impact that this seemingly small change made.  Most renewal requests (including the 3D printing-related one) were unopposed and the Copyright Office simply renewed them.

This is not, however, the end of the process. Requests for new exemptions, as well as requests for expansions of existing exemptions, will battle it out in the old way.  There are 12 of these requests, including mine related to 3D printing.

What is my request?  As I noted at the top, the current exemption has some ridiculously broad qualifying language 

“The exemption shall not extend to any computer program on a 3D printer that produces goods or materials for use in commerce the physical production of which is subject to legal or regulatory oversight…”

Briefly, this language is problematic because 1) it arguably covers almost all 3D printers because almost every object is subject to some sort of legal or regulatory oversight, and 2) it uses copyright law to enforce every area of law that is not related to copyright.  

Therefore, I am asking the Copyright Office to remove the qualifying language.  In a nutshell, I think the Copyright Office should stick to questions of copyright law.  If using a 3D printer with third party materials violates FDA regulations, let the FDA worry about that.

Comments in support of my petition are due December 18, 2017.  Responses from opponents are due February 12, 2018 (coincidentally my sister’s birthday).  Reply comments to the opposition comments are due March 14, 2018.  After that the Copyright Office will hold hearings the week of April 9, 2018 in Washington, DC and also hearings in California at a date TBA.  At some point after that the Copyright Office will make a decision.

What can you do to help?  Submitting a comment in support of the petition by March 14, 2018 would be great!  I’ll try and put together some example language before then, but the key will be asking the Copyright Office not to regulate beyond the world of copyright.

One of the issues that continues to vex the open source hardware community is licensing.  The reason for this is simple: licensing in open source hardware is hard.  From an IP standpoint, open source software is basically a single blob of stuff comprehensively covered by a single copyright.  That means you can pick a single copyright license and be done.

Open source hardware isn’t that easy. It is actually a mix of a bunch of different elements covered by a bunch of different types of IP.  That means that you are probably going to need to pick a few types of licenses for a few different parts of your hardware.  OSHWA is working on building a tool to make this easier to figure out, but in the meantime I wanted to throw up a quick post setting up a bit of a framework.  This framework is largely based on the work that Ryan Lawson and Adam Alperowicz did as students at the NYU Technology Law and Policy Clinic, although all errors are entirely mine.

When you are thinking about licensing your hardware, there are at least four parts that might be involved. That doesn’t mean that every piece of hardware has all four, but at a minimum you should take the time to cross it off the list if it is appropriate.

Hardware.  These are the physical elements of your hardware.  This might be protected by a combination of nothing, copyright, and patent.  If it is nothing, you don’t need to worry about a license. If it is copyright, you should be looking at Creative Commons licenses (note that licenses with Non-Commercial restrictions are not compatible with the open source hardware definition).  If it is patent, things get a bit more complicated.  The good news is that you don’t just back into a patent. If you hardware is protected by a patent it is because you paid a lot of money to acquire that patent.  Talk to the lawyer who got you your patent about licensing options.  Not sure what to do?  If the CC disclaim and request option existed that would be best.  Until then, unless your hardware includes a lot of artistic or decorative elements you can probably skip this.

Documentation.  This is covered by copyright.  It is a required part of the open source hardware definition. Pick a Creative Commons license and apply it to the documentation.  That will let other people make copies of your documentation.

Software.  This is also covered by copyright.  There are many copyright licenses written precisely for software.  Pick an OSI-compliant license and apply it to your software.

Branding.  The name of your hardware can be protected by trademark. If you have a trademark you probably do not want to causally license it, because your trademark tells people “this version of X comes from me.”  Fortunately not licensing your trademark is totally allowed under the open source hardware definition. In fact, not offering blanket licenses on your trademark is part of what makes open source hardware work because it allows other people to build on your hardware without suggesting that you are responsible for whatever they put out in the world.

And that’s it.  Quick and dirty.  Wherever you are posting your licensing and documentation, it might make sense to break out the various licenses.  You know, something like this:

Documentation: Creative Commons Attribution 4.0

Software: MIT

(note the absence of a hardware license because this imaginary piece of hardware does not have any protectable elements in the physical hardware. I also didn’t license the imaginary trademark that is connected to the imaginary hardware.)

Thoughts, questions, or corrections?  Hit me up. Want more?  Keep an eye on OSHWA, where we are working to build out a much less dirty (but if appropriate to the use just as quick) version in the coming months. 


*This title is not a lie. This guide is quick and it is dirty. That means that it doesn’t contemplate every possible situation, so there are plenty of right ways to do open source hardware licensing that are not listed.  That also means that it is full of gross generalizations that may not apply to you.  That also also means that it is not intended to substitute for legal advice.  If you are thinking seriously about this issue for your own hardware, it may be worth talking to a lawyer who is your lawyer about how licensing impacts your hardware.