Candies for everybody: Hacking from 9 to 6

90
@YourTwitterHandle #Voxxed Candies for everybody: hacking from 9 to 6 Alberto López Braintree_Dev.

Transcript of Candies for everybody: Hacking from 9 to 6

Page 1: Candies for everybody: Hacking from 9 to 6

@YourTwitterHandle#Voxxed

Candies for everybody: hacking from 9 to 6

Alberto López Braintree_Dev.

Page 2: Candies for everybody: Hacking from 9 to 6

Candies for everybody: hacking from 9 to 6

Alberto López Braintree_Dev.

<Advocate/>

https://flic.kr/p/6kFQBc

Page 3: Candies for everybody: Hacking from 9 to 6

#Voxxed

@Braintree_Dev

@AlbertusLM

Page 4: Candies for everybody: Hacking from 9 to 6

>who am I?_

Page 5: Candies for everybody: Hacking from 9 to 6

@PayPalDev @AlbertusLM@AlbertusLM@Braintree_Dev#Voxxed

Page 6: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 7: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

2015.battlehack.org

Page 8: Candies for everybody: Hacking from 9 to 6

My Office

@AlbertusLM@Braintree_Dev#Voxxed

Page 9: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

I <3 hacking from 9 to 6

Page 10: Candies for everybody: Hacking from 9 to 6

>how is our world?_

Page 11: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our breakfast

Page 12: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our plants

Page 13: Candies for everybody: Hacking from 9 to 6

deportes

@AlbertusLM@Braintree_Dev#Voxxed

Our sports

Page 14: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our watches

Page 15: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our cars

Page 16: Candies for everybody: Hacking from 9 to 6

>how could be our real world?_

Page 17: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our breakfast

Page 18: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our plants

Page 19: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our sports

Page 20: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our watches

Page 21: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Our cars

Page 22: Candies for everybody: Hacking from 9 to 6

welcome…

Page 23: Candies for everybody: Hacking from 9 to 6

to the present!

Page 24: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 25: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

"In the next century, planet earth will don an electronic skin."

Neil Gross, 1999

Page 26: Candies for everybody: Hacking from 9 to 6

>levers of innovation_

Page 27: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

technology

Page 28: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

new business models

Page 29: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

meet new needs

Page 30: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

DIY trend

Page 31: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

new ways to learn

Page 32: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

movement to open source

Page 33: Candies for everybody: Hacking from 9 to 6

>internet of things_everything

Page 34: Candies for everybody: Hacking from 9 to 6

Disney Effect

Page 35: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 36: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 37: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 38: Candies for everybody: Hacking from 9 to 6

>Introducing: The Hype Cicle_gartner.com/newsroom/id/2819918 (2014)

Page 39: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 40: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 41: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 42: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 43: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

4.9 Billion Connected "Things" by 2015

http://www.gartner.com/newsroom/id/2905717

Gartner Symposium/ITxpo 2014, November 9-13 in Barcelona, Spain

Page 44: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

25 Billion Connected “Things" by 2020

http://www.gartner.com/newsroom/id/2905717

Gartner Symposium/ITxpo 2014, November 9-13 in Barcelona, Spain

Page 45: Candies for everybody: Hacking from 9 to 6

different point of views

Different points of view

Page 46: Candies for everybody: Hacking from 9 to 6
Page 47: Candies for everybody: Hacking from 9 to 6

>popular IoT devices

Page 48: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Raspberry Pi

Page 49: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Arduino Yún

Page 50: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Intel Galileo

Page 51: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Spark Core

Page 52: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Weareable devices

Flora Wearable Electronic Platform

Gemma Tiny Sewable Microcontroller

Page 53: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

I <3 them

Page 54: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

I <3 hacking from 9 to 6

Page 55: Candies for everybody: Hacking from 9 to 6

>and what about BT_Dev Team?_

Page 56: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

best way to learn is teach

Page 57: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

try, fail, success

Page 58: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

amazing projects

Page 59: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

everything handy to everyone

Page 60: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

We <3 hack from 9 to 6

Page 61: Candies for everybody: Hacking from 9 to 6

>study case: Candy Machine_

Page 62: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

common candy machine

digital sensor

4 bateries AA

low level core

Page 63: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

The Candy Machine 2.0

tft screen

4 bateries AA & USB cable

spark core

connected to the Internet

Page 64: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

target

learn about Internet of Things

learn how Spark core works

refresh C&C++

learn python & django

integrate v.zero SDK

demo online & offline

Page 65: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

features

Internet connected

shows on the screen the tweet name

shows on the screen the transaction id

delivers candies after payment on a

website

mobilized website: candymachine.ngrok.com

Page 66: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

hardware

generic candy machine (r.ebay.com/CBVghK)

spark core (spark.io)

2.2” TFT with SD (goo.gl/lDS3FH)

CC motor 5V (goo.gl/zLjKL4)

generic SD 1GB

Page 67: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Braintree v.zero SDK

