Top Banner
Connecting Hardware to ColdFusion Justin Mclean Twitter @justinmclean http://www.classsoftware.com 1
47

Connecting hardware up to ColdFusion

Jan 28, 2015

Download

Technology

Justin Mclean

This session will look at the revolution in low cost easy to program embedded computing. It focuses on the Arduino open source hardware and software platform and how this can be connected to and communicate with ColdFusion. Topics covered include how to implement the Firmata protocol in ColdFusion, using Arduino Ethernet shields and unsing Pachube.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Connecting hardware up to ColdFusion

Connecting Hardware to ColdFusion• Justin Mclean• Twitter @justinmclean• http://www.classsoftware.com

1

Page 2: Connecting hardware up to ColdFusion

Who am I?

• Director of Class Software for 10 years• Developing and creating web applications

for 15 years• Programming for 25 years• Adobe solution partner• Adobe certified developer and trainer in

Flex and ColdFusion• Based in Sydney Australia

2

Page 3: Connecting hardware up to ColdFusion

Electronics Trends

• Low cost components• Small components• Complex components with simple

standard interfaces

3

Page 4: Connecting hardware up to ColdFusion

Computing Trends

• Easier to program• Use of high level languages• Software tools• Open source

4

Page 5: Connecting hardware up to ColdFusion

Are We There Yet?

• Low cost fast devices• It’s easy to communicate between devices

and computers• Can build complex systems from off the

shelf components

5

Page 6: Connecting hardware up to ColdFusion

Arduino

• Overview of the Arduino Platform

6

Page 7: Connecting hardware up to ColdFusion

Arduino Platform

• Open source hardware and software platform

• Easy to program• Hardware is flexible, fast, low power and

low cost

7

Page 8: Connecting hardware up to ColdFusion

Arduino Hardware

• Comes in a number of shapes sizes• Low cost• Easy to extend

8

Page 9: Connecting hardware up to ColdFusion

Arduino Boards

9

Page 10: Connecting hardware up to ColdFusion

Arduino Shields

10

Page 11: Connecting hardware up to ColdFusion

Arduino Software Platform

• Open source cross platform IDE• Alpha but very stable• Updated frequently• Growing and active community

11

Page 12: Connecting hardware up to ColdFusion

Arduino Code

• C like high level language• Inbuilt functions to read and set digital and

analog inputs and outputs• Includes libraries to perform common

hardware or software tasks

12

Page 13: Connecting hardware up to ColdFusion

Arduino IDE

13

Page 14: Connecting hardware up to ColdFusion

Led Shield Demo

14

Page 15: Connecting hardware up to ColdFusion

Issues

• Debugging can be hard• No simulator• Memory, power and speed limits • Need a little electronics knowledge

15

Page 16: Connecting hardware up to ColdFusion

Connecting ColdFusion

• How to communicate between ColdFusion and Arduino

16

Page 17: Connecting hardware up to ColdFusion

ColdFusion Communication

• ColdFusion can’t easily talk USB• Use a socket to USB proxy• ColdFusion can’t easily talk raw sockets

17

Page 18: Connecting hardware up to ColdFusion

Layers of Communication

• ColdFusion to proxy via Java/CFML code• Proxy to USB communication• USB to arduino

Page 19: Connecting hardware up to ColdFusion

Connection Diagram

USB Proxy FirmataLibrary

Application Code Arduino

USBCable

TCP/IPSocket

Computer Arduino

Function Calls and Events

Code

Page 20: Connecting hardware up to ColdFusion

Firmata Protocal

• Simple Binary Protocol• Based on MIDI• Easy to extend• Standard Arduino software library• No ColdFusion library exists yet

20

Page 21: Connecting hardware up to ColdFusion

Firmata Protocal

21

Type Command MIDI Byte #1 Btye #2

Analog 0xE0 pin Bits 0-6 Bits 7-13

Digital 0x90 port Bits 0-6 Bits 7-13

Report Analog 0xC0 pin 0 or 1

Report Digital 0xD0 port 0 or 1

Pin Mode 0xF4 port 0 or 1

