Raspberry-Pi live streaming using web cam - raspberry-pi

I am new with RASPBERRY PI . But i've successfully completed a project with the use of Brick Pi which is actually a WIFI based moving car. Now i want to enable live camera streaming to my project. Can i do it using my USB webcam ?
I actually want to stream it on any browser.
If YES, how can i achieve it ?
Is there any better solution than using a webcam ?

Install MJPG-streamer on your Rasperry Pi
sudo apt-get install libjpeg8-dev imagemagick libv4l-dev
sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h
git clone https://github.com/jacksonliam/mjpg-streamer.git
and then you can use a command like this:
mjpg_streamer -i “/usr/local/lib/input_uvc.so" -o “/usr/local/lib/output_http.so -p 9000 -w www”
You can check out this tutorial by Tinkernut, which basicly does what you want as well as some other cool stuff

Related

Running AWS CloudWatch logs agent on Raspberry Pi 4

Has anybody successfully run the AWS CloudWatch Logs Agent on a Raspberry Pi 4?
When I run the script below, it appears to work, but the awslogs.service does not get created.
curl https://s3.amazonaws.com//aws-cloudwatch/downloads/latest/awslogs-agent-setup.py -O
I suspect it simply isn't compatible, so I what to see if anybody else had success. Any other suggestions for centralized logging for a Raspberry Pi cluster?
I ended up re-imaging my Raspberry Pi 4 with the 64 bit Raspberry Pi OS, at which point I was able to follow the instructions to download and install the .deb file for ARM64 Ubuntu on https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/download-cloudwatch-agent-commandline.html.
cd /opt
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/arm64/latest/amazon-cloudwatch-agent.deb
sudo dpkg -i -E ./amazon-cloudwatch-agent.deb

How to run Google Assistant library (on AIY kit), upon startup of Raspberry Pi?

We set up a voice kit using Raspberry Pi (using "the MagPi essentials AIY Projects" manual). We are able to enable Google Assistant using the command "src/assistant_library_demo.py" in the dev terminal, after Raspberry Pi starts up. We would like to embed the voice kit in a stuffed animal with a portable power supply (i.e., used to charge cell phone on the go). But when the portable power supply is charged, the Raspberry Pi resets. That requires us to go back into the Raspberry Pi, open the dev terminal, and run the Google Assistant file.
My question: Is it possible to run a startup script that automatically runs Google Assistant upon Raspberry Pi starting up? How to do this?
I ended up creating a crontab job after a 10 second wait. Starting right at boot didn't give it enough time for the internet to connect fully.
In terminal type:
crontab -e
Choose an option if it asks how you want to open/edit the file. Then at the bottom put:
#reboot sleep 10 && /home/pi/pathtofile > /home/pi/cronlog 2>&1
Save the file and reboot or pull the cable out and plug it back in. The cronlog helped me troubleshoot this whole process and get feedback on why it didn't work.
Take a look at this page. It tells you how to set up a service which will run automatically.
If the link has gone bad, here is a short explanation of it:
Create a file called my_assistant.service in the src directory, and put in the following code
[Unit]
Description=My awesome assistant app
[Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000
ExecStart=/bin/bash -c 'python3 -u src/my_assistant.py'
WorkingDirectory=/home/pi/AIY-projects-python
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
Where the file says src/my_assistant.py, replace my_assistant with your program's filename. Now go to the folder that file the .sevice file is in, and run the command sudo mv my_assistant.service /lib/systemd/system/. This code moves the file to the services folder. Now you can run the following commands to change the service:
Enable the service- sudo systemctl enable my_assistant.service
Disable it- sudo systemctl disable my_assistant.service
Start it (just runs it once, enabling makes it run on startup)- sudo service my_assistant start
Stop it- sudo service my_assistant stop
See the logs, when the program was started and if an error occurred- sudo service my_assistant status

Pi 3 + Microstack GPS communication

I bought a Raspberry Pi 3 Model B, a microstack baseboard and a microstack GPS.
I followed the instructions written in the official documentation but I can't connect to the GPS.
Basically, the GPS led flashes so it means it has find a gps fix, but I can't see any data from the PI.
For example, if I try
cat /dev/ttyAMA0
I get always nothing. I already used raspi-config to disable kernel serial and to enable i2c and spi.
Also if I try
stty -F /dev/ttyAMA0 ispeed 4800 && cat </dev/ttyAMA0"
I get an error.
Anyone has any advice, please?
Or maybe these modules are not compatible with Pi 3?
Thanks a lot!
It's hard telling what has been done, or not done. The 'official' documentation from Microstack provides two methods of setting up the serial port. It then continues with
Automatically Starting gpsd
To automatically start the gps service when the Raspberry Pi® boots, re­configure the GPS
daemon by typing into a terminal
sudo dpkg-­reconfigure gpsd
● Choose <yes> when asked if you want to start gpsd automatically.
● Choose <no> when asked “should gpsd handle attached USB GPS
receivers automatically” .
● When asked which “Device the GPS receiver is attached to” , enter
/dev/ttyAMA0 .
● Accept the defaults for other options.
If you have configured your serial port as per instructions and configured gpsd to automagically start and pick up the device you have just setup, ...then, since the gpsd is handling the device (right?), the device will be busy and the command cat /dev/ttyAMA0 should return cat: /dev/ttyAMA0: Device or resource busy...but, it did not.
Either the serial is not configured as per instructions, or the gpsd is not running and picking up the device, or both.
The goal is not to cat your gps data, but the cat not returning an error indicates something is amiss.
Typically, it's just a typo. But it can be from skipping a step in the process, or mixing instructions from various sources so that the left hand doesn't know what the right hand has done.
Try:
sudo killall gpsd if it returns gpsd: no process found that answers one question.
If it returns with no error, follow it up with cat /dev/ttyAMA0. If it returns nothing, the direction you should look is your serial port configuration.
If sudo dpkg-reconfigure gpsd is not allowing you to reconfigure (I thought it was just me) you can modify the configuration of gpsd by using your favourite editor, e.g. sudo nano /etc/default/gpsd and entering something like:
# Default settings for the gpsd init script and the hotplug wrapper.
# Start the gpsd daemon automatically at boot time
START_DAEMON="true"
# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="false"
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyAMA0"
# Other options you want to pass to gpsd
GPSD_OPTIONS="-n -G"
You may find the -n and -G useful. Save and restart.
I finally found a solution:
On the Pi 3, there are more steps to use serial, you have to disable the BT.
Edit config file:
sudo nano /boot/config.txt
Add this at the bottom:
dtoverlay=pi3-disable-bt-overlay
Then run this:
sudo systemctl disable hciuart
This article was very usefull for me
http://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/#comment-67160
and i recommand you to read it
Now on RPI3 the Serial port
ttyAMA0 is used by BlueTooth
ttySO refers to the GPIO
The Alias Serial0 refers to the GPIO both on RPI2 and RPI3.
So :
after a reinstallation of Jessie with a recent version to be sure all is clean
as usual
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo raspi-config
go to Advanced options : Would you like a login shell to be accessible over serial? response "yes" (not as in the microstack datasheet )
$ sudo apt-­get install python3-­microstacknode
To install the gpsd standard tools
$ sudo apt­-get install gpsd gpsd-­clients python­-gps
edit GPSD by
$ sudo nano /etc/default/gpsd
and put the options :
START_DAEMON="true"
USBAUTO="false"
DEVICES="/dev/serial0"
GPSD_OPTIONS="-n -G"
equally
$ sudo nano /boot/cmdline.txt
remove
console=serial0,115200
and save
$ sudo nano /boot/config.txt
you must have at the end
enable_uart=1
Disable the console by
$ sudo systemctl stop serial-getty#ttyS0.service
$ sudo systemctl disable serial-getty#ttyS0.service
i have equally done $ sudo chmod 775 ../../dev/ttySO ( i dont know if it is really necessary )
and obviously a reboot
and miracle the gps works with
cgps -s
NB: you must have a fix on the GPS ( the red led flashes )
jpherrenknecht

How to measure network contention

I have rasberry pi with a 3G shield connected to it. Is there a way to gather metrics about the network such as available data capacity/throughput, latency and way to measure contention on the network?
I am assuming that you want to know the statistics for your connection to the internet.
There is a great Command-Line tool for this by sivel which you can install from the command line using:
sudo pip install speedtest-cli
or
sudo easy_install speedtest-cli
and then just run it with the command:
speedtest-cli
and it will give you the results.
For more information please see the project page on GitHub: https://github.com/sivel/speedtest-cli

Raspberry PI iBeacon

I am a new contributor to this site so please cut me some slack if this question sounds too simple. I have been using to Pi devices as iBeacon readers for a few weeks and i was able to find my LE beacons with no problem using hcitool lescan and hcidump. The problem i am facing now is that for some reason when i run hcitool lescan i see my devices, but hcidump doesn't see to be working - it doesn't even seem to run.
Since hcitool lescan works i know that the devices are working and that my Pi can find them.. but i need the hcidump to work as my code pulls from this output for my programs to run properly.
Any thoughts on what could be causing this? What information can I provide to help you understand the situation better?
This is a known bug with bluez.
To rectify it you simply need to shut down the Bluetooth interface and re-enable it.
sudo hciconfig hci0 down
sudo hciconfig hci0 up
hci0 being the interface of your Bluetooth dongle.
You can then run the dump simultaneously with the scan:
sudo hcitool lescan --duplicates & sudo hcidump -w file.txt