Sergiy Baydachnyy

Blog about technologies

Archive for the ‘IoT’ Category

Azure services and Internet of Things

leave a comment »

I just finished several posts about Galileo board for beginners. In those posts I showed how to create simple projects, which help us to collect data from sensors. But there still is a question: what we should do with collected data there. That’s why in this post I want to show several cloud services, which will help you to collect and analyze data from many devices at the same time in order to be ready to present consolidated data for users.

Of course I am going to talk about Azure because Azure provides not just base services like VM hosting, WebSites, SQL Azure etc. but several specific services, which are ready for solutions based on “micro” devices – devices which might contain many different boards and sensors around the World.

Queue

I will start with most simple Storage service component like Queue, which was presented in the beginning of Azure era and which is important for some scenarios in Internet of Things area.

Queue supports REST API and works fine in IoT projects which have just one event publisher or just one event consumer and if you don’t need to implement any special algorithm for access data in queue.

For example, you design a device, which plays music in restaurants or bars. Everybody may order favorite music using smartphone, tablet, terminal at the bar etc. But the device can play just one composition at the same time. So, you will have a queue there with orders inside and each element will contain some expiration time as well. In these case you have just one consumer device and it doesn’t require any special algorithm for selecting messages.

You can design one more device, which will provide the next number in line to government officials. This device increases internal counter, provides a new number, prints tickers with the number and puts a given number to the queue. Each official has a table – one more device, which connects to the queue and takes the next number from the queue. In this case we have just one publisher but many consumers (several agents with own tables).

So, there are many scenarios where queue is good enough. You can find REST API documentation for queue using this link.

Pay special attention that there are very strong requirements for queue. You should use low case symbols only. I forget about it from time to time and then it takes some time to find a mistake.

Event Hub

If you have many publishers and consumers at the same time, a simple queue will not work fine.

Imagine cashiers at the food store. Usually each cashier has his own line and there is a chance to increase number of cashiers in real time etc. There is no ways to use just single queue. At the same time it’s too hard and expensive to use many queues, because you need to implement lots of code, which will create queues dynamically and manage elements there. In other words you will need super queue.

Probably it was a good idea to create something like super queue with much own code inside but today we have Event Hubs.

Event Hubs is a special service which supports messaging scenarios with many event publishers and many consumers at the same time.

clip_image002

Thanks to partitions, consumer groups and offsets it’s possible to implement any scenarios there. Of course, you can use Event Hubs in scenarios, which work with Queue as well. In this case you will use a universal approach.

Of course, Event Hubs like Queue and other services, support REST API as well.

Mobile Services

In some scenarios you might want to notify users about some events using standard Push notification services. In this case, it’s easy to use Azure Mobile Services. I already wrote a series about Azure Mobile Services. So, if you are interested in some aspects of it, you can read my series.

Tables and Blobs

Of course, previous services allow to use events in order to communicate between publishers and consumers. But in many scenarios you are required to store a lot of data from sensors. For example, you can create a device, which will collect data about pollution in the area. Your device is not going to send any events. Instead, you are going to use this data to analyze the situation for many years. So, you need a storage but Queue and Event Hubs cannot works like a storage.

Since usually devices send much non-relationship data, you will use non-SQL storages. In case of Azure you can use Tables and Blobs.

Tables allow to store data in table format and you can store hundred thousands terabytes there. But Tables have two disadvantages there. First of all in order to store data from sensors, your device need permanent access to Internet. Of course, you can preserve data to a local file but in this case it’s better to send to Azure file itself. The second disadvantage is related to format of data. You can store text data there but in case of images, videos etc. you need to return to files. So, usually, in IoT scenarios you will use Blobs instead of Tables.

Blobs allow to store any files inside and support REST API as well. So, usually you will preserve sensor data to a file and send it to Blobs based on your own scenario.

Stream Analytics

So, we already have some services which help with events and storage but we still need a way to analyze stored data. A new Azure service, called Stream Analytics, will help you to implement this task as well.

Stream Analytics can use Event Hubs and Blobs like a source for analysis. So, it is able to get and prepare all the needed data from your analysis. After that Stream Analytics provides query language, which helps you to implement your own algorithm in order to prepare data for analysis. Finally, stream analytics can upload all your results to new blobs, Event Hubs, SQL Azure database, which could be used as a source for many analysis tools.

Stream Analytics is still in preview mode but you can try it for free right now using trial accounts or your regular Azure account.

