Wednesday, 21 September 2016

Pay digitally without internet connection

Sound waves technology is going to be the next big disruptor
Sound waves are emerging as a potential game-changer for digital payments. The technology is making financial transactions possible between devices without the need for internet connectivity or communication tools such as NFC, widening the scope for digital payments. J Vignesh gives a lowdown on how the technology works:

How can you pay with sound? You can use a mobile app equipped with sound-based payments technology to make purchases at a store by placing your phone near the merchant's device. The app has to be linked to your bank or credit card accounts or digital wallets. The transaction happens over sound waves. Bengaluru-based ToneTag and UltraCash have developed sound-based payments technology that function independently or can be integrated with the platforms of banks or digital wallets. Digital wallet Paytm earlier this year announced it was testing sound waves-based technology for payments.

How it works
An algorithm is used to encode data into sound waves which can be transmitted for making offline payments. It has to be integrated at both ends — the buyer's mobile phone as well as the merchant's phone or card readers. There is no need for any additional hardware. A transaction is initiated when a merchant's device generates sound containing the encrypted payment data. This data is received by the microphone on the buyer's phone.

Sound is an analog signal, which means it is continuous. So, when the merchant initiates the payment by entering the bill amount on his device, the algorithm converts the numbers (digital) into analog format. During this conversion, the digital signal is massaged with encryption. An error-detecting code is used to detect any accidental changes to the raw data.

The analog data is transmitted through the merchant's device as a sound signal to the buyer's phone. The buyer needs to place their phone near the merchant's device to receive the bill. The buyer's phone does the reverse of the above steps and decrypts the data, so the bill is readable. The buyer then makes the payment through a digital wallet or debit or credit card.

Google launches Allo in the play store

Google launches Allo in the play store; here is how to get started

Image Credit: Google Play Store
1




By
Google has finally launched the much anticipated messaging app by the company, Google Allo. It was previously reported that that messaging app would launch today. Allo is the part of communication platform made in conjunction with Google Duo. Duo was released some time back by the company, and it focused on video whereas Google Allo is focused on text communication along with sending media such as photos, audio messages, stickers and locations.
Google Allo
You can start using Allo by going to Google Play Store and installing it on your Android device. The interface is pretty bare bones but quite functional for a messaging app. When you launch the app for the first time, the app asks you to verify your mobile number similar to how things work on Google Duo. The SMS verification servers seem to be in place for Allo verification. After the verification, the app asks you to set a profile picture and name.
Google Allo
Google Allo main screen
The app interface is reminiscent to how Google Hangout looks like (but without all the features in Hangouts). Nothing has changed since the leaked screenshots for Google Allo in alpha stage. On launching, you get the first (and only) surprise that Google Allo holds, that is “Google Assistant”, the bot by Google while will replace Google Now in the upcoming update, Android Nougat 7.1. It is a vital part of the experience provided by Google Assistant and a step away from how popular messaging apps work. Google Assistant is what Cortana from Microsoft and Siri from Apple are, but inside a chat window currently. The bot is labelled as ‘Preview Edition’ but in the limited tests that we ran, Assistant left us impressed coming from Google Now as the previous native offering in Android.
Google Allo
Google Assistant
While diving into the chat experience, Allo does the basics of sending text, photos shot from the front or back camera, pictures from gallery, stickers and location. You can send 20 photos at a time in Allo from the ten photos limited on WhatsApp. Another small change is that in the notifications area, the app shows smart response as a quick reply to contacts who message you. Machine learning is working full time to suggest bubble shape cards in the chat as appropriate message responses to the conversations. Finally, you can search inside your conversations, as against the searchless realm that Google Hangouts are.
Google Allo
Sticker Store, Template replies
There is nothing new when you dive in the Profile section or the General settings menu, and there are just small things like controlling the notifications, sounds, vibration and to download the media when you receive it. There is no status updates or message that you can set for people in your contact list to read.
Google Allo
Incognito Chats
The reason we mentioned that the chatting experience is different from how it is in the conventional messaging is apps is that you can summon Google Assistant in your private conversations to ask questions, play games or device on dinner options or the movie options. This brings a whole different side to the concept of user privacy and the only remedy seen is the use of incognito chat with other users.
Google Allo
Google Allo turns into Snapchat
Incognito mode features auto-destruct messages just like Snapchat which expire after a fixed amount of time depending on the settings. Infact, you can turn Google Allo into an almost functioning Snapchat clone except Stories or ability to check who saw your stories.
Google Allo
Group conversations
The summon behaviour is consistent across individual as well as group chats where you can call in Google Assistant to ask questions and suggestions on places nearby. However, you can’t tag Google Assistant in incognito chats. Apart from this nothing much stands out in the latest messaging app by Google, Google Allo.

Thursday, 15 September 2016

A better way to mine gold from old electronics


