11
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 inexpensiv e 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 Raspberry Pi $39.95   1 TFT 2.8" LCD touchscreen $34.95   1 USB mini Wi-Fi adapter $11.95   1 DC to DC Voltage Step Down Transformer $2.99   1 Bridge Rectifier GBU608 $1.47   3 Single Relay Board $29.97   1 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 

How to Build Your Own Embedded Project

Embed Size (px)

Citation preview

Page 1: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 111

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 1)

By hinkmond on Jan 22 2014

As we all saw recently the company thatstarts with the letter G up Highway 101in Mountain View bought Nest Labs for$32 billion (with a b) maker of theInternet of Things (IoT) Nest thermostatWell heres your chance in this new JavaSE Embedded IoT blog series to learnhow to build your own $32 billion NestStartup using a Raspberry Pi some hobbyelectronic parts and Java SE Embedded

Technology

This blog series was inspired by SparkTeams Arduino Based blog post at thesparkio But well use a more powerful

but still inexpensive Raspberry Pi andwell base the software on Java SE

Embedded which is a much more powerful programming language and platform than you canever find on the Arduino

This project will need the following parts

1 Raspberry Pi $3995

1 TFT 28 LCD touchscreen $3495

1 USB mini Wi-Fi adapter $1195

1 DC to DC Voltage Step Down Transformer $299

1 Bridge Rectifier GBU608 $147

3 Single Relay Board $2997

1 DS18B20 Digital temperature sensor $400

So for the low total cost of about $12528 (plus tax and shipping) you can build your own$32 billion IoT startup company Well maybe the start of a $32 billion IoT startup

company but youll have a nifty IoT Java SE Embedded enabled home thermostat in the endregardless And thats just as good as a $32 billion IoT startup right

Come back for the next steps in this series to get you on your way

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 2)

By hinkmond on Jan 27 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 211

So lets get started in building your

own $32 billion (with a b) Nest

Startup using a Raspberry Pi some

hobby electronic parts and Java SEEmbedded Technology The journey of

a $32 billion startup begins with a

single step-down transformer er or

something like that

First well need a crash course in home thermostat technology Here in the US if you firstflip off the circuit breaker to your home heating furnace and AC then take off the thermostat

panel in your house you should see these standardized labeled wires (with various colors ofwires that are not standardized)

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool callBlue or Black - C - Common

If you see a wire labeled C (Common) and the rest of the labeled wires (above) then youare OK If you do not see the C label on a wire you must ask an electrician friend or hirean electrical contractor to run the common C wire from a furnace relay to your thermostatOtherwise if you do not have the C wire at your thermostat stop here since the C wire isneeded to power the Raspberry Pi and especially for the Wi-Fi adapter to have enough powerto 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 forthe first step which is to connect the Bridge Rectifier GBU608 and the DC to DC step-downtransformer 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 24VACof your furnace relay from 24 volts of AC power to 33 volts DC power and the step-downtransformer 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 thats done Its a fun step since its your firstone

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 3)

By hinkmond on Feb 03 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 311

If you are this far along it means you do have a Cwire at your thermostat Yay That means you canconnect the Bridge Rectifier GBU608 and the DC toDC step-down transformer from your thermostat wiresto power your Raspberry Pi from the 24VAC of your

thermostat wiring We are using the C wire and eitherthe (Rh or Rc wire) or the R wire to power the RPisince one of the R wires is considered in AC termshot and the C wire is considered neutral

NOTE You need a hot wire and a neutral wire inAC household electrical circuits to complete or closean AC circuit With most US household thermostatswe are working with a lower 24VAC standard and not your typical 110VAC found in UShomes If your thermostat happens to be a higher voltage 110VAC thermostat stop here anddo 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 anelectrician 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 5volts DC for the Raspberry Pi (and all its peripherals)

