Showing posts with label IoT. Show all posts
Showing posts with label IoT. Show all posts

Sunday, October 5, 2014

Visible Light Communication Chronicles - Part V - The Boards

The boards are here !! The images shown below are the VLC RX and TX boards i designed as shields for the Arduino UNO. An array of 12 LEDs forms the transmitter, a TEMD6200FX photodiode on the RX board, an Analog Devices XRAD8051 transimpedance amplifier followed by a SY8890 limiting amplifier. The wires on the TX board are test points i added at every stage of the output blocks. The FTDI is an alternative interface to connect the boards on USB-UART to a cellphone over OTG. The control path signalling is implemented using the NRF24L01+ RF module.

Time to solder all them components and get 'em boards runnin' (strong southern accent :P)









Saturday, October 4, 2014

Wireless RGB Light Control (Adafruit BT + NeoPixels)

This is a massive upgrade to my earlier project that i posted a couple a days ago here. The interface using the RoundButtons from Coding4Fun toolkit looks much cleaner and aesthetic. More features like controlling the light intensity, single tap color change, turning off all the LEDs on the shield, reflection of a hardware reset in the phone UI etc. The paragraphs below briefly detail out the two main components.

The Roundbuttons - Created using the RoundButton class from coding4fun toolkit. These buttons have two event handlers registered in the code, one for Hold and other for a Click. Holding a button for a certain duration causes the color selector window to pop up. This window has a Hexagon color picker interface created using the same coding4fun toolkit. Touching and dragging your finger on this picker will update the selected RGB LED color in real-time. Once a color is selected it can be applied to one or more LEDs by clicking on them, this is handled by the Click event handler.

The ColorPicker - The hexagon color picker has a handler registered to it's Color Changed event. The color data received is framed in a transmission packet and sent over the BT interface to the Arduino board in this handler. Adjusting the slider below the color picker adjusts the brightness of the LEDs. The Turn Off button turns off all the LEDs on the shield and also clears the button background color on the UI.


Implementation

All the round buttons used, follow the xaml template shown below. 40 buttons have been created using the same xaml statement. The only difference is the Name field which is unique for each button. The buttons are placed inside a Grid component therefore the (0, 0) grid position corresponds to the upper left LED near the Reset button on the RGB shield. the buttons have been named in a similar pattern. The button inside the     (0, 0) grid cell is named a_a, the button in cell (0, 1) as a_b, (1, 0) as b_a and so on. All buttons have the same Click and Hold event handler.

When the application is started it establishes a connetion with the Arduino BT shield, which exposes serial ports to the Arduino. (The shield uses the BT Serial Port Profile) The read / write operations on the arduino are done using the softwareserial library at 9600 baud. On the phone side, DataReader and  DataWriter objects are created to read from the Socket (StremSocket class). The socket connects using the ConnectAsync call in the StreamSocket class.

When a button is held for a specific amount of time the Hold Event occurs. This triggers the hold event handler and opens another window that displays the hexagon color picker. The hexagon color picker has a event handler attached to its ColorChanged event. When you touch the color picker and move your finger over it, the ColorChanged handler is continuously called. The OS passes the sender and the Color to the event handler. Inside the event handler, the serial packet to be transmitted to the arduino is built. It has the format as shown below. Hence if i click on button (2, 3) in the grid with full green color selected on the color picker then the packet will be

c_d_0_255_0


As the data is sent as a String the "_" is used as a separator. This command will be parsed on the Arduino. Since the X and Y co-ordinate positions in the command are fixed at offsets 0 and 2 respectively the value can be easily obtained by doing a (int)command[0] - 97. extracting the color values requires a little processing. This value can be then sent to the NeoPixel Library. The intensity adjustment follows a similar format with a smaller packet and a command identifier as 'I'. An alternative method would be to send the numerical values corresponding to the buttons directly. But i could not find any means to figure out which button inside the grid had been clicked without using the Name property....(duh)

When the arduino is reset all LEDs on the phone UI need to be turned off. This is accomplished by sending the string "RESET" from the Arduino to the phone. The phone maintains a journal in an custom LEDManager class about the LEDs that are currently active. When the reset command is received, using the DependencyObject with the grid as the parent and the VisualTreeHelper class, a list of all buttons in the parent is created, then iterating over the List, each button's background color is set the to the OFF color which is black. Similarly when the Turn Off button is clicked on the color picker interface it sends a "OFF" command to the Arduino, turning off all the LEDs and clearing the UI.

Most of the actions are demonstrated in the below video where you can see me messing around with the LEDs.



Some Usage scenarios
1. Arduino Powered Up, Windows phone BT turned ON, Application start
In this case the serial link is established between the phone and the arduino hardware and the data packets are exchanged normally between the two.

2. Arduino Powered Up, Windows Phone BT turned OFF, Application start
In this case the application will open a message box indicating the the phone bluetooth connection is turned off. The application UI will be disabled. Application will have to exit and be restarted once the phone BT is turned ON

3. Arduino OFF, Whindows phone BT turned ON, Applicatino start
- Undefined behavior. Application runs without crashing. Re-connect will not happen even when the board is powered up. The application needs to be restarted.

Future upgrades include hooking up the shield with Facebook API, group control of LEDs, Gesture controls, using sensor interfaces on the WP8 to manipulate LED colore etc. Now this is one hell of a way to learn Windows Phone Programming....

References: 
Bluetooth communication between Arduino and Windows 8.1
Windows Phone API Reference


Where is all the code ? Here is the code running on the Arduino. The Windows Phone code will make this post the longest ever. Therefore i leave it up to you to implement.




Monday, June 9, 2014

Arduino + Internet of Things - Part I

...IoT...

The term "Internet of Things" is used to describe a system where the Internet is connected to the physical world via ubiquitous sensors [1]. In an article dated June 22, 2009 in the RFID Journal Kevin Ashton said - 

Today computers—and, therefore, the Internet—are almost wholly dependent on human beings for information. Nearly all of the roughly 50 petabytes (a petabyte is 1,024 terabytes) of data available on the Internet were first captured and created by human beings—by typing, pressing a record button, taking a digital picture or scanning a bar code. Conventional diagrams of the Internet include servers and routers and so on, but they leave out the most numerous and important routers of all: people. The problem is, people have limited time, attention and accuracy—all of which means they are not very good at capturing data about things in the real world.

And that's a big deal. We're physical, and so is our environment. Our economy, society and survival aren't based on ideas or information—they're based on things. You can't eat bits, burn them to stay warm or put them in your gas tank. Ideas and information are important, but things matter much more. Yet today's information technology is so dependent on data originated by people that our computers know more about ideas than things.

We need to empower computers with their own means of gathering information, so they can see, hear and smell the world for themselves, in all its random glory. RFID and sensor technology enable computers to observe, identify and understand the world—without the limitations of human-entered data.


Gartner Inc. states that the Internet of Things will grow to 26 billion units installed in 2020, representing an almost 30-fold increase from 2009. Furthermore, Gartner said that IoT product and service suppliers will generate incremental revenue exceeding $300 billion, mostly in services, in 2020. The market research firm further states IoT will result in $1.9 trillion in global economic value-add through sales into diverse end markets.Is IoT the latest hype ? Most of the opportunities predicted from IoT are nothing new. Everything will be connected but most those items like cars, appliances, printers, etc. have been talked about for more than a decade. The big differentiator this time is advanced sensor technology, but how long before these sensors become commodities? OK, so most of these devices will be IPv6, but what's the big deal about what standards they use to communicate? Most of the chatter about IoT seems to be evolutionary, not revolutionary. [2]

Data is all around us, data we cannot see - Dark Data. If harnessed properly this data can be quantified and utilized to make this planet a better place to live (jeezz...). Unless people make smart use of IoT it will just remain in the evolutionary stage.  Everthing will just remain an Internet-of-Thermostats...

Allright, i am fed up gathering data visit this link to read further.

That Temperature Thing...

