Surajdroid ( Ramudroid v7 Solar Powered )

Ramudroid is an ingeniously build robot to clean outdoors and alleys inspired by Bharat Swachhata Abhiyaan . Read more

Prototype in Development

Stages include, assembly of frame and wheels , attaching bin and equalising weight distribution , adding circuits for drivers , relays , micro processors and controllers . Finally attaching power sources – solar panel and a standby battery for the micro controller so that it can communicate remotely without any solar power too.

Frame and wheel
Side view of Robot
solar panel mounted

Algorithm Enhancements

Exprimentation with Obstruction Detection .

  • Ultrasonic senors – primitive
  • LiDar – depth sending
  • Steroscopic vision – dual camras
  • train model to idnetify walls, poles , tree , tyres

Experimentation to find if tray is full and Stop Operation , retreat to dumping point

  • Tray Weight reaching threshold
  • Marker point detction

Pause operation and take Shelter in Rain

  • Rain sensors

Equipment Cost

Power And Charge Devices

  1. Solar Panel MicroSun MS 12v 60 WP – 2500 INR
  2. Solar charger Controller – 600 INR
  3. Battery 11.1 V 2200 mAh – 500 INR

Frame and Motion Assembly

  1. Wheels 10 cm diameter – 50 INR x 4 ie 200 INR
  2. Tray – 400 INR
  3. Frame Assembly – 1000 INR
  4. Arduino to control Motors Drivers – 500 INR
  5. Motor Driver – 300 INR
  6. LCD display – 200 INR

Electronics , Communicating modules and Sensors

  1. Raspberry Pi Moddel B+/ 4 -2700 INR
  2. GPS module – 700 INR
  3. GSM module – 1400 INR
  4. Camera 5 MP Board Module – 450 INR

Total Cost to Develop – 12000 INR

Working Principle

The robot is divided into 2 parts – Cleaning Unit and driving unit

Driving Unit

Consists of 4 wheel to drive the setup . Wheels must be tightly fixed into position to prevent them from tilting, spreading outwards and imbalancing the load. 2 rear controller by 12 V 1 amp DC motors with 300 RPM and 2 front free wheels. Motors are conneted to Arduino for receving command for start , stop , left or right navigation.

There are three input pins for each motor, including Input1 (IN1), Input2 (IN2), and Enable1 (EN1) for Motor1 and Input3, Input4, and Enable2 for Motor2.

IN 1IN2Motor
00Brake
10Forward
01Backward
11Move

Cleaning Unit

Uses 3 tough bristled brushes controlled by 3 5V DC gear motors with 60 RPM. The arrangement of the brushes is such that the bottom 2 brushes use clockwise and anticlockwise motion outwards to pull in the litter and push up with the flow of the air and bristles of the brush. The third brush combs the collected into the collector tray. The tray is attached to weight control system to stop operations when critical weight is reached to prevent overloading the robot

Solar specification

  • Maximum Power (Pmax) – 60 Wp
  • Voltage at Maximum Power (Vmpp) – 18.1 V
  • Current at Maximum Power (Impp) – 3.32 A
  • Open Circuit Voltage (Voc) – 22.32 V
  • Short Circuit Current (Isc) – 3.63 A
  • Standard Test Conditions (STC): air mass AM 1.5, irradiance 1000W/m2, cell Temperature 25°C
  • Maximum System Voltage 1000 V

Electrical Data at NOCT

  • Temperature – 47±2 °C
  • Nominal Operating Cell Temperature (NOCT): 800W/m2, AM 1.5, windspeed 1m/s,ambient temperature 20°C

Thermal Ratings

  • Operating Temperature Range -20~90 °C
  • Temperature Coefficient of Pmax -0.43 %/°C
  • Temperature Coefficient of Voc -0.36 %/°C
  • Temperature Coefficient of Isc 0.66 %/°C

Material Data

  • Panel Dimension (H/W/D) 705x655x35 mm
  • Weight 6 kg
  • Cell Type Polycrystalline
  • Cell Size 156×156 mm
  • Cell Number 36
  • Encapsulant Type – EVA ( Ethylene vinyl acetate)
  • Frame Type Anodized Aluminium Alloy

Physical

  • Dimentions – 70mm x 655mm x 35mm
  • cells per module – 36
  • cell type – poly crystalline sIlicon
  • fuel cell dimention – 156mm x 156mm
  • Encapsulation – EVA
  • back cover – PV sheet

Ref : https://www.enfsolar.com/pv/panel-datasheet/crystalline/20863

Load

  • Solar panel weight – 5kg with annodixed alumium frame , 3 kg without the frame with just the toughened texture glass on panel
  • Frame and wheels – 2kg
  • Accessories – 1 kg
  • Garbage holding capacity – 2 kg
  • Total Weight of the Robot : maximum upto 10Kg

Scenarios

Good Sunlight scenario : This 12 Volt solar panel provide about 2.5 Amps of current on average during daytime. In such a situtaion it is directly used to drive the machine’s motors for wheels and brushes and electrical components such as PI and arduino. In no motion of rest conditions the genrated power is used to charge the attached backup battery.

Shady / evening / morning scenario : When the panel is not receiving direct or strong sunlight, the power generated is less hence not sufficient to take the load of driving the wheels for movement. Hence is the power falls below a certain prespecified threhold, the current is drawn from battery backup.