As with any $32 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 Inthis 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 Step-Down Transformer and do the same with your unnotched edge pin of your GBU608which is the negative connector and solder that to the negative IN pad on your DCto DC Voltage Step-Down Transformer

3

Solder two separate wires to the positive and negative OUT pads of your DC to DCVoltage Step-Down transformer

4

Connect the two inner pins (marked with the ~ symbol) of your GBU608 BridgeRectifier to your thermostat wires as described in Step 1 one inner pin connects tothe C wire of your thermostat and the other inner pin connects to one of the Rwires (or better yet for workbench development purposes connect them to atemporary 24VAC power supply like this one to represent the thermostat power asyou develop on your bench first)

5 Use a voltmeter to measure the OUT pads of your DC to DC Voltage Step-Downtransformer 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 yourRaspberry Pi in the next step Fun

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 411

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 4)

By hinkmond on Feb 19 2014

So youve now added your Bridge Rectifier and

Transformer to your $32bln Nest Startup

prototype You just need to connect to power

up your Raspberry Pi

This next step is pretty straight-forward To make life easyyou 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 fordetails 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 Thats it

Plug in one end of a standard micro USB cable to your USB A Jack and the other end toyour Raspberry Pi Then connect your 24VAC power from your house thermostat wiring to

your breadboard Bridge Rectifier as mentioned in Part 3Step 4 and turn your circuit breaker back on or use a temporary power source on your workbench as described in the later sectionof Part 3Step 4 to test it

If you reach this point and you havent fried your Raspberry Pi then thats a very good thingIf you accidentally see white smoke coming out of your Raspberry Pi board shout out yourfavorite expletive and quickly unplug everything But dont worry just go back to Part 1 and

buy another one Heck theyre just $35 each Buy 2 or 3 more just in case Wouldnthurt

When you reach this point and your RPi powers up correctly with very little or no swearingdo a little dance and get ready for the next step in building your own $32bln Nest Startupwhich is where you connect up the LCD touchscreen

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 5)

By hinkmond on Mar 14 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 511

We now have power

to your Raspberry Pi

Next we need to hook

up the cool LCDTouchscreen from

adafruitcom so that

your Java SE

Embedded thermostat

app will have a UI

Lady Ada has some

rockin cool gear foryour Raspberry Pi at

her Web site

See the cool video demo ofthe 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

adafruitcom

First do the assembly TFT touchscreen assembly

Next do the software installation TFT touchscreen software

Thats it for this part You can also check out the other steps at the adafruitcom Web site forscreen calibration and other optional set-up steps But with the above minimal steps you nowhave a working touchscreen

Next up we will connect the PiFace for the relays needed to turn on and off your furnace andAC via a Java SE Embedded app Thats when the stuff gets real Or sparks fly One orthe other

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 611

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 AC of a home heating and

cooling system (just like the Nest thermostat)

So its time to show how to do a time-honored tradition in high tech start-up prototypingRefactoring

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 AC Andmost importantly this Single Relay Board can take a 33 VDC signal from a microcontrolleror 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 (33VDC) from the Raspberry Pi

header pins from a Java SE Embedded app will control the relays Cool

So Ive got a bit of refactoring to do of my previous blog posts to swap in 3 of these SingleRelay Boards (go ahead and order 3 if you are playing along at home) But its all good

Refactoring is part of the process of high tech start-up prototyping right

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 7)

By hinkmond on Jun 20 2014

So youve got your Parallax Single

Relay Board Next you need to connect

this to your furnace fan and AC

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 2: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 211

So lets get started in building your

own $32 billion (with a b) Nest

Startup using a Raspberry Pi some

hobby electronic parts and Java SEEmbedded Technology The journey of

a $32 billion startup begins with a

single step-down transformer er or

something like that

First well need a crash course in home thermostat technology Here in the US if you firstflip off the circuit breaker to your home heating furnace and AC then take off the thermostat

panel in your house you should see these standardized labeled wires (with various colors ofwires that are not standardized)

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool callBlue or Black - C - Common

