Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

EasyIoT Cloud and Raspberry Pi 3

DZone's Guide to

EasyIoT Cloud and Raspberry Pi 3

EasyIoT Cloud is a great option for IoT devices. Of course, there's some configuration legwork to be done, but setting it up to interact with your Raspberry Pi 3 is a snap.

· IoT Zone
Free Resource

Build an open IoT platform with Red Hat—keep it flexible with open source software.

The Raspberry Pi is a tiny and affordable computer with a GPIO interface. In this tutorial, we will connect a Raspberry Pi 3 to EasyIoT Cloud and control the GPIO pins in a web interface or mobile application. GPIO pins can be connected to relay modules and to be used to control different devices like lights, motors, and so on. You can configure GPIO pin as digital inputs.

The Raspberry Pi application is stored on a Raspbian SD card image. 


Here's a look at the EasyIoT Cloud user interface:

Materials

  • Raspberry Pi 3
  • SD card
  • Power supply
  • Relay module
  • 2N2222 NPN transistor
  • 5K resistor
  • MB102 Breadboard

 

EasyIoT Cloud Configuration

Register to the EasyIoT Cloud service and remember your username and password. If there are pre-configured demo modules in the user interface, simply delete them.

Raspberry Pi 3 Configuration 

First, go to the download page and download the EasyIoT Cloud Raspberry PI 3 Client image file. The image consists of the Raspbian OS and EasyIoT Cloud client service to control the GPIO pins.

Copy the image to your SD card. You can use dotNetDiskImager.exe or a similar program to copy the image to the SD card. You need 8GB or more space on your SD card. After copying it over, put the SD card into Raspberry Pi 3 and connect it to a power supply and the Internet.

Use a keyboard and monitor (or SSH access) to log into the Raspberry Pi 3. The default username is pi and the password raspberry. After logging in, go to the nano editor to edit the EasyIoT Cloud username and password. In the console, enter:

sudo nano /usr/share/eiotclient/config/RPIConfig.xml


After editor is opened, correct the following:

<Username>xxx</Username>
<Password>xxx</Password>


If you want to change the GPIO pin directions (Input/Output), you can also change this in the XML file under Type. Possible entries are Input and Output

<GpioPin>
    <Enabled>true</Enabled>
    <ConnectorPin>Pin_P1_03</ConnectorPin>
    <Type>Output</Type>
    <GPIOResistor>OFF</GPIOResistor>
    <GPIOPin>2</GPIOPin>
    <ModuleId>2</ModuleId>
</GpioPin>


If you are using a GPIO pin as your input, you can also configure the GPIOResistor value to: OFF, PULL_UP, or PULL_DOWN.

After you finish the configuration, close the editor by pressing Crtl+X.

Reboot Raspberry Pi with the command:

sudo reboot now


After the reboot, log into EasyIoT Cloud and you should see new modules with the names Pin_P1_[pin number]. Pin numbers are displayed in the following picture:

For example, the module Pin_P1_3 is GPIO2.

Later, you can change the pin name in the EasyIoT Cloud interface under Configure->Modules to a more appropriate name like "Light living room."

Additionally, if you want the Raspberry Pi to be connected to Wi-Fi, configure the Wi-Fi adapter. In the console, enter:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


And at the end of the file, add:

network={
    ssid="Your_ESSID"
    psk="Your_wifi_password"
}


And replace "Your_ESSID" and "Your_wifi_password" to your own, of course. Close the editor with Ctrl+X and reboot the Raspberry Pi.

Hardware

In our demo configuration, the GPIO output pin is connected to a relay module:

Input pin (Pin_P1_5 ) is configured with the PULL_UP resistor. If you do not connect anything, the input is in the high state (On). If you connect this pin to GND, the input state is OFF.

Download Red Hat’s blueprint for building an open IoT platform—open source from cloud to gateways to devices.

Topics:
iot ,easyiot cloud ,raspberry pi ,gpio ,tutorial

Published at DZone with permission of Igor Jarc, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}