Night / No sunlight Scenario : battery is used to power the setup. panel can be dismounted to lower the load.

Contributing to Ramudroid Project or Reuse

It is deigned and developed as an MIT licensed Opensourced product by a bunch of developers and engineers in Bangalore for greater good.

https://github.com/altanai/Ramudroid

Automatic Garbage Segregation by Machine Learning

Sharing work in progress on the automatic garbage segregation system. This operates as an independent unit in addition to Ramudorid ( a road cleaning robot).

The system deals with incorporating image and edge detection algorithm over incoming video media to classify and identify items into one of the following categories

  1. Recyclable waste – paper , cardboard , leaves , sticks ..
  2. Non – Recyclable waste – plastic , bottles , wrappers ..
  3. E waste – ICs , computer peripherals , home appliances ..
  4. Dust and Sand
  5. Unidentified / unclassified objects

Components :

  1. High definition camera
  2. God lighting condition
  3. Grid marked conveyor belt
  4. image processing algorithm Open CV
  5. Object identification algorithm – AI
  6. feedback from manually classified unidentified objects – Machine learning

Garbage Segrigation system

Challenges:

  1. Difficulty in identification if the objects are broken beyond identification or molted together with other garbage
  2. Very minute particles such as glitter and thermocol balls cannot be segregated in this fashion

Tools and techniques :

1.Media Streaming on vp8

Using raspi cam and webrtc peer to streaming network over v8 video codec we achieve high frame rate to capture and send images for analysis by the backend analytics engine.

2. Robot arm for lifting  using arduino

-tbd-

robotics-lifting-arm-with-bi-directional-flex-sensors.jpg

flex / EMG sensors

string controlled by servos

change position on flexing or bending

 

3. Apache spark ML

Machine learning algorithms can be broken down into supervised and unsupervised learning . Supervised learning has linear of logistic regression and classification is form of Naive Bayes probabilistic model , support vector machines model ( SVM ) or Random Decision Forest . Whereas unsupervised learning works on dimensionality reduction such as principle components analysis or Single Value Decomposition. Often unsupervised learning is using clustering K means algorithms.

From among the 3 types of ML ( clustering , classifications and collaborative filtering ) , we are using classification approach to  identify every object’s characteristics on conveyer belt   .

As part of the implementation decision tress are created for evaluation using branches and nodes.

Snippets from programs :

step 1 : create environment for Spark , preferably 8GB ram Ubuntu

step 2 : Imports for Scala program

org.apache.spark._
org.apache.spark.rdd.RDD
org.apache.spark.mllib.regression.LabeledPoint
org.apache.spark.mllib.linalg.Vectors
org.apache.spark.mllib.tree.DecisionTree
org.apache.spark.mllib.tree.model.DecisionTreeModel
org.apache.spark.mllib.util.MLUtils

step 3 : Load the data from identified objects into for the  robotic arm to learn its coordinated , pick it up and put it in one of the bins . For this use the collected data to insert into RDD class.

Step 4 : Extract features to build a classifier model -> RDD containing feature array

Step 5 :  RDD containing features array – > RDD containing labelled points

Step 6 : train the model using the DecisionTree.trainClassifier method which returns a DecisionTreeModel

Parameters : MaxDepth , maxBisn , maxImpurity ,

var categoricalFeaturesInfo = MapInt, Int

val model = DecisionTree.trainClassifier(trainingData, numClasses, categoricalFeaturesInfo, impurity, maxDepth, maxBins)

model.toDebugString // prints out the decision tree

Step 7 : Use model.predict to test the data

Predicted value for a node param: predict predicted value param: prob probability of the label (classification only)

Reference : https://spark.apache.org/docs/latest/api/java/index.html

 

 

 

 

RamuDroid

Bot to clean roads and outdoors for a better and cleaner India. It lifts up small objects like plastic cups,wrappers,leaves etc.

ramudroid image.png

The droid also provides real-time camera stream and detects obstruction to re-route itself. It can communicates over GSM ,wifi and BLE . It can also be remote navigated via browsers or android.

Working :

stages of ramudroid

  1. Litter comes between rotating brushes
  2. Litter is picked by brushes and pushed upwards  
  3. Brushes push it towards the tray

Is is inspired by Swach Bharat Abhiyaan in India , its an effort to contribute to society and welfare and well-being through technology . Following are some diagrams for the current and the previous versions , along with major delta points .


RamuDroid v1.0

Remote Streaming and movement via motors switched manually. Communication over Ethernet.

Ramudroidv1.0.jpg

Dashboard /console Screen

RamuDroid v1  console


v3.0

Cleaning garbage on public roads and outdoors through robot . Remote navigation and control of control through web page and camera live streaming .

Ramudroid compoenet diagram v5

v3 web console

Screenshot from 2015-12-03 08:55:27.png


v6

Clean roads , pick up litter ( wrappers, leaves , cups , plastics bits etc ) . communicated over BLE ,Wifi and 3G n/w . Auto buzzer when meet with an obstruction in way . Flash Lights . Enhanced Design .

Ramudroid 6.5 componet diagram

 

Web Dashboard:

Screenshot from 2016-03-19 04-28-53.png