Therefore, as you can see, Azure supports full stack of needed services for IoT world and could be used with any IoT devices.

Written by Sergiy Baydachnyy

01/20/2015 at 11:10 PM

Posted in IoT, Microsoft Azure

Tagged with ,

Internet of Things: My first experience with Galileo 2 (part 6)

leave a comment »

Today it’s my last post about Galileo board for beginners. So I decided to test some features, which I avoided for some time due to soldering requirements. I have never used soldering iron before but I have a weather shield and a LCD panel, which don’t have already prepared pins.

For example, in order to operate, the weather shield requires four different “male to female” pin headers

clip_image001

In case of my LCD 1602 panel, it’s better to use something like this:

clip_image003

So, it’s time to visit a shop in order to buy some stuff for soldering. Finally, I spent around 30 Canadian dollars to buy the following:

clip_image005

There is the cheapest soldering iron, solder and some stuff for clearing iron itself.

Finally, I started to assemble the following device:

clip_image007

This device uses Weather board in order to measure temperature, pressure and humidity. In order to show collected data, I used LCD panel.

Of course, soldering requires some patience and frankly speaking, I didn’t have faith in the result and I was too surprised then it started to work.

So in order to create the device I used Weather shield. As I told before, I don’t like shields very much but in some cases shields help you to create something without special knowledge and very fast. You need just put your shield on your board and you should not think about circuits, voltage and anything else. At the same time, shields contains pins, which extends board’s pins and you may use them in usual way.

In case of LCD panel it’s not so easy. You need to know how to connect the panel to the board. So, you need review a datasheet for your panel. My panel has the following pins:

· VSS – pin that connects to ground

· VDD – pin that connects to 5V power supply

· V0 – pin that allow to change contrast of LCD

· RS – a special pin that controls where in memory you are writing data to;

· R/W – allows to select read/write modes;

· E – an enable pin;

· D0-D7 – pins for reading and writing data

· A and K – control the LED backlight

Review the datasheet more careful I found that I need connect my LCD to the board in the following way:

clip_image009

In order to connect V0 pin you may use potentiometer or resistor to control contrast but I decided to avoid one more component in my schema.

So, once you connected all pins properly you may start work with code. It’s not easy because you should understand right sequence of commands and prepare some functions there. But in many cases you can find already prepared libraries for your sensors and shields. In case of LCD and the weather shield you can find all needed files in Internet. There is a library for LCD and there is a library for humidity sensors and pressure sensor. You need to add all .cpp and .h files in your project and you are ready to create some code.

Thanks to our libraries, we just need to create objects of our sensors and panels and start listening data (begin method). After that we will use loop method in order to get the latest data and show it on LCD. You can use the following code:

#include "stdafx.h"
#include "HTU21D.h"
#include "MPL3115A2.h"
#include "arduino.h"

int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}

MPL3115A2 myPressure;
HTU21D myHumidity;

LiquidCrystal *lcd;

void setup()
{
//configure LCD to use selected pins
lcd =new LiquidCrystal(4, 5, 6, 7, 8, 9);

//16 symbols and 2 rows
lcd->begin(16, 2);

myHumidity.begin();
myPressure.begin();

// Configure the sensor
myPressure.setModeBarometer();
myPressure.setOversampleRate(7);
myPressure.enableEventFlags();
}

void loop()
{
float pressure = myPressure.readPressure();
Log(L"Pressure(Pa): %lf\n", pressure);

lcd->setCursor(0, 0);
lcd->print("Pressure");

lcd->setCursor(0, 1);
lcd->print(pressure, 4);
delay(1000);

float altitude = myPressure.readAltitudeFt();
Log(L"altitude(Ft): %lf\n", altitude);

lcd->setCursor(0, 0);
lcd->print("Altitude");

lcd->setCursor(0, 1);
lcd->print(altitude, 4);
delay(1000);

float temperature = myPressure.readTemp();
Log(L"Temperature(C): %lf\n", temperature);

lcd->setCursor(0, 0);
lcd->print("Temperature");

lcd->setCursor(0, 1);
lcd->print(temperature, 4);
delay(1000);

float humidity = myHumidity.readHumidity();
Log(L"Humidity(f): %lf\n\n", humidity);

lcd->setCursor(0, 0);
lcd->print("Humidity");

lcd->setCursor(0, 1);
lcd->print(humidity, 4);
delay(1000);
}