There's gold in dem dar electronics!
There's gold in dem dar electronics! (Credit: webandi/Pixabay)
When you get rid of an old phone or tablet, you're likely to remove your valuable information from it, but what about the valuable materials – like gold – that it contains?
Naturally, such substances are too hard for consumers to retrieve, which might be why, according to the University of Edinburgh (UE), about seven percent of the world's gold supply is currently locked inside of electronics. While removing that gold has heretofore been a highly toxic and inefficient proposition, researchers now think that a new process will make prospecting for gold in electronics heaps more achievable than ever.
Gold is often found on printed circuit boards, particularly under keyboards where its durability is an advantage. According to the UE researchers, about 300 tonnes of the metal are used in electronics each year.
The new process to remove it uses a mild acid as opposed to harsher chemicals such as cyanide or mercury that are currently used to extract gold.
First, printed circuit boards are dissolved in the acid which turns all of the metal in the board to liquid. Then, an oily solvent made from toluene is added, kicking off a process known as solvent extraction. Toluene is an aromatic hydrocarbon commonly found in paint thinners. The toluene solvent pulls the gold free from the other materials in the acid wash where the metal can be recovered and used again. Likewise, the solvent and acid can be reused, cutting down on waste.
"The solvent extraction technique is great in that the recycling of reagents and acid are integral to the process," lead researcher Jason Love of UE's School of Chemistry told New Atlas.
Love also says that it might be possible to extract other metals using the process.
"Once you have dissolved metals in acid, you can use solvent extraction to separate all of them," he said. "So, in principle, we could devise a process that would be able to separate all of the metals in electronic waste, which of course would have environmental and potentially economic benefits, but this would depend on the prices of metals and the cost of the process."
The work Love and his team carried out is part of a student- and staff-led initiative at UE to promote the circular economy, which focuses on the efficient use of materials and their reuse as well.

Wednesday, 14 September 2016

Ultrasonic Range Sensor interfacing with Raspberry Pi

In previous tutorials we've outlined temperature sensing, PIR motion controllers and buttons and switches, all of which can plug directly into the Raspberry Pi's GPIO ports. The HC-SR04 ultrasonic range finder is very simple to use, however the signal it outputs needs to be converted from 5V to 3.3V so as not to damage our Raspberry Pi! We'll introduce some Physics along with Electronics in this tutorial in order to explain each step!
What you'll need:
HC-SR04
1kΩ Resistor
2kΩ Resistor
Jumper Wires
Ultrasonic Distance Sensors
Sound consists of oscillating waves through a medium (such as air) with the pitch being determined by the closeness of those waves to each other, defined as the frequency. Only some of the sound spectrum (the range of sound wave frequencies) is audible to the human ear, defined as the “Acoustic” range. Very low frequency sound below Acoustic is defined as “Infrasound”, with high frequency sounds above, called “Ultrasound”. Ultrasonic sensors are designed to sense object proximity or range using ultrasound reflection, similar to radar, to calculate the time it takes to reflect ultrasound waves between the sensor and a solid object. Ultrasound is mainly used because it’s inaudible to the human ear and is relatively accurate within short distances. You could of course use Acoustic sound for this purpose, but you would have a noisy robot, beeping every few seconds. . . .
A basic ultrasonic sensor consists of one or more ultrasonic transmitters (basically speakers), a receiver, and a control circuit. The transmitters emit a high frequency ultrasonic sound, which bounce off any nearby solid objects. Some of that ultrasonic noise is reflected and detected by the receiver on the sensor. That return signal is then processed by the control circuit to calculate the time difference between the signal being transmitted and received. This time can subsequently be used, along with some clever math, to calculate the distance between the sensor and the reflecting object.

The HC-SR04 Ultrasonic sensor we’ll be using in this tutorial for the Raspberry Pi has four pins: ground (GND), Echo Pulse Output (ECHO), Trigger Pulse Input (TRIG), and 5V Supply (Vcc). We power the module using Vcc, ground it using GND, and use our Raspberry Pi to send an input signal to TRIG, which triggers the sensor to send an ultrasonic pulse. The pulse waves bounce off any nearby objects and some are reflected back to the sensor. The sensor detects these return waves and measures the time between the trigger and returned pulse, and then sends a 5V signal on the ECHO pin.
ECHO will be “low” (0V) until the sensor is triggered when it receives the echo pulse. Once a return pulse has been located ECHO is set “high” (5V) for the duration of that pulse. Pulse duration is the full time between the sensor outputting an ultrasonic pulse, and the return pulse being detected by the sensor receiver. Our Python script must therefore measure the pulse duration and then calculate distance from this.
IMPORTANT. The sensor output signal (ECHO) on the HC-SR04 is rated at 5V. However, the input pin on the Raspberry Pi GPIO is rated at 3.3V. Sending a 5V signal into that unprotected 3.3V input port could damage your GPIO pins, which is something we want to avoid! We’ll need to use a small voltage divider circuit, consisting of two resistors, to lower the sensor output voltage to something our Raspberry Pi can handle.
Voltage Dividers
A voltage divider consists of two resistors (R1 and R2) in series connected to an input voltage (Vin), which needs to be reduced to our output voltage (Vout). In our circuit, Vin will be ECHO, which needs to be decreased from 5V to our Vout of 3.3V.

The following circuit and simple equation can be applied to many applications where a voltage needs to be reduced. If you don’t want to learn the techy bit, just grab 1 x 1kΩ and 1 x 2kΩ resistor.

Without getting too deep into the math side, we only actually need to calculate one resistor value, as it’s the dividing ratio that’s important. We know our input voltage (5V), and our required output voltage (3.3V), and we can use any combination of resistors to achieve the reduction. I happen to have a bunch of extra 1kΩ resistors, so I decided to use one of these in the circuit as R1.
Plugging our values in, this would be the following:

So, we’ll use a 1kΩ for R1 and a 2kΩ resistor as R2!
Assemble the Circuit
We’ll be using four pins on the Raspberry Pi for this project: GPIO 5V [Pin 2]; Vcc (5V Power), GPIO GND [Pin 6]; GND (0V Ground), GPIO 23 [Pin 16]; TRIG (GPIO Output) and GPIO 24 [Pin 18]; ECHO (GPIO Input)

1. Plug four of your male to female jumper wires into the pins on the HC-SR04 as follows: Red; Vcc, Blue; TRIG, Yellow; ECHO and Black; GND.

2. Plug Vcc into the positive rail of your breadboard, and plug GND into your negative rail.
3. Plug GPIO 5V [Pin 2] into the positive rail, and GPIO GND [Pin 6] into the negative rail.

4. Plug TRIG into a blank rail, and plug that rail into GPIO 23 [Pin 16]. (You can plug TRIG directly into GPIO 23 if you want). I personally just like to do everything on a breadboard!

5. Plug ECHO into a blank rail, link another blank rail using R1 (1kΩ resistor)
6. Link your R1 rail with the GND rail using R2 (2kΩ resistor). Leave a space between the two resistors.

7. Add GPIO 24 [Pin 18] to the rail with your R1 (1kΩ resistor). This GPIO pin needs to sit between R1 and R2

That's it! Our HC-SR04 sensor is connected to our Raspberry Pi!


Sensing with Python
Now that we’ve hooked our Ultrasonic Sensor up to our Pi, we need to program a Python script to detect distance!
The Ultrasonic sensor output (ECHO) will always output low (0V) unless it’s been triggered in which case it will output 5V (3.3V with our voltage divider!). We therefore need to set one GPIO pin as an output, to trigger the sensor, and one as an input to detect the ECHO voltage change.
First, import the Python GPIO library, import our time library (so we make our Pi wait between steps) and set our GPIO pin numbering.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
Next, we need to name our input and output pins, so that we can refer to it later in our Python code. We’ll name our output pin (which triggers the sensor) GPIO 23 [Pin 16] as TRIG, and our input pin (which reads the return signal from the sensor) GPIO 24 [Pin 18] as ECHO.
TRIG = 23
ECHO = 24
We’ll then print a message to let the user know that distance measurement is in progress. . . .
print "Distance Measurement In Progress"
Next, set your two GPIO ports as either inputs or outputs as defined previously.
GPIO.setup(TRIG,GPIO.OUT)
GPIO.setup(ECHO,GPIO.IN)
Then, ensure that the Trigger pin is set low, and give the sensor a second to settle.
GPIO.output(TRIG, False)
print "Waiting For Sensor To Settle"
time.sleep(2)
The HC-SR04 sensor requires a short 10uS pulse to trigger the module, which will cause the sensor to start the ranging program (8 ultrasound bursts at 40 kHz) in order to obtain an echo response. So, to create our trigger pulse, we set out trigger pin high for 10uS then set it low again.
GPIO.output(TRIG, True)
time.sleep(0.00001)
GPIO.output(TRIG, False)
Now that we’ve sent our pulse signal we need to listen to our input pin, which is connected to ECHO. The sensor sets ECHO to high for the amount of time it takes for the pulse to go and come back, so our code therefore needs to measure the amount of time that the ECHO pin stays high. We use the “while” string to ensure that each signal timestamp is recorded in the correct order.
The time.time() function will record the latest timestamp for a given condition. For example, if a pin goes from low to high, and we’re recording the low condition using the time.time() function, the recorded timestamp will be the latest time at which that pin was low.
Our first step must therefore be to record the last low timestamp for ECHO (pulse_start) e.g. just before the return signal is received and the pin goes high.
while GPIO.input(ECHO)==0:
  pulse_start = time.time()
Once a signal is received, the value changes from low (0) to high (1), and the signal will remain high for the duration of the echo pulse. We therefore also need the last high timestamp for ECHO (pulse_end).
while GPIO.input(ECHO)==1:
  pulse_end = time.time()      
We can now calculate the difference between the two recorded timestamps, and hence the duration of pulse (pulse_duration).
pulse_duration = pulse_end - pulse_start
With the time it takes for the signal to travel to an object and back again, we can calculate the distance using the following formula.

The speed of sound is variable, depending on what medium it’s travelling through, in addition to the temperature of that medium. However, some clever physicists have calculated the speed of sound at sea level so we’ll take our baseline as the 343m/s. If you’re trying to measure distance through water, this is where you’re falling down – make sure you’re using the right speed of sound!
We also need to divide our time by two because what we’ve calculated above is actually the time it takes for the ultrasonic pulse to travel the distance to the object and back again. We simply want the distance to the object! We can simplify the calculation to be completed in our Python script as follows:

We can plug this calculation into our Python script:
distance = pulse_duration x 17150
Now we need to round our distance to 2 decimal places (for neatness!)
distance = round(distance, 2)
Then, we print the distance. The below command will print the word “Distance:” followed by the distance variable, followed by the unit “cm”
print "Distance:",distance,"cm"
Finally, we clean our GPIO pins to ensure that all inputs/outputs are reset
GPIO.cleanup()