Pin Diagram associated with activities

Pin Pin 0 Pin 1 Pin 2 Pin 3 Pin 4 Pin 5 Pin 6 Pin 7
Front 0 1 0 1 1 1 1 1
Back 1 0 1 0 1 1 1 1
Left 1 0 1 0 1 1 1 1
Right 1 0 1 0 1 1 1 1
Brushes ON 1 0 1 0 1 1 1 1
Brushes OFF 1 0 1 0 1 1 1 1
Lift ON 1 0 1 0 1 1 1 1
Life OFF 1 0 1 0 1 1 1 1

 

Github : https://github.com/altanai/m2mcommunication

Slideshare :

Twitter :https://twitter.com/search?q=%23ramudroid


 

IOT Survillance with Arduino + Rpi + WebRTC

“ The Internet of Things (IoT) is the network of physical objects or “things” embedded with electronics, software, sensors and connectivity to enable it to achieve greater value and service by exchanging data with the manufacturer, operator and/or other connected devices. “ – wikipedia

Smart TV , mobiles , CCTV cams and other few things are already connected to the Internet.So whether we’ve known it or not, the “Internet of Things” is already here. But , number of these interconnections is on the rise and need to controlled , monitored and optimized .

IOT areas where media streaming capabilities of

  • Home automation
  • Targeted marketing
  • Wildlife and environment
  • Manufacturing
  • Smart Grid /  real-time energy optimization.
  • Connected logistics
  • Augmented reality
  • Ubiquitous computing (ubicomp) / BYOD
  • Healthcare
  • Transportation / connected car

This post describes the process of creating a Arduino based IOT control setup over Internet. The features of this application are

  1. Cheap and more customized solution to specific use cases
  2. Recycled components
  3. No patented or proprietary protocols
  4. Easy person-to-machine and machine-to-machine comm.
  5. Can be integrated with other modules like Recording , Multiplexing , transcoding .

Requirements :

Hardware requirements

  1. Rpi as communication hub to internet
  2. ultrasonic sensors to detect obstruction in field of view
  3. camera module of Rpi or standrad webcam
  4. Motion Sensors
  5. Buzzer
  6. mic
  7. flash lights connected via relay drivers to rpi

Software requirements

  1. open CV ( image processing)
  2. Simple CV ( face recognition )
  3. motion
  4. webrtc for media live streaming in case of remote monitoring

 

Screenshot from 2015-11-10 22:02:25

Screenshot from 2015-11-11 11:22:09

WebRTC communication and media streaming setup

Screenshot from 2015-11-11 11:31:30

Raspberry Pi Communication Modules

 

Ethernet

Ethernet wires can connect rpi to a another machine such as  laptop  from which it can be connected via terminal or using remote desktop accessing software’s such as tightvnc .

ethernet

Undoubtedly Ethernet offers the fastest speed, lowest latency and no  data loss due to wireless interference problems however it is as the price of being immobile , as its is a wired connection and shifting disrupts the connection .

Cat-5e cable and  Cat-6e cable can offer upto  1 Gb/s and  10 Gb/s respecctively .

Wifi or IEEE 802.11  wifi

Wi-Fi was launched in the year 1997. Victor Hayes is known as father of Wi-Fi.

There are various standards and adoptions for IEEE802.11 like 802.11ac, 802.11n, 802.11g, and 802.11b which can offer maximum speeds of 866.7 Mbit/s , 150 Mbit/s  ,  54 Mbit/s and 11 Mbit/s respectively , however consumes more power than Bluetoooth .

Image Wifi hotspot

wifi

Image Wifi USB

wifi2

Image Wifi module Rpi

Wifi -direct can even reach upto 250mbps of data transferring rate at  2.4, 3.6 and 5 GHz frequency . Range is around 100m .

BLE / Bluetooth ble

Bleutooth was launched in 1994 as a wireless communication alternative to RS232 by  Ericsson . Now it is handled by Special Interest group  for Bluetooth.

ble

Bluetooth 4.0 can do data transfer rates to be upto 25mbps  at 2.4GHz frequency  while maximum range being 30 m .

GSM / GPRS

This section refers to the data provider by the network of a telecom carrier company such as Airtel , Tata Docomo etc in India . 2G capabilities

gsm

Majorly the technology behind the differnt generation of telecom is as follows
2G – GSM 900, GSM 1800 – 14.4 kbps
3G – UMTS 2100 – 3.1 Mbps
4G – LTE 850 (5), LTE 1800 (3), LTE 2300 (40) – 100 Mbps

The carries frquency varries from 200 KH , 5 MHz , 15 MHz recpectively

NFC

Short for Near Field Communication . NFC uses electromagnetic induction between two loop antennae in smart devices to exchange information.
It uses unlicensed radio frequency ISM band of 13.56 MHz with data trabsfer rate of about 106 to 424 kbit/s.Unlike bluetooth it is a point to point communication .

Audio / Video Streaming

First enable the rpi camera support from the boot screen

rpi_camera._support

One can choose between the following ways to be able to stream data from a Rpi

  1. Motion

To start motion detection edit motion.cong file

$ vi /etc/motion/motion.conf

Although the it starts detecting motion automatically we can modify few properties like