That’s all for today. As I told before, it’s my last post for beginners but I am going to continue to write posts about IoT. Next time I will describe how to integrate Galileo and Raspberry Pi boards together.

Written by Sergiy Baydachnyy

01/02/2015 at 9:40 PM

Posted in IoT

Tagged with

Internet of Things: My first experience with Galileo 2 (part 5)

leave a comment »

When you are planning to build your own device you should think about power. In some cases it’s OK to connect your device to the nearest socket but for some projects it will not work. Just imagine a robot, which requires access to socket. So, we need to use independent sources of power like batteries.

In order to understand, which power supply is supported by Galileo, I visited Intel site and found the Galileo 2 datasheet there. According to it, Galileo 2 supports power supplies from 7 V to 15 V. So, in order to be power independent, simple 9V battery should be OK. So, I visited Fry’s Electronics and found the following components there:

clip_image002

Finally, I spent about 2 minutes in order to assemble all components together and check that everything works fine. Right now I have an independent power supply and I may build something like a robot or a flying drone.

In order to build a robot you need to work with motors. There are three general types of motors: DC motors, Stepper-motors and Servos.

DC motors work based on electromagnetism and are used to rotate an axle continuously. You cannot control angle of rotation, so, usually this type of motors is using to turn wheels.

Stepper-motors allow to rotate axle step by step in fixed number of degrees. You should use this type of motors if you need good accuracy there. A simple example of Stepper-motors is second hand in many battery-powered clocks.

Servos are very popular in robotics because they are used in order to create joints. They cannot turn continuously but they can move to fixed number of degrees in both directions with great accuracy. Therefore in order to realize legs, hands, fingers etc. you will use servos.

Today I decided to make some experiments with a DC motor. Usually, DC motors have their own power supply, because they require more voltage than Galileo might give. At the same time we need a way to manage the source of external voltage in order to start and stop our motor. Of course, we may use relay and some components in order to do it or special motor shields but the best way is using a small control chip. This is L293D chip, which allows to control up to two DC motors.

I don’t like special motor shields, because they require a lot of space, they are expensive and limited to 2-4 motors. So, if you need more motors, you need to buy one more shield etc.

In case of L293D, the chip is pretty small, cheap and you can put as many chips as needed on your breadboard.

In order to understand how the chip works, you need to find a datasheet in Internet. In general, the chip looks like this:

clip_image004

There are the following pins:

· EN, A pins – we should use them in order to control our DC motor. We may use them in order to start a motor turning right or left and stop it;

· Y pins – we should use them in order to connect our motor. Thanks to L293D, you may use motors with voltage up to 36V;

· VCC2 pin – it should be used for power supply. This power chip be used in order to start motor turning. So, in general, we will use external power supply there (up to 36V);

· VCC1 pin – the chip requires power as well in order to operate, so we will use it in order to provide power from external supply or from the board (5V is OK);

The chip allows to use up to two motors. Because I have just one motor, I will not use 3A, 3Y, 4A, 4Y, 3,4 EN in my example.

Therefore, in order to use one motor you should implement the following schema:

clip_image006

I decided to use there 5V power from my board in order to set up VCC1 because recommended voltage for VCC1 is between 4.5V and 7V. But you may use external power there as well, using some resistors there. In order to set up VCC2 I decided to use 9V battery, because my DC motor operates find under this condition. Finally, we should understand, how to operate the motor. In order to do it, you can use the following table:

clip_image008

So, if you want to start the motor, you may use the following code:

pinMode(en, OUTPUT);       
pinMode(a1, OUTPUT);
pinMode(a2, OUTPUT);

digitalWrite(en, HIGH);
digitalWrite(a2, HIGH);
digitalWrite(a1, LOW);

There en, a1 and a2 are numbers of digital pins, which you use in your Galileo in order to communicate with chip.

Finally, I got a working solution:

clip_image010

Written by Sergiy Baydachnyy

12/15/2014 at 7:54 PM

Posted in IoT

Tagged with

Internet of Things: My first experience with Galileo 2 (part 4)

leave a comment »

Today I am going to continue my series about Galileo 2 board for beginners and I will discuss analog inputs. But before it, I want to discuss resistors as well.