If you see a wire labeled C (Common) and the rest of the labeled wires (above) then youare OK If you do not see the C label on a wire you must ask an electrician friend or hirean electrical contractor to run the common C wire from a furnace relay to your thermostatOtherwise if you do not have the C wire at your thermostat stop here since the C wire isneeded to power the Raspberry Pi and especially for the Wi-Fi adapter to have enough powerto 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 forthe first step which is to connect the Bridge Rectifier GBU608 and the DC to DC step-downtransformer 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 24VACof your furnace relay from 24 volts of AC power to 33 volts DC power and the step-downtransformer 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 thats done Its a fun step since its your firstone

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 3)

By hinkmond on Feb 03 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 311

If you are this far along it means you do have a Cwire at your thermostat Yay That means you canconnect the Bridge Rectifier GBU608 and the DC toDC step-down transformer from your thermostat wiresto power your Raspberry Pi from the 24VAC of your

thermostat wiring We are using the C wire and eitherthe (Rh or Rc wire) or the R wire to power the RPisince one of the R wires is considered in AC termshot and the C wire is considered neutral

NOTE You need a hot wire and a neutral wire inAC household electrical circuits to complete or closean AC circuit With most US household thermostatswe are working with a lower 24VAC standard and not your typical 110VAC found in UShomes If your thermostat happens to be a higher voltage 110VAC thermostat stop here anddo 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 anelectrician 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 5volts DC for the Raspberry Pi (and all its peripherals)

As with any $32 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 Inthis 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 Step-Down Transformer and do the same with your unnotched edge pin of your GBU608which is the negative connector and solder that to the negative IN pad on your DCto DC Voltage Step-Down Transformer

3

Solder two separate wires to the positive and negative OUT pads of your DC to DCVoltage Step-Down transformer

4

Connect the two inner pins (marked with the ~ symbol) of your GBU608 BridgeRectifier to your thermostat wires as described in Step 1 one inner pin connects tothe C wire of your thermostat and the other inner pin connects to one of the Rwires (or better yet for workbench development purposes connect them to atemporary 24VAC power supply like this one to represent the thermostat power asyou develop on your bench first)

5 Use a voltmeter to measure the OUT pads of your DC to DC Voltage Step-Downtransformer 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 yourRaspberry Pi in the next step Fun

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 411

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 4)

By hinkmond on Feb 19 2014

So youve now added your Bridge Rectifier and

Transformer to your $32bln Nest Startup

prototype You just need to connect to power

up your Raspberry Pi

This next step is pretty straight-forward To make life easyyou 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 fordetails 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 Thats it

Plug in one end of a standard micro USB cable to your USB A Jack and the other end toyour Raspberry Pi Then connect your 24VAC power from your house thermostat wiring to

your breadboard Bridge Rectifier as mentioned in Part 3Step 4 and turn your circuit breaker back on or use a temporary power source on your workbench as described in the later sectionof Part 3Step 4 to test it

If you reach this point and you havent fried your Raspberry Pi then thats a very good thingIf you accidentally see white smoke coming out of your Raspberry Pi board shout out yourfavorite expletive and quickly unplug everything But dont worry just go back to Part 1 and

buy another one Heck theyre just $35 each Buy 2 or 3 more just in case Wouldnthurt

When you reach this point and your RPi powers up correctly with very little or no swearingdo a little dance and get ready for the next step in building your own $32bln Nest Startupwhich is where you connect up the LCD touchscreen

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 5)

By hinkmond on Mar 14 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 511

We now have power

to your Raspberry Pi

Next we need to hook

up the cool LCDTouchscreen from

adafruitcom so that

your Java SE

Embedded thermostat

app will have a UI

Lady Ada has some

rockin cool gear foryour Raspberry Pi at

her Web site

See the cool video demo ofthe 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

adafruitcom

First do the assembly TFT touchscreen assembly

Next do the software installation TFT touchscreen software