Version 0xF9

Reset 0xFF

Page 22: Connecting hardware up to ColdFusion

ColdFusion Socket Component

• Mixed Java/CFML code• ColdFusion 8 or 9 makes it easy

22

Page 23: Connecting hardware up to ColdFusion

ColdFusion Arduino Component

• Alpha software• ColdFusion implementation of Firmata• Read analog values• Read/write digital values

23

Page 24: Connecting hardware up to ColdFusion

ColdFusion Arduino Demo

24

Page 25: Connecting hardware up to ColdFusion

Issues

• Arduino startup time• Auto reset• Not a persistent connect• Proxy must be running on machine

Arduino is connected to• Use under load

25

Page 26: Connecting hardware up to ColdFusion

Ethernet

• Using Arduino Ethernet Shields

26

Page 27: Connecting hardware up to ColdFusion

Ethernet Shields

• Allow direct internet connection• No dedicated PC needed• Most need a little config• Can act as web server or client

27

Page 28: Connecting hardware up to ColdFusion

Ethernet Shields

28

Page 29: Connecting hardware up to ColdFusion

Ethernet Arduino Code

• Web server code• Easy to modify

29

Page 30: Connecting hardware up to ColdFusion

ColdFusion Code

• CFHTTP to get data• Data returned as XML• Parse XML via ParseXML()• Display or act on values

30

Page 31: Connecting hardware up to ColdFusion

ColdFusion Ethernet Demo

31

Page 32: Connecting hardware up to ColdFusion

Pachube

• An easier way to connect Arduinos

32

Page 33: Connecting hardware up to ColdFusion

Pachube

• Store and share and access realtime sensor data

• Simple and secure• API to interact with all data and services• Graphs and maps

33

Page 34: Connecting hardware up to ColdFusion

Pachube

34

Page 35: Connecting hardware up to ColdFusion

Pachube API

• Communicates HTTP • Plain text (csv), XML or Jason• REST based• Large base of supported languages

35

Page 36: Connecting hardware up to ColdFusion

Pachube Arduino Code

• Runs on Arduino with ethernet shield• Sends values to Pachube• Can request values directly or via

Pachube

36

Page 37: Connecting hardware up to ColdFusion

ColdFusion

• Call pachube API using CFHTTP• ParseXML()• XML is in EEML format• Display or act on values

37

Page 38: Connecting hardware up to ColdFusion

Demo

38

Page 39: Connecting hardware up to ColdFusion

Pachube Triggers

• Pachube can call an URL when an analog or digital value changes or goes over or under a value

• The URL can be a ColdFusion one

39

Page 40: Connecting hardware up to ColdFusion

Why do this?

• Expose yourself to new ideas and new ways of solving problems

• Involves interaction with the real world• Encourages creativity• Makes you a better programmer

40

Page 41: Connecting hardware up to ColdFusion

It’s Fun!

41

Page 42: Connecting hardware up to ColdFusion

Questions?

• Ask now, see me after the session or email me at [email protected]

42

Page 43: Connecting hardware up to ColdFusion

Questions?

• Ask now, see me after session or email [email protected]

43

Page 44: Connecting hardware up to ColdFusion

Useful Sites

• List of useful hardware and software sites

44

Page 45: Connecting hardware up to ColdFusion

Software Sites

• Arduino http://www.arduino.cc for software, user forum and playground

• Ethernet Shields http://arduino.cc/en/Reference/Ethernet

• Pachhub http://www.pachube.com/

45

Page 46: Connecting hardware up to ColdFusion

Hardware Sites

• Little Bird Electronics (AUS) http://www.littlebirdelectronics.com/

• Spark Fun (US) http://www.sparcfun.com/• Adafruit Industries (US) http://

www.adafruit.com/• Electronic Goldmine (US) http://

www.goldmine-elec.com/

46

Page 47: Connecting hardware up to ColdFusion

Other Sites

• Lady Ada http://www.ladyada.com/• Evil Mad Scientist http://

www.evilmadscientist.com/• NY Resistor http://www.nycresistor.com/• Make Zine http://www.makezine.com/

47