We already used several resistors in our projects in previous posts but it’s still too hard to understand a value of particular resistor. There are two ways to do it. First of all we may use a multimeter device. You can buy it in any electronics shop. If you want to find a resistor in 330 ohm you need to set the dial of multimeter to 20 KOhm and touch red and black probes of multimeter to different legs of the resistor. You will see something around 0.330 for 330 ohm resistor.

image

At the same time it’s not easy to find a right resistor among many types of them. Here is my box with different types of resistors and there are about 4 resistors in 330 Ohm only. Probably I will spend up to one hour in order to check all of them.

image

So, in order to find a right resistor you need to use the second way – you need to understand color marks there. It’s not too hard. Usually, you will find resistors with 4 or 5 bands there. Based on these bands you can calculate resistance of a particular resistor. Here is a small table, which will help:

Color

1st Band

2nd Band

3rd Band

Multiplier

Tolerance

Black

0

0

0

1 Ohm

 

Brown

1

1

1

10 Ohm

1%

Red

2

2

2

100 Ohm

2%

Orange

3

3

3

1 KOhm

 

Yellow

4

4

4

10 KOhm

 

Green

5

5

5

100 KOhm

0.5%

Blue

6

6

6

1 MOhm

0.25%

Violet

7

7

7

10 MOhm

0.10%

Grey

8

8

8

 

0.05%

White

9

9

9

   

Gold

     

0.1

5%

Silver

     

0.01

10%

So, if you have resistor with 4 bands, you will not use 3rd band column. Just find the right number for the first band and the right number for the second band and combine them to the one number like <first number><second number>. And multiply this number by multiplier in order to get the final resistance. That’s why we need <Orange, Orange, Brown> forth band resistor in order to get 330 Ohm resistor.

Let’s start to create a project based on sensors, which can send inputs to our board. I wanted to use a flame sensor in the first project but today I woke up at 4 A. M. due to fire alarm in my building. Probably somebody forgot to turn off a stove or something like it but buzzer’s sound was terrible and I decided that it was a sign to stop my experiments with flame. So, we will use a photoresistor sensor.

If you have a modern car, you should have something like “Auto” mode for your lights. This mode allows to switch your light based on amount of external light. We will try to emulate the same behavior in our project. In order to do it we will create a circuit like this:

image

Depending on your kit, you will find many types of photoresistors there. In my case I have an analog sensor, which looks like as a separate board:

image

It has three legs, which should connect your sensor to power, ground and analog input pin on the board. You should check the datasheet for your sensor in order to understand how to connect it.

Since we are using an analog sensor, it should be connected to an analog pin. Photoresistor works like a variable resistor, which resists our voltage based on the amount of light. If you have a lot of light, the resistor will put down your voltage. Galileo converts the analog input to digital and it helps to understand the quantity of light. Here is a simple code, which you may use to test the project:

int led = 8;  
int photo = A0;

void setup()
{
pinMode(led, OUTPUT);
pinMode(photo, INPUT);
}

void loop()
{
int res=analogRead(photo);
if (res <= 700)
{
digitalWrite(led, LOW);
}
else
{
digitalWrite(led, HIGH);
}
delay(1000);
}

Galileo convertor will convert the analog input to a number between 0 and 1023. In this code I decided that if our number is smaller than 700 (resistor resists enough voltage), we will switch off our led because we have enough amount of light. If our resistor doesn’t resist enough voltage (it’s dark) we will switch on out led. Based on this example you are able to make many experiments with light and analog input.

Since we are using Visual Studio, it’s easy to launch our projects in a debug mode. When you will stop debugging, Visual Studio kills your process automatically. Visual Studio allows us to set breakpoints and review variables values etc. You may also use the Log method in order to print something to the output screen in the Debug mode. If you are launching your application without Debug mode, you need to kill your process using the Telnet as I mentioned in previous articles.

So, Visual Studio makes our life better but there still is a question: how to launch our projects just after startup of our operation system. It’s very important if you already created the final version of your project. Because we are using Windows, it’s easy to do in two steps. First of all you need to navigate to the following folder: \\mygalileo\c$\Windows\System32\Boot. You will need to enter your credentials there. On the next step, change autorun.cmd file and put one more command there, like start YourFolder\YourApp.exe. That’s all and your application will launch on the system startup.

Today I will finish my post. Next time I am planning to show more advanced projects.

Written by Sergiy Baydachnyy

12/01/2014 at 7:42 PM

Posted in IoT

Tagged with

Internet of Things: My first experience with Galileo (part 3)

