How to Build Your Own Embedded Project

Published on March 2017 | Categories: Documents | Downloads: 48 | Comments: 0 | Views: 305
of 11
Download PDF   Embed   Report

Comments

Content

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 1)
By hinkmond on Jan 22, 2014
As we all saw recently, the company that
starts with the letter "G" up Highway 101
in Mountain View bought Nest Labs for
$3.2 billion (with a "b"), maker of the
Internet of Things (IoT) Nest thermostat.
Well, here's your chance in this new Java
SE Embedded IoT blog series, to learn
how to build your own $3.2 billion Nest
Startup using a Raspberry Pi, some hobby
electronic parts, and Java SE Embedded
Technology.
This blog series was inspired by Spark
Team's Arduino Based blog post at the
spark.io. But, we'll use a more powerful
but still inexpensive Raspberry Pi, and
we'll base the software on Java SE
Embedded which is a much more powerful programming language and platform than you can
ever find on the Arduino.
This project will need the following parts:








1
1
1
1
1
3
1

Raspberry Pi $39.95
TFT 2.8" LCD touchscreen $34.95
USB mini Wi-Fi adapter $11.95
DC to DC Voltage Step Down Transformer $2.99
Bridge Rectifier GBU608 $1.47
Single Relay Board $29.97
DS18B20 Digital temperature sensor $4.00

So, for the low total cost of about $125.28 (plus tax and shipping) you can build your own
$3.2 billion IoT startup company. Well... maybe, the start of a $3.2 billion IoT startup
company, but you'll have a nifty IoT Java SE Embedded enabled home thermostat in the end,
regardless. And, that's just as good as a $3.2 billion IoT startup, right?
Come back for the next steps in this series, to get you on your way...

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 2)
By hinkmond on Jan 27, 2014

So, let's get started in building your
own $3.2 billion (with a "b") Nest
Startup using a Raspberry Pi, some
hobby electronic parts, and Java SE
Embedded Technology. The journey of
a $3.2 billion startup begins with a
single step-down transformer... er, or
something like that.
First, we'll need a crash course in home thermostat technology. Here in the U.S., if you first
flip off the circuit breaker to your home heating furnace and A/C, then take off the thermostat
panel in your house, you should see these standardized labeled wires (with various colors of
wires that are not standardized):
Red - R - 24VAC
or
Red - Rh - 24VAC (dedicated to heat call)
Red - Rc - 24VAC (dedicated to cooling call)
Green - G - Fan on
White - W - Heat call
Yellow - Y - Cool call
Blue or Black - C - Common

If you see a wire labeled "C" (Common) and the rest of the labeled wires (above), then you
are OK. If you do not see the "C" label on a wire, you must ask an electrician friend or hire
an electrical contractor to run the common "C" wire from a furnace relay to your thermostat.
Otherwise, if you do not have the "C" wire at your thermostat, stop here since the "C" wire is
needed to power the Raspberry Pi and especially for the Wi-Fi adapter to have enough power
to allow your new SmartThermostat to be networked.
If after one way or another you do have a "C" wire at your thermostat, then you are ready for
the first step which is to connect the Bridge Rectifier GBU608 and the DC to DC step-down
transformer from your Raspberry Pi to your thermostat wires to power it from the 24VAC of
your thermostat wiring (C and either Rh or Rc or R). The Bridge Rectifier turns the 24VAC
of your furnace relay from 24 volts of AC power to 33 volts DC power, and the step-down
transformer turns the 33 volts DC down to 5 volts DC for the Raspberry Pi (and all its
peripherals).
Come back to the next blog post to see how that's done... It's a fun step since it's your first
one

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 3)
By hinkmond on Feb 03, 2014