Thats it for this part You can also check out the other steps at the adafruitcom Web site forscreen calibration and other optional set-up steps But with the above minimal steps you nowhave a working touchscreen

Next up we will connect the PiFace for the relays needed to turn on and off your furnace andAC via a Java SE Embedded app Thats when the stuff gets real Or sparks fly One orthe other

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 611

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 AC of a home heating and

cooling system (just like the Nest thermostat)

So its time to show how to do a time-honored tradition in high tech start-up prototypingRefactoring

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 AC Andmost importantly this Single Relay Board can take a 33 VDC signal from a microcontrolleror 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 (33VDC) from the Raspberry Pi

header pins from a Java SE Embedded app will control the relays Cool

So Ive got a bit of refactoring to do of my previous blog posts to swap in 3 of these SingleRelay Boards (go ahead and order 3 if you are playing along at home) But its all good

Refactoring is part of the process of high tech start-up prototyping right

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 7)

By hinkmond on Jun 20 2014

So youve got your Parallax Single

Relay Board Next you need to connect

this to your furnace fan and AC

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 3: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 311

If you are this far along it means you do have a Cwire at your thermostat Yay That means you canconnect the Bridge Rectifier GBU608 and the DC toDC step-down transformer from your thermostat wiresto power your Raspberry Pi from the 24VAC of your

thermostat wiring We are using the C wire and eitherthe (Rh or Rc wire) or the R wire to power the RPisince one of the R wires is considered in AC termshot and the C wire is considered neutral

NOTE You need a hot wire and a neutral wire inAC household electrical circuits to complete or closean AC circuit With most US household thermostatswe are working with a lower 24VAC standard and not your typical 110VAC found in UShomes If your thermostat happens to be a higher voltage 110VAC thermostat stop here anddo 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 anelectrician 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 5volts DC for the Raspberry Pi (and all its peripherals)

As with any $32 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 Inthis 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 Step-Down Transformer and do the same with your unnotched edge pin of your GBU608which is the negative connector and solder that to the negative IN pad on your DCto DC Voltage Step-Down Transformer

3

Solder two separate wires to the positive and negative OUT pads of your DC to DCVoltage Step-Down transformer

4

Connect the two inner pins (marked with the ~ symbol) of your GBU608 BridgeRectifier to your thermostat wires as described in Step 1 one inner pin connects tothe C wire of your thermostat and the other inner pin connects to one of the Rwires (or better yet for workbench development purposes connect them to atemporary 24VAC power supply like this one to represent the thermostat power asyou develop on your bench first)

5 Use a voltmeter to measure the OUT pads of your DC to DC Voltage Step-Downtransformer 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 yourRaspberry Pi in the next step Fun

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 411

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 4)

By hinkmond on Feb 19 2014

So youve now added your Bridge Rectifier and

Transformer to your $32bln Nest Startup

prototype You just need to connect to power

up your Raspberry Pi

This next step is pretty straight-forward To make life easyyou 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 fordetails 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 Thats it

Plug in one end of a standard micro USB cable to your USB A Jack and the other end toyour Raspberry Pi Then connect your 24VAC power from your house thermostat wiring to

your breadboard Bridge Rectifier as mentioned in Part 3Step 4 and turn your circuit breaker back on or use a temporary power source on your workbench as described in the later sectionof Part 3Step 4 to test it

If you reach this point and you havent fried your Raspberry Pi then thats a very good thingIf you accidentally see white smoke coming out of your Raspberry Pi board shout out yourfavorite expletive and quickly unplug everything But dont worry just go back to Part 1 and

buy another one Heck theyre just $35 each Buy 2 or 3 more just in case Wouldnthurt

When you reach this point and your RPi powers up correctly with very little or no swearingdo a little dance and get ready for the next step in building your own $32bln Nest Startupwhich is where you connect up the LCD touchscreen

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 5)

By hinkmond on Mar 14 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 511