leave a comment »

Published on MSDN Blog. Please, visit it for more great articles from Canadian DX team.

In the previous post we developed our first device based on digital outputs from Galileo board. Today I am going to show emulation of analog outputs.

But before we will start to create something I want to return to question about electric schemas. Frankly speaking I am not sure if I want to learn all symbols related to schemas but at the same time we need a tool which will help us show design of our schemas. In order to do it I am going to use a free, open-source application called Fritzing. This application was developed by University of Applied Sciences in Potsdam, Germany. You can download the tool here: http://fritzing.org and it contains links to versions for operation systems like Windows, Linux and OS X.

clip_image002

It’s too easy to recognize needed components, put them to a breadboard and understand if your circuit is completed. Just drag and drop needed components from the parts section to breadboard and connect them in order to make a route.

I tried to create a schema for the previous example and you can see the result below:

clip_image004

If you are not able to find some components here you can make search in Internet. For example, I found a better look of Galileo board on Intel Community site. I just clicked the Mine tab and imported “.fzpz” file there.

So, I just used Fritzing in order to show our next example.

clip_image005

Here we are going to use RGB LED in order to show digital outputs in pulse mode. RGB LED is able to show different colors based on RGB schema (R – red, G – green, B – Blue) and it allows different voltage for each lead (the longest lead relates to the ground; the shortest lead, near the ground, relates to red; the shortest lead, on opposite side, relates to blue color; last one relates to green). As I mentioned in the previous post, we are able to emulate analog output using the digital pins with mark “~”. So, let’s connect each lead of RGB LED to appropriate pins (like the image shows) and complete the circuit. We will need more 330 Ohm resistors in order to resist our voltage.

In order to emulate analog output we should use analogWrite method instead of digitalWrite. This method allows to vary parameter from 0 to 255 instead of High/Low and looks very simple in our example. This code will help to show basic color with RGB LED. It will help you to test your circuit and later you can change the parameters of color method in order to generate different colors.

#include "stdafx.h"
#include "arduino.h"

int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}

const int redPin = 6;
const int greenPin = 5;
const int bluePin = 3;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void color(unsigned char red, unsigned char green, unsigned char blue)
{
analogWrite(redPin, red);
analogWrite(bluePin, blue);
analogWrite(greenPin, green);
}

void loop()
{
color(255, 0, 0); // turn the RGB LED red
delay(10000);
color(0, 255, 0); // turn the RGB LED green
delay(10000);
color(0, 0, 255); // turn the RGB LED blue
delay(10000);
}

In the next article I am going to talk about digital and analog inputs and we will create more examples there.

Written by Sergiy Baydachnyy

11/22/2014 at 1:19 AM

Posted in IoT

Tagged with

Internet of Things: My first experience with Galileo 2 (part 2)

leave a comment »

In the previous article we discussed how to setup your first Galileo board and showed some stuff that you need to deploy applications there. In this article we will try to understand what is Galileo and how we may use it in more advanced projects.

So, Galileo is a powerful development platform with x86 compatible processor, USB, mini-PCI, Ethernet port, 256MB DDR3, SD slot, which may help makers, students and enthusiasts to develop their own projects. Galileo is compatible with Arduino prototyping boards, so developers may use any existing hardware, which could be used with Arduino Uno or something like this. And, of course, Galileo may support not just Linux but Windows platform as well. It allows us to create our software in a friendly environment.

Of course, Galileo is the heart of your device and enables reading some inputs from external world and provides own outputs there. For example in order to get inputs you can use many different sensors, buttons, switches etc. and in order to show some outputs you can use motors, LEDs, relays etc. Thanks to the Ethernet adapter, 3G and WiFi shields, Galileo may communicate with external services and other devices, which are connected to Internet.

Our goal, in this article, is to understand how we may connect external devices to Galileo and how we may start developing something. From this prospective we will start with the most important part of the board for developers – with pins. Galileo 2 contains two sets of pins, which allow us to control inputs and outputs. In every project we are going to work with pins, that’s why their understanding is so important.

Usually we will work with the first set of pins – Digital pins. We may use this set in order to send outputs and receive inputs. You can use these pins for outputs in on/off mode. So, output voltage may have 0V or 5V there. Pay attention that all pins provide 5V voltage but Galileo board has a special switcher, which allows to set board in 3.3V mode in order to guarantee compatibility with some 3.3V shields. We will use just 5V voltage in our devices. If you use this set of pins for inputs, you will have the same range of values there – 0V or 5V.