Now to the real content for which this post is meant for. In a nutshell - i've used the Sparkfun Weather shield connected to the Arduino to send the temperature, humidity and luminosity data of my room to a Xively server using a Adafruit CC3000 TI WiFi sheld. This is the stacked up assembly. The bottom board is an Arduino Uno R3, in the center there is the Adafruit  WiFi shield and the Sparkfun weather shield on top. Pretty neat arrangement eh ? Rapid prototyping at it's finest with such boards available...


The data is displayed on the Xively website. Surprisingly i have observed that the data transmission to the server is slow. It takes approximately 40 seconds after a connection has been established with the server to upload the JSON formatted data using the UNO R3. The entire code for the Arduino sketch is shown below and some screenshots from the Xively site. Most of the code has been adapted from Adafruit's learning site with minor modifications by me for the weather shield. Does a demo like this come under the hood of IoT ? Well, right now, if i stop this project here, then No, it does not. The data is merely being displayed, it does not control any-thing or talks to any other thing to modify that thing's behavior. This just validates the platform on which future IoT applications aspire to run on...


The light levels started to increase from 05:53 hrs in the morning as seen in above graph.
The sunrise time as per local weather station data was indeed 05:53 A.M

It is pretty hot out here. Those spikes you see are me turning off the air cooling of my room. 37.99 degrees celcius was the maximum temperature hit inside my room...after which i turned on the air conditioning

If you are reading this post and have some information to share on the CC3000 as to why it takes so much time to push data to the website, leave a comment below. Thanks for reading through...





And that's a big deal. We're physical, and so is our environment. Our economy, society and survival aren't based on ideas or information—they're based on things. You can't eat bits, burn them to stay warm or put them in your gas tank. Ideas and information are important, but things matter much more. Yet today's information technology is so dependent on data originated by people that our computers know more about ideas than things. - See more at: http://www.rfidjournal.com/articles/view?4986#sthash.uvAv1voe.dpuf
Today computers—and, therefore, the Internet—are almost wholly dependent on human beings for information. Nearly all of the roughly 50 petabytes (a petabyte is 1,024 terabytes) of data available on the Internet were first captured and created by human beings—by typing, pressing a record button, taking a digital picture or scanning a bar code. Conventional diagrams of the Internet include servers and routers and so on, but they leave out the most numerous and important routers of all: people. The problem is, people have limited time, attention and accuracy—all of which means they are not very good at capturing data about things in the real world. - See more at: http://www.rfidjournal.com/articles/view?4986#sthash.uvAv1voe.dpuf
Today computers—and, therefore, the Internet—are almost wholly dependent on human beings for information. Nearly all of the roughly 50 petabytes (a petabyte is 1,024 terabytes) of data available on the Internet were first captured and created by human beings—by typing, pressing a record button, taking a digital picture or scanning a bar code. Conventional diagrams of the Internet include servers and routers and so on, but they leave out the most numerous and important routers of all: people. The problem is, people have limited time, attention and accuracy—all of which means they are not very good at capturing data about things in the real world. - See more at: http://www.rfidjournal.com/articles/view?4986#sthash.uvAv1voe.dpuf
Today computers—and, therefore, the Internet—are almost wholly dependent on human beings for information. Nearly all of the roughly 50 petabytes (a petabyte is 1,024 terabytes) of data available on the Internet were first captured and created by human beings—by typing, pressing a record button, taking a digital picture or scanning a bar code. Conventional diagrams of the Internet include servers and routers and so on, but they leave out the most numerous and important routers of all: people. The problem is, people have limited time, attention and accuracy—all of which means they are not very good at capturing data about things in the real world. - See more at: http://www.rfidjournal.com/articles/view?4986#sthash.uvAv1voe.dpuf
Today computers—and, therefore, the Internet—are almost wholly dependent on human beings for information. Nearly all of the roughly 50 petabytes (a petabyte is 1,024 terabytes) of data available on the Internet were first captured and created by human beings—by typing, pressing a record button, taking a digital picture or scanning a bar code. Conventional diagrams of the Internet include servers and routers and so on, but they leave out the most numerous and important routers of all: people. The problem is, people have limited time, attention and accuracy—all of which means they are not very good at capturing data about things in the real world. - See more at: http://www.rfidjournal.com/articles/view?4986#sthash.uvAv1voe.dpuf