# Threshold for number of changed pixels in an image that
# triggers motion detection (default: 1500)
threshold 1500
# Detect motion in predefined areas (1 – 9). Areas are numbered like that: 1 2 3
# A script (on_area_detected) is started immediately when motion is 4 5 6
# detected in one of the given areas, but only once during an event. 7 8 9
# One or more areas can be specified with this option. Take care: This option
# does NOT restrict detection to these areas! (Default: not defined)
; area_detect value

# Picture frames must contain motion at least the specified number of frames
# in a row before they are detected as true motion. At the default of 1, all
# motion is detected. Valid range: 1 to thousands, recommended 1-5
minimum_motion_frames 1

# Specifies the number of pre-captured (buffered) pictures from before motion
# was detected that will be output at motion detection.
# Recommended range: 0 to 5 (default: 0)
# Do not use large values! Large values will cause Motion to skip video frames and
# cause unsmooth movies. To smooth movies use larger values of post_capture instead.
pre_capture 10

# Number of frames to capture after motion is no longer detected (default: 0)
post_capture 10

# Event Gap is the seconds of no motion detection that triggers the end of an event.
# An event is defined as a series of motion images taken within a short timeframe.
# Recommended value is 60 seconds (Default). The value -1 is allowed and disables
# events causing all Motion to be written to one single movie file and no pre_capture.
# If set to 0, motion is running in gapless mode. Movies don’t have gaps anymore. An
# event ends right after no more motion is detected and post_capture is over.
event_gap 60

# Maximum length in seconds of a movie
# When value is exceeded a new movie file is created. (Default: 0 = infinite)
#max_movie_time 0
max_mpeg_time 240

# Always save images even if there was no motion (default: off)
emulate_motion off
To beep when motion is detected
Note: Motion never beeps when running in daemon mode.
quiet off

To draw a identifiable area where motion is deceted
# Set the look and style of the locate box if enabled.
# Valid values: box, redbox, cross, redcross (default: box)
# Set to ‘box’ will draw the traditional box.
# Set to ‘redbox’ will draw a red box.
# Set to ‘cross’ will draw a little cross to mark center.

locate_motion_style box

 

2.WebRTC ( rpi model 2 onwards)

In terminal:

$ curl http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc | sudo apt-key add -
add this to /etc/apt/sources.list : 
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main 

or simply run

wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc

linuxProject

Update the repos

 $ sudo apt-get update

Now install uv4l and supported software

 $ sudo apt-get install uv4l uv4l-raspicam

If you want the driver to be loaded at boot, also install this optional package:

 $ sudo apt-get install uv4l-raspicam-extras

 

Most importantly install the uv4l server and the WebRTC extension for the Streaming Server

 $ sudo apt-get install uv4l-webrtc

Screenshot from 2016-06-19 15-24-00

Type uv4l –help for getting  list of options for core , streaming , fine tuning , logging etc

start the service using following command


sudo service uv4l_raspicam start

Screenshot from 2016-06-19 15-41-10

Open web
http://<rpi ip address>:8080/conference

Screenshot from 2016-06-19 15-41-34

Once the media capture and stream is established it is important to decide the stream methodology such as relay through a centralized media server or mesh streaming network as in webrtc p2p.

Click on any of the given options to see a incoming media stream from rpi

For example

Webrtc :

http://<rpi_ip&gt;:8080/stream/webrtc  gives incoming Webrtc media stream.

MJpeg

http://<rpi_ip&gt;:8080/stream/video.mjpeg gives mjpeg

 

The default server config is

  • basic HTTP/HTTPS authentication: disabled
  • underlying video device node: /dev/video0
  • current connections: 1, queued: 0, total handled: 11
  • max. simultaneous streams allowed: 3, max. threads: 5
  • raw HTTP/HTTPS video streams in MJPEG, JPEG (continuous stills) and H264 formats – if supported – are available under the /stream/video.mjpeg, /stream/video.jpeg, and /stream/video.h264URL paths respectively

Note : https is required if you want to have a outgoing video from your computer to rpi as browser mandates secure origin but https is not required for an incoming video stream so you can easily view the rpi genrated webrtc video without being on https .


 

Bluetooth Low Energy on Adafruit Arduino

Lately as I develop and realize few IOT use-cases , I have concluded that BLE ( Bluetooth Low Energy) , also known as Bluetooth smart , is a very good choice as it runs for longer periods of time with smaller power sources.

What is BLE ?

This is the version 4.0+ of Bluetooth which is aimed as building the communication network for IOT ( Internet of things ) . Like classic Bluetooth it utilizes the 2.4 Ghz band and performs in dual-mode. Also both the models use Gaussian frequency shift modulation for data transmission.

How is BLE different from classic Bluetooth ?

Power and Life : BLE provided better bit rate with lesser power consumption( 0.01W to 0.1W) than classic bluetooth technology ( 1 W). Channel : While Classic Bluetooth uses 79 1-MHz channels , BLE has 40 2-MHz channels

How can one make use of BLE in IOT ?

If you have a usecase that needs implementation than high changes are it needs 3 basic components: 1. End devices such as machines , automated doors , surveillance systems , metering systems etc This is where BLE can be used to transmit realtime data quickly to central controller

  1. Central control hub to control the end points and communicate to server This has to be a bridge between BLE devices and internet to put all the gathered information on the cloud for analysis and logic processing.
  2. User provisioning system or Graphical interface to who stats , status , control options etc . This is also a critical component as the user needs to have a way of controlling the operation without physically going to the machines . Although the system can very much work without given a pre-programmed operation .