Save your python script, I called ours "range_sensor.py", and run it using the following command. Running a root (sudo), is important with this script:

The sensor will settle for a few seconds, and then record your distance!

Monday, 12 September 2016

New smart strap turns your finger into a phone!



smartwatch

Seoul: Move over, earphones! You may soon be able to answer phone calls just by placing your finger in your ear, thanks to a new wearable smartwatch strap developed by a Korean company.
Sgnl is a smart strap that can be attached to existing smartwatches, and enables the user to answer phone calls through their fingertip.
“With Sgnl, you can keep your cell phone alone in your pocket and simply raise your hand to answer a phone call without carrying any extra headset or earphone,” according to the Innomdle Lab, a company based in Seoul that developed the device.

“When you place your finger to your ear, your finger not only transmits the sound but it also blocks out background noise,” it said.
The device receives voice signal from the phone through Bluetooth. When a voice signal is received, it generates vibration through its Body Conduction Unit (BCU) which transmits the vibration through the hand to the fingertip.
“As transmission is made through vibrations, there is no risk of harm to the human body,” the company said.
When the fingertip is placed to the ear, the vibration echoes to create amplified sound in the ear.
 Move over, earphones! You may soon be able to answer phone calls just by placing your finger in your ear, thanks to a new wearable smartwatch strap developed by a Korean company.


SEOUL: Move over, earphones! You may soon be able to answer phone calls just by placing your finger in your ear, thanks to a new wearable smartwatch strap developed by a Korean company.

Sgnl is a smart strap that can be attached to existing smartwatches, and enables the user to answer phone calls through their fingertip.

"With Sgnl, you can keep your cell phone alone in your pocket and simply raise your hand to answer a phone call without carrying any extra headset or earphone," according to the Innomdle Lab, a company based in Seoul that developed the device.

"When you place your finger to your ear, your finger not only transmits the sound but it also blocks out background noise," it said.

The device receives voice signal from the phone through Bluetooth. When a voice signal is received, it generates vibration through its Body Conduction Unit (BCU) which transmits the vibration through the hand to the fingertip.

"As transmission is made through vibrations, there is no risk of harm to the human body," the company said.

When the fingertip is placed to the ear, the vibration echoes to create amplified sound in the ear.

Thursday, 8 September 2016

Zubie GPS Plus In-Car Wi-Fi review

Watch your car from afar and turn it into a rolling hotspot with Zubie

Highs

  • Strong Wi-Fi connection through Verizon
  • Best all-around mobile application
  • Business features and plan available

Lows

  • Much more expensive than competition

Everyone from fleet businesses to families are looking for modern ways to track their vehicles. The new Zubie device aims to meet the needs of both applications with a device to send your vehicle’s information from the ODBII port right to your smartphone or computer. Whether you want to get automated updates on your car’s location or keep track of maintenance, we put the Zubie through the paces to see if it is the right device for you.

Start with the basics

Back in 2012 the Zubie was created with partial funding from Best Buy. The device has been one of the earlier pioneers in the connected car industry and have expanded to the newest Wi-Fi model that we tested. The basic Zubie unit without Wi-Fi is technically free but you will pay $100 which includes the first year of service and service going forward will continue at $100/year. Service for the Wi-Fi model we tested will cost you a bit more at $10 per month or $120 per year. In either case there are no contracts, a 30 day money back guarantee, and one year warranty. To allow Zubie Wi-Fi to act as a hotspot you will also need to connect it to the Verizon network with your existing plan or start a new Verizon account. Because of the partnership with Verizon the Zubie did have a more consistent Wi-Fi connection and higher speeds than any of the competing devices using T-Mobile or Sprint. So while the Zubie may have a lower initial cost and better Wi-Fi, the competition will cost you nearly half as much for an annual service fee. The Vinli and Mojio devices will only cost you $30 and $60 per year for service respectively.

Driving connected

Once you have received the device you can go ahead and sync your Zubie with an account you create on http://my.zubie.co/ or within the Zubie mobile application for iOS and Android. The Zubie application does a fantastic job at giving the location of vehicles within your group and making important information readily available. Once you have selected a vehicle card on the main screen you will see the current fuel level, battery status, self test results, and any maintenance alerts. Scrolling down further, you will see a map and information such as distance, time length, driving habits, and fuel cost of your latest trip. Within each trip you can quickly tag it as a “personal”, “business”, or “other” drive for anyone who may need to maintain driving records. We had issues with initial trip calculations on our MKZ Hybrid because the Zubie would mark the end of a trip each time it switched to the electric motor. This was solved with an OTA update that our unit had not received and it tracked fine once the update was pushed to the device.
While other products like the Vinli rely more on additional applications for additional features, the Zubie does it all with one download. The application settings allow for very customized notifications for when any number of tracked vehicles speeds, brakes hard, leaves/enters an area, or finishes a trip. We prefer maintaining all important information in one application instead of using several to handle common tracking data.

Zubie for business