If you are this far along, it means you do have a "C"
wire at your thermostat. Yay! That means you can
connect the Bridge Rectifier GBU608 and the DC to
DC step-down transformer from your thermostat wires
to power your Raspberry Pi from the 24VAC of your
thermostat wiring. We are using the C wire and either
the (Rh or Rc wire) or the R wire to power the RPi,
since one of the "R" wires is considered in AC terms
"hot" and the "C" wire is considered "neutral".
NOTE: You need a "hot" wire and a "neutral" wire in
AC household electrical circuits to complete or close
an AC circuit. With most U.S. household thermostats,
we are working with a lower 24VAC standard, and not your typical 110VAC found in U.S.
homes. If your thermostat happens to be a higher voltage 110VAC thermostat, stop here and
do not proceed. Your wiring for a 110VAC thermostat is not the same as the 24VAC we need
for this project. If you are unsure whether your thermostat is 24VAC or 110VAC, ask an
electrician friend or electrical contractor to check for you.
As a review, the Bridge Rectifier turns the 24VAC of your furnace relay from 24 volts of AC
power to 33 volts DC power, and the step-down transformer turns the 33 volts DC down to 5
volts DC for the Raspberry Pi (and all its peripherals).
As with any $3.2 billion startup, you begin with a prototype, and that prototype is typically
built using a breadboard, so that you can easily put it together and change it if necessary.
1. So find a hobby electronic breadboard, and add your GBU608 Bridge Rectifier. In
this part of the project you will run the inner two wires to connect from the
breadboard to your "C" and one of your "R" wires of your thermostat (refer to the
pinout diagram above)
2. Use a wire connected to the notched edge pin of your GBU608 which represents the
positive terminal to solder to the positive "IN" pad on your DC to DC Voltage StepDown Transformer, and do the same with your unnotched edge pin of your GBU608
which is the negative connector and solder that to the negative "IN" pad on your DC
to DC Voltage Step-Down Transformer.
3. Solder two separate wires to the positive and negative "OUT" pads of your DC to DC
Voltage Step-Down transformer
4. Connect the two inner pins (marked with the "~" symbol) of your GBU608 Bridge
Rectifier to your thermostat wires as described in Step #1: one inner pin connects to
the "C" wire of your thermostat and the other inner pin connects to one of the "R"
wires (or better yet for workbench development purposes, connect them to a
temporary 24VAC power supply like this one to represent the thermostat power as
you develop on your bench first).
5. Use a voltmeter to measure the OUT pads of your DC to DC Voltage Step-Down
transformer and adjust the screw of the transformer until your voltmeter reads 5 volts.
Once you have the screw set on your transformer, then your are ready to connect your
Raspberry Pi in the next step... Fun!

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 4)
By hinkmond on Feb 19, 2014

So, you've now added your Bridge Rectifier and
Transformer to your $3.2bln Nest Startup
prototype. You just need to connect to power
up your Raspberry Pi.
This next step is pretty straight-forward. To make life easy,
you should buy a USB A Jack to Wire Lead connector at
element14 or Newark Electronics: here. This jack will allow you to plug in a typical micro
USB cable to power up your RPi.
After you purchase the USB A Jack to Wire Lead connector (above), see the spec sheet for
details on how to hook it up to your Transformer: here.
Then, connect the black wire of your USB A Jack to your Transformer GROUND OUT (-)
pad by soldering it together, and connect the red wire to your Transformer POWER OUT (+)
pad by soldering those together. That's it!
Plug in one end of a standard micro USB cable to your USB A Jack, and the other end to
your Raspberry Pi. Then connect your 24VAC power from your house thermostat wiring to
your breadboard Bridge Rectifier as mentioned in Part 3/Step 4 and turn your circuit breaker
back on, or use a temporary power source on your workbench as described in the later section
of Part 3/Step 4 to test it.
If you reach this point and you haven't fried your Raspberry Pi, then that's a very good thing.
If you accidentally see white smoke coming out of your Raspberry Pi board, shout out your
favorite expletive and quickly unplug everything. But don't worry, just go back to Part 1 and
buy another one. Heck, they're just $35 each! Buy, 2 or 3 more, just in case... Wouldn't
hurt.
When you reach this point, and your RPi powers up correctly with very little or no swearing,
do a little dance and get ready for the next step in building your own $3.2bln Nest Startup,
which is where you connect up the LCD touchscreen

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 5)
By hinkmond on Mar 14, 2014

We now have power
to your Raspberry Pi.
Next, we need to hook
up the cool LCD
Touchscreen from
adafruit.com so that
your Java SE
Embedded thermostat
app will have a UI.
Lady Ada has some
rockin' cool gear for
your Raspberry Pi at
her Web site!
See the cool video demo of
the TFT touchscreen below:

To hook up her LCD Touchscreen to your RPi so that your Java SE
Embedded app can use it, just follow these two sets of instructions from
adafruit.com.
First do the assembly: TFT touchscreen assembly
Next do the software installation: TFT touchscreen software
That's it for this part. You can also check out the other steps at the adafruit.com Web site for
screen calibration and other optional set-up steps. But, with the above minimal steps you now
have a working touchscreen.
Next up, we will connect the PiFace for the relays needed to turn on and off your furnace and
A/C via a Java SE Embedded app. That's when the stuff gets real... Or, sparks fly... One, or
the other.

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 6)

By hinkmond on May 11, 2014

After showing how to
connect the LCD
Touchscreen from
adafruit in Part 5 for
this Java SE Embedded
thermostat project, I
figured out a simpler
solution for the relays
needed to turn on and off the furnace, fan, and A/C of a home heating and
cooling system (just like the Nest thermostat).
So, it's time to show how to do a time-honored tradition in high tech start-up prototyping:
Refactoring.
I found this cool Single Relay Board from Parallax. It can control up to 120VAC at 10 amps,
but we only need to control 24VAC 1 amp relays for the home furnace, fan, and A/C. And
most importantly, this Single Relay Board can take a 3.3 VDC signal from a microcontroller
or Raspberry Pi running the Java SE Embedded platform (like we are doing in the project).
No need for SPI or i2c, just a straight GPIO high value (3.3VDC) from the Raspberry Pi
header pins from a Java SE Embedded app will control the relays. Cool!
So, I've got a bit of refactoring to do of my previous blog posts to swap in 3 of these Single
Relay Boards (go ahead and order 3 if you are playing along at home). But, it's all good.
Refactoring is part of the process of high tech start-up prototyping, right?

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 7)
By hinkmond on Jun 20, 2014

So, you've got your Parallax Single
Relay Board. Next you need to connect
this to your furnace, fan, and A/C
control wires... and, not burn down
your house in the process. Got that?
Good.
Refer back to your thermostat wires. We need to connect a Relay Board to each of the control

wires for the Fan, Heat call, and Cool call. Here's a reminder which wire is which.
Red - R - 24VAC
or
Red - Rh - 24VAC (dedicated to heat call)
Red - Rc - 24VAC (dedicated to cooling call)
Green - G - Fan on
White - W - Heat call
Yellow - Y - Cool call
Blue or Black - C - Common