*References *

you can learn more about bluetooth form these links


Simple Adafruit Bluefruit Bluetooth LE UART android app

This is the first and the most basic example of using BLE.

Code

Key concepts for BLE programming

GATT ( Generic Attribute Profile) : The bluetooth Special Interest Group ( SIG ) defines many profile for low energy devices.  GATT is also an profile for sending and receiving short data in low energy devices .

ATT (Attribute Protocol ) : Each attribute is uniquely identified by a Universally Unique Identifier (UUID), which is a standardized 128-bit format for a string ID. The attributes transported by ATT are formatted as characteristics and services

BLE activity class

While defining the Bluetooth LE UART acttivity class we must extend the BluetoothGattCallback parent class and implement the BluetoothAdapter.LeScanCallback interface .

Then define the public data values for the device such as UUID of the UART , TX and RX. Also the UUID for the UART BTLE client characteristic which is necessary for notifications .UUIDs for the Device Information service and associated characeristics such as Manufacture , Model , hardware , software .

set the adapter to BluetoothAdapter.getDefaultAdapter()

we can define some callbacks in an interface , This enables BLE UART client to be notified of UART actions .

 public interface Callback {
 public void onConnected(BluetoothLeUart uart);
 public void onConnectFailed(BluetoothLeUart uart);
 public void onDisconnected(BluetoothLeUart uart);
 public void onReceive(BluetoothLeUart uart, BluetoothGattCharacteristic rx);
 public void onDeviceFound(BluetoothDevice device);
 public void onDeviceInfoAvailable();
 }

For scanning the available devices , call adapter.startLeScan(this) . This will Start scanning for BLE UART devices. Registered callback’s onDeviceFound method will be called when devices are found during scanning. Similarly call adapter.stopLeScan(this) to stop the device scan .

we may also define Handlers for BluetoothGatt and LeScan events such as ,

1. onLeScan

Stop if the device doesn’t have the UART service

        if (!parseUUIDs(scanRecord).contains(UART_UUID)) {
            return;
        }

Notify registered callbacks of found device.

        notifyOnDeviceFound(device);

connect to device

	gatt = device.connectGatt(context, true, this);

2. onConnectionStateChange

super.onConnectionStateChange(gatt, status, newState);

we can check the state through BluetoothGatt.STATE_CONNECTED and status of connection through BluetoothGatt.GATT_SUCCESS.
Further more we can check if the service was found on the device through gatt.discoverServices()
If any of the above conndition were not checked we can call connectFailure() which signifies that connection was a failure and reset cinnection state through

        rx = null;
        tx = null;
        notifyOnConnectFailed(this);

Simillarlily if state was BluetoothGatt.STATE_DISCONNECTED then notify callbacks of disconnection.
3. onServicesDiscovered
super.onServicesDiscovered(gatt, status);

notify connection failure if service discivery failed

status == BluetoothGatt.GATT_FAILURE

Save reference to each UART characteristic.

        tx = gatt.getService(UART_UUID).getCharacteristic(TX_UUID);
        rx = gatt.getService(UART_UUID).getCharacteristic(RX_UUID);

Save reference to each DIS characteristic.

        disManuf = gatt.getService(DIS_UUID).getCharacteristic(DIS_MANUF_UUID);
        disModel = gatt.getService(DIS_UUID).getCharacteristic(DIS_MODEL_UUID);
        disHWRev = gatt.getService(DIS_UUID).getCharacteristic(DIS_HWREV_UUID);
        disSWRev = gatt.getService(DIS_UUID).getCharacteristic(DIS_SWREV_UUID);

Add device information characteristics to the read queue . These need to be queued because we have to wait for the response to the first read request before a second one can be processed

        readQueue.offer(disManuf);
        readQueue.offer(disModel);
        readQueue.offer(disHWRev);
        readQueue.offer(disSWRev);

Request a dummy read to get the device information queue going

        gatt.readCharacteristic(disManuf);

Setup notifications on RX characteristic changes (i.e. data received).

First call setCharacteristicNotification to enable notification

gatt.setCharacteristicNotification(rx, true)

Stop if the characteristic notification setup failed.

Next update the RX characteristic’s client descriptor to enable notifications

BluetoothGattDescriptor desc = rx.getDescriptor(CLIENT_UUID)
desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(desc)

Stop if the RX characteristic desc has no client descriptor ie null or if the client descriptor could not be written.

Notify of connection completion.

        notifyOnConnected(this);

3. onCharacteristicChanged

        super.onCharacteristicChanged(gatt, characteristic);
        notifyOnReceive(this, characteristic);

4. onCharacteristicRead

	super.onCharacteristicRead(gatt, characteristic, status);

Check if there is anything left in the queue

            BluetoothGattCharacteristic nextRequest = readQueue.poll();

if nextRequest is not null ie it has items more Send a read request for the next item in the queue

                gatt.readCharacteristic(nextRequest);

else We’ve reached the end of the queue so set the flags and make the callback

                disAvailable = true;
                notifyOnDeviceInfoAvailable();

