4. BUILD THE SCRIPT AND
WEB BUTTON
To remotely tell the Boron to activate the opener,
you’ll need a script for the board and a web page
with a virtual button that accesses it. I modified
the code from the Buzz Wolf dog collar project
by Nancy Yi Liang (particle.hackster.io/nyl/buzz-
wolf-837db0) to make a simple interface for our
gate opener.
First, go to makezine.com/go/cellgateopener to
download the opener code and web-button HTML
(see end box for QR code).
In the Particle IDE at build.particle.io, create a
new app for your Boron (Figure
K
). I called mine
“gateopener.Paste in the code for the controller
and upload to your device.
On the HTML, there are two fields to update in
the code for your specific board: device_id and
access_token. You can find your Device ID on
Particle’s console at console.particle.io/devices.
The Access Token can be a little trickier to
locate;the published methods didn’t work well
for me. What I did to find ours was to click the
device link from the same Particle console page,
and then click the Terminal tab under the Events
section. A popup window will show your Device ID
and Access Token (Figure
L
) inside the displayed
URL. Copy the token number and paste it into the
code above.
CAUTION: Don’t share your Device ID and
Access Token publicly! They will grant anyone who
knows them access to your Particle device. The
way we’ve published it here, a simple look at the
HTML page source reveals both of those sensitive
elements. If you will share your web app with anyone
else, you’ll want to utilize a personal server so you
can keep the Device ID and Access Token private.
Particle has documentation on doing this:
docs.particle.io/datasheets/app-notes/an032-
calling-api-from-web-page
Save this document as an HTML file and upload it
to your website.
When you navigate to that page on a browser
(desktop or mobile, both work the same), you
should now see a plain webpage with a blue
button that says “CLICK GATE” (Figure
M
)
—press that button and a few moments
later you’ll see the LED on the remote light up.
It’s working!
5. FINAL STEPS
From here, you can carefully tuck your
breadboard into an enclosure (Figure
N
). Be sure
to tie a knot into the power cord inside the case so
PROJECTS Cell Gate Opener
Device ID
Access token
76 makezine.com
M
K
L
M78_072-77_GateOpener_F1.indd 76M78_072-77_GateOpener_F1.indd 76 7/12/21 1:45 PM7/12/21 1:45 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
35.175.174.36