วันพุธที่ 25 มกราคม พ.ศ. 2560

Raspberry Pi connect OLED I2C Display ( Python Code )



Raspberry Pi connect OLED I2C Display ( Python Code )



Wiring Diagram

Hardware

Raspberry Pi Board ( we use Raspberry Pi3 board )
I2C OLED Display ( 128 x 64 0.96' SSD1306 chip )


OLED I2C Python  Library from Adafruit

use command line

sudo apt-get install build-essential python-dev python-pip python-imaging python-smbus git

sudo pip install RPi.GPIO

git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git

cd Adafruit_Python_SSD1306
sudo python setup.py install


My Code on Github ( Edit from original ) and add some fonts ( Minecrafia.ttf )
https://github.com/amphancm/RaspberryPi_OLED


Reference
https://blog.jokielowie.com/en/2016/03/wyswietlacz-oled-ssd1306-i-raspberry-pi/

OLED Adafruit Python Library
https://github.com/adafruit/Adafruit_Python_SSD1306



My Website
email : info@softpowergroup.net   Tel .081-6452400

My Blog about Android and Arduino IoT



LINE : adunfong
FaceBook : https://www.facebook.com/adun.nantakaew
email: amphancm@gmail.com




วันอังคารที่ 6 ธันวาคม พ.ศ. 2559

5 Inch HDMI LCD Display for Raspberry Pi


 5 Inch HDMI LCD Display for Raspberry Pi with Touch Screen

Features:
Resolution: 800 x 480 px
Screen Type: Resistive screen
With backlight control switch
Working Voltage/Current: DC 5V / 2A
It's suitable for Raspberry pi series; and also support banana pi, pcduino or Cubieboard etc.( but the touch function is unavailable)
You can donw offical firmware and drivers from us to use it.
And you can use integrated firmware to use it.(the firmware with driver, is very easy. )
Package included:
1 x LCD module(with install screws)
1 x HDMI connector
1 x Touch pen

Setup for Full Screen

This model has 800 x 480 pixel resolution.
You need to some setup for set full screen display.


Edit file /boot/config.txt

uncomment the following line

hdmi_force_hotplug=1

uncomment and add the following line.

hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0




Setup Touch Screen

Download Driver http://www.waveshare.com/w/upload/4/4b/LCD-show-161112.tar.gz

then copy this driver to raspberry pi use WinSCP tools.



Use Command

$ tar xzvf LCD-show-161112.tar.gz

$ cd LCD-show

$ ./LCD5-show






Option Virtual Keyboard


Reference

http://www.waveshare.com/wiki/5inch_HDMI_LCD

http://www.electrodragon.com/w/RPI_LCD



My Website
email : info@softpowergroup.net   Tel .081-6452400

My Blog about Android and Arduino IoT


วันอาทิตย์ที่ 4 ธันวาคม พ.ศ. 2559

Raspberry Pi Smart Home Automation with Home Assistant



Raspberry Pi Smart Home Automation with Home Assistant

In the last article we know about OpenHAB Raspberry Pi Open Source smart home. In this blog we will know about Home Assistant Open Source smart home.


What is Home Assistant?

Home Assistant is Open Source Software for smart home or home automation systems.

Home Assistant is an open-source home automation platform running on Python 3.
Track and control all devices at home and automate control.

Home Assistant can install on many platforms such as Windows, Linux ,Mac OSX and embedded platforms such as Raspberry Pi , BeagleBone Black , UDOO , Cubietruck  so you can install in to Raspberry Pi. ( Raspberry pi is popular and low cost then we us Raspberry pi3 board)

Current Version: 0.33.4
Released: November 23, 2016

System Diagram



Hardware

You will need :
Raspberry Pi3 Board
SD card (8GB or more) we use 16 GB
Power supply
Ethernet or WiFi Connection


Software

Raspberry Pi OS
Raspbian Jessie – at the time of writing I have used version Sep 2016 which can be download from here – Raspbian Jessie

RASPBIAN JESSIE WITH PIXEL
Image with PIXEL desktop based on Debian Jessie
Version:September 2016
Release date:2016-09-23
Kernel version:4.4

Raspberry Pi Tools
For Windows User
PuTTY is SSH tools for Remote Command line. Download  moreinfo
WinSCP for remote edit and transfer files. Download  moreinfo

for Linux or MAC os
use terminal for remote command line. ( without installing additional software )
fugu ssh or Filezilla

How to Install Home Assistant on Raspberry Pi

There’s three options to install Home Assistant on a Raspberry Pi.

Manual installation. 
Following this guide doing each step manually. This is highly recommended as a first installation since you get a good overview of the installation.

Hassbian image. 
Basic installation with the same settings as following the manual installation guide. Some additional software is preinstalled to make installation quicker and easier. Installation uses homeassistant user.

All-in-One Installer. 
Fabric based installation script that installs and compiles many of the things an advanced Home Assistant install is likely to need. Installation uses hass user.


We use All-In-One Installer method to install.
Because there is including support for MQTT with websockets, Z-Wave, and the Open-Zwave Control Panel.

The only requirement is that you have a Raspberry Pi with a fresh installation of Raspbian Jessie connected to your network.

Run the following command

$ wget -Nnv https://raw.githubusercontent.com/home-assistant/fabric-home-assistant/master/hass_rpi_installer.sh && bash hass_rpi_installer.sh




VDO Install Home Assistant on Raspberry Pi


more info on Home Assistant
https://home-assistant.io/getting-started/installation-raspberry-pi/



My Website
email : info@softpowergroup.net   Tel .081-6452400

My Blog about Android and Arduino

วันพฤหัสบดีที่ 3 พฤศจิกายน พ.ศ. 2559

Raspberry Pi Smart Home with OpenHAB2


Raspberry Pi Smart Home with OpenHAB2

What is OpenHAB?

OpenHAB is Open Source Software for smart home or home automation systems.

Now Version is openHAB 2. ( Oct 2016 )

OpenHAB 2 is based on the Eclipse SmartHome framework and is fully written in Java.
OpenHAB can install on many platforms such as Windows, Linux ,Mac OSX and embedded platforms such as Raspberry Pi , BeagleBone Black , UDOO , Cubietruck  so you can install in to Raspberry Pi. ( Raspberry pi is popular and low cost )

System Diagram



Hardware


You will need:

Raspberry Pi Board 
SD card (8GB or more)
Power supply  
Ethernet or WiFi Connection

Software

Raspberry Pi OS
Raspbian Jessie at the time of writing I have used version Sep 2016 which can be download from here  Raspbian Jessie

RASPBIAN JESSIE WITH PIXEL
Image with PIXEL desktop based on Debian Jessie
Version:September 2016
Release date:2016-09-23
Kernel version:4.4

Raspberry Pi Tools
for Windows User
PuTTY is SSH tools for Remote Command line. Download  moreinfo
WinSCP for remote edit and transfer files. Download  moreinfo

for Linux or MAC os
use terminal for remote command line. ( without installing additional software )
fugu ssh or Filezilla



How to Install OpenHAB2

1.Update your Raspberry Pi first

sudo apt-get update
sudo apt-get upgrade


2.Install MQTT ( mosquitto ) on Raspberry Pi


First get the repository package signing key, import it into apt, and remove the key file after adding,
sudo wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
sudo rm mosquitto-repo.gpg.key



Then make the mosquitto repository available to apt:
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list

sudo apt-get update





Now we can install the core packages (server & clients):

sudo apt-get install mosquitto mosquitto-clients



3.Package Repository Installation


Now is Beta Release
Add the openHAB 2 Beta repository to your systems apt sources list (will overwrite your existing openhab2.list):
echo 'deb http://dl.bintray.com/openhab/apt-repo2 testing main' | sudo tee /etc/apt/sources.list.d/openhab2.list

Additionally, you need to add the openHAB 2 Bintray repository key to your package manager:
wget -qO - 'https://bintray.com/user/downloadSubjectPublicKey?username=openhab' | sudo apt-key add -

sudo apt-get update


4.Install add-ons

The offline distribution is full blown and comes with all add-ons


sudo apt-get install openhab2-offline



158 MB. take a time. Relax !


It take 1h 5min 2s ( Thailand only )



5.Start System Service

Start openHAB and register it to be automatically executed at system startup.

sudo systemctl start openhab2.service
sudo systemctl status openhab2.service

sudo systemctl daemon-reload
sudo systemctl enable openhab2.service




Open Web browser goto http://your raspberry pi ip address:8080



Now Install already. 
Then your must config some file for set your smart home automation system.


see next article... How to config file.



Reference

My Website
email : info@softpowergroup.net   Tel .081-6452400


My Blog about Android and Arduino

วันพุธที่ 2 พฤศจิกายน พ.ศ. 2559

Raspberry Pi MQTT Broker (Mosquitto)



Raspberry Pi MQTT Broker (Mosquitto)

What is Mosquitto?

Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1. MQTT.

Broker , Publisher , Subscriber


How to Install?


Update your Raspberry pi First.

sudo apt-get update
sudo apt-get upgrade




Install mosquitto developer api library

sudo apt-get install libmosquitto-dev



Install mosquitto

sudo apt-get install mosquitto mosquitto-clients


How to Test?

After installation Mosquitto will be automatically started. To test, install the MQTT.FX software. ( DownloadAfter installation issue following command into terminal window where we left after mosquitto installation
mosquitto_sub -d -t hello/world



Now open MQTT.FX and click on setting. Then enter IP address of your Pi and port address 1883 (by default) ( see pics below ). Click apply and connect





Connect Mosquitto Broker at Raspberry Pi IP Address


Publish Topic "hello/world" Payload "Test 123456789"


Mosquitto Broker received data.




My Website
email : info@softpowergroup.net   Tel .081-6452400


My Blog about Android and Arduino

วันพฤหัสบดีที่ 4 สิงหาคม พ.ศ. 2559

Raspberry Pi Web Server


Raspberry Pi Web Server

Learn to set up a LAMP (Linux, Apache, MySQL, PHP) stack on your Raspberry Pi and configure it to work as a web server.


INSTALL APACHE 
Apache is a popular web server application you can install on the Raspberry Pi.
Setting up an Apache Web Server on a Raspberry Pi.

First install the apache2 package by typing the following command in to the Terminal:

    sudo apt-get install apache2 -y



Test LocalHost use web browser and input your IP address. ( My IPaddress is 192.168.0.101 )

If you don't know your ip address use this command.



If It's work. show html page.




INSTALL PHP

PHP is a preprocessor. it's code that runs when the server receives a request for a web page. It runs, works out what needs to be shown on the page, then sends that page to the browser. Unlike static HTML, PHP can show different content under different circumstances. Other languages are capable of this, but since WordPress is written in PHP, that's what we need to use this time. PHP is a very popular language on the web; large projects like Facebook and Wikipedia are written in PHP.

Install the PHP and Apache packages with the following

command:
    sudo apt-get install php5 libapache2-mod-php5 -y



CHANGING THE DEFAULT WEB PAGE

This default web page is just a HTML file on the filesystem. It is located at /var/www/html/index.html

Note: The directory was /var/www in Raspbian Wheezy but is now /var/www/html in Raspbian Jessie


TEST php file

Create index.php file

Edit Code

Test on Browser

your_ip_address/index.php




INSTALL MYSQL

MySQL (pronounced My Sequel or My S-Q-L) is a popular database engine. Like PHP, its overwhelming presence on web servers enhanced its popularity. This is why projects like WordPress use it, and why those projects are so popular.

Install the MySQL Server and PHP-MySQL packages by entering the following command into the terminal:
    sudo apt-get install mysql-server php5-mysql -y

It will be take a long time.
When installing MySQL you will be asked for a root password. You'll need to remember this to allow your website to access the database.

Now restart Apache:
sudo service apache2 restart

INSTALL PHPMyAdmin
phpMyAdmin is an open source tool used for the administration of MySQL. In addition to offering the capability to perform administration tasks such as creating, editing, or deleting databases, and managing users and permissions, phpMyAdmin provides a graphical user interface to do all of these tasks and more.

   sudo apt-get install phpmyadmin -y

As the installation runs you’ll be asked a few simple questions regarding the basic configuration of phpMyAdmin.

At the first screen, select apache2 by using the space bar, then hit enter to continue.


At the second screen, which asks “configure the database for phpmyadmin with dbconfig-common?”, select Yes, then hit enter to continue.


At the third screen enter your MySQL password, then hit enter to continue.



TEST PHPMyAdmin

Open Web Browser
Goto your_ipaddress/phpmyadmin ( xxx.xxx.x.xx/phpmyadmin )
or http://localhost/phpmyadmin
You 'll see PHPMyAdmin Login Page.


Username is root and Your Password



Now You can use Raspberry Pi Web Server.



My Website
email : info@softpowergroup.net   Tel .081-6452400