5. onCharacteristicWrite

	super.onCharacteristicWrite(gatt, characteristic, status);

android manifest file

1. Declare the Bluetooth permission to perform connection and data transfer over bluetooth

<uses-permission android:name=”android.permission.BLUETOOTH”/>

2. To initiate device discovery or manipulate Bluetooth settings, you must also declare the BLUETOOTH_ADMIN permission.

<uses-permission android:name=”android.permission.BLUETOOTH_ADMIN”/>

3. To declare that your app is available to BLE-capable devices only.

<uses-feature android:name=”android.hardware.bluetooth_le” android:required=”true”/>

Layout

Android studio screenshots 

I have used Adafruit Bluefruit LE UART Friend – Bluetooth Low Energy (BLE) device . More details about this can be found here .

The circuit for a BLE Arduino is as follows :

This application has more modules than the previous simple read and write application . It can work in 4 modes namely

  1. Info
  2. UART
  3. Controller
  4. Beacon

The circuit arrangement is shown in following pictures :

The edited source code of the android application is on the github repo : https://github.com/DKAagri/BluefruitArduinoLE

screenshots of the Android application

The controller mode

ColorPickerActivity

We can connect a android phone in adb mode to android studio and monitor the realtime network , memory and other stats.

See the connection and communication entities form the android device monitor logcat

The code of this application is derived from

https://github.com/adafruit/Bluefruit_LE_Connect_Android

More information about Bluefruit LE the device can be obtained form

https://blog.adafruit.com/2014/11/19/new-products-bluefruit-le-friend-bluetooth-low-energy-ble-4-0-nrf51822-v1-0-bluefruit-le-sniffer-bluetooth-low-energy-ble-4-0-nrf51822-v1-0/

Remote machine control via Raspberry pi

What is a Raspberry pi ?

The Raspberry Pi is a series of credit card-sized single-board computers. It can be used to build hardware along with software system . It essentially acts like a mini computer where we can install our programs and work on them pretty much like a regular computer . However the applications of Rpi is really diversifies from making robots to kiosks , surveillance system to remote control agents etc .

Yes the new model B+ is out yet I have an old B model and I am trying ot most of the things using it before making the investment of purchasing a  new one .