You will need 3 Relay Boards connecting to the
Raspberry Pi to control the 3 house thermostat control
wires (Green for Fan, White for Heat, and Yellow for
Cool). First, make sure on your Adafruit PiTFT has the
2x13 male header properly soldered on to it to daisy
chain your RPi header pins (to allow your Relay Boards
to connect down to the RPi). This way your Adafruit
PiTFT can use the SPI pins (SCK, MOSI, MISO, CE0,
CE1) plus GPIO #24 and #25 for its use, while we use
GPIO #00, #01, and #04 for the Relay Boards. It's nice
to share.
On each Relay Board, connect the + to the +5 VDC pin on your Adafruit PiTFT (male header
pin #2). Make use of continuous jumper wires to share the one +5 VDC pin with all 3 of the
Relay Boards. Then, connect the - to the GND pin (male header pin #6) using a continuous
jumper wire to share this pin also. And, finally connect the S pin of one of your Relay Boards
to GPIO #00 (pin #3), one S pin to GPIO #01 (pin #5), and the final S pin to GPIO #04 (pin
#7).
Then connect all 3 Relay Boards Common screw down connector to the C - Common wire of
your thermostat. Connect one Relay Board Normal Open (NO) screw down connector to the
Green Fan wire, one NO screw down connector to the White Heat wire, and the final NO
screw down connector to the Yellow Cool wire. Cool? Cool!
You are good to go for the next step!

See, not so bad still, right?
How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 8)
By hinkmond on Jul 23, 2014

Now, your Parallax Single Relay Board
from your Raspberry Pi is connected to
your furnace, fan, and A/C control
wires. Let's just stop right there and
soak that in.
Your Raspberry Pi is now the hardware
equivalent to a Nest Thermostat. Nice work so far! You just need intelligent software to run
the Raspberry Pi to control your home heating and A/C. And, of course, you don't want to use
just any programming language to do that. You want your Raspberry Pi to be a smart Internet
of Things (IoT) device, not a dumb device. So, you're going to need Java SE Embedded
Technology.
Here's the simple Java code that will drive your relays to turn on your furnace, fan, and A/C.
It's a test app that cycles your heat on for 5 minutes, then your fan on for 5 minutes, then your
A/C on for 5 minutes with a rest period of 2 minutes in between.
static String[] GpioChannels =
{ "0", "1", "4" };
/* ... */
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
FileWriter[] commandChannels;
try {
/*** Init GPIO port for output ***/
// Open file handles to GPIO port unexport and export controls
FileWriter unexportFile =
new FileWriter("/sys/class/gpio/unexport");
FileWriter exportFile =
new FileWriter("/sys/class/gpio/export");
for (String gpioChannel : GpioChannels) {
System.out.println(gpioChannel);
// Reset the port
File exportFileCheck = new File("/sys/class/gpio/gpio"+
gpioChannel);
if (exportFileCheck.exists()) {
unexportFile.write(gpioChannel);
unexportFile.flush();
}
// Set the port for use
exportFile.write(gpioChannel);
exportFile.flush();
// Open file handle to port input/output control

FileWriter directionFile =
new FileWriter("/sys/class/gpio/gpio" + gpioChannel +
"/direction");
// Set port for output
directionFile.write(GPIO_OUT);
directionFile.flush();
}
/* ... */
// Set up a GPIO ports as a command channels
FileWriter heatChannel = new
FileWriter("/sys/class/gpio/gpio" +
GpioChannels[0] + "/value");
FileWriter fanChannel = new
FileWriter("/sys/class/gpio/gpio" +
GpioChannels[1] + "/value");
FileWriter acChannel = new
FileWriter("/sys/class/gpio/gpio" +
GpioChannels[2] + "/value");
// TEST Cycle all 5 min. on, 2 min. off
// HIGH: Set GPIO port ON
heatChannel.write(GPIO_ON);
heatChannel.flush();
java.lang.Thread.sleep(300000);
// LOW: Set GPIO port OFF
heatChannel.write(GPIO_OFF);
heatChannel.flush();
java.lang.Thread.sleep(120000);
// HIGH: Set GPIO port ON
fanChannel.write(GPIO_ON);
fanChannel.flush();
java.lang.Thread.sleep(300000);
// LOW: Set GPIO port OFF
fanChannel.write(GPIO_OFF);
fanChannel.flush();
java.lang.Thread.sleep(120000);
// HIGH: Set GPIO port ON
acChannel.write(GPIO_ON);
acChannel.flush();
java.lang.Thread.sleep(300000);
// LOW: Set GPIO port OFF
acChannel.write(GPIO_OFF);
acChannel.flush();
java.lang.Thread.sleep(120000);
}
} catch (Exception exception) {
exception.printStackTrace();
}
}

Pretty straight-forward stuff. It's easy when you use Java SE Embedded technology and a
Raspberry Pi. Hey, someone should trademark that...

How to Build Your Own $3.2bln Nest Startup Using Java SE Embedded Tech
(Part 9)
By hinkmond on Aug 26, 2014

This is the final part of
"How to Build Your Own
$3.2bln Nest Startup
Using Java SE Embedded
Technology". You've
followed along and now
have your Raspberry Pi
connected to your home
thermostat to control
your heating, cooling,
and fan controls of your
furnace and A/C. You also ran through a Java diagnostic app that cycled
through the heating, cooling, and fan relays to make sure you are able to
turn on and off the controls programmatically. Very nice.
Now, it's up to you to create your user interface and control software. Remember to utilize
the Web since you are connected via Wi-Fi to your home wireless network. Just make sure to
use the proper HTTPS connection to any server and check for proper authorization for every
connection. Using certificate based authentication is best, but that's a topic that's outside the
scope of this series.
For the UI, just make sure Jetty is installed on your RPi. Jetty is a Java SE Embedded based
Web server to run your UI on your local LCD touchscreen.
sudo apt-get install jetty
(cd /usr/share/jetty; sudo java -jar start.jar)

Now, when you boot up your Raspberry Pi, just configure your boot-up to bring up the
Midori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Web
server and your UI page to your software.
See: http://www.ediy.com.my/index.php/blog/item/102-raspberry-pi-running-midoribrowser-without-a-desktop

That should get you started on your way to building your own home thermostat control based
on Java SE Embedded technology. Not too shabby!
Good luck on finishing out your project! Hope this was useful in getting you on your way to
creating your own Nest startup.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close