While the Zubie may have a lower initial cost, the competition will cost you half as much for an annual service fee.
Companies like Vinli or Mojio tend to market more to the personal driver and families but Zubie has also attempted to get businesses on board with the connected car market. The Zubie online dashboard shows how your fleet can be separated into different work groups and a business can track all important information remotely. Maintenance tracking on things like oil changes, tires, batteries, etc. can be done automatically through Zubie. A fleet manager can help track the cost of driving for any given month and get alerts for dangerous driving habits with an improved dashboard. This is a great asset and larger companies can even use Zubie’s open API to integrate the data into their existing systems to allow for expanded use. The business service will cost $180 per year for the updated business dashboard.

Third party app development

In addition to the useful Zubie application, there is large support from third-party developers to help unleash more potential. In addition to connected car staples like IFTTT , there is support through the Amazon Echo. With the Echo, you can ask the location of any vehicles in your family group. You can even ask what time a vehicle left work or home and if any of your vehicles needs fuel. Additional apps from Fleetio, Expensify, and Spot Angels can help you track business expenses or simply find an open parking spot in town.
Zubie also has a screen for featured “perks” you have earned for your driving. The initial list is short but offered things like a discount on cleaning products, extended warranties, or roadside assistance. This feature could have potential to offer items based on your driving habits and locations you visit. For the moment, it seems like back-page advertising and will largely go unnoticed.

Conclusion


In the connected car market, there are companies that focus either on the third-party support or try and build essential applications from within. Zubie seems to be the best balance of both as the standard mobile application is easily the best in terms of user interface and features. The third party support from brands like Amazon also give hope for future expansion for those whose life is full of connected devices. That being said, for most buyers, a service like this comes down to price and unfortunately the Zubie may not be worth the extra $40-$70 per year compared to the closest competition despite its improved features.

Skinny Tile tracker

New Skinny Tile tracker fits in your wallet, helps you find everything else


Thin is in. The new Tile Slim tracker fits in a man’s wallet without making your butt look markedly bigger. The Bluetooth tracker is less than a tenth of an inch thick, same as two credit cards with raised lettering, and otherwise works the same as the two-year-old Tile classic lost-item finders.
Otherwise, Tile Slim works the same as what’s now called Tile Original. Using Bluetooth, your Apple or Android phone points you in the direction of your missing wallet, tablet, or backpack. If you still can’t locate it, tap the Find button and the device chirps. Tile Slim costs $30 or $25 each in a four-pack.
World's Thinnest Bluetooth Tracker

Still listens for a year, then you replace

Tile Slim Laying AngleThe Tile Slim (also above left in photo, also inset right) measures 54mm x 54mm x 2.4mm, or 2.1 inches square by 0.9 inches, or about the same as two credit cards. A credit card measures 3.4 x 2.1 inches.
The original Tile measured 37mm x 37mm x 5.3mm, or 1.4 inches square x 0.2 inches thick. They’re still on the market.
Tile uses embedded Bluetooth 4.0 to communicate with Tile software on your smartphone or tablet. Range is about 100-150 feet. You know you’re getting close when segments on an onscreen circle (there are eight segments total) turn green. At that point, you’ll either see the Tile and attached device, or you press the Find button to make the Tile chirp.
At longer distances, crowd GPS, meaning the community of Tile users with the app and Bluetooth turned on, will anonymously send the location to the owner if another person’s app located the tile. It’s also possible to share a Tile with another user so both can hunt for it.
As with the original Tile, the battery starts to run down after a year, so you have to send the first Tile back and exchange it for a new one. Tile says the original Tile is recycled. Competitors with thicker tags offer you the ability to replace the batteries.
Tile Slim Woman's Wallet

Tile moves to provide an industry standard

Tile Slim FrontTile also announced a development package, the Tile Smart Location Package, that lets other developers integrate the Tile technology into their products. The kit includes access to the Tile network, mobile app, and technology stack. Their products would show up on your existing Tile phone app. Partners include:
  • EcoReco, maker of electric scooters, with Tile technology in their Model R scooters.
  • Noman, a maker of smartphone and smart watches, in PowerPack, a portable battery pack.
  • Zillion, a smart wallet with a built-iin powerbank and cable.
With the announcments, Tile is moving to establish itself as the industry’s major player, banking on innovation and breadth of its network, rather than on being the low-cost provider.
Tile is on sale today (Aug. 31) on the company site, and at the end of the week at Amazon, Best Buy, Target and phone stores.

Tuesday, 6 September 2016

Raspberry Pi Webcam Robot – Best Video Streaming Tutorial


 

 

Raspberry pi webcam robot DIY Hacking
Raspberry pi webcam robot
It is always cool to add a camera to your remote controlled car or robot, so that you can see where its heading exactly and probably use a wifi enabled smartphone or tablet to view the video as well.Its very simple now to do this using a raspberry pi and a USB webcam.Real time streaming can be done with minimum delay too. Here, steps are given on how to view the feed from your webcam on the monitor connected to the raspberry pi as well as on another device in the same local network. This tutorial will show you how you can add a camera and video broadcasting system and make a raspberry pi webcam robot . Have fun with this DIY Hacking tutorial!
Raspberry pi webcam robot DIY Hacking
USB webcam
What are the stuff required to do this project? Hardware:
  1. Raspberry Pi model B with memory card preloaded with an OS.
  2. WiFi dongle : Edimax EW 7811UN.
  3. A USB webcam.
Software (Programming languages and OS  involved): 
  1. HTML.
  2. Linux/Rasbian.
How does it work? The working of the raspberry pi webcam robot is explained as follows. Here, the USB webcam connected to the raspberry pi usually associates with the pi at /dev/video0.A streaming service called mjpg streamer after installation is then used to broadcast the video on the raspberry pi’s local IP address and port number. The resolution of the video and frame rate can be set using linux commands while running the mjpg streamer.The video feed can then be viewed on any local network connected device by opening an HTML file in a browser that invokes the video from raspberry pi’s IPaddress:portno.The file required for this is provided in this tutorial as well. Also, in order to test the webcam locally on the pi, a service called ffmpeg is used. This allows you to view the webcam feed on the monitor connected to the raspberry pi. A block diagram showing the basic working:
Raspberry pi webcam robot DIY Hacking
Block diagram for the raspberry pi webcam robot

Step 1: Connecting the USB webcam and checking it

First of all, you need to check if your webcam is getting detected in the raspberry pi and whether its feed can be viewed. For this, first run the command “lsusb” in the terminal of the raspberry pi. This shows you a list of all the USB connected devices on the pi. Find out, from the list if your webcam’s name or software is displayed (sometimes driver name is displayed eg: Microdia for Iball webcams). Next, we need to check whether you can view the feed from the webcam on the pi. For this use “cd /dev” to go to /dev directory. Next, use “ls” to list its contents, check if “video0” is present.
Raspberry pi webcam robot DIY Hacking
Raspberry pi with USB webcam and wifi dongle
Now, you have to use a service called ffmpeg to view the feed from the webcam on the monitor connected to the pi.Use “sudo apt-get update” to update lists. To install ffmpeg service, use these commands:

sudo apt-get install ffmpeg
ffplay -f video4linux2 -framerate 15 -video_size 320x240 /dev/video0

The first command installs ffmpeg. The second commands starts up the video having a frame rate of 15fps using the video4linux2 mode , having a resolution of 320×240 and using the device from /dev/video0. Once you run it, you will see the webcam feed on the monitor.

Step 2: Setting up the video streaming service for the webcam

Here, the video from the raspberry pi is broadcasted on the local network. Any device on this network can view the video from the webcam.To do this, you need to first install the mjpg streamer. Use these commands to install it:

sudo apt-get install libv4l-dev
sudo apt-get install libjpeg8-dev
sudo apt-get install subversion
sudo apt-get install imagemagick

libv4l-dev and libjpeg8-dev serve as dependencies, imagemagick is used for installation whereas subversion is used for installing open source softwares. In order to download and compile the code use these commands :

svn co https://svn.code.sf.net/p/mjpg-streamer/code/
cd /home/pi/code/mjpg-streamer/
make USE_LIBV4L2=true clean all
sudo make DESTDIR=/usr install

Next, to run this service and to begin streaming use the following command:

mjpg_streamer -i "/usr/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -f 10" -o "/usr/lib/output_http.so -p 8090 -w /var/www/mjpg_streamer"

  • -i input plugin parameters
  • -d represents the video device
  • -y enables YUV format, disables MJPEG
  • -r specifies the resolution
  • -f is the frame rate
  • -o output plugin parameters
  • -p specifies the port number
  • -w specifies output webserving directory
Now your raspberry pi has started broadcasting the video, to view this video download this HTML file : video.html. The contents of it are like this raspberry pi webcam robot (the box in the page will be replaced by your video stream) , but you need to edit the file before using it:

<html> <body> <h1>DIY Hacking - Webcam Robot</h1> <img src="http:192.168.1.9:8090/?action=stream" width="600"> </body> </html>

Here, edit the IPaddress “192.168.1.9” with the IP address of your raspberry pi. You can find it out by using the command “ifconfig” on your pi. Finally use your browser to open this html file and view the video. For devices, like Ipad, etc use any file manager apps to open the HTML file.

Step 3: Building the Raspberry Pi Webcam Robot

If you wish to build your own robot then continue reading. Follow the instructions at : Smartphone controlled robot, to build a smartphone controlled robot and then come back to this tutorial.This is the robot from the tutorial :
Raspberry pi webcam robot DIY Hacking
Smartphone controlled Robot
Now you need to add the raspberry pi and the webcam to this and use a wifi dongle to make it wireless. I have used one half of a plastic box to create a platform for the raspberry pi and webcam. Use hotglue to stick them together. And that’s it, you have made a video streaming, smartphone controlled robot. You can use SSH to initiate the program remotely on the raspberry pi without having the need to hook it up to a monitor.
Raspberry pi webcam robot DIY Hacking
Assembling the raspberry pi webcam robot
The robot can be maneuvered using a smartphone application on an android phone. The corresponding feed from the USB webcam of the raspberry pi can then be streamed using an Ipad, pc or any other device connected to the local wifi network.
Raspberry pi webcam robot DIY Hacking
Parts of the raspberry pi webcam robot
Use this DIY Hacking tutorial to make surveillance systems , video streaming robots or even drones. Real time streaming can be done at minimum delay using the mjpg streamer and is considered as one of the best streaming services. Please note that , it is not required to have an arduino along with pi for building this robot. You can build it by just using the raspberry pi.

Monday, 5 September 2016

Build a WiFi Controlled Robot with the ESP8266


featured copy








Building your own mobile robot is becoming easier and easier, thanks to excellent ready-to-use robotic platforms. A good example of such platform is the Adafruit Mini Robot Chassis kit, which comes with a nice robot chassis, two servo motors with wheels and a support-wheel. This makes it the perfect base for all your mobile robot projects.
On the other hand, you now can buy powerful & cheap microcontrollers like the ESP8266 WiFi chip, which is not only easy to use but also comes with onboard WiFi connectivity. That’s a chip I used a lot on this website to build home automation projects, but it is also the perfect chip to control robots remotely from your computer or mobile device. In this project, we are going to build a WiFi controlled mobile robot based on the ESP8266. At the end of this tutorial, you will be able to control your own mobile robot from your computer, right from your favourite web browser. Let’s dive in!

Hardware & Software Requirements

We are first going to see what components are needed to build this project. First, you will of course need a robot platform. I used the Adafruit mini robot rover chassis as the platform, as it’s really convenient to use along with the ESP8266 WiFi chip. It also comes with servomotors and wheels, so you don’t have to buy those components separately.
Then, to actually control the robot, I used the Adafruit ESP8266 feather board, along with the Adafruit Motor FeatherWing board to control the motors. To connect both boards, I used the Adafruit FeatherWing doubler board.
Finally, to power the robot, I used two different power sources. I used a 3.7V LiPo battery to power the ESP8266 WiFi board, and a 4 x AA battery pack with 1.2V batteries to power the motors of the robot.
This is the list of all the components you will need for this project:
For this project, you will need the latest version of the Arduino IDE, along with the following libraries:
  • aREST
  • Adafruit_MotorShield

Hardware Configuration

Let’s now see how to assemble the robot. The Mini Robot Rover Chassis comes as a kit, so for the basic assembly I will refer you to this excellent guide to assemble the main parts of the robot:
https://learn.adafruit.com/bluefruit-feather-robot/wiring-and-assembly
You can basically follow this guide till you obtain a result like on the following picture:
hw1
So far, you should have the motors and the wheels assembled on the robot, as well as the 3.7V LiPo battery & the FeatherWing doubler mounted on the robot. We are going to use the battery to power the ESP8266 WiFi chip and the Motor FeatherWing, and we’ll use the FeatherWing Doubler to mount all the feather boards on the robot without using a lot of vertical space.
Now, we are going to take care about the motors of the robot. These will be powered by a larger power supply, that can drive the motors faster. First place four batteries (1.2V to 1.5V Alkaline or NimHA AA) into the 4 x AA battery holder, and then connect the battery holder to the motor FeatherWing component just as on the picture:
hw2
You can now place this FeatherWing on the FeatherWing doubler, as well as the ESP8266 Feather HUZZAH board. Also connect the two stepper motors to the motor FeatherWing. This should be the result at this stage:
hw3
Finally, mount the second stage of the robot using the metallic spacers, and also mount the battery holder on top of the robot:
hw4
Note that on the last picture, I already connected the 3.7V LiPo battery to the ESP8266 feather board. However, you can wait until the robot is fully configured to connect the battery.
Congratulations, you just assembled your mobile robot based on the ESP8266 WiFi chip! In the next section, we are going to learn how to configure it so it can receive commands via WiFi.

Configuring the Robot

We now need to configure the ESP8266 WiFi chip on our robot so it can receive commands via WiFi. For that, we are going to use the aREST framework, which is a very convenient way to make the ESP8266 be completely controllable via WiFi.
Let’s now have a look at the code for this project. It stars by including the required libraries:
  1. #include "ESP8266WiFi.h"
  2. #include <aREST.h>
  3. #include <Wire.h>
  4. #include <Adafruit_MotorShield.h>
#include "ESP8266WiFi.h"
#include <aREST.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
After that, we create an instance of the Adafruit_MotorShield, and also create instances for the two motors:
  1. Adafruit_MotorShield AFMS = Adafruit_MotorShield();
  2. Adafruit_DCMotor *L_MOTOR = AFMS.getMotor(4);
  3. Adafruit_DCMotor *R_MOTOR = AFMS.getMotor(3);
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
Adafruit_DCMotor *L_MOTOR = AFMS.getMotor(4);
Adafruit_DCMotor *R_MOTOR = AFMS.getMotor(3);
We also create an instance of the aREST library:
  1. aREST rest = aREST();
aREST rest = aREST();
You will need to enter your WiFi network name & password inside the sketch:
  1. const char* ssid = "your-wifi-password";
  2. const char* password = "your-wifi-name";
const char* ssid = "your-wifi-password";
const char* password = "your-wifi-name";
We also declare a set of functions to control the robots:
  1. int stop(String message);
  2. int forward(String message);
  3. int right(String message);
  4. int left(String message);
  5. int backward(String message);
int stop(String message);
int forward(String message);
int right(String message);
int left(String message);
int backward(String message);
We also expose all the control functions to the aREST API, so we can call them via WiFi:
  1. rest.function("stop", stop);
  2. rest.function("forward", forward);
  3. rest.function("left", left);
  4. rest.function("right", right);
  5. rest.function("backward", backward);