2 3(images from : http://www.adafruit.com/products/998)

Configuration :

  • The design is based around a Broadcom BCM2835 SoC, which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and 512 Megabytes of RAM.
  • The design does not include a built-in hard disk or solid-state drive, instead relying on an SD card for booting and long-term storage.
  • This board is intended to run Linux kernel based operating systems.
  • Generic USB keyboards and mice are compatible with it .
  • It does not come with a real-time clock, so an OS must use a network time server, or ask the user for time information at boot time to get access to time and date info for file time and date stamping. However a real time clock (such as the DS1307) with battery backup can be easily added via the I2C interface.

Physical architecture :

rpib

Pin Model :

p1header

Rpi model B startup

Requirements for boot

  1. Power supply
  2. HDMI cable to connect to HDMI tv or HDMI to VGA adapterto connect to monitor
  3. power charger ( micro USB same as phone )
  4. SD card upto 8 GB ( in case its a micro SD card then SD card adpater as well)
  5. monitor
  6. keyboard
  7. mouse
  8. internet through ethernet
  9. ethernet wire

Steps:

top view of the board
top view of the board
HDMI connector for screen display from Rpi
HDMI connector for screen display from Rpi
NOOBS
NOOBS
Raspbian start
Raspbian start
rpi5
rpi6
rpi8
rpi9
Default id : pi  default password : raspberry
Default id : pi
default password : raspberry
OS boot up
OS boot up
rpi12
raspbian on Raspberry pi
raspbian on Raspberry pi
run sudo apt-get update
run sudo apt-get update

 RPI model B to LED glow using timers in python

Aim :

First time booting Raspbian on Raspberry pi Model B . Connecting it to LED ( series with resistor ) and controlling the on -off process using timer logic written in python .

Requirements :

  1. Rs(RaspberryPi)
  2. Power supply
  3. Ethernet wire(3m)
  4. SDcard or micro SD card with adpater
  5. Breadboard
  6. LED(7)
  7. resistors(1k )(7)
  8. button
  9. breadboard wires

Steps :

1. Manual ON and OFF of LED on Rpi GPIO

To manually make the LED turn ON and OFF ,  make a serial connection of two GPIO pins with a LED  and resistor ( shown in the picture )

rpi15
  • Open terminal and sudo su  to :/home/pi#
  • #echo25>/sys/class/gpio/export
  • File manager -> /home/pi -> sys -> class ->gpio -> gpiochip0 -> device -> gpio ->gpio25 , Change directory to this location
  • #cd /sys/class/gpio/gpiochip0/device/gpio/gpio25
  • List all files , with gpio#ls

To give output to LED through the pin 25 :

  • echo out>direction ( set this pin as output)
  • To tuen ON the LED , write 1 to the value of pin echo 1> value

To take input through pin 24 through a button

  • connect button to pin 24 of Rpi as earlier
  • echo in >direction
  • see the changes on pressing the button on cat value

2. GPIO control with WiringPi library

  • Install git , sudo apt-get innstall git-core
  • Get the sourcecode with :sudo git clone git://git.drogon.net/wiringpi
  • cd wiringPi
  • ./build
  • $gpio -v
  • $gpio readall

To turn ON or OFF the first LED wiring pin 0 , set the pin as an output  -> gpio mode 0 out

  • To turn ON LED  -> $gpio write 0 1
  • To turn OFF  -> $gpio write 0 0

To read from a digital switch on wiringPin no

  • $ gpio read 0

Applications:

1.  Timer based control

Following are the steps to make and execute a LED  control using timers in python .


 Machine control through RPi via Mobile app on Internet

Aim :

Controlling a machine via Rpi hub connected to internet . Users can control machine behavior through a web page or mobile app .

Steps:

1. Install Raspbian wheezy ( details of installation are provided in the 1fisrt application on this page )

2. Get win32 Disk-manager 0.25 and dump into raspberry

3. Connect the Rpi via Ethernet wire to internet router . Find IP address of Rpi client by checking the router default console .

4. Connect the Rpi to remote machine

For Linux remote machine OS –Install tightVNC server

  • ssh  raspberrypi_username@ipaddress
  • sudo apt-get updates
  • sudo apt-get install tightvncserver
  • During installation supply a username and password example , username pi  , password altanai.

The viewer for VNC could be Remmina VNC viewer on linux

  • Incoming VNC server .
  • Enter username and password

For Windows  remote machine OS –Install putty

  • Enter Rpi_ip:port
  • login as pi given password  for example altanai

5. For the webpage

  • Install a web server  :sudo apt-get install apache2 php5 libapache2-mod-php5
  • transfer the web page for machine control  to Rpi inside /var/www
  • index.phpo :  <?php phpinfo(); ?>
  • ctrl+ o to save , ctrl + x to exit
  • change permission fr user pi :  chown -R pi /var/www
  • test the webpage at http://rpi_address

6. For the android app

7. To control real machine like fan , tubelight , washing machine  , connect the output of Rpi to relay.

8. To control the machines from anywhere on the internet , this page need to be on public DNS . There fore host the website on public server like amazon Ec2 instance .

Light Fan control Rpi web

Github Repo for Rpi setup

https://github.com/altanai/Ramudroid/tree/master/robot_controller_rpi_setup

Github project page

http://altanai.github.io/Ramudroid/

Demo video


Ref :

  1. http://www.adafruit.com/products/998
  2. http://www.raspberrypi.org/
  3. http://www.instructables.com/id/Simple-and-intuitive-web-interface-for-your-Raspbe/

RFID- Radio Frequency Identification

Automatic identification method, relying on storing and remotely retrieving data using devices called RFID tags or transponders. An RFID tag is a small object that can be attached to or incorporated into a product, animal, or person. RFID tags contain silicon chips and antennas to enable them to receive and respond to radio-frequency queries from an RFID transceiver. Passive tags require no internal power source, whereas active tags require a power source.

14891130616_d155bbf0cd_b

The purpose of an RFID system is to enable data to be transmitted by a mobile device, called a tag, which is read by an RFID reader and processed according to the needs of a particular application.

The use of RFID in tracking and access applications first appeared during the 1980s. RFID quickly gained attention because of its ability to track moving objects. As the technology is refined, more pervasive and possibly invasive uses for RFID tags are in the works.

Operation

In a typical RFID system, individual objects are equipped with a small, inexpensive tag. The tag contains a transponder with a digital memory chip that is given a unique electronic product code.

The interrogator, an antenna packaged with a transceiver and decoder, emits a signal activating the RFID tag so it can read and write data to it.

When an RFID tag passes through the electromagnetic zone, it detects the reader’s activation signal. The reader decodes the data encoded in the tag’s integrated circuit (silicon chip) and the data is passed to the host computer.

Frequencies:

RFID_frequency.jpg

Low-frequency (LF: 125 – 134.2 kHz and 140 – 148.5 kHz)

A low-frequency device typically provides slower data transfer and must work at closer distances to an object. Relative speed of the tag moving on a production line past an interrogation unit is approximately 20 miles an hour.

High-frequency (HF: 13.56 MHz) RFID tags can be used globally without a license.

High-frequency devices can work at distances up to 250 feet and at relative speeds greater than 150 miles per hour.

Ultra-high-frequency (UHF: 868 MHz-928 MHz) cannot be used globally as there is no single global standard.

High-frequency passive systems are typically in the UHF range — i.e. from 500 MHz and above, but usually in the 900 MHz band to 2.5 GHz. These systems are particularly well suited to the automotive, trucking and container shipping industries because they can read distances in excess of 15 feet and can communicate large amounts of information at very high speeds.

Benefits

It offers powerful benefits as part of a comprehensive enterprise mobility strategy.

  • Ensure a higher level of patient safety
  • Reduce opportunities for counterfeiting, product diversion or substitution along the supply chain
  • Rapid identification of product location for improved recall management
  • Lower inventory costs with less safety stock and work in process (WIP)
  • Minimize inventory loss and write-offs due to concealed shrink and expired product
  • Satisfy electronic pedigree requirements
  • Simplify processes and cost of regulatory compliance with automation
  • Eliminate potential errors from manual-based processes
  • Improve productivity across the board

Security

Protection against Tag Clonning :

A second class of defense uses cryptography to prevent tag cloning. Some tags use a form of “rolling code” scheme, wherein the tag identifier information changes after each scan, thus reducing the usefulness of observed responses.

Cryptographically-enabled tags :

More sophisticated devices engage in challenge-response protocols where the tag interacts with the reader. In these protocols, secret tag information is never sent over the insecure communication channel between tag and reader. Rather, the reader issues a challenge to the tag, which responds with a result computed using a cryptographic circuit keyed with some secret value. Such protocols may be based on symmetric or public key cryptography.

Cryptographically-enabled tags typically have dramatically higher cost and power requirements than simpler equivalents, and as a result, deployment of these tags is much more limited. This cost/power limitation has led some manufacturers to implement cryptographic tags using substantially weakened, or proprietary encryption schemes, which do not necessarily resist sophisticated attack.

For example, the Exxon-Mobil Speedpass uses a cryptographically-enabled tag manufactured by Texas Instruments, called the Digital Signature Transponder (DST), which incorporates a weak, proprietary encryption scheme to perform a challenge-response protocol. In 2005, researchers from RSA Labs and Johns Hopkins University reverse engineered the algorithm and were able to clone Speedpass tags.

Types of RFID tags

1. Passive RFID tags

passiveRFID

No internal power supply.

electrical current induced in the antenna by the incoming radio frequency signal provides just enough power for the CMOS IC in the tag to power up and transmit a response.

Tags signal by backscattering the carrier signal from the reader. Aerial is designed to both collect power from the incoming signal and also to transmit the outbound backscatter signal.

Rresponse of a passive RFID tag is ID number (GUID) + tag chip can contain nonvolatile EEPROM for storing data.

Read distances ranging from 2 mm – few meters depending on the chosen radio frequency.

Simplicity in design . It is suitable for manufacture with a printing process for the antennae.

Development target are polycarbon semiconductor tags to become entirely printed.
Passive RFID tags do not require batteries, and can be much smaller and have an unlimited life span.

2. Semi-passive RFID tags

similar to passive tags except for the addition of a small battery. This battery allows the tag IC to be constantly powered.

This removes the need for the aerial to be designed to collect power from the incoming signal. Aerials can therefore be optimised for the backscattering signal.

Semi-passive RFID tags are faster in response and therefore stronger in reading ratio compared to passive tags.

3. Active RFID tags or beacons

activeRFID

Have their own internal power source which is used to power any ICs and generate the outgoing signal.

They may have longer range and larger memories than passive tags, as well as the ability to store additional information sent by the transceiver.

To economize power consumption, many beacon concepts operate at fixed intervals. At present, the smallest active tags are about the size of a coin. Many active tags have practical ranges of tens of metres, and a battery life of up to 10 years.

Applications of RFID

Medical Prescriptions 

RFID tags are placed on prescriptions for Visually Impaired Veterans. The Department of Veterans Affairs Outpatient pharmacies are now supplying the tags with label information stored inside that can be read by a battery powered, talking prescription reader. This reader speaks information such as: Drug Name; Instruction; Warnings; etc.

Inventory Management

t-7-antenna-A6020

The data transmitted by the tag may provide identification or location information, or specifics about the product tagged, such as price, color, date of purchase, etc.

Traffic Control

By extending this technology to traffic control and automation, RFID can be used to reduce traffic congestion and avoid accidents efficiently.

Traffic signals need not be static and can be made dynamic by intelligent use of RFID technology depending upon the road traffic conditions.

Animal Collars

SONY DSC


Low-frequency RFID tags are commonly used for animal identification. Pets can be implanted with small chips so that they may be returned to their owners if lost. Beer kegs are also tracked with LF RFID.

Libraries / Baggage

60275172_50bddd0f0a_b


High-frequency RFID tags are used in library book or bookstore tracking, pallet tracking, building access control, airline baggage tracking, and apparel item tracking. High-frequency tags are widely used in identification badges, replacing earlier magnetic stripe cards. These badges need only be held within a certain distance of the reader to authenticate the holder. The American Express Blue credit card now includes a high-frequency RFID tag, a feature American Express call express pay.

Truck/ Trailer Tracking in shipping yards

Wilma relief

UHF RFID tags are commonly used commercially in pallet and container tracking, and truck and trailer tracking in shipping yards.
Microwave RFID tags are used in long range access control for vehicles.

Remote Data Collection

3264489209_81f4e45544_z
Remote Data Collection

Sensors such as seismic sensors may be read using RFID transceivers, greatly simplifying remote data collection.
Location sensing of RFID with millimeter accuracy is possible by adding a low cost photo sensor. The real time location sensing supports many complex geometric queries.
Michelin began testing RFID transponders embedded into tires. After a testing period that is expected to last 18 months, the manufacturer will offer RFID enabled tires to car makers. Their primary purpose is tire-tracking in compliance with the United States Transportation, Recall, Enhancement, Accountability and Documentation Act (TREAD Act).

Smart Key/Smart Start

carkeyRFID

Starting with the 2004, a Smart Key/Smart Start option became available to cars. The key uses an active RFID circuit which allows the car to acknowledge the key’s presence within approximately 3 feet of the sensor. The driver can open the doors and start the car while the key remains in a purse or pocket.