image

So, we have 13 pins for digital outputs/inputs. But you can notice that some of these pins have a special mark “~”. This shows that we may use marked pins in order to send signals (outputs) in pulse mode. It allows us to emulate rheostat effect, when we have a way to send just n% of current per unit of time. You can use this effect in order to regulate brightness of LEDs or temperature in your apartment etc.

The second set of pins (A0-A5) is used for input only. But in this case it should be analogue input like data from thermometers, potentiometers, variable resistors etc.

image

This set of pins is important then we receive data, which describes more than two states. We will use these pins in more advantage projects.

Finally you can find some more pins like POWER, 5V, GND and so on. Some of these pins are used in order to control the board, some pins like 5V and VIN are used as source of current and GND pins are used for the ground.

So, right now we got some knowledge about pins and it’s time to look at development tools for Galileo.

If you already installed VS Extensions for Galileo, you can create projects in C++ based on Galileo Wiring App template. Frankly speaking, Microsoft already included much code there but it allows us to concentrate on device only. Right now we can work with Main.cpp files only. Probably, later, we will dig to code there but today I am going to use already prepared stuff. So, there is the following code in the main.cpp file:

#include "stdafx.h"
#include "arduino.h"

int _tmain(int argc, _TCHAR* argv[])
{
return RunArduinoSketch();
}

int led = 13;

void setup()
{
pinMode(led, OUTPUT);
}

void loop()
{
digitalWrite(led, LOW);
Log(L"LED OFF\n");
delay(1000);
digitalWrite(led, HIGH);
Log(L"LED ON\n");
delay(1000);
}

Here there are three functions only. Of course the application will begin with _tmain, which runs RunArduinoSketch functions. The main task of this function is calling setup function and putting loop function inside infinity loop. So, it’s clear that we can use setup function in order to initialize something there and we will use loop function in order to create our runtime logic.

We can see that setup and loop functions are already prepopulated. There is just one call from setup function – pinMode method, which informs our board that we will work with pin number 13. This pin is also connected to a led on the board but we can still use it for external stuff. loop method contains just six lines of code but the most important call there is digitalWrite call. This function allows two parameters like number of pin and state. LOW state shows that we should have 0V voltage and HIGH – 5V.

Let’s use existing code in the template but we will try to use external LED there. In order to do it we need the following components:

· LED – usually LED consumes voltage around 1.7V. So we should resist our 5V voltage there and in order to do it we need a resistor;

· Resistor – in order to resist our voltage we need 330 ohm resistor. It’s time to remember high school and Ohm’s low: I=U/R, where I is current (amperage), U is voltage and R is resistance. So, Galileo board has current in 10 milliamperes and voltage in 5V but we need to select a resistor, which will resist voltage to 1.7V: (5-1.7)/0.01=330. I used a resistor, which contains rings in the following sequence: orange, orange, brown and gold colors. In the next article I will describe how to select the right resistor;

· Breadboard – usually you will use this stuff in order to create a prototype of your final board and it’s good for testing and investigations. You can buy this one separately or find it in many kits;

· 2 wires

Finally, I created this:

image

In order to understand how it works, you need some information about the breadboard. You can see that our breadboard has several lines that are marked by numbers (from 1 to 30). Pins in each of these lines are connected. So, I used a yellow wire in order to connect pin on my board to pin in line 12 on my breadboard. So, when I put my digital pin to HIGH, current will be in line 12. The resistor connects line 12 and 21, so, we will have 1.7V voltage in line 21. It’s time to connect our LED – put the longer lead (anode) to the same line (21) and put the shorter lead (cathode) to line 23. To the same line (23) connect the blue wire.

Next time I will try to create some schemas but many developers (like me) don’t have knowledge in electrical schemas at all:)

Finally, you can connect yellow wire to digital pin 13 and blue wire to GND pin and just deploy the default application from Visual Studio. Your led should blink. In order to stop the process you can use telnet and tlist/kill commands there.

In the next article we will test more sensors and functions from API.

Written by Sergiy Baydachnyy

11/18/2014 at 8:55 PM

Posted in IoT

Tagged with

Internet of Things: My first experience with Galileo 2 (part 1)

with 2 comments

Published on MSDN Blog. Please, visit it for more great articles from Canadian DX team.

