Turn your mobile phone into an IoT device

Daniel Béguelin recently posted a great developerWorks tutorial and video on getting started with IoT using just your phone.

Here in Africa, IoT devices are hard to obtain (and expensive) so these kinds of tutorials are vital when teaching IoT principles as Android smart phones are abundant (most Kenyans carry two!)

Readers of this blog (both of you ;-)) may recall I posted a similar tutorial myself earlier this year.

Here’s an update to the code snippet currently posted on the tutorial to address a formatting issue that will be fixed soon (and by the time you read this might be fixed already):

[{“id”:”215c6601.12d32a”,”type”:”ibmiot in”,”authentication”:”boundService”,”apiKey”:””,”inputType”:”evt”,”deviceId”:””,”applicationId”:””,”deviceType”:””,”eventType”:”accel”,”commandType”:””,”format”:”json”,”name”:”IBM IoT App In”,”service”:”registered”,”allDevices”:true,”allApplications”:””,”allDeviceTypes”:true,”allEvents”:””,”allCommands”:””,”allFormats”:””,”x”:264.1999969482422,”y”:434.1999969482422,”z”:”dc6a0ca6.7993b”,”wires”:[[“ce21edbb.320628″,”fdfdaaa2.a45678”]]},{“id”:”ce21edbb.320628″,”type”:”function”,”name”:”calc color”,”func”:”var accelZ = msg.payload.d.acceleration_z;\nvar r = 0.0;\nvar b = 0.0;\nvar g = 0.0;\nif (accelZ > 0) {\n\tg = Math.round(accelZ * 25);\n} else if (accelZ < 0) {\n\tr = 255.0;\n} else {\n\tr = 104;\n\tg = 109;\n\tb = 115;\n}\na = 1.0;\n\nmsg.eventOrCommandType = \”color\”;\nmsg.payload = JSON.stringify({\”d\”:{\”r\”:r,\”b\”:b,\”g\”:g,\”alpha\”:a}});\n\nreturn msg;”,”outputs”:1,”noerr”:0,”x”:437.1999969482422,”y”:430.1999969482422,”z”:”dc6a0ca6.7993b”,”wires”:[[“9df37edb.5d4588”]]},{“id”:”9df37edb.5d4588″,”type”:”ibmiot out”,”authentication”:”boundService”,”apiKey”:””,”outputType”:”cmd”,”deviceId”:”112233445566″,”deviceType”:”Android”,”eventCommandType”:”text”,”format”:”json”,”data”:”{\”d\”:{\”value\”:\”text\”}}”,”name”:”IBM IoT App Out”,”service”:”registered”,”x”:629.1999969482422,”y”:443.1999969482422,”z”:”dc6a0ca6.7993b”,”wires”:[]},{“id”:”fdfdaaa2.a45678″,”type”:”debug”,”name”:””,”active”:false,”console”:”false”,”complete”:”false”,”x”:442.1999969482422,”y”:364.1999969482422,”z”:”dc6a0ca6.7993b”,”wires”:[]}]

Also, my device wsn’t running Android 501, so I needed to recompile the apk code for Android 4x devices.

To save you the trouble I’ve put the Android 4x build on box.com here.

Happy IoTing!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s