วันพุธที่ 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


วันจันทร์ที่ 18 กรกฎาคม พ.ศ. 2559

Raspberry Pi linux Command Line

Raspberry Pi linux Command Line

Useful Commands Every Raspberry Pi User Should Know.
If you’re using a Raspberry Pi for your project.
Then you'd know command line instructions will save you some time.


File/Directory Commands

ls


ls -l


lsusb


whereis


Networking/Internet Commands

sudo apt-get update


sudo apt-get upgrade


hostname


hostname -l


ifconfig


iwconfig


netstat



System Information Commands

raspi-config



cat /proc/version



cat /proc/cpuinfo



cat /proc/meminfo



cat /proc/partitions



vcgencmd measure_temp




Shutdown and restart

sudo shutdown -r now

sudo reboot


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