We now have power

to your Raspberry Pi

Next we need to hook

up the cool LCDTouchscreen from

adafruitcom so that

your Java SE

Embedded thermostat

app will have a UI

Lady Ada has some

rockin cool gear foryour Raspberry Pi at

her Web site

See the cool video demo ofthe 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

adafruitcom

First do the assembly TFT touchscreen assembly

Next do the software installation TFT touchscreen software

Thats it for this part You can also check out the other steps at the adafruitcom Web site forscreen calibration and other optional set-up steps But with the above minimal steps you nowhave a working touchscreen

Next up we will connect the PiFace for the relays needed to turn on and off your furnace andAC via a Java SE Embedded app Thats when the stuff gets real Or sparks fly One orthe other

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 611

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 AC of a home heating and

cooling system (just like the Nest thermostat)

So its time to show how to do a time-honored tradition in high tech start-up prototypingRefactoring

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 AC Andmost importantly this Single Relay Board can take a 33 VDC signal from a microcontrolleror 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 (33VDC) from the Raspberry Pi

header pins from a Java SE Embedded app will control the relays Cool

So Ive got a bit of refactoring to do of my previous blog posts to swap in 3 of these SingleRelay Boards (go ahead and order 3 if you are playing along at home) But its all good

Refactoring is part of the process of high tech start-up prototyping right

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 7)

By hinkmond on Jun 20 2014

So youve got your Parallax Single

Relay Board Next you need to connect

this to your furnace fan and AC

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 4: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 411

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 4)

By hinkmond on Feb 19 2014

So youve now added your Bridge Rectifier and

Transformer to your $32bln Nest Startup

prototype You just need to connect to power

up your Raspberry Pi

This next step is pretty straight-forward To make life easyyou 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 fordetails 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 Thats it

Plug in one end of a standard micro USB cable to your USB A Jack and the other end toyour Raspberry Pi Then connect your 24VAC power from your house thermostat wiring to

your breadboard Bridge Rectifier as mentioned in Part 3Step 4 and turn your circuit breaker back on or use a temporary power source on your workbench as described in the later sectionof Part 3Step 4 to test it

If you reach this point and you havent fried your Raspberry Pi then thats a very good thingIf you accidentally see white smoke coming out of your Raspberry Pi board shout out yourfavorite expletive and quickly unplug everything But dont worry just go back to Part 1 and

buy another one Heck theyre just $35 each Buy 2 or 3 more just in case Wouldnthurt

When you reach this point and your RPi powers up correctly with very little or no swearingdo a little dance and get ready for the next step in building your own $32bln Nest Startupwhich is where you connect up the LCD touchscreen

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 5)

By hinkmond on Mar 14 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 511

We now have power

to your Raspberry Pi

Next we need to hook

up the cool LCDTouchscreen from

adafruitcom so that

your Java SE

Embedded thermostat

app will have a UI

Lady Ada has some

rockin cool gear foryour Raspberry Pi at

her Web site

See the cool video demo ofthe 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

adafruitcom

First do the assembly TFT touchscreen assembly

Next do the software installation TFT touchscreen software

Thats it for this part You can also check out the other steps at the adafruitcom Web site forscreen calibration and other optional set-up steps But with the above minimal steps you nowhave a working touchscreen

Next up we will connect the PiFace for the relays needed to turn on and off your furnace andAC via a Java SE Embedded app Thats when the stuff gets real Or sparks fly One orthe other

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 611

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 AC of a home heating and

cooling system (just like the Nest thermostat)

So its time to show how to do a time-honored tradition in high tech start-up prototypingRefactoring

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 AC Andmost importantly this Single Relay Board can take a 33 VDC signal from a microcontrolleror 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 (33VDC) from the Raspberry Pi

header pins from a Java SE Embedded app will control the relays Cool

So Ive got a bit of refactoring to do of my previous blog posts to swap in 3 of these SingleRelay Boards (go ahead and order 3 if you are playing along at home) But its all good

