Sergiy Baydachnyy

Blog about technologies

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.

Advertisements

Written by Sergiy Baydachnyy

01/02/2015 at 9:40 PM

Posted in IoT

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: