MathWorks recently ran a hardware challenge, where in users were asked to submit a project in which they programmed hardware boards using MATLAB or Simulink. The grand prize for this challenge was 1000 USD and we received over 60 submissions for this challenge. Here is a link to the announcement page where you can read about the top 3 prize winners and also see their videos.
The announcement page also has a link to all the submissions for those who are interested in seeing the rest of the videos.
This tutorial is an overview of interacting with SQLite database using JDBC connector running on Raspberry Pi. It's not about learning SQlite. I have tried to show briefly how it can be done.
SQLite Getting STarted : http://goo.gl/UuQvzV
Java Application on Pi : http://goo.gl/5zGGME
Create SQLite Database JAVA : http://goo.gl/ZUI2Em
Create Table : http://goo.gl/nqP87g
Insert Data : http://goo.gl/u0JMjs
Show Data : http://goo.gl/nDegtY
Update Data : http://goo.gl/7bwaZx
Delete Data : http://goo.gl/OX6I3g
Subscribe : http://goo.gl/gM134X
Guys Subscribe to my channel for latest contents into your inbox.
Support me to keep going.
Twitter : http://goo.gl/1UVHjG
In this article we'll show how to stream live videos from your Pi to a web browser. The technology that we've used to achieve that is an MJPG-streamer application and a Raspberry Pi camera. Below is a preview of the end result.
You will need:
The first thing to do is to set up the camera and make sure it's working. Connect the camera to your Pi as show below with the blue marking on the camera tape connector facing the ethernet port.
After the camera is physically connected you have to enable it. This is done using the native Raspberry Pi configuration tool -
raspi-config. Run the tool using the command below.
A menu with different configuration options will appear. Navigate to Enable camera and press enter.
Select Yes option and press enter.
From the main menu exit
raspi-config by pressing the right arrow twice to navigate to the "<Finish>" option and press enter to exit. You will be prompted to reboot your Raspberry Pi for changes to take effect - select Yes.
To test that the camera is functioning correctly we'll take one image and save it to /home/pi using the command below.
raspistill -o /home/pi/image.jpg
When the command is executed you will see a camera preview appear on your display. The preview will stay on for few seconds and then an image will be taken.
The Raspberry Pi camera can appear in /dev as a standard USB video device (required by MJPG) if we load the "Video for Linux 2" (V4L2) module for the corresponding hardware (BCM2835). We do this as follows:
sudo modprobe bcm2835-v4l2
Upon successful execution of this command you should see Video0 device file inside
/dev directory. To verify, run the command below.
ls /dev | grep vid
sudo apt-get install update
sudo apt-get install upgrade
This project requires the presence of libjpeg-dev, imagemagick, libv4l-dev. Install them as follows:
sudo apt-get install libjpeg8-dev imagemagick libv4l-dev
The MJPG-streamer application doesn't come in a package form that we can install using
sudo apt-get install command. Instead, what we have to do is to download and compile it from source code.
Source code usually comes in the form of a "tarball" i.e. multiple files packed together into an archive using the tar utility and then compressed using gzip utility to reduce the size of the archive.
Download MJPG-streamer tarball using the command below.
Unpack the tarball as follows:
tar -xvzf mjpg-streamer.tar.gz
Make a symlink between two libraries that will be used to compile MJPG-streamer:
sudo ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.h
Navigate into MJPG-streamer directory and edit Makefile using your favourite editor.
In this file, comment out the input_gspcav1 plugin by inserting " # " at the beginning of the line, like so:
# PLUGINS += input_gspcav1.so
make to compile the program.
Compilation should only take couple of seconds and should produce no errors. When successful we'll have an MJPG-streamer application executable built.
The command below will run the server.
sudo ./mjpg_streamer -i "./input_uvc.so -f 10 -r 640x320 -n -y" -o "./output_http.so -w ./www -p 80"
If you see an output similar to the one below it means that the server is running correctly
If you haven't already done so, log in to your Dataplicity account and go to the device (e.g. the Pi) you want to link to. At the top of the page will be a link to 'Activate Wormhole'.
Press it and enable Wormhole. The link will contain your device ID.
To see our video stream embedded using HTML we'll go to the address below (remember to replace <YOUR_ID> with your device Wormhole URL from your Dataplicity account).
Below is an example of the video captured from the above URL.
You might find that sometimes your stream could crash, jitter or suffer high lag. This can happen if your Pi and/or your internet connection cannot sustain the video stream at the framerate and resolution you have selected
Breakdown of MJPG-streamer run command
The MJPG-streamer itself contains couple of options. In the above command that we used to run the server we've set two options:
The parameters that we've used for the input plugin are:
The parameters that output option takes that we're using are:
Accordingly, as we ran it above, mjpg_streamer was operating at a resolution of 640x320 and a framerate of 10 images per second. Here is the command to run it at a reduced 5 frames per second:
sudo ./mjpg_streamer -i "./input_uvc.so -f 5 -r 640x320 -n -y" -o "./output_http.so -w ./www -p 80"
There are four components in this system:
We start by assembling our LEDs on a breadboard as shown in schematic below:
Note that in this example we have chosen to connect our LEDs to pins 16 and 18 on the Raspberry Pi.
You can verify that LEDs are working by running the python script below:
import RPi.GPIO as GPIO
#Set GPIO pins as outputs
#Switch GPIO pins ON
#Wait 5 seconds
#Switch GPIO pins OFF
#Reset GPIO pins to their default state
To get remote access to your Raspberry Pi please visit www.dataplicity.com(free sign up) and follow the installation instructions to get remote terminal access to your Pi. When done, locate your device in your dataplicity account and click "Enable wormhole". You'll then need the wormhole address which can be found just above the remote shell (see below).
Run the Project
Step 1 : Click the link below to download all the code necessary for this project.
Step 2 : Run the server.
If you don't have tornado framework installed for python please type in the command below.
sudo pip install tornado
Open the "ws-webio" directory in terminal and run the command below.
sudo python server.py
When done you should see a printout informing you that Tornado server has started.
In your browser type in:
If the webpage loads correctly you should see it in your browser and get additional printouts in your terminal.
Click the buttons on the page to switch ON/OFF the LEDs !
Now that you've got the project set up and running if you would like to know a bit more on how it works "behind the scenes" please read further.
> Inside the web browser
On page load:
After all the files have loaded, the browser component looks like this.
Note there are two communication channels with the Raspberry Pi - one for the static files and one for the long-running WebSocket command channel.
> Inside the application server (Tornado)
In this example, the web application server is running inside a Python web framework called "Tornado" (see http://www.tornadoweb.org/en/stable/). All of the files are prepared in the "ws-webio" folder, with "server.py" hosting the receiving end of the WebSocket.
The diagram below illustrates what is happening inside "ws-webio" folder when the "server.py" application is running, and how each piece of code interacts with each other.
I want to introduce a new enclosure project for the Pi Zero. It's a new din rail housing and protoboard with integrated voltage regulator.