Refactoring is part of the process of high tech start-up prototyping right

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 7)

By hinkmond on Jun 20 2014

So youve got your Parallax Single

Relay Board Next you need to connect

this to your furnace fan and AC

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 5: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 511

We now have power

to your Raspberry Pi

Next we need to hook

up the cool LCDTouchscreen from

adafruitcom so that

your Java SE

Embedded thermostat

app will have a UI

Lady Ada has some

rockin cool gear foryour Raspberry Pi at

her Web site

See the cool video demo ofthe 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

adafruitcom

First do the assembly TFT touchscreen assembly

Next do the software installation TFT touchscreen software

Thats it for this part You can also check out the other steps at the adafruitcom Web site forscreen calibration and other optional set-up steps But with the above minimal steps you nowhave a working touchscreen

Next up we will connect the PiFace for the relays needed to turn on and off your furnace andAC via a Java SE Embedded app Thats when the stuff gets real Or sparks fly One orthe other

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 611

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 AC of a home heating and

cooling system (just like the Nest thermostat)

So its time to show how to do a time-honored tradition in high tech start-up prototypingRefactoring

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 AC Andmost importantly this Single Relay Board can take a 33 VDC signal from a microcontrolleror 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 (33VDC) from the Raspberry Pi

header pins from a Java SE Embedded app will control the relays Cool

So Ive got a bit of refactoring to do of my previous blog posts to swap in 3 of these SingleRelay Boards (go ahead and order 3 if you are playing along at home) But its all good

Refactoring is part of the process of high tech start-up prototyping right

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 7)

By hinkmond on Jun 20 2014

So youve got your Parallax Single

Relay Board Next you need to connect

this to your furnace fan and AC

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 6: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 611

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 AC of a home heating and

cooling system (just like the Nest thermostat)

So its time to show how to do a time-honored tradition in high tech start-up prototypingRefactoring

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 AC Andmost importantly this Single Relay Board can take a 33 VDC signal from a microcontrolleror 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 (33VDC) from the Raspberry Pi

header pins from a Java SE Embedded app will control the relays Cool

So Ive got a bit of refactoring to do of my previous blog posts to swap in 3 of these SingleRelay Boards (go ahead and order 3 if you are playing along at home) But its all good

Refactoring is part of the process of high tech start-up prototyping right

How to Build Your Own $32bln Nest Startup Using Java SE Embedded Tech

(Part 7)

By hinkmond on Jun 20 2014

So youve got your Parallax Single

Relay Board Next you need to connect

this to your furnace fan and AC

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

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 7: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 711

wires for the Fan Heat call and Cool call Heres a reminder which wire is which

Red - R - 24VACor

Red - Rh - 24VAC (dedicated to heat call)Red - Rc - 24VAC (dedicated to cooling call)

Green - G - Fan onWhite - W - Heat callYellow - Y - Cool call

Blue or Black - C - Common

You will need 3 Relay Boards connecting to theRaspberry Pi to control the 3 house thermostat controlwires (Green for Fan White for Heat and Yellow forCool) First make sure on your Adafruit PiTFT has the2x13 male header properly soldered on to it to daisy

chain your RPi header pins (to allow your Relay Boardsto connect down to the RPi) This way your AdafruitPiTFT can use the SPI pins (SCK MOSI MISO CE0CE1) plus GPIO 24 and 25 for its use while we useGPIO 00 01 and 04 for the Relay Boards Its niceto 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 theRelay Boards Then connect the - to the GND pin (male header pin 6) using a continuousumper 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 (pin7)

Then connect all 3 Relay Boards Common screw down connector to the C - Common wire ofyour thermostat Connect one Relay Board Normal Open (NO) screw down connector to theGreen Fan wire one NO screw down connector to the White Heat wire and the final NOscrew 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 $32bln Nest Startup Using Java SE Embedded Tech

(Part 8)

By hinkmond on Jul 23 2014

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 8: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 811

Now your Parallax Single Relay Board

from your Raspberry Pi is connected to

your furnace fan and AC control

wires Lets just stop right there andsoak that in

Your Raspberry Pi is now the hardwareequivalent to a Nest Thermostat Nice work so far You just need intelligent software to runthe Raspberry Pi to control your home heating and AC And of course you dont want to useust 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 youre going to need Java SE EmbeddedTechnology

Heres the simple Java code that will drive your relays to turn on your furnace fan and ACIts a test app that cycles your heat on for 5 minutes then your fan on for 5 minutes then yourAC 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 controlsFileWriter unexportFile =

new FileWriter(sysclassgpiounexport)FileWriter exportFile =

new FileWriter(sysclassgpioexport)

for (String gpioChannel GpioChannels)

Systemoutprintln(gpioChannel)

Reset the portFile exportFileCheck = new File(sysclassgpiogpio+

gpioChannel)if (exportFileCheckexists())

unexportFilewrite(gpioChannel)unexportFileflush()

Set the port for useexportFilewrite(gpioChannel)exportFileflush()

Open file handle to port inputoutput control

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 9: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 911

FileWriter directionFile =new FileWriter(sysclassgpiogpio + gpioChannel +

direction)

Set port for outputdirectionFilewrite(GPIO_OUT)

directionFileflush()

Set up a GPIO ports as a command channelsFileWriter heatChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[0] + value)

FileWriter fanChannel = newFileWriter(sysclassgpiogpio +

GpioChannels[1] + value)FileWriter acChannel = new

FileWriter(sysclassgpiogpio +GpioChannels[2] + value)

TEST Cycle all 5 min on 2 min off HIGH Set GPIO port ONheatChannelwrite(GPIO_ON)heatChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFheatChannelwrite(GPIO_OFF)heatChannelflush()

javalangThreadsleep(120000)

HIGH Set GPIO port ONfanChannelwrite(GPIO_ON)fanChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFfanChannelwrite(GPIO_OFF)fanChannelflush()javalangThreadsleep(120000)

HIGH Set GPIO port ON

acChannelwrite(GPIO_ON)acChannelflush()javalangThreadsleep(300000)

LOW Set GPIO port OFFacChannelwrite(GPIO_OFF)acChannelflush()javalangThreadsleep(120000)

catch (Exception exception)

exceptionprintStackTrace()

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 10: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1011

Pretty straight-forward stuff Its easy when you use Java SE Embedded technology and a

Raspberry Pi Hey someone should trademark that

How to Build Your Own $32bln 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

$32bln Nest Startup

Using Java SE Embedded

Technology Youve

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 AC 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 its up to you to create your user interface and control software Remember to utilizethe Web since you are connected via Wi-Fi to your home wireless network Just make sure touse the proper HTTPS connection to any server and check for proper authorization for everyconnection Using certificate based authentication is best but thats a topic thats outside thescope of this series

For the UI just make sure Jetty is installed on your RPi Jetty is a Java SE Embedded basedWeb server to run your UI on your local LCD touchscreen

sudo apt-get install jetty(cd usrsharejetty sudo java -jar startjar)

Now when you boot up your Raspberry Pi just configure your boot-up to bring up theMidori Web browser on the Ada Fruit TFT LCD screen pointing to your local Jetty Webserver and your UI page to your software

See httpwwwediycommyindexphpblogitem102-raspberry-pi-running-midori-

browser-without-a-desktop

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup

Page 11: How to Build Your Own Embedded Project

8102019 How to Build Your Own Embedded Project

httpslidepdfcomreaderfullhow-to-build-your-own-embedded-project 1111

That should get you started on your way to building your own home thermostat control basedon Java SE Embedded technology Not too shabby

Good luck on finishing out your project Hope this was useful in getting you on your way tocreating your own Nest startup