tngotran / homeHubControl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

original tutorial link http://arduino.vn/tutorial/1396-toi-da-tu-lam-robot-voi-raspberry-pi-va-arduino-nhu-nao-phan-2-dieu-khien-den-led-tu
password of pi is 1

-----set up raspbery-------
Enable wifi/ethernet
Allow ssh (either console or via command)

------ install environment----------
1. Install apache2 -> type the ip of raspbery on a web broswer to see if apache2 server run or not
2. Install php (tested and work for version 7.4) -> type php -v in the terminal to see if php has been installed or not
   Install mpg321 via sudo apt	
3. go to directory /var/wwww/html
Delete the default index.html file and copy all files from the repository and paste to /var/wwww/html or folder of apache2

4. go to /var/www/html , open terminal, type sudo chmod 777 -R .
check the permission again on terminal
ls -l 
all files should be now rwxrwxrwx

5. type in terminal: sudo visudo
add this line to the end of the file
www-data ALL=(ALL) NOPASSWD: ALL
then reboot

-----------check the system-----------------
Find the ip of the raspebery and type it to any web browswer (either phone or computer). Click on the file control.php
You should see volume available

the main control board is the file the control.php
use ifconfig to get the ipaddress of the raspebry
the local server is automatically run
type the ip address on the Chrome/firefox

click on control.php
 - The playlist1,2,3 linked with the youtube channel
 - Type keywords and then search the youtube videos. Click on playthis to play that video. This script functions to play autoplay on youtube.
 - Remember to get the youtube KEY API and substitute to the control.php line gapi.client.setApiKey
 - in order to see the updated volume, refresh/F5 your webpage
 - to copy the music from master to pi rsync -ah --progress /home/tony/Downloads/music.mp3 pi@192.168.0.31:/var/www/html/
- cut mp4 into smaller file
ffmpeg -i bird.mp4 -ss 00:00:20 -c copy -t 1:00:00 bird_out.mp4
00:00:20 is starting time (20 sec)
1:00:00 is duration of the output
-  Convert mp4 to mp3
ffmpeg -i bird_out.mp4 -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 bird.mp3





========================================================================================================
DEBUGGING 
	 - check ip of raspberry by command `ifconfig`
	 - ssh to your raspbery `ssh pi@192.168.1.abc`
 
	 - how to install selenium:
	 - pip install selenium

	 - ERROR1: geckodriver need to be in PATH
		  1. check your system by uname -a then
		  2. downdload the geckodriver from website https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path
		  3. cp geckodriver /usr/local/bin

	 - ERROR2: OSError: [Errno 8] Exec format error:-> this error is related to your downloaded geckodrive use uname -i to chekc
	 - ERROR3: open random youtube videos. When checking with terminal ./stream "ANY_YOUTUBE_LINK_ID", seeing error related to signature/extractor error, requiring update. Reason: we have to update youtube-dl sometimes because youtube change their request youtube method. Then update to youtube-dl by try first  "pip3 install youtube-dl -U". If faile, try the commands on the original website. Follow this link:


https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl
specifically, looking for the commands below also written in the website

""""""""""""""""""""""
sudo apt-get remove -y youtube-dl
Afterwards, simply follow our manual installation instructions:

sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
hash -r
youtube-dl --version ->>compare with the lastest version on the website

""""""""""""""""""""""




	 - ERROR4: If there is any error related to LC_ALL cannot set localation. then try sudo raspi-config then go to locate setting to check if the LC_ALL was set or not. If not then open the /etc/environment and type this line LC_ALL="en_GB.utf8"  and restart the raspibi and run the mspyt again


==========================================================================================================

TIPs:
	1. open the console F12 in chrome to see the log -> to check if the search function returns correct youtube links
	2. ./stream "YOUTUBE_LINK_ID" to test the stream bash command. Most of time error happen here. 
	3. open terminal -> htop to see the actual playing link
==========================================================================================================


CREDIT:
The mpv can stream and play from youtube much better than the mpsyt
the script streamMedia get from this account 'https://github.com/i-PUSH/arch-setup-i3wm/blob/master/config/home/.bin/streamMedia.sh'

About


Languages

Language:PHP 60.6%Language:Roff 21.9%Language:Shell 17.5%