I didn’t feel so excited since that time, when I bought my first PC – ZX Spectrum. It was a new world, which required strong programming knowledge as well as ability to make research. And today I will open a door to one another new world, where I will try to integrate my programming knowledge with new types of hardware in order to build many new devices. Let’s begin.

First of all, in order to create a new hardware we need to buy some stuff like a board, sensors and wires. Because I have a good experience with Microsoft platform and Visual Studio, I have selected Intel Galileo 2 board, which is supported by Microsoft and it is compatible with Arduino boards, so you will able to find some stuff like sensors, shields, breadboards anywhere. At this time, I don’t have an idea about my future devices, so, I decided to buy a board as well as several starter kits. Finally, I bought my Galileo 2 board, SunFounder 37 modules Arduino Sensor Kit and Sunfounder Project Super Starter Kit.

clip_image002

I used Amazon in order to buy this stuff but you can use any online store. Additionally, I have visited Fry’s Electronics last week and I was too surprised that you may buy a board as well as many of these sensors and components there. There was a huge selection of kits for building own robots, sensors and wires. Probably, there is a special shop in Canada but I am a newcomer in Canada right now. So, please, recommend a good place here and it will help many Canadian developers.

Additionally, you will need a network cable, a microSD card (16 Gb should be enough) and microUSB to USB cable. The last one is used for all modern phones, so it should not be a problem but I forgot to buy a microSD, so I needed to find a nearest Staples in order to buy it. Pay special attention that in order to deploy your application, you need a network cable, which will connect your computer and your board.

Ok, right now, we have a board and some stuff, so we are ready to test the board. In order to use Windows as well as Visual Studio there, you will need to sign a special Windows Developer Program for IoT, which is available here: http://www.windowsondevices.com. You will need to use your Live ID, fill the registration form and right after your application is approved you will get access to Connect site, there you will be able to download all needed software.

In order to set up everything you will need three packages there: WIM image of the operation system, which you will deploy to your board (microSD card); apply-bootmedia.cmd file, which you will use to deploy the operation system; MSI package, which include some tools like Galileo Watcher and Visual Studio integration package.

In order to setup your PC you will need to launch the MSI package and enable Telnet features there. Later we will use Telnet in order to kill processes and get some information from the board. In order to enable Telnet features just go to “Program and Features” in the “Control Panel” and call “Turn Windows Features on or off” window.

clip_image004

Right now it’s time to setup your board. In order to do it you need to deploy Windows image to microSD card. Apply-BootMedia.cmd is able to do it for you. Just run the following command in the Command Prompt window (with Administrator permissions):

apply-bootmedia.cmd -destination {YourSDCardDrive} -image {.wimFile} -hostname mygalileo -password admin

Your card will be ready in 2-3 minutes.

clip_image006

Right now, we are ready to run something on Galileo. So, put your microSD card to the slot on the board, use the network cable to connect your Galileo board and turn on your board. Pay attention that Intel provides a universal power supply unit with different connectors. So you will able to use your board anywhere despite of voltage of the local system.

Usually it takes Galileo 2 2-3 minutes in order to start Windows there. During this process you will see blinking LED, which is marked as SD. When LED finishes blinking, your board is ready to communicate with your computer. The second way to understand that the board is ready – launch Galileo Watcher, which will show IP address of your board, MAC address, name and information about state of your board.

clip_image007

Using the Galileo Watcher you are able to monitor the state of your board as well as to launch some stuff like window in browser, which will show existing processes.

Pay attention that if you will use Visual Studio or Telnet in order to connect your board, you will need to provide the name and password there. We provided our password below and the default name is administrator. But, in many cases, you will need to provide the full name of the user like localhost\administrator or mygalileo\administrator, especially, if your computer is in a domain.

Finally, you may launch Visual Studio and create your first project for Galileo 2.

clip_image009

Microsoft provides a ready to go template, which we will discuss next time. Just try to start it on Galileo. If deployment is successful you will see that one more LED is blinking in infinity loop on your board.

In order to kill the process you will need to start Telnet and use the following commands:

· tlist – in order to see all existing processes

· kill <process ID> – in order to kill selected process

Probably I wrote enough for the first part. In the next article we will try to understand, what is Galileo and how to create a simple scenarios there.

Written by Sergiy Baydachnyy

11/07/2014 at 9:00 PM

Posted in IoT, Microsoft, Windows 8

Tagged with ,