<frontend> <backend>

Page 68: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

server

django v.1.7.1 (djangoproject.com)

ngrok (ngrok.com)

braintree v.zero SDK (developers.braintreepayments.com)

tweetpony API (pypi.python.org/pypi/TweetPony)

spyrk API (pypi.python.org/pypi/spyrk)

Page 69: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

spark core

ILI9341 for Spark (github.com/pkourany/ILI9341_SPI_LCD)

SD library for Spark (github.com/technobly/SparkCore-SD)

Page 70: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

Page 71: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

github.com/albertuslm/CandyMachine

Page 72: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

1. home

nothing interesting to show.

it’s only a template!

< server />

Page 73: Candies for everybody: Hacking from 9 to 6

[…] <script src=“https://js.braintreegateway.com/v2/braintree.js"> </script> </head> <body> […] <form id="paymentForm" action="/checkout" method="post"> <div class="content"> <label for="twitterName">Twitter Alias (optional)</label> <input type="text" id="twitter" name="twitter"> </div> <div id="container"> </div> <input type="submit" value="Pay $1 USD"> </form> […] <script> braintree.setup("{{client_token}}","dropin",{ container:"container" }) </script> </body>

@AlbertusLM@Braintree_Dev#Voxxed

2. payment page

< server : frontend />

Calling to Braintree to create v.zero form

Page 74: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

< server : backend />

2. payment page

import braintree

[…]

braintree.Configuration.configure( braintree.Environment.Sandbox, merchant_id=“<BT merchant id>", public_key="<BT public key>", private_key="<BT private key>" )

[…]

def payment(request):

client_token=braintree.ClientToken.generate({})

return render_to_response("payment.html",locals())

Asking for client token to create v.zero form

Page 75: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

3. checkout page[…] braintree.Configuration.configure([…])

spark = SparkCloud(USERNAME, PASSWORD)

[…]

def checkout(request): nonce=request.POST.get("payment_method_nonce")

result=braintree.Transaction.sale({ "amount":"1.00", "payment_method_nonce":nonce })

transaction_id=result.transaction.id

[…] spark.albertusLM_core.twitter(twitterName)

api = tweetpony.API() api.update_status(text)

[…]

spark.albertusLM_core.candy(transaction_id)

< server : backend />

finishing the transaction

sending info to spark

Page 76: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

< server : frontend />

3. checkout page

<body>

[…]

<h3>Payment Completed</h3>

<p><b>Transaction ID:</b>{{transaction_id}}</p>

[…]

</body>

Page 77: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

1. setup

< spark core />

#define SD_CS A6 #define TFT_CS A2 #define TFT_RST A0 #define TFT_DC A1 #define MOTOR D0 #define BUFFPIXEL 20

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

void setup() […] tft.begin();

testFillScreen(); SD.begin(SD_CS);

pinMode(MOTOR, OUTPUT);

setScreenToStandBy();

Spark.function("twitter", tftShowTwitter);

Spark.function("candy", moveMotorCandy);

Page 78: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

2. show Twitter image

< spark core />

int tftShowTwitter(String command) { //Adjustment to present correctly the text on the screen String textToPrint = " Sending tweet to \n" " "+ command;

//Printing the Twitter screen bmpDraw("twitter.bmp", 0, 0); showTextInScreen(textToPrint,10,140); delay(4000); }

Sending  tweet  to  albertusLM

Page 79: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

3. move motor and show transaction

< spark core />

int moveMotorCandy(String command) { //Adjustment to present correctly the text on the screen String textToPrint = " Enjoy! \n" " Tr.ID: "+ command;

//Printing the MotorMovement screen bmpDraw("motor.bmp", 0, 0); showTextInScreen (textToPrint,10,160); delay(1000);

digitalWrite(MOTOR, 1); // Turn ON the motor delay(milisecsMovingMotor); digitalWrite(MOTOR, 0); // Turn OFF the motor

delay(3000); setScreenToStandBy(); }

Enjoy!  Tr.ID:  dfr43

Page 80: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

dem

Page 81: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

dem

connect to candymachine.ngrok.com

follow the instructions to write the CC

enjoy your candies!

Page 82: Candies for everybody: Hacking from 9 to 6

backup plan:

video J

@AlbertusLM@Braintree_Dev#Voxxed

Page 83: Candies for everybody: Hacking from 9 to 6

>conclussions_

Page 84: Candies for everybody: Hacking from 9 to 6
Page 85: Candies for everybody: Hacking from 9 to 6

internet of things tendencia

Year of Internet of Things

Page 86: Candies for everybody: Hacking from 9 to 6
Page 87: Candies for everybody: Hacking from 9 to 6

goo.gl/ixjlaa

Page 88: Candies for everybody: Hacking from 9 to 6

@AlbertusLM@Braintree_Dev#Voxxed

u <3 hack?

Page 90: Candies for everybody: Hacking from 9 to 6

Alberto López [email protected]

@AlbertusLM / @Braintree_Dev