rest.function("stop", stop);
rest.function("forward", forward);
rest.function("left", left);
rest.function("right", right);
rest.function("backward", backward);
Inside the loop() function of the sketch, we process incoming connections with aREST:
  1. WiFiClient client = server.available();
  2. if (!client) {
  3. return;
  4. }
  5. while(!client.available()){
  6. delay(1);
  7. }
  8. rest.handle(client);
WiFiClient client = server.available();
if (!client) {
  return;
}
while(!client.available()){
  delay(1);
}
rest.handle(client);
Let’s now have a look at the implementation of the functions used to control the robot. For example, this is the function used to make the robot move forward:
  1. int forward(String command) {
  2. // Stop
  3. L_MOTOR->setSpeed(200);
  4. L_MOTOR->run( FORWARD );
  5. R_MOTOR->setSpeed(200);
  6. R_MOTOR->run( FORWARD );
  7. }
int forward(String command) {
  
  // Stop
  L_MOTOR->setSpeed(200);
  L_MOTOR->run( FORWARD );
 
  R_MOTOR->setSpeed(200);
  R_MOTOR->run( FORWARD );
  
}
Note that you can find the complete code inside the GitHub repository of the project:
https://github.com/openhomeautomation/esp8266-robot
It’s now finally time to configure the robot! First, grab all the code from the GitHub repository of the project, and modify it with your own WiFi name and password. Then, upload the code to the ESP8266 feather board. Once that’s done, open the Serial monitor, you should see the IP address of the board. Make sure you copy and paste this IP somewhere, you’ll need it in the next section where we’ll configure the interface to control the robot.

Controlling the Robot via WiFi

We now have a robot that can accept commands via WiFi, but we definitely don’t want to have to type any of commands inside a web browser: it would be way to slow to control a robot! That’s why we are now going to create a nice graphical interface to control the robot.
This interface will be based on aREST.js, a JavaScript library which is very convenient to control aREST-based projects. It will be automatically imported by the interface we are going to create in a moment, so you don’t need to worry about it. If you want to learn more about aREST.js, you can visit the GitHub repository of the library:
https://github.com/marcoschwartz/aREST.js
Let’s first have a look at the HTML file of the interface. Inside thetag, we import all the required files for the interface:
  1. <script type="text/javascript" src="https://cdn.rawgit.com/marcoschwartz/aREST.js/master/aREST.js"></script>
  2. <script type="text/javascript" src="script.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/marcoschwartz/aREST.js/master/aREST.js"></script>
<script type="text/javascript" src="script.js"></script>
Now, inside the same file, we define a button for each of the commands of the robot, for example to make the robot go forward:
  1. <div class='row'>
  2. <div class="col-md-5"></div>
  3. <div class="col-md-2">
  4. <button id='forward' class='btn btn-primary btn-block' type="button">Forward</button>
  5. </div>
  6. <div class="col-md-5"></div>
  7. </div>
<div class='row'>

  <div class="col-md-5"></div>
  <div class="col-md-2">
    <button id='forward' class='btn btn-primary btn-block' type="button">Forward</button>
  </div>
  <div class="col-md-5"></div>

</div>
We still need to link the buttons inside the interface to the actual commands of the robot. This will be done in a file called script.js, which will make the link between the graphical interface & the robot.
The file starts by defining the IP address of the robot, and by creating an instance of an aREST device:
  1. var address = "192.168.0.103";
  2. var device = new Device(address);
var address = "192.168.0.103";
var device = new Device(address);
Then, for each of the buttons of the interface, we call the corresponding function on the robot. Also, as we want the buttons to behave like push buttons (meaning whenever the button is released, the robot stops), we also need to call the stop function when the button is released:
  1. $('#forward').mousedown(function() {
  2. device.callFunction("forward");
  3. });
  4. $('#forward').mouseup(function() {
  5. device.callFunction("stop");
  6. });
$('#forward').mousedown(function() {
  device.callFunction("forward");
 });
 $('#forward').mouseup(function() {
   device.callFunction("stop");
 });
It’s now time to finally test our interface and make our robot move around! For that, make sure to edit the script.js file inside the interface folder, and put the actual IP address of your ESP8266 WiFi chip. If that’s not done yet, also disconnect the ESP8266 feather board from USB, and power the ESP8266 using the 3.7V LiPo battery.
Then, open the interface with your favorite web browser. This is what you should see:
Screen Shot 2016-06-16 at 14.04.09
As you can see, there is a button for each function of the robot. You can now try it: whenever you press a button (and keep it pressed), your robot should move immediately!
This is an example of my own mobile robot moving around while I was using the interface:
giv_prev
Congratulations, you built your own mobile robot based on the ESP8266 and controlled it via WiFi! Note that you also control the robot using a mobile device, like a smartphone or tablet, using the exact same interface.

How to Go Further

In this article, we learned how to build a mobile robot based on the ESP8266 WiFi chip, and on the Adafruit Mini Robot Rover Chassis Kit. We first assembled the robot, and configured it so it accepts commands via WiFi. We then controlled the robot using a graphical interface running in your web browser.
There are of course many ways to now improve the project, based on what you learned in this article. You could for example add a distance sensor in front of the robot, and have the measured distance displayed inside the same interface. You could also couple a gyroscope to the robot, and have more complex functions like making the robot turn from a given angle. The possibilities offered by this excellent chassis & the ESP8266 WiFi chip are endless, so don’t hesitate to experiment and have fun!