An unattended Raspberry PI 3 with webcam and Infrared remote control
Remotely connect via web to a Raspberry PI, equipped with an audio class D amplifier, a loudspeaker and optionally with a HDMI screen, to:
- issue IR commands to a TV or similar
- view the USB camera connected to the PI
- listen from the USB microphone connected to the PI
- The uv4l software platform with uv4l web and streaming servers run in the PI.
- The lirc (infrared) library is installed on the PI.
- See the logic diagram below also.
1. Audio Ampilfier. I Chose a PAM8403 5V 3W Class D Audio Ampifier like this
0. I used a Raspberry PI 3 Model B Scheda madre CPU 1.2 GHz Quad Core, 1 GB RAM bought at Amazon
- Stretch " 2018-11-13-raspbian-stretch.zip" downloaded and with "installation guide" at Download Raspbian Stretch
- DON'T DON'T DON'T install any newer version of the Raspian Kernel than this (Linux 4.14). Otherwise IR infrared transmitter won't work! Never do "sudo apt-get upgrade"
3. (Optional, if you don't have screen, keyboard and mouse) Prepare the SD you just created for headless operations following these instructions. See also Raspbian Stretch Headless Setup Procedure
0. I tested "Logitech C525" and "Trust SPOTLIGHT PRO" succesfully. Simply plug it into any USB port. Both have an integrated microphone but if yours doesn't have it, plug a USB microphone in any USB port.
1. Test your USB webcam with chromium-browser navigating to a site like this webrtc Hacks
2. Test your USB microphone (integrated with the webcam or not) with chromium-browser navigating to https://www.google.com and using the speech recognition
Install the uv4l library. For details see also UV4L for Raspberry PI Installation Procedure
$ curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add -
$ deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main
$ sudo apt-get update
$ sudo apt-get install uv4l uv4l-server uv4l-uvc uv4l-webrtc
- After rebooting, uv4l is supposed to be installed and available for next use.
Navigate to http://localhost:8090 This page should appear:
This page should appear: [](htt### ps://github.com/guido57/IReye/blob/master/screenshots/UV4L%20Streaming%20Server%20-%20Web%20RTC.PNG)
6. Clicking on Call (the green button) the image of your camera should appear on the "remote" rectangle
For Google Chrome and other recent browsers versions is mandatory to use https insead of http.
sudo openssl genrsa -out selfsign.key 2048 && sudo openssl req -new -x509 -key selfsign.key -out selfsign.crt -sha256
$ sudo mv selfsign.* /etc/uv4l/
#HTTPS options:
server-option = --use-ssl=yes
server-option = --ssl-private-key-file=/etc/uv4l/selfsign.key
server-option = --ssl-certificate-file=/etc/uv4l/selfsign.crt
In Raspian Buster only it looks like the environment OPENSSL_CONF='/etc/ssl/' is not set. For this reason, uv4l works fine with http but it doesn't with https. Therefore add the line
Environment="OPENSSL_CONF='/etc/ssl/'"
to /etc/systemd/system/uv4l_uvc@.service in this way:
[Unit]
Description=UV4L UVC driver
[Service]
Type=simple
Environment="OPENSSL_CONF='/etc/ssl/'" # <------------ this line added
ExecStart=/etc/init.d/uv4l_uvc add %I
ExecStop=/etc/init.d/uv4l_uvc remove %I
RemainAfterExit=yes
KillMode=none
4. After rebooting, verify thathttps://localhost:8090 is accessible by your Raspberry PI browser
pcm.!default {
type asym
capture.pcm "mic"
playback.pcm "speaker"
}
pcm.mic {
type plug
slave {
pcm "hw:1,0"
}
}
pcm.speaker {
type plug
slave {
pcm "hw:0,0"
}
}
2. after rebooting your USB microphone will be the default one and your RPI speaker (the headphone jack) will be the default speaker.
arecord --list-pcms
my working result is:
hw:CARD=C525,DEV=0
HD Webcam C525, USB Audio
Direct hardware device without any conversions
which is at the 11th position (starting from 0) in the list. Now uncomment and set the following line in /etc/uv4l/uv4l-uvc.conf
server-option = --webrtc-recdevice-index=11
After rebooting, even the USB microphone should work when uv4l web server is called at: https://your_raspberry-PI_IP_address:8090/stream/rtc/
sudo apt-get install lirc
In my Raspberry PI 3 circuit, the infrared receiver is connected at GPIO 23 (connector pin 16) while the infrared LED transmittter at GPIO 22 (connector pin 15). Change them accordingly to your circuit.
lirc_dev
lirc_rpi gpio_in_pin=23 gpio_out_pin=22
LIRCD_ARGS="--uinput --listen"
LOAD_MODULES=true
DRIVER="default"
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
See point 2 for the correct pin settings.
dtoverlay=lirc-rpi,gpio_in_pin=23,gpio_out_pin=22
driver = default
device = /dev/lirc0
sudo /etc/init.d/lircd stop
sudo /etc/init.d/lircd start
sudo /etc/init.d/lircd status
then reboot
sudo reboot
To test if lirc driver is working, firstly stop the lirc deamon:
sudo /etc/init.d/lircd stop
then start a continuos IR receiver:
mode2 -d /dev/lirc0
now try to press a key of any infrared remote control in front of the IR LED receiver and you should see multiple lines like below
pulse 560
space 1706
pulse 535
sudo pip install Flask
sudo pip install Flask-BasicAuth
sudo touch IRsend.log
sudo chown pi: IRsend.log
sudo systemctl start IRsend
You should see something like this:
pi@raspberrypi:/usr/share/uv4l/www $ sudo systemctl status IRsend
● IRsend.service - Flask web app to send IR commands to a TV
Loaded: loaded (/etc/systemd/system/IRsend.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2019-08-09 21:24:07 BST; 7ms ago
Main PID: 6556 (python)
CGroup: /system.slice/IRsend.service
└─6556 /usr/bin/python IRsend.py > IRsend.log 2>&1
Aug 09 21:24:07 raspberrypi systemd[1]: Started Flask web app to send IR commands to a TV.
sudo systemctl stop IRsend
sudo systemctl enable IRsend
Navigate to: https://localhost/webrtcir.html:8092
In this way your IReye can be reached using VNC or SSH and properly configured.
Follow this instructions Set a Raspberry WIFI hotspot (access point) and client