Smart Water Leak Detection & Automatic Shut-Off System

Smart Water Leak Detection & Automatic Shut-Off System

Detect Slow Leaks. Stop Burst Hose Pipes. Save Water Automatically.

FlowShield is a smart water leak monitoring system that detects abnormal continuous water flow, slow leaks, burst hose pipes, and unattended taps — then automatically shuts off the water supply to help prevent water damage and water wastage.

Prevent Water Damage Before It Becomes Expensive

Water leaks can happen anytime — at night, during office closure, over the weekend, or while you are away on holiday.

A bidet hose may burst. A flexible pipe may fail. A water tap may be left slightly open. A valve may not be completely turned off. When nobody is around, water can continue flowing for hours or even days.

FlowShield is designed as a practical water leak detection system with automatic water shut-off. It helps protect homes, offices, rental units, toilets, pantries, shops, and facility zones from unnecessary water loss and water damage.

Common Water Leak Problems

Common Causes

  • Burst bidet hose
  • Water tap not fully turned off
  • Valve not completely closed
  • Toilet cistern leaking continuously
  • Faulty flush valve
  • Worn flexible hose
  • Loose pipe connection
  • Pantry tap left running
  • Washing machine hose failure
  • Water dispenser slow leak

Possible Damage

  • Unnecessary water wastage
  • Flooded toilets, kitchens, pantries, or service areas
  • Damaged cabinets, flooring, walls, and ceilings
  • Leakage to lower floors
  • Expensive repair work
  • Complaints from neighbours or tenants
  • Business interruption
  • Facility maintenance headaches

More Than a Basic Water Leak Alarm

A normal water leak alarm usually detects water only after it has reached the floor. By then, the water may already be spreading.

FlowShield works differently. It monitors the water supply line using a water flow sensor. When the system detects abnormal continuous water flow, it can trigger an alert and automatically close the shut-off valve.

If water keeps flowing continuously beyond the preset timing, FlowShield treats it as a possible leak, burst hose pipe, unattended tap, or faulty valve — and shuts off the water supply automatically.

Detects Slow Leaks and Burst Hose Pipes

Not all water leaks are the same. Some leaks happen suddenly with high water flow. Some leaks are small, slow, and easy to miss.

FlowShield can be configured to detect both fast leak events and slow continuous leak events by monitoring water flow rate and continuous flow duration.

Fast Leak Detection

High-flow leakage can waste a large amount of water quickly and cause serious damage.

  • Burst bidet hose
  • Broken pipe
  • Fully opened tap
  • Failed flexible hose
  • Pipe joint failure
  • Toilet hose bursting

Slow Leak Detection

Small continuous leaks may look harmless, but they can waste water for many hours if nobody notices.

  • Tap not fully turned off
  • Valve not completely closed
  • Toilet cistern slowly leaking
  • Flush valve not sealing properly
  • Bidet spray slightly dripping
  • Small pipe joint seepage
  • Water dispenser slow leak

How the Automatic Water Shut-Off System Works

1. Monitors Water Flow

A water flow sensor is installed on the water supply line to detect water movement through the pipe.

2. Measures Flow Duration

The electronic controller checks how long the water has been flowing continuously and compares it with the preset timing.

3. Detects Abnormal Usage

If the water keeps flowing for too long, the system identifies it as a possible leak, burst pipe, or unattended tap.

4. Closes the Water Valve

The automatic shut-off valve closes the water supply to stop further leakage and water wastage.

5. Sounds Alarm or Sends Alert

A local buzzer, LED indicator, or remote notification can alert the homeowner, office, or maintenance team.

6. Reset After Inspection

After the problem is checked and corrected, the user can press a reset button to restore normal operation.

Configurable Water Leak Monitoring

Every location has a different water usage pattern. FlowShield can be configured based on the expected usage of the area.

Area TypeExample Trigger SettingPurpose
Toilet Area10 minutesDetect unattended taps, burst bidet hoses, and abnormal toilet water usage
Home Use30 minutesGeneral protection against leaks, burst hoses, and forgotten taps
Pantry or Utility Area60 minutesAllow longer normal usage while still detecting abnormal continuous flow
Commercial or Facility AreaCustom timingAdjust based on site operation and water usage behaviour

For high-usage public areas, the system can also work with a human traffic sensor or occupancy sensor to help differentiate normal heavy usage from unattended water leakage.

Suitable for Homes, Offices, Rental Units and Facilities

FlowShield can be used as a home water leak detection system, an office water leak monitoring system, or a facility water leak prevention system.

Homes and Apartments

Protect against burst bidet hoses, leaking toilets, unattended taps, and water pipe failures while the family is asleep or away.

Small Offices

Monitor toilets, pantries, utility rooms, and cleaning points after office hours.

Rental Properties

Reduce the risk of unattended water damage caused by tenants, worn fittings, or forgotten taps.

Shops and Commercial Units

Protect premises during non-operating hours, weekends, and public holidays.

Schools, Hostels and Dormitories

Monitor washrooms, common toilets, pantries, and shared utility areas.

Factories and Warehouses

Deploy protection in selected water supply zones without shutting down water to the entire building.

Zone-Based Water Shut-Off Protection

For buildings and facilities, multiple FlowShield units can be installed strategically in different zones. This allows the system to isolate only the affected area instead of cutting off water to the entire building.

  • One unit for each toilet
  • One unit for each pantry
  • One unit for each rental room
  • One unit for each office floor
  • One unit for each building section
  • One unit for each high-risk water point

This makes FlowShield suitable for facility water leak monitoring, remote water leak alert, and selected-area automatic water shut-off applications.

Timer-Based Monitoring for Night, Weekend and Holiday Protection

Some locations have normal water usage during the day but very little usage at night. FlowShield can be configured to monitor more actively during selected periods.

  • Night monitoring from 10:00 pm to 7:00 am
  • After-office-hours monitoring
  • Weekend protection mode
  • Holiday protection mode
  • Special closure period monitoring

This is useful for homes, offices, shops, schools, dormitories, and facilities where water leakage may go unnoticed during non-operating hours.

Key Benefits of FlowShield

  • Automatic water shut-off when abnormal continuous flow is detected
  • Slow leak detection for taps, valves, cisterns, and small pipe seepage
  • Burst hose pipe protection for bidet hoses and flexible water hoses
  • Water damage prevention for homes, offices, and facilities
  • Remote water leak alert option for responsible personnel
  • Zone-based protection to isolate only the affected area
  • Configurable timing for different water usage patterns
  • Low-power monitoring for continuous protection

Smart Water Leak Detection Features

Depending on the application, FlowShield can support the following features:

  • Water flow monitoring
  • Continuous flow timing
  • Low-flow leak detection
  • Burst pipe and burst hose detection
  • Automatic shut-off valve control
  • Manual reset button
  • Local buzzer alarm
  • LED status indication
  • Remote notification option
  • Control office alert option
  • Night mode monitoring
  • Weekend and holiday monitoring
  • Human traffic sensor input option
  • Zone-based deployment
  • Flow event logging option
  • Building management integration option

Flow-Based Detection vs Floor Leak Sensors

Floor leak sensors are useful, but they only detect water after it reaches the sensor location. If water flows in another direction, the leak may not be detected immediately.

FlowShield detects abnormal water usage from the water supply line itself. This helps identify possible leaks before water spreads across the floor.

This makes FlowShield especially useful for toilets, pantries, under-sink areas, concealed areas, service rooms, rental rooms, and unattended premises.

Example Scenario: Burst Bidet Hose at Night

A bidet hose bursts at 2:00 am. Without protection, water may continue flowing for hours until someone wakes up or returns to the premises.

  1. FlowShield detects continuous water flow
  2. The controller starts measuring the flow duration
  3. The flow continues beyond the preset timing
  4. The automatic water shut-off valve closes
  5. A local alarm sounds or remote notification is sent
  6. Water wastage and damage are reduced
  7. The user resets the system after inspection

Example Scenario: Tap or Valve Not Fully Turned Off

A tap or water valve is not completely closed after use. Only a small amount of water continues flowing, so nobody notices immediately.

Without monitoring, this small leak may continue overnight or during a long holiday period.

  1. FlowShield detects small continuous water flow
  2. The controller monitors the flow duration
  3. The system identifies abnormal long-duration water usage
  4. An alert or automatic shut-off is triggered
  5. Water wastage is stopped

Simple System Components

Water Flow Sensor

Detects water movement through the pipe and helps identify continuous water flow conditions.

Electronic Monitoring Controller

Measures water flow duration and determines whether the flow pattern is normal or abnormal.

Automatic Shut-Off Valve

Closes the water supply when a leak, burst hose, or abnormal continuous flow condition is detected.

Alarm and Status Indicator

Provides local warning and system status indication when the system detects abnormal water flow.

Reset Button

Allows the user to reset the system after checking and correcting the leakage condition.

Optional Remote Alert Module

Sends notification to the homeowner, tenant, maintenance team, security office, or control room.

Comparison: Basic Water Leak Alarm vs FlowShield

FeatureBasic Water Leak AlarmFlowShield Water Protection System
Detects water on floorYesOptional
Detects continuous water flowNoYes
Detects slow continuous leaksNoYes
Detects burst hose pipe conditionLimitedYes
Automatically shuts off waterNoYes
Works before water spreads on floorNoYes
Suitable when nobody is aroundLimitedYes
Supports zone-based protectionNoYes
Can send remote water leak alertSome modelsYes
Helps save waterLimitedYes

Frequently Asked Questions

Can this system detect a small water leak?

Yes. The system can be configured to detect small continuous water flow, such as a tap not fully turned off, a valve not completely closed, or a toilet cistern slowly leaking.

Can it stop a burst bidet hose?

Yes. If a bidet hose or flexible hose bursts and water keeps flowing continuously beyond the preset timing, the system can automatically shut off the water supply.

Will normal water usage trigger the shut-off?

Normal short water usage should not trigger the shut-off. The system is based on abnormal continuous water flow duration and can be adjusted according to the location.

Can this be used in offices or commercial facilities?

Yes. FlowShield can be deployed in toilets, pantries, service rooms, rental rooms, office floors, and facility zones. Multiple units can be installed to isolate only the affected area.

Can it send remote alerts?

Yes. An optional remote alert module can notify a homeowner, tenant, security office, maintenance team, or control room when abnormal water flow is detected.

Protect Your Property Before the Next Water Leak Happens

Water leaks are unpredictable. They can happen while you sleep, while your office is closed, or while nobody is around.

FlowShield gives you a practical layer of protection against slow leaks, burst hose pipes, unattended taps, and abnormal continuous water flow.

Detect Slow Leaks. Stop Burst Hose Pipes. Save Water Automatically.

Controller for Electrode Water Sensor Rods

Water Tank Level sensor controller

Choosing the Right Controller for PS-5R Water Level Sensor Rods

The PS-5R electrode holder is used together with a conductive / floatless water level controller. The electrode rods detect water contact, while the controller converts that signal into relay output for pump control, high level alarm, low level alarm, or level indication.

✓ Water tank level sensing

✓ Pump control

✓ High / low level alarm

✓ Conductive liquid sensing

PS-5R Is the Sensor Holder — The 61F Is the Controller

A common misunderstanding is to treat the PS-5R as a complete water level sensor system. In actual use, the PS-5R is the electrode holder and rod assembly. It needs a compatible controller such as the Omron 61F series to operate the relay output.

1. Electrode Holder

PS-5R

Holds up to 5 electrode rods. The rods are cut to different lengths according to the required water levels.

2. Controller

61F Series

Detects the conductive path through water and provides relay output for control, alarm, or indication.

3. Output Device

Pump / Alarm

The controller output can drive a contactor, pump starter, alarm lamp, buzzer, PLC input, or BMS input.

Most Common Controller Choices

For most PS-5R water level applications, customers usually choose between a basic controller such as 61F-GP-N and a multi-level controller such as 61F-G3N.

Basic Level Control

61F-GP-N

Choose this when you only need simple water level control, such as pump ON/OFF between two levels or a single high/low level alarm.

  • Suitable for simple tank level control
  • Good for 1 or 2 level points
  • Compact plug-in type controller
  • Common choice for basic pump start/stop applications
  • Cost-effective for simple control panels

Multi-Level Control + Alarm

61F-G3N

Choose this when you need pump control together with high and low water level alarm points. This is usually the better choice for fire water tanks, service tanks, and applications where multiple level signals are required.

  • Suitable for multiple level points
  • Can support pump control plus high/low level alarms
  • Cleaner setup than using multiple basic controllers
  • Recommended for 3-level fire water tank monitoring
  • Better for control panels with alarm outputs

61F-GP-N vs 61F-G3N: Which One Should You Use?

Selection Point61F-GP-N61F-G3N
Best forSimple level control Pump control with high / low alarm
Typical number of level points1 or 2 level points3 or more level functions depending on wiring and application
Typical applicationBasic tank full/empty control, pump start/stop, simple high or low alarmFire water tank, service water tank, refill tank, tank with high alarm and low alarm
When to chooseChoose when the customer only needs basic pump ON/OFF or one simple alarm outputChoose when the customer needs more complete monitoring, such as high level, refill control, and low level alarm
Panel designSmaller and simpler panel. Suitable for basic applicationsMore complete control panel. Suitable when alarm points must be clearly separated
Recommended for PS-5R?Yes, for simple applications using only some of the rodsYes, especially when using PS-5R for multi-level monitoring
Simple recommendationUse this for basic tank controlUse this for fire water tank / 3-level monitoring

Typical 3-Level Fire Water Tank Setup

For a fire water tank, a typical setup uses one common electrode and several level electrodes. The common electrode is normally the longest rod. The other rods are cut to the required alarm and control levels.

Electrode LevelFunctionTypical Action
High AlarmDetects overfill or high water conditionTrigger high level alarm, indicator lamp, BMS input, or alarm panel input
Stop RefillNormal full levelStop refill pump or close inlet valve
Start RefillNormal low operating levelStart refill pump or open inlet valve
Low AlarmLow water reserve warningTrigger low level alarm, fire alarm monitoring input, or BMS input
Common ElectrodeReference electrodeUsually the longest rod, extending below the lowest detection point

Practical recommendation: For a 3-level fire water tank application, use the PS-5R electrode holder together with a multi-level controller such as 61F-G3N. This gives a cleaner solution for refill control plus high and low level alarm.

How to Select the Correct 61F Controller

Step 1: Count the Required Levels

If you only need simple pump ON/OFF, 61F-GP-N is usually enough. If you need high alarm, normal control, and low alarm, use 61F-G3N.

Step 2: Check Cable Distance

If the tank is far from the control panel, a long-distance version may be required. This is important for rooftop tanks, remote tanks, and large facilities.

Step 3: Check Water Conductivity

Conductive level controllers require the liquid to conduct electricity. Normal tap water is usually suitable, but very clean or low-conductivity water may need a high-sensitivity model.

Other 61F Variants You May See

Besides the normal general-purpose models, 61F controllers may also come in special versions depending on site conditions.

Variant TypeMeaningUse When
General-purposeStandard model for normal conductive water level controlNormal tap water, tank control, refill pump control
Long-distance typeDesigned for longer wiring distance between tank electrodes and controllerTank is far away from the control panel
High-sensitivity typeMore sensitive detection for lower-conductivity liquidClean water, rainwater, purified water, or weakly conductive liquid
Low-sensitivity typeLess sensitive to leakage current, condensation, foam, or wet cable pathsNoisy environments or sites with false triggering problems
Two-wire typeSpecial wiring method for reducing electrode wiringUse only when matched with the correct two-wire electrode holder / application

Quick Recommendation

Choose 61F-GP-N if…

  • You need simple water level control.
  • You only need pump ON/OFF between two levels.
  • You only need one high or low level alarm.
  • You want a compact and cost-effective controller.

Choose 61F-G3N if…

  • You need 3-level water tank monitoring.
  • You need pump control plus high and low alarms.
  • You are monitoring a fire water tank or service water tank.
  • You want a cleaner solution than using multiple basic controllers.

Important note for fire water tanks: Fire water tank alarm and control requirements may be subject to project specifications, local authority requirements, fire code requirements, and licensed fire protection contractor approval. Always confirm the final control logic and alarm connection with the project consultant or qualified contractor.

Need Help Choosing the Correct Water Level Controller?

Tell us your tank application, number of level points, cable distance, water type, and required output such as pump control, high level alarm, low level alarm, PLC input, or BMS input. We can help recommend a suitable controller setup for use with PS-5R electrode rods.

Executive Protocol

Executive Protocol, also known as EXE, Exec or Protocol A, is one of the classic communication standards used between vending machines and payment systems. It is especially well known in Europe and is still commonly found in older vending machines, particularly in markets such as Italy, France and Spain.

What Is Executive Protocol?

Executive Protocol is a vending machine communication protocol used to connect the vending machine controller with payment devices such as coin mechanisms, change givers and payment controllers. It was originally developed as a proprietary protocol by Mars Electronics International, also known as MEI, and became widely adopted in the vending industry.

In many vending machine installations, Executive Protocol is used to manage payment credit, product pricing, vend authorisation and communication between the vending machine and the payment system.

Simple explanation: Executive Protocol is the communication language used by some vending machines and payment systems to decide when enough money has been inserted and whether the machine should allow a product to be dispensed.

Common Names for Executive Protocol

Depending on the machine manufacturer, payment system supplier or technical manual, Executive Protocol may be referred to using different names.

The full name commonly used in vending machine manuals and payment system documentation.

EXE / Exec

Short form used by many vending technicians and machine suppliers.

Protocol A

An alternative technical name often associated with MEI / Mars payment system documentation.

Why Executive Protocol Is Important

Executive Protocol remains important because many vending machines in Europe were designed around this payment interface. While newer machines often use MDB, there are still many machines in the field that continue to use Executive Protocol.

This is especially relevant when upgrading an older vending machine with modern payment systems such as cashless card readers, QR payment terminals, telemetry devices or remote monitoring systems.

  • It is widely used in older European vending machines.
  • It is commonly associated with Italian vending machines.
  • It is often found in machines using older coin mechanisms or payment controllers.
  • It may require an adapter when connecting to modern MDB-based cashless systems.
  • It is useful to understand when repairing, retrofitting or upgrading vending machines.

Executive Protocol in Europe and Italy

Executive Protocol is commonly found in European vending machines, especially in countries such as Italy, France and Spain. In the Italian vending industry, Executive Protocol has historically been very popular, and many technicians consider it one of the dominant protocols used in older Italian vending machines.

Industry observation: It is often said within the vending industry that a very high percentage of Italian vending machines use Executive Protocol, with some estimates claiming around 90%. The exact percentage can vary depending on machine age, manufacturer, location and whether the machine has been upgraded to MDB or cashless payment systems.

For this reason, anyone working with Italian vending machines, imported European machines or older coffee and snack vending machines may need to understand Executive Protocol.

Executive Protocol vs MDB

Executive Protocol and MDB are both vending machine payment communication protocols, but they are not the same. MDB is now more common in modern vending machines, while Executive Protocol is more commonly associated with older European vending systems.

FeatureExecutive ProtocolMDB Protocol
Common NameExecutive, EXE, Exec, Protocol AMDB, Multi-Drop Bus
Typical UsageOlder vending machines, especially in EuropeModern vending machines worldwide
Common RegionEurope, especially Italy, France and SpainGlobal vending market
Payment System RoleThe payment system has a strong role in controlling vend credit and permissionThe vending machine controller usually acts as the main controller and polls MDB devices
Cashless UpgradeMay require an Executive-to-MDB adapter or compatible cashless deviceUsually easier to connect to modern card readers, QR payment terminals and telemetry systems
Best ForMaintaining or upgrading older European vending machinesNew vending machine designs and modern cashless payment integration

Is Executive Protocol Open Source?

Executive Protocol was originally created as a proprietary vending machine protocol. Over time, as the protocol became widely used and many older machines remained in service, information about the protocol became more accessible to technicians, payment system suppliers and vending machine developers.

Today, Executive Protocol is often treated as an open or publicly documented legacy protocol in practical vending machine work. This makes it possible for repairers, retrofitters and equipment developers to support older machines that still rely on Executive communication.

Important note: “Open source” and “open protocol” are not always the same thing. Executive Protocol is better described as a widely documented legacy vending protocol rather than software source code. When developing commercial equipment, always check the actual protocol specification, electrical interface and any relevant compliance requirements.

MDB to Executive Protocol Converter

One common challenge is connecting modern MDB-based payment devices to older vending machines that use Executive Protocol. In this situation, an MDB to Executive Protocol converter can be used as an interface between the modern payment system and the older machine.

A converter board may translate communication between MDB and Executive Protocol, allowing the vending machine to work with newer cashless payment terminals, card readers, QR payment systems or telemetry devices.

  • Connects modern MDB payment devices to older Executive vending machines.
  • Translates payment credit and vend authorisation signals.
  • Helps extend the useful life of older European vending machines.
  • Allows upgrade paths for cashless payment and remote monitoring.
  • Can be useful for vending machine retrofit and repair projects.

When Do You Need Executive Protocol?

You may need Executive Protocol knowledge when working with vending machines that do not support MDB directly, or when the existing payment system is based on Executive communication.

Common situations include:

  • Replacing an old coin mechanism in a European vending machine.
  • Adding a cashless payment terminal to an older machine.
  • Repairing an Italian coffee, snack or drink vending machine.
  • Connecting a telemetry system to a vending machine using Executive Protocol.
  • Building an adapter between Executive Protocol and MDB.
  • Developing a custom payment controller for older vending machines.

Executive Protocol Adapter and Upgrade Considerations

Many modern cashless payment devices are designed around MDB because MDB is widely supported in newer vending machines. If the vending machine only supports Executive Protocol, an adapter may be required.

The adapter may perform one of the following functions:

  • Convert Executive Protocol to MDB.
  • Allow an MDB cashless reader to work with an Executive vending machine.
  • Translate payment credit and vend commands between the two systems.
  • Provide compatibility between old vending machines and modern payment terminals.

Practical recommendation: For a new vending machine project, MDB is usually the better starting point. For supporting older European vending machines, Executive Protocol support can be added as a compatibility feature or through a dedicated adapter.

Technical Points to Check

Before connecting to an Executive Protocol vending machine, it is important to check the machine manual and payment system documentation. Different machines and payment systems may have different wiring, connector pinouts and configuration options.

  • Connector type and pinout
  • Voltage level and power supply requirement
  • Executive / EXE mode setting in the vending machine
  • Payment system compatibility
  • Vend price configuration
  • Credit handling and vend authorisation behaviour
  • Whether the machine supports MDB, Executive, BDV or multiple protocols

Summary

Executive Protocol is an important legacy vending machine communication standard. It is especially relevant in Europe and is commonly associated with Italian vending machines. Although MDB is now more common in modern vending machine designs, Executive Protocol is still important for servicing, upgrading and integrating payment systems with older machines.

For businesses working with vending machine payment systems, understanding Executive Protocol can help when upgrading old machines, adding cashless payment, troubleshooting coin mechanisms or designing protocol adapters.

Need Help with Vending Machine Payment Integration?

PIC-CONTROL can help with vending machine interface projects, including MDB, Executive Protocol, coin mechanisms, cashless readers, protocol converters and custom payment interface hardware.

Documentation

Pressure Switch

A pressure switch is a practical and reliable sensor used to monitor and maintain water pipe pressure in pumps, water systems, tanks, and piping installations. It helps detect pressure changes and automatically triggers connected equipment when the pressure reaches a preset pressure level.

We supply pressure switches suitable for industrial, commercial, and general water pressure control applications in Singapore.


What Is a Pressure Switch?

A pressure switch is a control device that responds to pressure in a pipe or system. When the water pressure rises or drops to a preset value, the pressure switch opens or closes an electrical contact.

This allows the switch to control pumps, alarms, indicators, or other equipment used to maintain safe and stable water pressure.

Common Applications

  • Water pump pressure control
  • Water pipe pressure monitoring
  • Booster pump systems
  • Water tank pressure systems
  • Industrial water piping
  • Building maintenance systems
  • Automatic pump start and stop control
  • Pressure safety monitoring

How It Helps Maintain Water Pipe Pressure

In a water pipe system, pressure may change due to pump operation, water usage, leakage, or system demand. A pressure switch helps monitor these changes and sends an electrical signal when the pressure reaches the preset value.

For example, when the pipe pressure drops below a certain level, the pressure switch can activate a pump. When the pressure reaches the desired level, the switch can stop the pump. This helps maintain consistent water pressure and protects the system from unnecessary pump operation.

Key Features

  • Reliable pressure sensing for water pipe systems
  • Suitable for pump control and pressure monitoring
  • Helps maintain stable water pressure
  • Can be used for automatic start and stop control
  • Compact and easy to install
  • Suitable for commercial and industrial applications
  • Available in different pressure ranges
  • Durable design for long-term operation

Why Use a Pressure Switch?

A pressure switch is useful when you need a simple and effective way to control equipment based on water pressure. It reduces the need for manual monitoring and helps protect pumps and pipe systems from pressure-related problems.

It is commonly used in water supply systems, pump rooms, industrial equipment, and building maintenance applications.

PS-100 Digital Pressure Switch

Product Specifications

Product TypePressure Switch / Pressure Sensor Switch
ApplicationWater pipe pressure monitoring and pump control
MediumWater or compatible liquid
Pressure RangePlease check with us for available pressure range
OutputElectrical switching contact
InstallationPipe, pump, or pressure line installation
UsagePressure control, pump automation, safety monitoring

Product NameDigital Pressure Switch
ModelPS-100
Pressure Range-0.1 to 60 MPa
Power Supply24VDC, 220VAC, 380VAC optional
Alarm OutputDual relay signal, each group normally open / normally closed
Alarm SettingFull range adjustable
Control OutputDual relay output
Load Capacity24VDC 3A, 220VAC 3A
Process ConnectionM20 × 1.5, G1/2, G1/4
Operating Temperature-20°C to 60°C
Measuring MediumGas, oil, water, and other media compatible with 304 stainless steel
Wetted Material304 stainless steel pressure port
InstallationAxial or radial installation optional
Wiring DefinitionPower: red / blue. High alarm: green. Low alarm: yellow. Common: black.

Model PS-100

Product NameDigital Pressure Switch with Plastic Housing
ModelPS-100
Pressure Range-0.1, 0.1, 0.6, 1, 1.6, 2.5, 6, 10, 25, 40, 60 MPa options
Overload Pressure150%
AccuracyBetter than 1%
Power Supply12VDC, 24VDC, 220VAC, 380VAC optional
Alarm SettingFull range adjustable
Output SignalRelay switch output
Load Capacity380V 3A, 220V 5A, 24V 5A
Sampling Rate5 times per second
Operating Temperature-20°C to 80°C
Measuring MediumGas, oil, water, and other media compatible with 304 stainless steel
Wiring ProtectionReverse polarity and short circuit protection
Process ConnectionM20 × 1.5, G1/2, G1/4
Wiring DefinitionPower: red / blue. Output: black / white.

Suitable for Singapore Water Pressure Applications

This pressure switch is suitable for customers in Singapore who need to monitor or control pressure in water piping systems. It can be used by contractors, maintenance teams, equipment builders, facility managers, and industrial users.

Whether you are replacing an existing pressure switch or building a new water pressure control system, we can help you select a suitable model based on your pressure range, connection size, and control requirement.

Product Dimension

Wiring Connection

Before Ordering

To recommend the correct pressure switch, please provide the following information:

  • Required pressure range
  • Pipe connection size
  • Type of liquid or medium
  • Electrical contact requirement
  • Application: pump control, alarm, monitoring, or safety
  • Quantity required

Need Help Choosing the Right Pressure Switch?

If you are unsure which pressure switch is suitable for your water pipe system, contact us with your application details. We can help you check the pressure range and recommend a suitable option.

Contact us today for pressure switch availability, pricing, and technical support in Singapore.

ICSP Circuit Design for Microchip microcontrollers

This page provides standard ICSP circuit design references for Microchip microcontrollers in SSOP-28, TSSOP-14/20, and SOT23-6 packages. These schematic blocks are intended for direct reuse in new designs, helping engineers implement a proven programming interface quickly and consistently.

Introduction

In-System Programming and Debugging (ICSP) is the standard method used to program many Microchip microcontrollers directly on the target board. Because the ICSP connection is widely used across products and projects, engineers often look for a proven reference circuit that can be copied into a new design with minimal modification.

This page provides standard ICSP circuit design references for common Microchip microcontroller package options. The goal is to give hardware designers a quick and reliable starting point for schematic capture and PCB design, while helping maintain programming compatibility, debugging access, and good signal integrity.

The reference circuits shown here cover three common package groups from Microchip microcontroller:

  • SSOP-28
  • TSSOP-20 / TSSOP-14
  • SOT23-6

These circuits are intended as standard implementation examples for typical engineering use. In most cases, they can be copied directly into a design and then adjusted only as needed for product-specific power, reset, connector, or layout requirements.

Standard ICSP Circuit Design Reference

This section collects standard ICSP schematic references for commonly used Microchip microcontroller packages. These designs are intended to support fast development and consistent implementation across projects.

Each reference circuit includes the essential connections required for device programming and, where applicable, debugging:

  • VPP / MCLR
  • VDD
  • VSS
  • PGD (Program Data)
  • PGC (Program Clock)

Depending on the device family, additional considerations such as pull-up resistors, decoupling capacitors, isolation resistors, or shared application pin usage may also apply.


Design Objective

The purpose of these reference circuits is to:

  • provide a known-good ICSP implementation
  • reduce schematic design time
  • improve consistency across hardware platforms
  • minimize programming and debugging issues during development and production
  • give engineers a circuit they can confidently reuse in new designs

These references are especially useful when the ICSP pins are multiplexed with application I/O and the designer needs a practical, standard connection approach.


General ICSP Design Guidelines

When using these reference circuits, the following practices are recommended:

1. Keep the ICSP interface accessible

Always provide a clear connection path to the programming tool through a dedicated header, test pads, pogo-pin interface, or production fixture.

2. Protect MCLR / VPP behavior

The MCLR/VPP line must support both normal device reset behavior and programming voltage entry requirements. Use the recommended pull-up network and avoid excessive loading on this pin.

3. Manage shared PGC and PGD signals

If PGC and PGD are also used by the application circuit, ensure connected circuitry does not interfere with programming or debugging. Isolation resistors may be used where needed.

4. Place decoupling capacitors close to the device

Power stability is important during programming and normal operation. Place bypass capacitors close to the microcontroller power pins.

5. Keep routing short and clean

Route ICSP signals with short, direct traces where possible. Avoid unnecessary stubs, heavy capacitive loading, or strong pull devices that can affect signal quality.

6. Verify connector orientation and pin definition

Use a consistent ICSP pinout and clearly mark the connector orientation in the schematic and PCB silkscreen to prevent programming errors.


Reference Circuits

1. SSOP-28 Microchip Microcontroller

This reference shows the standard ICSP implementation for Microchip microcontrollers in SSOP-28 package format. It is suitable for designs where the device provides a larger I/O count while still requiring a straightforward programming interface.

ICSP for SSOP28 Microchip Micro-controller

Typical use cases include:

  • general embedded control
  • mixed I/O applications
  • cost-sensitive designs using 8-bit Microchip MCUs

The reference circuit includes the required ICSP connections and recommended support components for stable programming and debugging. It can be used as a baseline schematic block in new SSOP-28 designs.

Recommended notes for this section:

  • show ICSP header or programming pads
  • identify MCLR/VPP pull-up arrangement
  • show VDD and VSS connection points
  • identify PGC and PGD pins by device pin number
  • note any resistors used for signal isolation if pins are shared with other functions

2. TSSOP-14 / TSSOP-20 Microchip Microcontroller

This reference covers TSSOP-14 and TSSOP-20 package devices. These packages are commonly selected for compact designs that still require a standard external ICSP interface.

Because pin count is lower, programming pins are often shared with functional application signals. For that reason, attention should be given to loading, signal direction, and any external circuitry attached to MCLR, PGC, and PGD.

ICSP for TSSOP20 TSSOP14 Microchip Micro-controller

This reference is intended to provide a compact, reusable ICSP design block that fits well into space-constrained products while preserving programming reliability.

Recommended notes for this section:

  • indicate which version applies to 14-pin and 20-pin devices
  • call out any common circuit differences if they exist
  • note precautions for multiplexed I/O on PGC/PGD
  • show recommended decoupling and reset components
  • indicate connector or pad access for manufacturing and development

3. SOT23-6 Microchip Microcontroller

This reference provides the standard ICSP circuit for SOT23-6 Microchip microcontrollers. These devices are typically used in highly space-constrained applications where simplicity, small size, and low component count are important.

Because of the very limited number of pins, nearly every signal is critical. The ICSP design must therefore be implemented carefully so that programming access is preserved without disturbing normal application behavior.

ICSP for SOT23-6 Microchip Micro-controller

This reference is intended as a compact standard solution for small-form-factor products and should be used as the preferred starting point for SOT23-6-based designs.

Recommended notes for this section:

  • identify the programming pins clearly
  • highlight any pin-sharing constraints
  • keep support circuitry minimal but compliant with programming needs
  • note layout sensitivity due to package size
  • show practical programming access method, such as test pads or fixture pads

How to Use These References

These ICSP reference circuits are intended to be copied directly into new designs as standard schematic building blocks. Before release, the designer should still confirm the following against the selected microcontroller datasheet:

  • programming pin assignment
  • MCLR/VPP requirements
  • supported debug interface behavior
  • supply voltage requirements during programming
  • any package-specific limitations
  • any family-specific recommendations from Microchip

Using a standard reference reduces risk, but final validation should always be completed for the exact device being used.


Recommended Engineering Note

These circuits are provided as standard internal design references for Microchip microcontroller ICSP implementation. They are intended to accelerate design reuse and improve consistency across projects. Final design verification remains the responsibility of the hardware engineer for the specific device and application.


Hotel Card Holder Switch

Integration-Ready Card Switch

Hotel Card Holder Switch for automation system integration

Simplify Access. Maximize Control.

In today’s smart environments, complexity is often the biggest obstacle. Traditional hotel card switch holders rely on RFID technologies, voltage requirements, and proprietary systems — making integration difficult for modern smart homes and PLC-based automation.

Introducing the Mechanical Hotel Card Holder Switch — a simple, reliable, and integration-friendly passive card holder switch designed specifically for smart system professionals.

Designed for Smart Integration

Unlike RFID-based card holders, this solution uses a pure mechanical switch mechanism. No frequency compatibility issues. No signal interference. No unnecessary electronics.

Just insert a card — and the system responds instantly.

This makes it ideal for:

  • Smart home integrators
  • KNX/EIB smart home automation system
  • PLC automation systems
  • Building management systems (BMS)
  • Custom IoT solutions

Features

  • No Power Required
  • Dry Contact Card Holder Switch
  • Suitable for Low Voltage System
  • Integration-Ready Card Switch

Key Features:

Universal Card Compatibility

Works with any card size — hotel cards, membership cards, or even custom placeholders. No RFID dependency.

Dry Contact Output

Provides clean, voltage-free switching (dry contact), making it easy to connect to:

  • Smart home controllers
  • PLC inputs
  • Relay modules
  • Low-voltage automation systems

No Power Required

Unlike traditional 230VAC units, this device:

  • Requires no external power supply
  • Eliminates wiring complexity
  • Reduces installation cost

Instant Response

Pure mechanical action ensures:

  • Zero latency
  • High reliability
  • Long operational life

Clean & Minimal Design

Modern, neutral aesthetics that fit:

  • Hotels
  • Serviced apartments
  • Smart homes
  • Offices

4 Colours to Choose from

  • Classic White
  • Matte Black
  • Champagne Gold
  • Silver Grey
4 colours to choose from (mechanical card holder switch 86 x 86mm faceplate)

Dimension of Card Holder

Standard 86x86mm socket

Also available in 120 type style faceplate

Style: 120 type faceplate

Custom Logo & Text

Faceplate customisation is available. Please contact us with your designed layout.

Perfect for Smart Systems

This product is built with system integrators in mind.

Seamless Integration Examples:

  • Trigger lighting scenes via smart controller
  • Enable HVAC systems when card is inserted
  • Activate energy-saving modes when removed
  • Interface directly with PLC digital inputs

🏗️ Ideal Applications

  • Smart homes
  • Boutique hotels
  • Airbnb / serviced apartments
  • Office energy-saving systems
  • Industrial control environments

💡 A Smarter, Simpler Choice

When your system already has intelligence, you don’t need more electronics — you need reliable input.

This mechanical card holder gives you exactly that:

  • No compatibility issues
  • No unnecessary complexity
  • Just clean, dependable switching

📦 Product Summary

  • Type: Mechanical card holder switch
  • Output: Dry contact (NO/NC options available)
  • Power: Not required
  • Compatibility: Universal card support
  • Installation: Standard wall box

🚀 Ready to Integrate?

Upgrade your projects with a solution designed for simplicity, flexibility, and reliability.

Contact us today to request a quote.

Automated Trellis Shade Control System

An Automated Trellis Shade Control System is becoming increasingly popular in Singapore due to the city’s hot climate, strong sunlight, and frequent sudden rain. These systems feature a smart roof structure—typically built with aluminium louvers or retractable fabric—that can open or close automatically depending on weather conditions.

Product Information

Product of Sunshade Trellis System Pte. Ltd. (Singapore)
Visit website: https://sunshadetrellis.wixsite.com/home

How the System Works

The trellis is powered by a motorised mechanism that allows the louvres or fabric panels to turn open for ventilation or sunlight and close completely for protection. When the system is in the sun shade position, it reduces heat gain on balconies, patios, and rooftop terraces.

Because the system is automated, it can operate on its own without user input. Sensors monitor environmental conditions, and the trellis will auto-close when rain is detected. This is especially useful in Singapore, where showers often come unexpectedly. At the same time, the roof can open automatically when conditions are safe, allowing airflow and natural daylight.

Trellis is an alternative to an awning for those who prefer a solid structure that can withstand wind and rain.

Key Features

  • Automated open/close control through remote, wall switch, or mobile app
  • Weather sensors that trigger auto-close when it rains
  • Adjustable louvre angles that let users turn open the roof partially or fully
  • Effective sun shade during peak afternoon heat
  • Strong, durable structure suitable for tropical climates

Why It’s Ideal for Singapore

Outdoor living spaces in Singapore—from HDB balconies to landed patios—benefit greatly from flexible weather control. An automated trellis enhances comfort by blocking heat, keeping areas dry, and providing a reliable shade solution that adapts instantly to changing skies.

Project 1

by Sunshade Trellis System Pte. Ltd. (Singapore)

Project 2

by Sunshade Trellis System Pte. Ltd. (Singapore)

Project 3

by Sunshade Trellis System Pte. Ltd. (Singapore)

Trellis Single-Bay Control Board

Single-Bay Trellis control board from
Sunshade Trellis System Pte. Ltd. (Singapore)

This control board provides the control for a single bay roof Trellis system. It can be identified from the 3 switches user control wall-switch.

Trellis Single-Bay Control Board Wiring Schematic

The top button is a rain sensor enable switch. Switching it to the down position will enable rain sensing. The Trellis will automatically close the Trellis from it detects the rain.

The two lower buttons are for Trellis panel control.

The left (yellow) momentary switch is for opening the Trellis roof panel. A single quick press and release will activate the Trellis to open the roof panel fully. If this button is pressed (and held), the panel will turn to open and halt only when the button is released.

The right (red) momentary switch is for closing the Trellis roof panel. A single quick press and release will activate the Trellis to close the roof panel fully. Similar to the open button, when this button is pressed (and held), the panel will do the closing and halt only when the button is released.

Trellis Multi-Bay Control Board

Multi-Bay Trellis control board from
Sunshade Trellis System Pte. Ltd. (Singapore)

This multi-bay board provides the control for 2 or more roof Trellis bay systems. It can be identified from the 4 switches user control wall switch.

Trellis Multi-Bay Control Board Wiring Schematic

This multi-bay user interface is similar to the single-bay version. It has an extra switch on the top left corner of the user switch panel. This button selects the bay that you want to control. Press one time for bay number 1, press two times for bay number 2.

The selected bay can be seen from the LED indicator (turned on) on the switch panel. The LED, starting from the left, indicates bay number 1, 2, 3, all the way to bay 6, which is the maximum number of Trillis roof bays this board can support.

Only when a bay is selected can the open/close button function. A blinking LED indicates that the board is now driving the motor of the particular bay when the open/close button is pressed. The LED indicator on the circuit board will also be lit up, indicating the status of the operation.

Troubleshooting the controller board.

— To be updated soon —

Battery Replacement

The system uses SLA (Sealed Lead Acid) battery as a means to drive the DC geared motor. Typical installation uses 12V 7Ah SLA battery. You can also use a smaller SLA battery rated 12V 1.3Ah.

These batteries can usually last for years, but they do wear off over time.

A typical full charge voltage measurement is expected to be between 13V to 13.8V. This is a healthly voltage level. When the voltage of the battery is measured below 12V, it is likely that the battery is worn and requires replacement.

Please handle the battery with care. Connect the correct polarity to the battery terminal. Please handle with care, and do not to short the positive (+) and the negative (-) terminal of the SLA battery, as it can catch fire instantly.

Motor Replacement

The motor used for this Trellis is a 12V geared DC motor (7 gear teeth version) that is typically used for the vehicle winding windows. It is important to note that there is a Left and Right versions of the motor.

The tools required to remove the motor panel is mainly a 10mm spanner and an Allen key set. The motor panel has to be dismounted in order for the motor to be replaced.

Trellis panel install calibration

These Trellis controllers are designed for simple installation without using any limit switch to set the motor motion boundary.

The Trellis calibrated position has its panel opened to 90 90-degree angle. At this angle, the gear teeth should be hitting the boundary limit stud. At the calibrated position, tighten the two M6 hex screw to lock the lever in position.

The panel’s closed position will naturally set the limit boundary. The panel will be closed tightly, resulting in a current surge which becomes an indicator for the controller to stop the motor.

New Model for Trellis Control Board

Click here for the newer Trellis control board model and documentation.

New automated Trellis control board

Raspberry Pi

Raspberry Pi (low level I/O electronics control)

Get started with Raspberry Pi (RPi), a step by step approach to get your Raspberry Pi with low level electronics hardware control.

Make simple, step by step.


Edited by Lim Siong Boon, last dated 22-Sep-2013.

Topic Discussion Overview

  1. Installation from scratch
  2. Hardware Pin Out
  3. Raspberry Pi, HelloWorld for I/O pins
  4. Understanding UART, SPI, I2C port on Raspberry Pi
  5. Networking on Raspberry Pi
  6. Accessing Raspberry Pi through the network
  7. C Programming
  8. Python Programming
  9. Java Programming
  10. List of frequent used Commands
  11. Add Wifi to Raspberry Pi


1. Installation from scratch

 

 

Your orientation to Raspberry Pi.

http://www.raspberrypi.org/

Status LED Indicator
OK  (Green) – SDCard Access       (D5 via GPIO16)
PWR (Red)   – 3.3 V Power         (D6           )
FDX (Green) – Full Duplex   (LAN) (D7 Model B   )
LNK (Green) – Link/Activity (LAN) (D8 Model B   )
10M (Yellow)- 10/100Mbit    (LAN) (D9 Model B   )

Click here for Raspberry Pi Schematic

STEP 01:

Download this quick start up guide to help you install your Linux OS on your Raspberry Pi.

STEP 02:

Get yourself a 4GB SD card, which is enough for use in many application.


NOTE: Not all SD cards work with the Raspberry Pi. High speed cards can be too fast for the Raspberry Pi bus. Check out which SD card is suitable for your Raspberry Pi. It has a lists of cards that have and have not worked for Raspberry Pi users. http://elinux.org/RPi_SD_cards

You may also like to check out the various peripherals that are compatiable to Raspberry Pi.
http://elinux.org/RPi_VerifiedPeripherals

 

STEP 03:

Format your SD card with SD Formatter 4.0 for SD/SDHC/SDXC
SDFormatter4exe.zip (5.99MB)

 

 

STEP 04:

You can download the image version New Out Of Box Software (NOOBS), extract all the files and copy into your SD card.

Insert this SD card into your Raspberry Pi, and power on it. Follow the instruction on your screen display to complete the installation process.

 

 

 

 

 

STEP 05:

You will be ask to select an Linux OS to install on your Raspberry Pi.

Choose the recommended “Raspian”, which is also the Raspbian “wheezy”.

The installation process will proceed.

 

Proceed to step 10.

Installing Raspbian operating system onto my Raspberry Pi.

 

 

 

STEP 06:

As of 02 Nov 2013, Raspbian now supports and pre-installed with Java.

Note: For those who want to run Java SDK on Raspberry Pi.

Raspbian “wheezy” is the recommended Linux OS for Raspberry Pi. This version is optimized to be run by Raspberry Pi which is using RP’s ARM processor supporting ‘hard-float’. However Java SDK only support ‘soft-float’ at this point in time (Jul 2013).

This call for another Debian Linux version which is known as Soft-float Debian “wheezy” (It is same as Raspbian “wheezy”, except that it will be slower. Use this version if you need to run Java JDK Linux ARM)

 

 

STEP 07:

Download and run the Win32DiskImager on your Windows Operating System.
win32diskimager-v0.8-binary.zip (5.67MB)

You can download the latest version at this website,
http://sourceforge.net/projects/win32diskimager/


STEP 08:

Unzip the Debian Linux version Soft-float Debian “wheezy”, which is a “2013-05-29-wheezy-armel.img” file.

Run the program Win32 Disk Imager.
a) Select the Image File “2013-05-29-wheezy-armel.img”
b) Select the Device, which is your storage drive for your SD card.
c) Click on the <Write> button to write the raw image onto your SD card.

Note: You can also use Win32 Disk Imager software to backup (clone)your existing SD card image, by click on the <Read> button, and choosing a *.img file name.

STEP 09:

Insert the SD card into your Raspberry Pi and power it up.

 

STEP 10:

On the first boot, the “raspi-config” menu will pop up.

raspi-config



Note: If you are at the command shell prompt. You can key in “sudo raspi-config” to access to this menu.

cmd prompt

“raspi-config” menu

raspi-config menu


Note: You may find yourself having problem when trying to key in the ‘#’ char by pressing <Shift+’3′>. A ” pound char may be generated instead.

This is because the Raspberry Pi’s default locale code is set as UK. You will need to set the locale code to US, for a US keyboard layout.

Key in the following command,
“sudo dpkg-reconfigure keyboard-configuration”

 

Alternative method to configure you keyboard layout.
a) key in “sudo nano /etc/default/keyboard”
b) look for the line containing “XKBLAYOUT=”gb””.
c) change “gb” to “us” for US keyboard layout.
d) save and exit.
e) reboot or key in the following “invoke-rc.d keyboard-setup start”, to reload the keymap.

STEP 11:

Select <1> and press enter to Expand Filesystem.

If you are connected to the network, select <8 Advanced Options> and press enter.

<A2 Hostname> to change the hostname default “raspberrypi”.

<A3 Memory Split> to configure the amount of ram allocation for GPU (graphic processing).

<A4 SSH> to enable or disable SSH (remote command access); it is enable by default.

<A5 Update> and then press enter to upgrade to the latest version of this tool. Try to perform this update.

“raspi-config” menu 8-A

raspi-config8A

ram for GPU

To change to the Standard US Keyboard mapping, select <4 Internationalisation Options>,

<I1 Change Locale>, with the following options,
Default Locale : None

<I2 Time Zone >, with the following options,
Geographic area: Asia
Time Zone      : Singapore

<I3>, with the following options,
Keyboard model : “Generic 105-key (Intl) PC”
Keyboard layout: “Others” -> “English (US)”
AltGr as       : “The default for the keyboard layout”
Compose Key    : “No compose key”
Ctrl+Alt+Backsp: “No”, (don’t use it to terminate Xserver)

You can also configure to allow the system to boot directly straight into the GUI desktop, using this raspi-config.

Select <Finish> then press enter to proceed to the system command shell.

You can always come back to this raspi-config menu again by executing the command “sudo raspi-config” from the shell command.

“raspi-config” menu 4-I

raspi-config4I menu

Very Very Important Note regarding boot up error

If you have encounter any error during the Linux operating system boot up, be sure to check the voltage level being supplied to your Raspberry Pi. It is a very common problem faced, if you have tried to power up your Raspberry Pi using any power adaptor that you have picked up.

Always check if your power adaptor is suitable by measuring the voltage supplied to your Raspberry Pi. If you deploy your Raspberry Pi for yoru project without ensuring that your power adaptor is ok, you may face random system error freeze/hang/halt. Problem can occur out of the norm. Be sure to check. Click here to find out how you can ensure that you are using the correct power adaptor and cable for your Raspberry Pi.

 

www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller

 

2. Hardware Pin Out

 

Raspberry Pi revision 2, header pins out.


3V3 1 2
5V

GPIO_2
<->SDA0 3 4
5V

GPIO_3
<->SCL0 5 6
Gnd

GPIO_4
GPCLK0 7 8
TXD->
GPIO_14

Gnd 9 10
RXD<-
GPIO_15
GPIO_17
GPIO0 11 12
GPIO1/PWM
GPIO_18
GPIO_27
GPIO2 13 14
Gnd

GPIO_22
GPIO3 15 16
GPIO4
GPIO_23

3V3 17 18
GPIO5
GPIO_24
GPIO_10
<-MOSI 19 20
Gnd

GPIO_9
->MISO 21 22
GPIO6
GPIO_29
GPIO_11
<-SCLK 23 24
CE0->
GPIO_8

Gnd 25 26
CE1->
GPIO_7

 

This is my Raspberry Pi. I have custom built a prototyping board that can be plugged on top of my Raspberry Pi. This prototyping board is soldered with 2.54mm housing connector (2 rows of 13 pins) so that I can easily access to the I/O pins of my Raspberry Pi.

My LED indicator wiring is as follows,
LED0 – GPIO_17 (Pin11)
LED1 – GPIO_18 (Pin12)
LED2 – GPIO_27 (Pin13)
LED3 – GPIO_22 (Pin15)
LED4 – GPIO_23 (Pin16)
LED5 – GPIO_24 (Pin18)
LED6 – GPIO_29 (Pin22)

UART (serial communication) wiring,
Gnd –         (Pin06)
TXD – GPIO_14 (Pin08)
RXD – GPIO_15 (Pin10)

SPI (serial communication) wiring,
MOSI – GPIO_10 (Pin19)
MISO – GPIO_09 (Pin21)
SCLK – GPIO_11 (Pin23)
CE0  – GPIO_08 (Pin24)
CE1  – GPIO_07 (Pin26)

I2C (serial communication) wiring,
SDA0 – GPIO_02 (Pin03)
SCL0 – GPIO_03 (Pin05)


GPIO input/output pin electrical characteristics
Output low voltage
VOL
< 0.40 V
< 0.66 V
< 0.40 V
Output high voltage
VOH
> 2.40 V
> 2.64 V
> 2.90 V
Input low voltage
VIL
< 0.80 V
< 0.54 V
< 1.15 V
Input high voltage
VIH
> 2.00 V
> 2.31 V
> 2.15 V
Hystereses > 0.25 V
   0.66 – 2.08 V
Schmitt trigger input low threshold
VT–
1.09 – 1.16 V
0.9
Schmitt trigger input high threshold
VT+
2.24 – 2.74 V
0.90 V
Pull-up/down
resistance
40 – 65KΩ
100KΩ
Pull-up/down
current
< 50 uA
< 28 uA
Pin capacitance 5 pF
Bus hold resistance 5-11KΩ

Information taken from
http://www.mosaic-industries.com/embedded-systems/

 

3. Raspberry Pi, HelloWorld for I/O pins  

Learning to control Raspberry Pi general purpose I/O pin 11 (which is known as GPIO_0, or GPIO_17 if base on BCM2835 IC pin assignment)Power on my Raspberry, and the operating system will prompt for my raspberrypi login.Key in “pi” for the login, and “raspberry” for the password.

 

raspberrypi login: pi
Password: raspberry

pi@raspberrypi ~ $

First start by keying the command “” to change to the root user, which have a higher privilege access rights to the system. pi@raspberrypi ~ $ sudo -i
You will see a new prompt -> root@raspberrypi:~#

Setup or initialise I/O port 17, by sending text “17” to the operating file system “/sys/class/gpio/export”

A directory folder will be created. “/sys/class/gpio/gpio17/”

root@raspberrypi:~# echo “17” > /sys/class/gpio/export
Setting the I/O pin as an output port, by sending text “out” to the operating file system “/sys/class/gpio/gpio17/direction” root@raspberrypi:~# echo “out” > /sys/class/gpio/gpio17/direction
To set logic 1 to the output port, send a text “1” to the operating file system “/sys/class/gpio/gpio17/value” root@raspberrypi:~# echo “1” > /sys/class/gpio/gpio17/value
My LED indicator0 (green color) gets lighted up. My very first hardware control using Raspberry Pi, Linux operating system. Yuppee…
To switch off my LED, send a text “0” to the operating file system “/sys/class/gpio/gpio17/value” root@raspberrypi:~# echo “0” > /sys/class/gpio/gpio17/value
 
Setting up an input port is quite similar. I will be using I/O port 18 as input.  
Setup I/O port 18. root@raspberrypi:~# echo “18” > /sys/class/gpio/export
Setup port 18 as an input port. root@raspberrypi:~# echo “in” > /sys/class/gpio/gpio18/direction
Reading input port 18. root@raspberrypi:~# cat /sys/class/gpio/gpio18/value
Command prompt will return the following value (logic 0) after reading the port. 0
root@raspberrypi:~#
The port 18, which is pin 12 on my Raspberry Pi is now connected to 3.3V to simulate a logic 1 input. The input port is then rRead in again. root@raspberrypi:~# cat /sys/class/gpio/gpio18/value
Command prompt will return the following value (logic 1) after reading the port, which is correct. 1
root@raspberrypi:~#

Reference:
http://elinux.org/RPi_Low-level_peripherals#GPIO_Driving_Example_.28C.29

 

 
 

I am able to control the I/O pins on my Raspberry Pi, but I want to larn more into controlling the I/O pins using native C. Controlling I/O pins using the “file directory system” like method will be very slow.The speed achieved base on this benchmark website, I/O control through this shell (or file directory system) method, achieved a maximum process speed of about 6.8kHz (2x 3.4kHz).To achieve a higher speed, I will need to use native C programming, which can process from 9.4Mhz to 44Mhz (2x 4.7Mhz to 22Mhz).

More things to learn…

 

References:

Notes regarding digital I/O pins, https://www.kernel.org/doc/Documentation/gpio.txt

 

 

4. Understanding UART, SPI, I2C port on Raspberry Pi  

UART

The UART port is actually pin8 (TxD) and pin10 (RxD) on the Raspberry Pi connectors. The UART signal is 3.3V.You can use RS232/RS422/RS485 communication to talk to the UART, but a level shifter (for example MAX3232) required. RS232 uses about +/- 7 to 13V, while UART uses digital voltage (1.8V, 3.3V or 5V). For our Raspberry Pi UART, it is 3.3V. More information about making your own level shifter, you can visit this page. There are also standard USB to UART products for interfacing to your Raspberry Pi.The Raspberry Pi default operating system uses this UART port as its diagnostic port. This port has the following default UART settings,
– Baudrate   : 115200bps
– Data       : 8 bits
– Parity     : None
– Handshaking: NoneThis default port act as another Linux shell terminal screen, as you would have seen on the screen through the Raspberry Pi’s HDMI or video output.

 

 

You can use a terminal program to access through this port.Using the Window’s Hyperterminal program, setup the correct com port settings. And connect the terminal. You will see nothing on the terminal screen, but actually the Raspberry Pi is prompting you for your login ID. This ID is “pi” which is similar to how you log on to your typical terminal screen. You will see the terminal replying you with the prompt for password. Key in the default password “raspberry”. You shall get a similar print out from the terminal program, as on the right. ->Looks very much like the typical terminal on your local display. This is mainly for troubleshooting, diagnostic or perhaps used for remote access of your Raspberry Pi.

 

raspberrypi login: pi
Password:
Last login: Wed Jun 19 15:36:44 UTC 2013 on tty1
Linux raspberrypi 3.6.11+ #474 PREEMPT Thu Jun 13 17:14:42 BST 2013 armv6lThe programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
pi@raspberrypi:~$

The UART on the Raspberry Pi is quite an useful peripheral. For me, I would like to use this UART as a serial communication to control my other circuit modular.

In order to use this UART, I need to disable the diagnostic features from the operating system’s boot up. This means that I do not want the system to setup the UART pins as diagnotic port, when the system boots up.

 
This means that we need to edit the boot up file. Before we do any editing, it is good to save a backup copy of it. Type the copy command “cp” as follows. -> pi@raspberrypi ~ $ sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt

The following command is key in to edit the system boot up script. vi is an text editor program, which is not very user friendly.Alternative, you can use nano editor instead of vi for the text file editing.
Or gedit editor. You can install then if they are not installed.
“sudo apt-get install nano” or
“sudo apt-get install gedit ” To learn how to use the vi editor, click on the following link, http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html

A summary of the vi editor’s command is summeries as follows, http://osr600doc.sco.com/en/FD_create/vi_summary.html

pi@raspberrypi ~ $ sudo vi /boot/cmdline.txt

After the vi command, you should see the following screen display. This is the vi editor diaplaying the text in the “cmdline.txt file”.The objective is to delete the text (in red color), which is relating to the UART setup. Press ‘l’ on your keyboard to shift the cursor to the right, until it is at the position of the char that we want to delete. Move the cursor under the first char ‘c’ (char as illustrated in red).Press ‘x’ on your keyboard to delete the char one by one. You should observed the delete action.When all the text in red are deleted, press ‘:w’ on your keyboard, follow by a enter key to save the text file.Press ‘:q’ on your keyboard, follow by a enter key to exit the vi program.If at anytime you have edit wrongly, you can enter the command ‘:q!’ on your keyboard, to exit the vi program without saving the text file.

 

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
~
~
~
~
~
~

Your “cmdline.txt” should contain the following text after the editing. dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
~
~
~
Next edit inittab with the following command. pi@raspberrypi ~ $ sudo vi /etc/inittab

Find and comment away the line containing the following text (near the end of the file),
“T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100”,
by pressing the ‘j’ on your keyboard to scroll down line by line.Issue an insert command by pressing ‘i’ to insert some text before the cursor. Insert a char ‘#’ at the beginning of the line to comment the whole line. The ‘#’ mask off the whole line. The line that are masked off will not be intepreted by the system.After the ‘#’ char is inserted, press <Esc> key on your keyboard to end the insert command that was issued.Press ‘:w’ save the text file.

Press ‘:q’ to exit the vi program.

#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

The UART device name is /dev/ttyAMA0
Now the UART is not in use by the Linux Raspbian operating system, and is available for my own use.

 

 
Reboot for the operating system’s settings to take effect. pi@raspberrypi ~ $ sudo reboot
 

To test the UART serial communication port, we can install a program call minicom. The use of minicom is similar to hyperterminal program that I use in Windows operating system (OS).

Enter the command “sudo apt-get install minicom

There are also alternative GUI based serial communication program, cutecom.

pi@raspberrypi ~ $ sudo apt-get install minicom

Reading package lists… Done
Building dependency tree
Reading state information… Done

Need to get 420 kB of archives.
After this operation, 1,189 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main lrzsz armhf 0.12.21-5 [106 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main minicom armhf 2.6.1-1 [314 kB]
Fetched 420 kB in 13s (30.2 kB/s)

Unpacking minicom (from …/minicom_2.6.1-1_armhf.deb) …
Processing triggers for man-db …
Processing triggers for menu …
Setting up lrzsz (0.12.21-5) …
Setting up minicom (2.6.1-1) …
Processing triggers for menu …

To run the minicom terminal program. Key in the following command “sudo minicom -b 9600 -o -D /dev/ttyAMA0“.

-o              (skip initialisation)
-D /dev/ttyAMA0 (specify the serial port)

Key in command “man minicom” to find out the other options that you can set with the minicom program.

Configuration Settings:
Baudrate : 9600bps
Data bit : 8    (default)
Stop bits: 1    (default)
Parity   : None (default)

Apply the configuration settings to serial port “ttyAMA0”. The label tty (known as teletype) denotes all serial communication that the linux operating system is handling. In Raspberry Pi, ttyAMA0 refers to the pin8 (TxD) and pin10 (RxD).

When you type a char on your keyboard, an ascii char code is actually sent out of the Raspberry Pi ‘s pin8 (TxD). You will not be able to see it on the screen. What you will see on your screen will be those serial data that the Raspberry Pi received through pin10, which is the RxD.

In order to see what we have transmitted out from TxD, we can short the pin8 (TxD) and pin10 (RxD) together. This means that what you send will be receive and display on the display. The serial port configuration for the TxD and RxD is the same, so the serial data that is received will be exactly what you have transmitted.

The following text “Hello World!!! ” were typed on the keyboard after shorting the RxD and Txd pin. The text will be displayed, indicating that the UART is working properly.

Now that you know that the UART on your Raspberry Pi is ready for use, you can use it to communicate with many other peripheral.

Press <Ctrl + ‘A’>, followed by <‘X’>, then key in enter for “Yes” to quit the minicom program.

pi@raspberrypi ~ $ sudo minicom -b 9600 -o -D /dev/ttyAMA0

——————————————-
Welcome to minicom 2.6.1OPTIONS: I18n
Compiled on Apr 28 2012, 19:24:31.
Port /dev/ttyAMA0Press CTRL-A Z for help on special keysHello World!!!

CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.6.1 | VT102 | Offline
——————————————-

Setting up the serial port with other settings,
Baudrate : 115200bps
Data bit : 8    
Stop bits: 1    
Parity   : Even

pi@raspberrypi ~ $ sudo minicom -b 115200 -8 -o -D /dev/ttyAMA0
Key in command “sudo minicom -s ” to launch the minicom menu for other default settings, which can be save onto *.dfl files.
The default config file is minicom.dfl
 
Other related commands

– “dmesg | grep tty” checking up the UART available on the system.
 
   

SPI

The SPI port onboard the Raspberry is disable by default. The first thing to do is to enable the SPI port.

Edit the file “/etc/modprobe.d/raspi-blacklist.conf”

Comment off the line “blacklist spi-bcm2708” with a # in front.

Key in Ctrl+’X’ to exit, then ‘Y’ yes to save the change to the file, and finally ‘Enter’. This will brings you back to the command prompt.

pi@raspberrypi ~ $ sudo nano /etc/modprobe.d/raspi-blacklist.conf

GNU nano 2.2.6 File: /etc/modprobe.d/raspi-blacklist.conf Modified

# blacklist spi and i2c by default (many users don’t need them)

#blacklist spi-bcm2708
blacklist i2c-bcm27088

 

Reboot Raspberry Pi pi@raspberrypi ~ $ sudo reboot

Check to see if the SPI is successfully enable in the Raspberry Pi.

You should see “/dev/spidev0.0 /dev/spidev0.1” created.

0.0 means SPI0 CS0 (CS is the chip select)
0.1 means SPI0 CS1

pi@raspberrypi ~ $ ls /dev/spidev*
/dev/spidev0.0 /dev/spidev0.1
pi@raspberrypi ~ $

Testing the SPI port

download this SPI loopback test code written in ‘C’ programming language.

spidev_test.c

Compile the *.c file using gcc command,then run the compiled program.

You should see the following hex dump data, indicating all 0x00.

This means that the SPI is receiving nothing, no data.

pi@raspberrypi ~ $ gcc spidev_test.c -o spidev_test
pi@raspberrypi ~ $ sudo ./spidev_test -D /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00
pi@raspberrypi ~ $

Now we do a SPI data loopback test.
Short the pins MISO (GPIO 9, Pin21) and MOSI (GPIO 10, Pin19) on your Raspberry Pie. This will enables the SPI MISO to received whatever data that is sent out from the MOSI pins.

From this test, we will be able to know if SPI hardware for sending and receving is working ok. Whatever that is sent out, the data should be properly received.

Run the compiled program again.

You should see the following hex dump data. This means that your SPI peripheral is working fine.

pi@raspberrypi ~ $ sudo ./spidev_test -D /dev/spidev0.0

spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D
pi@raspberrypi ~ $

   

I2C

The SPI port onboard the Raspberry is disable by default. The first thing to do is to enable the SPI port.

Edit the file “/etc/modprobe.d/raspi-blacklist.conf”

Comment off the line “blacklist i2c-bcm2708” with a # in front.

Key in Ctrl+’X’ to exit, then ‘Y’ yes to save the change to the file, and finally ‘Enter’. This will brings you back to the command prompt.

pi@raspberrypi ~ $ sudo nano /etc/modprobe.d/raspi-blacklist.conf

GNU nano 2.2.6 File: /etc/modprobe.d/raspi-blacklist.conf Modified

# blacklist spi and i2c by default (many users don’t need them)

blacklist spi-bcm2708
#blacklist i2c-bcm27088

 

Edit the file “/etc/modules”

Add in “i2c-dev” to the end of the file.

Key in Ctrl+’X’ to exit, then ‘Y’ yes to save the change to the file, and finally ‘Enter’. This will brings you back to the command prompt.

pi@raspberrypi ~ $ sudo nano /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.

snd-bcm2835
i2c-dev

 

Install I2C Tools to test on the I2C peripheral. pi@raspberrypi ~ $ sudo apt-get install i2c-tools
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
libi2c-dev python-smbus
The following NEW packages will be installed:
i2c-tools
0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded.
Need to get 59.5 kB of archives.
After this operation, 223 kB of additional disk space will be used.
Get:1 http://http.debian.net/debian/ wheezy/main i2c-tools armel 3.1.0-2 [59.5 kB]
Fetched 59.5 kB in 4s (12.5 kB/s)
Selecting previously unselected package i2c-tools.
(Reading database … 57047 files and directories currently installed.)
Unpacking i2c-tools (from …/i2c-tools_3.1.0-2_armel.deb) …
Processing triggers for man-db …
Setting up i2c-tools (3.1.0-2) …

Allow Pi User to Access I2C peripheral.

This allow configuration of the software.

pi@raspberrypi ~ $ sudo adduser pi i2c
Adding user `pi’ to group `i2c’ …
Adding user pi to group i2c
Done.
Reboot Raspberry Pi pi@raspberrypi ~ $ sudo reboot

Check to see if the SPI is successfully enable in the Raspberry Pi.

You should see “/dev/i2c-0 /dev/i2c-1” created.

pi@raspberrypi ~ $ ls /dev/i2c*
/dev/i2c-0 /dev/i2c-1
pi@raspberrypi ~ $

Running the test program.

You will see that there is a total of 0x77 or 119 blanks “–“. This indicates that no I2C devices is detected on the bus.

pi@raspberrypi ~ $ i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: — — — — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — — — — — — — — —
50: — — — — — — — — — — — — — — — —
60: — — — — — — — — — — — — — — — —
70: — — — — — — — —
If the I2C devices is on the I2C bus, it will appeared as follows.
For this example, the I2C devices has an address of 0x60. The software detects a device is currently onto the I2C data bus.
pi@raspberrypi ~ $ i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: — — — — — — — — — — — — — — — —
10: — — — — — — — — — — — — — — — —
20: — — — — — — — — — — — — — — — —
30: — — — — — — — — — — — — — — — —
40: — — — — — — — — — — — — — — — —
50: — — — — — — — — — — — — — — — —
60: 60 — — — — — — — — — — — — — — —
70: — — — — — — — —

 

 

www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller


5. Networking on Raspberry Pi References:
Installing Samba program
Checking the IP setting on my Raspberry Pi. pi@raspberrypi 
Ping gateway 192.168.1.1 pi@raspberrypi ping 192.168.1.1 -c 4
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=1.98 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.17 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=1.19 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=1.23 ms

— 192.168.1.1 ping statistics —
4 packets transmitted, 4 packets received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.171/1.399/1.988/0.340 ms
Ping website www.yahoo.com.sg pi@raspberrypi ~ $ ping yahoo.com.sg -c 4
PING yahoo.com.sg (106.10.165.51) 56(84) bytes of data.
64 bytes from w2.rc.vip.sg3.yahoo.com (106.10.165.51): icmp_seq=1 ttl=51 time=16.9 ms
64 bytes from w2.rc.vip.sg3.yahoo.com (106.10.165.51): icmp_seq=2 ttl=51 time=28.1 ms
64 bytes from w2.rc.vip.sg3.yahoo.com (106.10.165.51): icmp_seq=3 ttl=51 time=20.3 ms
64 bytes from w2.rc.vip.sg3.yahoo.com (106.10.165.51): icmp_seq=4 ttl=51 time=17.5 ms

— yahoo.com.sg ping statistics —
4 packets transmitted, 4 packets received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 16.996/20.762/28.140/4.441 ms

Other command:
ifconfig eth0 (display the first ethernet adaptor)
– ifconfig -a (show all network interface, active or inactive)
traceroute

 
 

Install Samba on the system so that my Raspberry Pi can be access from a Window operating system.

Ensure that the network cable (internet enabled) is plugged onto the Raspberry Pi before powering on the board. Enter the following command to install samba software. The process will fetch the installation from the internet.

pi@raspberrypi ~ $ sudo apt-get install samba samba-common-bin
Optional:
Enable security on the Samba server on the Raspberry Pi (RPi)
 
Making a backup of the samba configuration file. pi@raspberrypi ~ $ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
Edit the samba configuration file using the nano text editor pi@raspberrypi ~ $ sudo nano /etc/samba/smb.conf

Search for the section marked ##### Authentication #####,
Change the following text “# security = user” to “security = user”.
To save the text file, Press “Ctrl+X”, then ‘Y’, then enter.

 
Restart samba to use the new configuration file. pi@raspberrypi ~ $ sudo /etc/init.d/samba restart
[ ok ] Stopping Samba daemons: nmdb smdb
[ ok ] Stopping Samba daemons: nmdb smdb

Use command “hostname -I” to check the IP address.

Alternate command “ifconfig” to check the IP address of my Raspberry Pi, which IP address is “192.168.1.99”

pi@raspberrypi ~ $ hostname -I
192.168.1.99

pi@raspberrypi ~ $  ifconfig
eth0  Link encap:Ethernet  HWaddr b8:27:eb:dc:ee:af
      inet addr:192.168.1.99  Bcast:192.168.1.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:337 errors:0 dropped:0 overruns:0 frame:0
      TX packets:198 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:30734 (30.0 Kib)  TX bytes:20136 (19.6 Kib)

Or using command “ip address show” pi@raspberrypi ~ $ ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:dc:ee:af brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.95/24 brd 192.168.1.255 scope global eth0
Configuring your network settings
sudo nano /etc/network/interfaces
 pi@raspberrypi ~ $ sudo nano /etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
To set static IP address, edit the file “interfaces” to the example as follows.
Save the file and reboot Raspberry Pi for the changes to take effect.
auto lo

iface lo inet loopback

#wired connection (using static IP address, instead of DHCP to auto allocate IP)
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.201
netmask 255.255.255.0
gateway 192.168.1.1

#wireless connection (using static IP address, instead of DHCP to auto allocate IP)
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface wlan0 inet dhcp
iface wlan0 inet static
address 192.168.1.202
netmask 255.255.255.0
gateway 192.168.1.1
#iface default inet dhcp

Go to window’s to map a network drive. The network folder path is “//192.168.1.99”. Check box for “Reconnect at logon” & “Connect using different credentials”

 

Check the network and port bind on the Raspberry Pi.

 

From the list, it can be seen that UDP port 6324 is currently being used by process ID PID 2361/java program.

 pi@raspberrypi ~ $ netstat -nlptu
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN –
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN –
udp 0 0 192.168.1.99:123 0.0.0.0:* –
udp 0 0 127.0.0.1:123 0.0.0.0:* –
udp 0 0 0.0.0.0:123 0.0.0.0:* –
udp 0 0 0.0.0.0:51876 0.0.0.0:* –
udp 0 0 0.0.0.0:6324 0.0.0.0:* 2361/java
udp 0 0 0.0.0.0:68 0.0.0.0:* –
Setting up a secure home Web Server with Raspberry Pi

 

6. Accessing Raspberry Pi through the network

Sometimes you may like to access to your Raspberry Pi without connecting your display monitor and your keyboard. This section provide a guide to allow access to your Raspberry Pi remotely through network connection.

 

Checking the IP setting on the Raspberry Pi, using command “ip address show”. For my Raspberry Pi, the IP address is 192.168.1.95. pi@raspberrypi ~ $ ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:dc:ee:af brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.95/24 brd 192.168.1.255 scope global eth0

How to locate your Raspberry Pi IP address from a remote computer?

The method above requires you to plugged a monitor display to your Raspberry Pi in order to obtain its IP address. The following method allows you to obtain raspberry pi address through thr

You can also check the IP address of your Raspberry Pi that is plugged into a dynamic network through the router webserver. Typical router’s IP address for a local network is 192.168.1.1. You will need your user name and password to log into the router’s webserver. From the webserver, you should be able to locate the device name “raspberrypi” (or known as hostname) and its allocated dynamic IP address and its MAC address.

Alternative, you can use this software “Advance Port Scanner” to scan for your Raspberry Device on the network.

pi@raspberrypi ~ $ hostname
raspberrypi


 

Note: To change the Raspberry Pi’s hostname “raspberrypi”, use nano text editor to edit the following file “/etc/hostname” and “/etc/hosts”. Replace the old hostname “raspberrypi” to your new hostname. Your new hostname can only contains lower/upper case character, numbers, and ‘-‘.

Your new hostname will appear on the raspberry prompt, after the device reboot.

pi@raspberrypi ~ $ sudo nano /etc/hostname

pi@raspberrypi ~ $ sudo nano /etc/hosts

pi@raspberrypi ~ $ sudo reboot

pi@newHostname ~ $

Download this program MobaXterm, and install in your Window operating system. You can download from http://mobaxterm.mobatek.net/


Alternative, you can also use this program call Putty.
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Alternative, you can also use this program call Filezilla
https://filezilla-project.org/ (for Microsoft Windows OS).
or (for Linux OS) “sudo apt-get install filezilla”

These program allow SSH connection logging in to your Raspberry Pi. You will be able to see what you would see with the display monitor and keyboard connected to your Raspberry Pi

 

Run the installed MobaXterm program.
Click on “Session”->”Open New Session”.
Choose “SSH” as the session type.
Key in the IP address of your Raspberry Pi.
The standard port number for SSH Remote Login Protocol is 22.

 

Click “OK” to connect to your Raspberry Pi.

Key in the Login user name “pi”, then press enter, and
standard password “raspberry” then press enter key.

You will see the following display as on the right.

Login: pi
Permanently added ‘192.168.1.95’ (ECDSA) to the list of known hosts.
rasppi@192.168.1.95’s password:
Linux raspberrypi 3.6.11+ #474 PREEMPT Thu Jun 13 17:14:42 BST 2013 armv6lThe programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 22 13:47:57 2013
pi@raspberrypi ~ $

You may encounter the following error on the right.
If not, you can skip this section.
This happens when you login successfully for the first time, but then you reinstall the server. The key becomes different, and you get prompt for this security message.Access into your Raspberry Pi and key in the following command,
rm -f ~/.ssh/known_hosts

Delete from your client computer.
C:\Users\LSB\Documents\MobaXterm\home\.ssh\known_hosts.

You may need to reboot the Linux in order for the change to take effect “sudo reboot”.

It should solve the problem. For more information regarding this issue, you can visit the following website,
http://www.geekride.com/ssh-warning-remote-host-identification-has-changed/


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is xx:xx:xx:xx:b1:66:fd:05:0c:43: …. … .. .

Congratulation. You have access your Raspberry Pi remotely through the network.  
To remotely access the desktop GUI of your Raspberry Pi, key in the following command from your MobaXterm’s command console. The ‘&’ at the end of the command help launch the application in the background (another thread process) so that we can continue using the terminal. pi@raspberrypi ~ $ lxsession&
The Raspberry Pi’s desktop will be launched from your Window operating system, as follows…
GUI application can also be launched directly within WinOS without accessing to the Raspberry Pi Linux desktop.

pi@raspberrypi ~ $ leadpad&

Using MobaXterm, you can actually drag and drop file in the lower left corner of the MobaXterm’s windows.
Key in “exit”, then press enter, to terminate the session. pi@raspberrypi ~ $ exit

 

7. C Programming on Raspberry Pi, Hello World!!!  
Classic first program to write every time we learn a new programming language on a new platform.  
Type in “gcc” command with a flag -v to see the version of the C complier.

pi@raspberrypi ~ $ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO…


Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-14+rpi1)

Create a folder “tutorial” to hold the files for this tutorial pi@raspberrypi ~ $ mkdir tutorial
Get into the newly create tutorial folder pi@raspberrypi ~ $ cd tutorial
Create a “main.c” file using the program nano (text editor) pi@raspberrypi ~ $ sudo nano main.c

Key in the following hello world source code into the nano editor.

When finish typing in the source code text, press CTRL+X to save this file “main.c”, press ‘Y’ to confirm. Press enter key to finish the process.

#include <stdio.h>

int main()
{
   printf(“Hello World!!!”);
   return(0);
}

Now compile the source code file “main.c” to executable file “main” pi@raspberrypi ~ $ gcc -o main main.c
Now execute the file “main”, you should see the text “Hello World!!!” as you have programmed in the source code. pi@raspberrypi ~ $ ./main
Hello World!!!

For compiling C++ language (*.cpp file), use g++ compiler.

 

 

8. Python Programming on Raspberry Pi, Hello World!!!  
Classic first program to write every time we learn a new programming language on a new platform.  
Type in “python -V ” command to see the version of the C complier.

pi@raspberrypi ~ $ python -V
Python 2.7.3

Run the python program, and key in the python script directly onto the python command line.

Type the script >>> print “Hello World!!!”

You will see the “Hellow World!!!” text echo back.

Press <Ctrl+’z’> to terminate the Python program.
pi@raspberrypi ~ $ sudo python
Python 2.7.3 (default, Jan 13 2013, 11:20:46)
[GCC 4.6.3] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> print “Hello World!!!”
Hello World!!!
>>>
You can also write the phython codes onto a *.py file, and run directly from the file saved with python scripts.

Create a folder “python_tutorial” to hold the files for this tutorial
pi@raspberrypi ~ $ mkdir python_tutorial
Get into the newly create tutorial folder pi@raspberrypi ~ $ cd python_tutorial
Create a “hello.py” file using the program nano (text editor) pi@raspberrypi ~ $ sudo nano hello.py

Key in the following hello world source code into the nano editor.

When finish typing in the source code text, press CTRL+X to save this file “hello.py“, press ‘Y’ to confirm. Press enter key to finish the process.

#!/usr/bin/python

print “Hello World!!!”nt “Boon, you’re awesome”
else :
print “Hello”, name

Now execute the file “hello.py”, you should see the text “Hello World!!!” as you have programmed in the source code. pi@raspberrypi ~ $ python hello.py
Alternative, you can make the file executable, and execute the file directly. pi@raspberrypi ~ $ chmod a+x hello.py
pi@raspberrypi ~ $ ./hello.py
Hello World!!!

Using Python to control the digital I/O port.
Before starting to program your I/O on Raspberry Pi, we will need to download and setup the library.

pi@raspberrypi ~ $ wget http://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.1.0.tar.gz
pi@raspberrypi ~ $ tar zxf RPi.GPIO-0.1.0.tar.gz
pi@raspberrypi ~ $ cd RPi.GPIO-0.1.0
pi@raspberrypi ~ $ sudo python setup.py install

Try controlling the Raspberry Pi’s digital I/O GPIO1 (pin12 of the header, GPIO18) as output port, using Python script.

1) import RPi.GPIO
2) setup I/O direction, as output port.
3) set digital I/O port to logic ‘1’, high
4) set digital I/O port to logic ‘0’, low

You should see the LED lights up and switched off, if wired an indicator to pin 12.

pi@raspberrypi ~ $ sudo Python
>>> import RPi.GPIO as GPIO
>>> GPIO.setup(18, GPIO.OUT)
>>> GPIO.output(18, True)
>>> GPIO.output(18, False)

Example of a typical python’s source code.

#!/usr/bin/python

import sys
import time
import serial

#print title
print(“start python program.”)#print out the arg passed from command line
for arg in sys.argv:
  print arg#delay 0.1sec
time.sleep(0.1)
#delay 1.0sec
time.sleep(1) #setup serial port
port = serial.Serial(“/dev/ttyAMA0”, baudrate=115200, timeout=3.0)#get user input
name = raw_input(‘what is your name? ‘)#conditional statement
if name == ‘Boon’ :
  print “Boon, you’re awesome”
else :
  print “Hello”, name

#while loop
while True:
  port.write(“\r\nSay something:”)
  rcv = port.read(10)
  port.write(“\r\nYou sent:” + repr(rcv))

Python code example for I/O.

#!/usr/bin/python

import time
import RPi.GPIO as GPIO

GPIO.setup(11, GPIO.IN)
while True:
  mybutton = GPIO.input(11)
  if mybutton == False:
    print “giggle”
  time.sleep(.2)

#!/usr/bin/python
import RPi.GPIO as GPIO
GPIO.setup(11, GPIO.IN)
GPIO.setup(12, GPIO.OUT)
while True:
  if GPIO.input(11):
    GPIO.output(12, True)
  else:
    GPIO.output(12, False)
Invoke system command (shell command) from Python script. >>> import commands
>>> commands.getstatusoutput(‘ls /bin/ls’)
(0, ‘/bin/ls’)
>>> commands.getstatusoutput(‘cat /bin/junk’)
(256, ‘cat: /bin/junk: No such file or directory’)
>>> commands.getstatusoutput(‘/bin/junk’)
(256, ‘sh: /bin/junk: not found’)
>>> commands.getoutput(‘ls /bin/ls’)
‘/bin/ls’
>>> commands.getstatus(‘/bin/ls’)
‘-rwxr-xr-x 1 root 13352 Oct 14 1994 /bin/ls’

 

9. Java Programming on Raspberry Pi, Hello World!!!  

Note: As of Nov 2013, the official operating system for Raspberry Pi “Raspian” is installed with Java by default. Proceed to the step for installing Pi4J.

Installing Java to your Raspberry Pi

First, we will need to download and instal the Java JDK onto the Raspberry Pi.Do take note that the JDK version that we will be downloading is meant for Linux ARM processor “Linux ARM v6/v7 Soft Float ABI”.
(28 July 2013)
JDK for Linux ARM, “jdk-21-linux-arm-sfp.tar.gz (65.12MB)”



You can download the lastest version of this file from this Java website,
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Remember to accept the Oracle Binary Code License Agreement for Java SE.

Untar the Java JDK distribution file. pi@raspberrypi ~ $ tar xvzf ~/jdk-7u21-linux-arm-sfp.tar.gz
Create a java directory and move the untarred distribution to it.
Delete the tar file once we are done.
pi@raspberrypi ~ $ sudo mkdir -p -v /opt/java
pi@raspberrypi ~ $ sudo mv -v ~/jdk1.7.0_21 /opt/java/
pi@raspberrypi ~ $ rm ~/jdk-7u21-linux-arm-sfp.tar.gz
Create the environment paths to the java and javac commands so that they can be used anywhere in the command line environment. pi@raspberrypi ~ $ sudo update-alternatives –install “/usr/bin/java” “java” “/opt/java/jdk1.7.0_21/bin/java” 1
pi@raspberrypi ~ $ sudo update-alternatives –set java /opt/java/jdk1.7.0_21/bin/java
pi@raspberrypi ~ $ sudo update-alternatives –install “/usr/bin/javac” “javac” “/opt/java/jdk1.7.0_21/bin/javac” 1
pi@raspberrypi ~ $ sudo update-alternatives –set javac /opt/java/jdk1.7.0_21/bin/javac

Check that the Java environment variable is setup correctly.

Note: If the following error is encountered when the command “java -version” is executed.
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

It is propably that you have installed the incorrect version of Debian Linux. At this point in time, Java SDK for Linux ARM has yet to support.

Please refer to the previous section, for the installtion of the correct Debian Linux version for use with Java SDK Linux ARM.

pi@raspberrypi ~ $ java -version
java version “1.7.0_21”
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) Client VM (build 23.21-b01, mixed mode)
Installing PI4J, a bridge project between the native libraries and Java for full access to the Raspberry Pi’s peripheral.

Check out PI4J website for more information.
pi@raspberrypi ~ $ wget http://pi4j.googlecode.com/files/pi4j-0.0.5.deb
pi@raspberrypi ~ $ sudo dpkg -i pi4j-0.0.5.deb

Check if PI4J is installed correctly.
Go to PI4J directory.
Compile the example “WiringPiGpioExample.java”.
Run the compile java program “WiringPiGpioExample”.

I am able to see my rows of LED lighting up in a wave sequence, up and down non-stop.

pi@raspberrypi ~ $ cd /opt/pi4j/examples/
pi@raspberrypi /opt/pi4j/examples $ sudo javac -classpath .:classes:/opt/pi4j/lib/’*’ -d . WiringPiGpioExample.java
pi@raspberrypi /opt/pi4j/examples $ sudo java -classpath .:classes:/opt/pi4j/lib/’*’ WiringPiGpioExample

To uninstall PI4J, check out the following command. pi@raspberrypi ~ $ sudo dpkg -r pi4j

Testing out with a simple Java program.
Let us do a hello world example.

Key in “nano hello.java”.
This will open a text editor for us to key in the java source code for our hello world example.

Key in the following java source code.

Press ‘Ctrl+X’ to exit, then ‘Y’ to save, then press ‘Enter’.

pi@raspberrypi ~ $ nano hello.java

class hello
{
   public static void main(String args[])
   {
      System.out.println(“Hello World!”);
   }
}

Compile the java source code “hello.java”, a java compiled file “hello.class” will be generated.

 

pi@raspberrypi ~ $ javac hello.java

To run the program, key in “java hello”.

You should be able to see the printed text “Hello World!” after execution.

pi@raspberrypi ~ $ java hello
Hello World!

Looking back to the wiringPi, which is the library for java to access to the native hardware I/O on the Raspberry Pi.

Taking a look at the java code using pi4j wiringPi.

WiringPiGpioExample.java

 

import com.pi4j.wiringpi.Gpio;
import com.pi4j.wiringpi.GpioUtil;

public class WiringPiGpioExample {
    
    // Simple sequencer data
    // Triplets of LED, On/Off and delay

    private static final int data[] = { 
            0, 1, 1, 1, 1, 1, 0, 0, 0, 2, 1, 1, 1, 0, 0, 3, 1, 1, 2, 0, 0, 4, 1, 1, 3, 0, 0, 5, 1, 1, 4,
            0, 0, 6, 1, 1, 5, 0, 0, 7, 1, 1, 6, 0, 1, 7, 0, 1,
            0, 0,
            1, // Extra delay
            // Back again
            7, 1, 1, 6, 1, 1, 7, 0, 0, 5, 1, 1, 6, 0, 0, 4, 1, 1, 5, 0, 0, 3, 1, 1, 4, 0, 0, 2, 1,
            1, 3, 0, 0, 1, 1, 1, 2, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1,
            0, 0, 1, // Extra delay
            9, 9, 9, // End marker
    };

    public static void main(String args[]) throws InterruptedException {
        int pin;
        int dataPtr;
        int l, s, d;
        
        System.out.println("<--Pi4J--> GPIO test program");

        // setup wiringPi
        if (Gpio.wiringPiSetup() == -1) {
            System.out.println(" ==>> GPIO SETUP FAILED");
            return;
        }

        // set GPIO 4 as the input trigger 
        GpioUtil.export(7, GpioUtil.DIRECTION_IN);
        GpioUtil.setEdgeDetection(7, GpioUtil.EDGE_BOTH);
        Gpio.pinMode (7, Gpio.INPUT) ;  
        Gpio.pullUpDnControl(7, Gpio.PUD_DOWN);        

        // set all other GPIO as outputs
        for (pin = 0; pin < 7; ++pin) {
            // export all the GPIO pins that we will be using
            GpioUtil.export(pin, GpioUtil.DIRECTION_OUT);            
            Gpio.pinMode(pin, Gpio.OUTPUT);
        }
        
        dataPtr = 0;
        for (;;) {
            l = data[dataPtr++]; // LED
            s = data[dataPtr++]; // State
            d = data[dataPtr++]; // Duration (10ths)

            if ((l + s + d) == 27) {
                dataPtr = 0;
                continue;
            }

            Gpio.digitalWrite(l, s);
            
            if (Gpio.digitalRead(7) == 1) // Pressed as our switch shorts to ground
                Gpio.delay(d * 10); // Faster!
            else
                Gpio.delay(d * 100);
        }
    }
}
Compile the “WiringPiGpioExample.java” with the pi4j lib files pi@raspberrypi ~ $  javac -classpath .:classes:/opt/pi4j/lib/’*’ -d . WiringPiGpioExample.java

Run the java program.

You may notice “wiringPiSetup: Unable to open /dev/mem”. This means that you do not have access to the hardware.

 

 

Run the java program with the “sudo” in front as follows.

You should see the LED light running from left to right.

pi@raspberrypi ~ $ java -classpath .:classes:/opt/pi4j/lib/’*’ WiringPiGpioExample

<–Pi4J–> GPIO test program
wiringPiSetup: Unable to open /dev/mem: Permission denied
==>> GPIO SETUP FAILED

pi@raspberrypi ~ $ sudo java -classpath .:classes:/opt/pi4j/lib/’*’ WiringPiGpioExample

<–Pi4J–> GPIO test program

   

Serial Java Programming with pi4j on Raspberry Pi

SerialExample.java

import java.util.Date;

import com.pi4j.io.serial.Serial;
import com.pi4j.io.serial.SerialDataEvent;
import com.pi4j.io.serial.SerialDataListener;
import com.pi4j.io.serial.SerialFactory;
import com.pi4j.io.serial.SerialPortException;

/**
* This example code demonstrates how to perform serial communications using the Raspberry Pi.
*
* @author Robert Savage
*/
public class SerialExample {
    
    public static void main(String args[]) throws InterruptedException {
        
        // !! ATTENTION !!
        // By default, the serial port is configured as a console port
        // for interacting with the Linux OS shell. If you want to use
        // the serial port in a software program, you must disable the
        // OS from using this port. Please see this blog article by
        // Clayton Smith for step-by-step instructions on how to disable
        // the OS console for this port:
        // http://www.irrational.net/2012/04/19/using-the-raspberry-pis-serial-port/
                
        System.out.println("<--Pi4J--> Serial Communication Example ... started.");
        System.out.println(" ... connect using settings: 38400, N, 8, 1.");
        System.out.println(" ... data received on serial port should be displayed below.");
        
        // create an instance of the serial communications class
        final Serial serial = SerialFactory.createInstance();

        // create and register the serial data listener
        serial.addListener(new SerialDataListener() {
            @Override
            public void dataReceived(SerialDataEvent event) {
                // print out the data received to the console
                System.out.print(event.getData());
            }
        });
                
        try {
            // open the default serial port provided on the GPIO header
            serial.open(Serial.DEFAULT_COM_PORT, 38400);
            
            // continuous loop to keep the program running until the user terminates the program
            for (;;) {
                try {
                    // write a formatted string to the serial transmit buffer
                    serial.write("CURRENT TIME: %s", new Date().toString());
    
                    // write a individual bytes to the serial transmit buffer
                    serial.write((byte) 13);
                    serial.write((byte) 10);
    
                    // write a simple string to the serial transmit buffer
                    serial.write("Second Line");
    
                    // write a individual characters to the serial transmit buffer
                    serial.write('\r');
                    serial.write('\n');
    
                    // write a string terminating with CR+LF to the serial transmit buffer
                    serial.writeln("Third Line");
                }
                catch(IllegalStateException ex){
                    ex.printStackTrace();
                }
                
                // wait 1 second before continuing
                Thread.sleep(1000);
            }
            
        }
        catch(SerialPortException ex) {
            System.out.println(" ==>> SERIAL SETUP FAILED : " + ex.getMessage());
            return;
        }
    }
}
Compile the “SerialExample.java pi@raspberrypi ~ $ javac -classpath .:classes:/opt/pi4j/lib/’*’ -d . SerialExample.java

Run the “SerialExample.java

If you encounter error when opening the serial port, do check out the eariler posting to ensure that the serial port is properly configured.

 

pi@raspberrypi ~ $ java -classpath .:classes:/opt/pi4j/lib/’*’ SerialExample
If you short the TX (GPIO_14, Pin08) & RX (GPIO_15, Pin10)pin on the Raspberry Pi, you should be able to see the following timestamp messages.
Raspberry Pi transmit the timestamp message for each second.

If the RX pin received data from other serial devices, the data can be seen on the console as well.

CURRENT TIME: Mon Nov 04 12:23:23 SGT 2013
Second Line
Third Line
CURRENT TIME: Mon Nov 04 12:23:24 SGT 2013
Second Line
Third Line
CURRENT TIME: Mon Nov 04 12:23:25 SGT 2013
Second Line
Third Line

   
SPI Java Programming with pi4j on Raspberry Pi  
   

Java examples (taken from www.pi4j.com)

WiringPiGpioExample.java
ControlGpioExample.java
ListenGpioExample.java
ShutdownGpioExample.java
TriggerGpioExample.java
SerialExample.java
SystemInfoExample.java

 
   

Linux bash script for launching/starting Java program. The command to launch Java is similar to those in WinOs, except for some notation changes. Note the use of char ‘:’ as the seperator and the slash ‘/’ for its file path. WinOS uses ‘;’ and the backslash ‘\’.
The script is similar to the batch file used in WinOS.

The following is an example of the script,
run.sh

Key in “. run.sh” to run the script in Linux command prompt.
Note: remember to make this file “run.sh” executable. (see examples in this website.)

inside file “run.sh”
#!/bin/bash
echo “Running SmartHomeSensors Java Program…”
java -classpath .:bin:lib/log4j-1.2.14.jar:lib/commons-logging-1.1.jar:classes:/opt/pi4j/lib/’*’:lib/json-simple-1.1.1.jar:lib/org.apache.httpcomponents.httpclient_4.3.1.jar:lib/utilities.jar:resource com.picControl.smartHomeSensors.MyMain

pi@raspberrypi ~ $ . run.sh

To auto run the script which launch the java program upon Raspberry Pi boot up (startup), edit the file “rc.local”.

Add in the following to the file,

cd /home/pi/smartHomeSensor
echo “Run script for SmartHomeSensor Java program”
SCRIPT=”/home/pi/smartHomeSensor/run.sh”
echo “run script \”-> $SCRIPT\””
sudo $SCRIPT &

 

The add command set the current directory to the project folder. During the boot process, it cannot be assume that you are in the user directory. Reference to the root directory to be safe.

Use sudo to run the script, and make the script run in the background.

pi@raspberrypi ~ $ sudo nano /etc/rc.local


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will “exit 0” on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ “$_IP” ]; then
   printf “My IP address is %s\n” “$_IP”
fi

cd /home/pi/smartHomeSensor
echo “Run script for SmartHomeSensor Java program”ensor Java program”
SCRIPT=”/home/pi/smartHomeSensor/run.sh”
echo “run script \”-> $SCRIPT\””
sudo $SCRIPT &

exit 0

save and reboot Raspberry Pi. After the Raspberry Pi reboot, you should be able to see the text “Run script for SmartHomeSensor Java program” printed before the user prompt or login. There should be no error message.

pi@raspberrypi ~ $ sudo nano /etc/rc.local

 

Login to check if the java process is running.
command “ps ax” print out the list of processes (thread) currently running in Raspberry Pi. “| grep java” pipe the output result and print out only those result that have the word “java” in it.

The result shows that the java program is running with PID 2242 (process ID). Remember this number, for you may need to use it to kill the process.

 

pi@raspberrypi ~ $ ps ax | grep java
2242 ? Sl 0:44 java -classpath .:bin:lib/log4j-1.2.14.jar:lib/commons-logging-1.1.jar:classes:/opt/pi4j/lib/*:lib/json-simple-1.1.1.jar:lib/org.apache.httpcomponents.httpclient_4.3.1.jar:lib/utilities.jar:resource com.picControl.smartHomeSensors.MyMain
2461 pts/0 S+ 0:00 grep –color=auto java


Now grep “run.sh”. Notice the PID 2241.

This is generated before the Java program is launch. Remember this PID no. You may need this number to kill the same java program.

pi@raspberrypi ~ $ ps ax | grep run.sh

2233 ? S 0:00 sudo /home/pi/smartHomeSensor/run.sh
2241 ? S 0:00 /bin/bash /home/pi/smartHomeSensor/run.sh
2481 pts/0 S+ 0:00 grep –color=auto run.sh

To kill the process.
Check the process currently running.
The previous process that appear is no longer running.

pi@raspberrypi ~ $ sudo kill -9 2242
pi@raspberrypi ~ $ ps ax | grep run.sh
2487 pts/0 S+ 0:00 grep –color=auto run.sh
pi@raspberrypi ~ $ ps ax | grep java
2489 pts/0 S+ 0:00 grep –color=auto java

 

List of frequently used commands
A list of frequently used Linux command (using Bash Shell)

Commands Illustration

List directory pi@raspberrypi ~ $ ls
Desktop ocr_pi.png python_games
or
pi@raspberrypi ~ $ ls -all
Change directory pi@raspberrypi ~ $ cd Desktop
Returning down one directory level. pi@raspberrypi ~/Desktop $ cd ..

Access to /sys directory which is hidden.
Containing system peripherals directory/information, for example GPIO, I2C, tty (UART, teletype).
http://www.linusakesson.net/programming/tty/index.php

pi@raspberrypi ~ $ /sys
pi@raspberrypi /sys $ 
Return to user’s root directory (~). pi@raspberrypi /sys $ cd ~
Rename a file from abc.txt to xyz.txt pi@raspberrypi /sys $ mv abc.txt xyz.txt
Delete or Remove a file pi@raspberrypi /sys $ rm abc.txt
Find or search a file name in the sub-directory, where ‘*’ is a wildcard. pi@raspberrypi /sys $ sudo find / -name *findText*
   
Press up down arrow keys to scroll through the previously executed commad list.  
Press tab to auto complete the command, file name, directory name or list all possibility. Press up down to select related name.  
Shortcut key to open terminal console <Ctrl+Alt+’T’>  
Create new directory. pi@raspberrypi ~ $ mk DIRECTORY_NAME
Remove file. pi@raspberrypi ~ $ rm FILENAME
Launch GUI, or Linux’s GUI pi@raspberrypi ~ $ startx
Stop Linux operating system pi@raspberrypi ~ $ sudo exit
or
pi@raspberrypi ~ $ sudo halt
or
pi@raspberrypi ~ $ sudo shutdown -h now
Reboot Linux operating system pi@raspberrypi ~ $ sudo reboot
or
pi@raspberrypi ~ $ sudo shutdown -r now

To get help or further details for any linux command, use the “man” command.
Help manual for any command or program, where ???? is the command/program name.

pi@raspberrypi ~ $ man ????
Pipe following terminal output text to this grep filter before display on the terminal console. Only the lines containing the text will be printed out. “XXXX” will be the command that generate the printed text on the terminal console, while “TEXT_FILTER” is the text to be filtered. The operator ‘|‘ pipes the console output from “XXXX” to the grep program. pi@raspberrypi ~ $ XXXX | grep TEXT_FILTER
Direct the terminal output text, saving to this file.txt pi@raspberrypi ~ $ XXXX > file.txt
To enable root privilege. Any command entered will be treated with root privilege as long as the terminal remains open. pi@raspberrypi ~ $ sudo su
Allow root privilege only for the command “XXXX pi@raspberrypi ~ $ sudo XXXX

Display the content of the file “XXXX”.
Example to display Raspberry Pi hardware revision, key in “cat /proc/cpuinfo

Example to display Linux OS information, key in “cat /etc/lsb-release

pi@raspberrypi ~ $ cat XXXX
pi@raspberrypi ~ $ cat /proc/cpuinfoProcessor : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7

Hardware : BCM2708
Revision : 000e
Serial : 000000005fdceeaf

Execute program in the background (execute program in a seperated thread), while allowing the current terminal for other more commands. This is done by appending the ‘&’ behind a program execution command, which is denoted as “XXXX”. pi@raspberrypi ~ $ XXXX&

Command “PS” List the program or threads running in the background of the Linux operating system (for the current user session only).
Where PID is the process ID number.

Command “ps” is a useful troubleshooting tools. Other related command is “top”.

Other useful troubleshooting commands are,
– “strace“, “ltrace
– “mtrace

 

pi@raspberrypi ~ $ ps
PID TTY TIME CMD
2803 pts/1 00:00:02 bash
2948 pts/1 00:00:00 ps

 

 

 

 


To list all the process running in the Raspberry Pi device, use command “PS AX”.
You can see the process created by other user session and you can kill it as well.

 

These are the bash session started by various user session 0, 1, 2, etc… ,

3477 pts/0 T 0:00 -bash
347? pts/1 T 0:00 -bash
347? pts/2 T 0:00 -bash

 

This is a bash session started for the main hardware,

2121 tty1 S+ 0:01 -bash

 

 

 

To list only the PID for a particular program, you can use with grep.

pi@raspberrypi ~ $ ps ax
PID TTY STAT TIME COMMAND
1 ? Ss 0:01 init [2]
2 ? S 0:00 [kthreadd]
3 ? S 0:00 [ksoftirqd/0]
5 ? S< 0:00 [kworker/0:0H]
6 ? S 0:01 [kworker/u:0]
7 ? S< 0:00 [kworker/u:0H]
8 ? S< 0:00 [khelper]
9 ? S 0:00 [kdevtmpfs]
10 ? S< 0:00 [netns]
12 ? S 0:00 [bdi-default]
13 ? S< 0:00 [kblockd]
14 ? S 0:00 [khubd]
15 ? S< 0:00 [rpciod]
16 ? S 0:00 [khungtaskd]
17 ? S 0:00 [kswapd0]
18 ? S 0:00 [fsnotify_mark]
19 ? S< 0:00 [nfsiod]
20 ? S< 0:00 [crypto]
27 ? S< 0:00 [kthrotld]
28 ? S< 0:00 [VCHIQ-0]
29 ? S< 0:00 [VCHIQr-0]
30 ? S< 0:00 [VCHIQs-0]
31 ? S< 0:00 [iscsi_eh]
32 ? S< 0:00 [dwc_otg]
33 ? S< 0:00 [DWC Notificatio]
35 ? S< 0:00 [deferwq]
36 ? S 0:00 [kworker/u:2]
37 ? S 0:08 [mmcqd/0]
38 ? S 0:00 [jbd2/mmcblk0p6-]
39 ? S< 0:00 [ext4-dio-unwrit]
154 ? Ss 0:00 udevd –daemon
1503 ? S 0:01 /usr/sbin/ifplugd -i lo -q -f -u0 -d10 -w -I
1592 ? S 0:07 /usr/sbin/ifplugd -i eth0 -q -f -u0 -d10 -w -I
1778 ? Sl 0:00 /usr/sbin/rsyslogd -c5
1863 ? Ss 0:00 /usr/sbin/cron
1888 ? Ss 0:00 dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhcli
1918 ? Ss 0:00 /usr/bin/dbus-daemon –system
1964 ? Ss 0:02 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 102:104
2003 ? Ss 0:00 /usr/sbin/thd –daemon –triggers /etc/triggerhappy/triggers.d
2008 ? Ss 0:00 /usr/sbin/sshd
2037 tty1 Ss 0:00 /bin/login -f tty1
2038 tty2 Ss+ 0:00 /sbin/getty 38400 tty2
2039 tty3 Ss+ 0:00 /sbin/getty 38400 tty3
2040 tty4 Ss+ 0:00 /sbin/getty 38400 tty4
2041 tty5 Ss+ 0:00 /sbin/getty 38400 tty5
2042 tty6 Ss+ 0:00 /sbin/getty 38400 tty6
2044 ? Sl 0:01 /usr/sbin/console-kit-daemon –no-daemon
2111 ? Sl 0:00 /usr/lib/policykit-1/polkitd –no-debug
2121 tty1 S+ 0:01 -bash
2151 ? S 0:00 [kworker/0:0]
2249 ? Ss 0:00 sshd: pi [priv]
2256 ? S 0:00 sshd: pi@notty
2257 ? Ss 0:00 /usr/lib/openssh/sftp-server
2258 ? Ss 0:00 /usr/lib/openssh/sftp-server
2662 ? S 0:00 [flush-179:0]
2663 ? Ss 0:00 sshd: pi [priv]
2667 ? Ss 0:00 sshd: pi [priv]
2674 ? S 0:01 sshd: pi@pts/0
2678 ? S 0:00 sshd: pi@notty
2679 ? Ss 0:00 /usr/lib/openssh/sftp-server
2684 pts/0 Ss 0:03 -bash
3127 ? S 0:00 udevd –daemon
3130 ? S 0:00 udevd –daemon
3338 ? S 0:00 [kworker/0:1]
3393 ? Ss 0:00 sshd: pi [priv]
3397 ? Ss 0:00 sshd: pi [priv]
3404 ? S 0:00 sshd: pi@pts/1
3408 ? S 0:00 sshd: pi@notty
3409 ? Ss 0:00 /usr/lib/openssh/sftp-server
3416 pts/1 Ss+ 0:01 -bash
3469 ? S 0:00 [kworker/0:2]
3476 pts/0 R+ 0:00 ps ax
3477 pts/0 T 0:00 -bash
3478 pts/0 Tl 0:03 java -classpath .:bin:lib/log4j-1.2.14.jar:lib/commons-logging

pi@raspberrypi ~ $ ps ax | grep java
3478 pts/0 Tl 0:03 java -classpath .:bin:lib/log4j-1.2.14.jar:lib/commons-logging

To terminate the program running in the background thread, use the kill command. Where “####” is the process ID (PID)

Putting an option -9 will force the process to be killed.

The process PID can be kill from another user session, even if the PID is not listed in its session.

pi@raspberrypi ~ $ kill ####

or

pi@raspberrypi ~ $ kill -9 ####

Check physical disk information. pi@raspberrypi ~ $ sudo fdisk -l
Check physical disk mount information pi@raspberrypi ~ $ sudo df -h
Measure Raspberry Pi temperature pi@raspberrypi ~ $ vcgencmd measure_temp
temp=58.4’C
 
Running a simple echo bash script on the command line terminal. pi@raspberrypi ~ $ echo “Hello World!!!”
Hello World!!!
The script can be save onto a file and be run just like a batch file under Microsoft Windows OS. Save the following echo bash script onto a file name “bash_script.sh”.

You can actually name the file whatever you like, but it is good to keep the *.sh file extension as under some GUI Linux OS, double clicking the file will automatic launch the correct application which runs the file.
#!/bin/bash
echo “Hello World!!!”
Run the file “bash_script.sh”. pi@raspberrypi ~ $ bash bash_script.sh
Hello World!!!

To run the “bash_script.sh” without the command bash, set the file as executable and run the file.

Note: You may encounter with the following
./test.sh: /bin/bash^M: bad interpreter: No such file or directory.

There is a ‘^M’ char detected at the end of the first line. Ensure that the script is not written on a Microsoft Window OS. Window’s environment will append ‘^M’ for enter key.

Use vi editor to view the file.
Type in command “vi bash_script.sh”.
You will see the ‘^M’ char in blue.
Delete those char.

Press ‘:w’ save the text file.
Press ‘:q’ to exit the vi program.

Try again, it should work fine now.

pi@raspberrypi ~ $ source bash_script.sh
Hello World!!!
or
pi@raspberrypi ~ $ . bash_script.sh
Hello World!!!

or
pi@raspberrypi ~ $ sudo chmod u+x bash_script.sh
pi@raspberrypi ~ $ ./bash_script.sh
Hello World!!!

To check the permission for the files in the current directory use “ls -l”.

To check permission for a particular file, type out the file name behind “ls -l filname”

File permissiondrwxrwxrwx 2 pi pi

    d – represent the name as a directory.
    – – Regular file or program.
    l – file/dir is a symbolic link.
    s – setuid/setgid permissions.
    t – sticky bit permissions.
    b – driver for storage medium.
    c – driver for communication hardware.


rwx – ‘r’ refers to the read permission
      ‘w’ refers to the write permission
      ‘x’ refers to the permission to execute

1st “rwx” -> owner (‘u’)
2nd “rwx” -> group (‘g’)
3rd “rwx” -> all users (‘o’ or ‘a’)
2 – referes to the number of hardlinks to the file.
pi pi -> Owner:Group

To change the file permission, use the following command,

“chmod a+x filename”
This will add all (‘a’) with executable (‘x’) permission.

“chmod ax filename”
This will remove all (‘a’) with executable (‘x’) permission.You can also set file permission using binary references (set to _rwxr—–),
command “chmod 740 filename”To change file’s owner and group,
command “chown newuser:newgroup filename”

 

pi@raspberrypi ~ $ ls -l
drwxr-xr-x 2 pi pi 4096 May 30 04:07 Desktop
-rw-r–r– 1 pi pi 5781 Feb  3  2013 ocr_pi.png
drwxrwxr-x 2 pi pi 4096 Mar 10 18:20 python_games

pi@raspberrypi ~ $ ls -l Desktop
drwxr-xr-x 2 pi pi 4096 May 30 04:07 Desktop

pi@raspberrypi ~ $ chmod a+x ocr_pi.png
pi@raspberrypi ~ $ ls -l
drwxr-xr-x 2 pi pi 4096 May 30 04:07 Desktop
-rwxr-xr-x 1 pi pi 5781 Feb  3  2013 ocr_pi.png
drwxrwxr-x 2 pi pi 4096 Mar 10 18:20 python_games

pi@raspberrypi ~ $ chmod a-x ocr_pi.png
pi@raspberrypi ~ $ ls -l
drwxr-xr-x 2 pi pi 4096 May 30 04:07 Desktop
-rw-r–r– 1 pi pi 5781 Feb  3  2013 ocr_pi.png
drwxrwxr-x 2 pi pi 4096 Mar 10 18:20 python_games

Auto Login (login without being prompt for password). Edit the file /etc/inittab.

Comment away the following line by inserting a ‘#’ in front of the statement.
“#1:2345:respawn:/sbin/getty 115200 tty1”
and insert the following line below it.
“1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1”

Reboot the system and you should be able to power up and go striaght into the command prompt without being prompt for user ID and password.

pi@raspberrypi ~ $ sudo nano /etc/inittab

#1:2345:respawn:/sbin/getty 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

Run a script after login (user specific),
by adding the following line to the end of the file /etc/profile (similar to /home/pi/.bashrc)
“. /home/pi/script1.sh”

“script1.sh” will run after the user has been sucessfully login. Local or remote user will get to auto execute “script1.sh” after login.

NOTE!!!
Please ensure to set the file as executable and run the file.

#! /bin/sh
echo “— script<1> ————–”
Run a script after the very end of the boot process (before any login), by adding the following line to the end of the file /etc/rc.local
“/home/pi/script3.sh”
 

Run a script after the booting process (or within the booting process), but before the login (using service method).

1) Create a script “script2.sh” in the folder /etc/init.d/script2.sh.
“sudo nano /etc/init.d/script2.sh”

2) Make the script executable.
“sudo chmod 755 /etc/init.d/script2.sh”

3) Test the script (service start).
“sudo /etc/init.d/script2.sh start”

4) Test the script (service stop).
“sudo /etc/init.d/script2.sh stop”

5) Register the script to be run at start-up (with default priorities).
“sudo update-rc.d script2.sh defaults”

update-rc.d is a program which mananged the start-up and shutdown using the file /etc/rcX.d (where rcX.d means rc0.d to rc6.d, rcS.d)
You can key in the following command to view the link to your script.
“ls -l /etc/rc?.d/”

6) To remove the script from start-up,
“sudo update-rc.d -f script2.sh remove”
‘-f’ is to force the removal of the symlinks even if the script is still under the /etc/init.d folder. Remember to delete away your script away from the folder /etc/init.d
Note: The command above will only disable the service until the next time the service is upgraded. To enable the service will not be re-enabled upon upgrade, type the following command, “update-rc.d script2.sh stop 80 0 1 2 3 4 5 6”

7) You can also register the services with custom priorities. (you can visit this website)

#! /bin/sh
# /etc/init.d/script2.sh### BEGIN INIT INFO
# Provides: —
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple script which will start / stop a program a boot / shutdown.
### END INIT INFO# If you want a command to always run, put it here# Carry out specific functions when asked to by the system
case “$1” in
  start)
    echo “— script<2> start ———“
    # run application you want to start
    # /usr/local/bin/noip2
    ;;
  stop)
    echo “— script<2> stop ———“
    # kill application you want to stop
    # killall noip2
    ;;
  *)
    echo “Usage: /etc/init.d/noip {start|stop}”
    exit 1
    ;;
esac

exit 0

After testing with various start-up scripts process, I have summarizes the sequence in which the scripts are call up.

— Booting process ——–
    before user login

– Script registered with update-rc.d
– /etc/rc.local

— User login prompt——-
    after user login

– /etc/profile
– /home/pi/.bashrc

— End of start-up process —–
    command prompt

 

Custom Splash screen
“apt-get install fbi”

Name your image file to “splash.png” and copy to the directory /etc

****encounter problem copying file to /etc directory.***
If the error above is encountered, copy the image file to the user directory instead. Then use “sudo mv” (move file command) to move it to the etc directory.

Edit a new text file “sudo nano”.
Cut and paste the followings,

#! /bin/sh
### BEGIN INIT INFO
# Provides: asplashscreen
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: S
# Default-Stop:
# Short-Description: Show custom splashscreen
# Description: Show custom splashscreen
### END INIT INFO
do_start () {
/usr/bin/fbi -T 1 -noverbose -a /etc/splash.png
exit 0
}
case "$1" in
start|"")
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
status)
exit 0
;;
*)
echo "Usage: asplashscreen [start|stop]" >&2
exit 3
;;
esac

:

save the file as /etc/init.d/asplashscreen

make the script executable and install it for init mode:

“sudo chmod a+x /etc/init.d/asplashscreen”

“sudo insserv /etc/init.d/asplashscreen”

Reboot

“sudo reboot “

 

The custom logo is displayed near the end of the booting process, not at the beginning.

This is followed by a blank screen.
Press <Ctrl + Alt + F2> to return to the command prompt.

pi@raspberrypi ~ $ sudo apt-get install fbi

pi@raspberrypi ~ $ sudo mv splash.png /etc

pi@raspberrypi ~ $ sudo nano

cut and paste, save file as

/etc/init.d/asplashscreen

pi@raspberrypi ~ $ sudo chmod a+x /etc/init.d/asplashscreen

pi@raspberrypi ~ $ sudo insserv /etc/init.d/asplashscreen

pi@raspberrypi ~ $ sudo reboot


Place your favourite wall paper on the desktop.
-> Login GUI Desktop
-> On the desktop, press right click , and -> Select “Desktop Preferences”.
-> Select your favourite wallpaper.

 
Hide boot up text, kernel loading modules (slient pi boot)  
– List process task, thread

enable sound
sudo modprobe snd_bcm2835
disable sound
rmmod snd_bcm2835

Root access

Some users believe that the root account has a password that they are not aware of. This is not the case. For security reasons, Raspbmc has been hardened by disabling the root account. There is no need to enable the root account in Raspbmc, and doing so increases the likelihood of you causing damage to the system. Instead, the following options are recommended:

  • Prefixing the command requiring root privileges with sudo will allow you to run the command as root.
  • Alternatively, you can temporarily have root privileges with the command sudo -s

If you truly wish to enable root access so that you can login as root. You can do so as follows:sudo passwd rootYou have now set a root password you can login with.To disable the root account again:

sudo passwd -l root

To change Raspberry Pi password. pi@raspberrypi ~ $ passwd
Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Changing Raspberry Pi user name (“newUserName”) and password (“abc1234”).

Follow the following procedure,

 
Add a new user with new password.

pi@raspberrypi ~ $ sudo adduser newUserName

Adding user `newUserName’ …
Adding new group `newUserName’ (1004) …
Adding new user `newUserName’ (1001) with group `newUserName’ …
Creating home directory `/home/newUserName’ …
Copying files from `/etc/skel’ …
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for newUserName
Enter the new value, or press ENTER for the default
     Full Name []:
     Room Number []:
     Work Phone []:
     Home Phone []:
     Other []:
Is the information correct? [Y/n] y
 

Give the new user sudo privileges, by editing the sudoers file.
Copy the line with the default user name pi and copy below it. Change the name pi to your newUserName.

After you have finished, key in Ctrl+’x’ then ‘Y’, followed by enter key.

pi@raspberrypi ~ $ sudo visudo

pi ALL=(ALL) NOPASSWD: ALL
newUserName ALL=(ALL) NOPASSWD: ALL

Testing the newUserName if it is working properly with sudo privileges.

pi@raspberrypi ~ $ logout

pi@raspberrypi ~ $ login

Enter your newUserName and passsword.

 

Try to see if you can edit the sudoers file. The file can only be edited if it has sudo access privileges.

Delete the line containing the “pi” user, if it is no longer required.
After you have finished, key in Ctrl+’x’ then ‘Y’, followed by enter key.

newUserName@raspberrypi ~ $ sudo visudo

Delete the old user “pi” account,
or add in option flag “-remove-home” to remove the “/home/pi” directory as well.

The process of changing the Raspberry Pi user name and password is completed.
Reboot the Raspberry Pi for the new user name to take effect. Old user name can no longer be in use.

(method do not work so well. still able login using pi as the user name.)

newUserName@raspberrypi ~ $ sudo deluser pi
newUserName@raspberrypi ~ $ sudo deluser -remove-home pi
Disable screen saver, or disable auto blank screen.

newUserName@raspberrypi ~ $ sudo nano /etc/kbd/config

BLANK_TIME=0
BLANK_DPMS=off
POWERDOWN_TIME=0

   
   
   

Advance command
– “lsusb” List all the USB peripherals
– “df /” check disk space
– “free” check memory RAM

 
Directory Structure of
Raspberry Pi running
Soft-float Debian “wheezy”

I have created an overview directory maps of my Raspberry Pi directory map to assist me in understanding the files modification that I will be dealing with.

Learning how things are being organised in a Linux platform.
/~–/bin    Essential commands that all user
  |
  |-/boot   Information that boots the machine, including Kernel.
  |  |-boot.rc
  |
  |-/dev    Device driver for all the hardware peripherals.
  |  |-/block
  |  |-/bus
  |  |-/char
  |  |-/disk
  |  |-/input
  |  |-/mapper
  |  |-/net
  |  |-/pts
  |  |-/raw
  |  |-/snd
  |-/etc    Configuration files for your system.
  |  |-/alternatives
  |  |-/apm
  |  |-/apparmor.d
  |  |-/apt
  |  |-/avahi
  |  |-/bash_completion.d
  |  |-/ca-certificates
  |  |-/calendar
  |  |-/console-setup
  |  |-/ConsoleKit
  |  |-/cron.d
  |  |-/cron.daily
  |  |-/cron.hourly
  |  |-/cron.monthly
  |  |-/cron.weekly
  |  |-/dbus-1
  |  |-/default
  |  |-/dhcp
  |  |-/dhcp3
  |  |-/dictionaries-common
  |  |-/dillo
  |  |-/dpkg
  |  |-/emacs
  |  |-/fonts
  |  |-/fstab.d
  |  |-/gconf
  |  |-/gdb
  |  |-/ghostscript
  |  |-/groff
  |  |-/gtk-2.0
  |  |-/gtk-3.0
  |  |-/ifplugd
  |  |-/init
  |  |-/init.d         save and register scripts in this directory to auto run when bootup or shutdown
  |  |-/insserv
  |  |-/insserv.conf.d
  |  |-/iproute2
  |  |-/kbd
  |  |-/ld.so.conf.d
  |  |-/ldap
  |  |-/libnl-3
  |  |-/libpaper.d
  |  |-/lightdm
  |  |-/logcheck
  |  |-/logrotate.d
  |  |-/menu
  |  |-/menu-methods
  |  |-/modprobe.d
  |  |-/network
  |  |-/opt
  |  |-/pam.d
  |  |-/perl
  |  |-/pm
  |  |-/polkit-1
  |  |-/profile.d
  |  |-/pulse
  |  |-/python
  |  |-/python2.7
  |  |-/python3
  |  |-/python3.2
  |  |-/rc0.d
  |  |-/rc1.d
  |  |-/rc2.d
  |  |-/rc3.d
  |  |-/rc4.d
  |  |-/rc5.d
  |  |-/rc6.d
  |  |-/rcS.d
  |  |-/request-key.d
  |  |-/rsyslog.d
  |  |-/samba
  |  |-/security
  |  |-/selinux
  |  |-/sgml
  |  |-/skel
  |  |-/ssh
  |  |-/ssl
  |  |-/sudoers.d
  |  |-/sysctl.d
  |  |-/systemd
  |  |-/terminfo
  |  |-/triggerhappy
  |  |-/udev
  |  |-/ufw
  |  |-/vim
  |  |-/wpa_supplicant
  |  |-/X11
  |  |-/xdg
  |  |-/xml
  |  |-/xpdf
  |  |-inittab   controls the startup/initialization process (example: auto login)
  |  |-profile
  |  |-rc.local
  |
  |-/home   Home directory for each of the user
  |  |~/pi  (User named pi)
  |     |-/Desktop
  |     |-/python_games
  |     |-.bashrc        script trigger everytime a specific user logs in
  |
  |-/lib    Library or code, Kernel or other programs use.
  |  |-/arm-linux-gnueabi
  |  |-/firmware
  |  |-/init
  |  |-/lsb
  |  |-/modprobe.d
  |  |-/modules
  |  |-/systemd
  |  |-/terminfo
  |  |-/udev
  |  |-/xtables
  |
  |-/lost+found
  |
  |-/media  Temp media (disk, CD-ROM)
  |
  |-/mnt    Temp media (disk, CD-ROM, network drive)
  |
  |-/opt    Location for installing new software package.
  |  |-/java
  |  |-/pi4j
  |  |-/vc
  |
  |-/proc
  |
  |-/root   Super user’s home directory
  |
  |-/run
  |  |-/ConsoleKit
  |  |-/dbus
  |  |-/lock
  |  |-/mount
  |  |-/network
  |  |-/sendsigs.omit.d
  |  |-/shm
  |  |-/sshd
  |  |-/udev
  |
  |-/sbin   Commands for system adminstrator.
  |
  |-/selinux
  |
  |-/srv    Data for system’s services (programs running in the background)
  |
  |-/sys
  |  |-/block
  |  |-/bus
  |  |-/class
  |  |-/dev
  |  |-/devices
  |  |-/firmware
  |  |-/fs
  |  |-/kernel
  |  |-/module
  |  |-/power
  |
  |-/tmp    for storing temp files
  |
  |-/usr    A complex hierarchy of additional programs and files
  |  |-/bin
  |  |-/games
  |  |-/include
  |  |-/lib
  |  |-/local
  |  |-/sbin
  |  |-/share
  |  |-/src
  |
  |-/var    The data that changes frequently. (log files, emails)
  |  |-/backups
  |  |-/cache
  |  |-/lib
  |  |-/local
  |  |-/log
  |  |-/mail
  |  |-/opt
  |  |-/spool
  |  |-/tmp


Linux Files and Directory Structure Reference

 

/~–/bin    Essential commands that all user
  |
  |-/boot   Information that boots the machine, including Kernel.
  |
  |-/dev    Device driver for all the hardware peripherals.
  |  |-/cd-rom
  |  |-/fd0
  |  |-/fd1
  |  |-/hda
  |  |-/hda1
  |  |-/hda2
  |  |-/hdb
  |  |-/hdb1
  |  |-/hdb2
  |  |-/sda
  |  |-/sda1
  |
  |-/etc    Configuration files for your system.
  |
  |-/home   Home directory for each of the user
  |  |~/pi  (User named pi)
  |     |-/Desktop
  |
  |-/lib    Library or code, Kernel or other programs use.
  |
  |-/media  Temp media (disk, CD-ROM)
  |
  |-/mnt    Temp media (disk, CD-ROM, network drive)
  |
  |-/opt    Location for installing new software package.
  |
  |-/root   Super user’s home directory
  |
  |-/sbin   Commands for system adminstrator.
  |
  |-/srv    Data for system’s services (programs running in the background)
  |
  |-/tmp    for storing temp files
  |
  |-/usr    A complex hierarchy of additional programs and files
  |  |-/X11R6
  |  |-/bin
  |  |-/games
  |  |-/include
  |  |-/lib
  |  |-/local
  |  |-/sbin
  |  |-/share
  |  |-/src
  |
  |-/var    The data that changes frequently. (log files, emails)

-/??? -> Directory related to the Linux operating system that needs careful attention in handling.

Linux Command Reference
linux_quickref.pdf
linuxcard.pdf

 
 
 

 

 

Add Wifi to Raspberry Pi
Add a Wifi to tap the internet access from your Wifi wireless network.

WiFi dongle keyword
– Edimax EW-7811Un
– Dynamode WL-700N-RXS

Commands Illustration

In order to connect to the Wifi, the first thing you will need is a Wifi dongle for your Raspberry Pi. The following contains the list of Wifi adaptors available that can work with Raspberry Pi.

http://elinux.org/RPi_USB_Wi-Fi_Adapters

In this example, D-Link DWA-123, H/W Ver.: B1, P/N IWA123EU…..B1G

 
Edit and Setup the network interface configuration pi@raspberrypi ~ $ sudo nano /etc/network/interfaces

Original setup look like the following,
——————————————————
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

 

If you have a DHCP server, change to the following
——————————————————
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet manualdhcp
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

 
If you are using a static IP, change to the following
——————————————————
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
 
Setup the WPA configuration, the following block to the file. Change the text in blue to your router settings. pi@raspberrypi ~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid=”SSID-GOES-HERE”
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=”WIFI-PASSWORD-GOES-HERE”
}
 
Reboot and unplug the ethernet cable. The Wifi should be taking over the network connection after the reboot. pi@raspberrypi ~ $ sudo reboot
Reference:
http://www.correderajorge.es/wifi-under-raspberry-pi-with-archlinux/

 

 


www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller





Reference book- Embedded Linux Primer (2nd Edition), A Practical, Real-World Approach, by Christopher Hallinan (indepth details of Linux OS operations) To explore list
– start up script, shutdown script
– Play Audio, Display images, Video – C I/O, UART, SPI programming



Keyword: Raspberry Pi, electronic hardware setup, UART, I2C, SPI, Digital I/O port, Python Programming, C Programming.

Spotronic1 Robot

Spotronic & my first Mine Avoidance Robot

Written by Lim Siong Boon, last dated 11-Apr-09.

 

Photos of SRG 1997

Robot Battlefield, laid with electronics mines. The mine will buzz and light up if it is being knock. Any robot that hit the mine will be out of the game.

 

 

Our senior’s robot representing Singapore Polytechnic in SRG 1997. MAR uses 3 infrared sensor, one in the middle and two at the side.

 

Our senior’s threat from Nanyang Polytechnic. Everybody were surprise by it performance in the 1997 competition. It has strong motor power and speed. This robot is able to complete the race before our senior MAR reaches their 2nd mine. The robot is able to stop quickly and negotiate the mine in a perfect curve in relatively short time, at least 5 times faster than MAR. It is no doubt a clear winner for Robot Battlefield 1997. No robot come close. It seems that they are using gear DC motor. The NYP robot have an array of sensor, sensing the mine from the top. A design that non of us expected. The design is a real genius, because they have break the impression that mines can only be sensed from the side. The position of the sensor is perfect, as mines sensing is very clear cut. This is unlike the side sensors position in MAR and the rest of the robots where sensing is more easily affected by the environment lightings when using infra-red. Looking into the components NYP use and the way the robot operate we guess that they are using PLC controller and a array of infra-red sensor. When the robot senses a defined pattern from the top-down sensor, it will negotiate the mine in a perfect curve close to the mine. Without side sensors to guide the robot, it is unlikely to negotiate the mine in such accuracy and speed. The only explanation for this behavior is that the curve movement profile is being pre-programmed into the PLC. Using PLC is the strength of their team, a group of mechantronic students.

Their design was great, and fit into the game. There is no rules at that time to restrict robot from using top down sensing. Since then, the SRG committee begin to seek new rule to deter new players to adopt such short-cut. The SRG 1998 committee begins to add on new odd shape obstacles prevent the use of such logic control robot. Example of new obstacles like a big/tall/non reflective dust bin in the middle of mine field, with low plank at the corner of the field. This new rules will ensure that the new generation of robot is intelligence enough to negotiate any type of obstacles and maneuver.

This robot from NYP becomes the ultimate aim in our project, to be better than this monster. Our team were looking forward to Robot Battlefield 1998, to fight with NYP robot. We will be following our senior’s robot technology, using direct drive stepper motor (without gear). It was a real challenge.

 

Robot powered by a 9V battery

This is the robot, I most admire among all robot. If I remember correctly, this robot is from NUS. It is driven by 2 very small tamiya motor with small wheels power by a 9V Alkaline Battery. The whole robot is flat and light like a pizza box, and movement is very swift. Unfortunately there is a problem with their sensing and algorithm which hinder their robot to move between two mines. The robot just move forward and backward very swiftly, just like a mouse who is afraid to move through the mine field. If programmed correctly, this robot could be a winner. The problem might also be their choice of battery. The alkaline battery might not be suitable to run high current application. This may affect the power stability, which affects their digital logic circuitry. It will be extremely difficult to troubleshoot software if the bug is partly contribute by the hardware. In my heart, this NUS robot will always be special for it’s performance in speed and energy efficient.

 

This is one of the robot using ultra sonic sensing. The sensor is enclose behind the casing. We are very aware that only this type of sensor at that time, can be mounted in this manner. We were trying very hard to analysis all possible threat for Robot Battlefield 1998.

 

Some other photos taken. It is a norm in SRG competition, that most IC chips are blank off, especially the important ones. This deter the competitor to learn more about their robotic system or to steal technological ideas. It is easy to learn about robot capability by observing their circuits, mechanical and sensing technology.

 

 

Spotronic Robot is still under development.

Motivate by my previous work in working on a mine avoidance vehicle, representing Singapore Polytechnic for the Singapore Robotic Games 1998. It is a new robotic event, and we are only the second batch of student competing in the event call “Robot Battlefield”. It was a very exciting moment in my life that no amount of words can described that feeling. The competition barely a minute in the battle field determines our one and a half year worth of effort.

The happiest moment, our commitment have won us a Gold Award in the competition. The award is won by my team namely, project leader Chew Chuen Hee (hardware motor), Lee Chin Kwang (firmware sensor and decision control), Pang Sze Hsin (hardware electronics) and lastly me Lim Siong Boon (motor driver firmware).

The rules of Robot Battlefield can be found in the SRG 1998 website or a copy of the rules I saved from the website. A lot of  changes to the rule have been make for Robot Battlefield 99. Part of the changes are resulted from some frustrating incident that occur during our competition in 1998. I shall touch further on this in future.

 

 

The following are some of my design work regarding the robot sensor positioning. It has never been implemented because of the demand in writing motor driver software. I am suppose to handle all the software coding for the whole robot. In the end, the demand in writing the motor control algorithm has taken me the whole one and a half year of our project schedule. It was quite complex to me at that time because it is not easy to debug the mechanical performance in real time. Electrical problem may surface when the robot operate by itself on the floor. Switches get trigger due to mechanical vibration when the robot travels. These are the kind of unforeseen bugs makes our debugging task extremely difficult. The task of writing sensing algorithm is eventually taken over by my team mate Chin Kwang who is in charge of sensor design.

Mine Avoidance Vehicle project report. (13.4 Mb)

My motor driver software for motorola microcontroller MC68HC705C8CS (commonly known as 6805), master and slave operation for the left and right stepper motor. The file are in asm machine language. Although I have written a lot of comment in the source code, it is now meaningless to me. I hardly remember that they were my own codes. The concept is still clear in my mind, how the two stepper motors are operated. The robot uses 3 microcontroller because we have meet the speed limitation in motorola 6805. A single 6805 chip is too slow in supporting our target robot speed at 2 meter per second. We have suggested switching to a more powerful microcontroller but was rejected by our supervisor as he is afraid that the learning curve for a new controller will be long. In the end, we had all agreed to implement 3 microcontroller to control the robot. One main controller for sensor algorithm, one master and slave microcontroller for left and right motor. Initially I have great doubt that individual controller for each motor will work. There might be synchronizing problem which affect the robot from traveling straight. Eventually after the first prototype, it seems working very well and the problem is in fact negligible. There was nothing to worry about after all.

 

 

 

 

 

My team mate Sze Hsin, and Chin Kwang. We take some photos during SRG 1997.

 

 

Our team leader Chuen Hee (Mechanical, Electronics hardware), Chin Kwang (Sensor, Robot algorithm firmware), Sze Hsin (Electronics hardware, PCB), Siong Boon (Me, Motor driver firmware & software tools).

Too bad that these are all the photos I have on hand. Furthermore they are blur. If you have more photos to share for SRG 1998, 1997, 1999, please forward me your collection. I will be excited to receive these precious.

Pinky (left), Brain (right).

Pinky & the Brain, the name has a very symbolic meaning. To conquer the world, the dream of Pinky and the Brain, which is what we want our robot to achieve.

 

 

 

 

 

We have created two similar robot for the competition. It is the cutest name we come up with. I love it. One robot, we call it “Pinky”, and the other one ” Brain”. Combine together, they are call “Pinky and the Brain“.

The saddest thing is that I didn’t keep any of the photos we had. I cannot forgive myself for not taking any pictures of our champion robot. It is one of the regret of my life for not taking any photos. The only traces of the robot we have created were our project report, certificates and the only website link on SRG 98.

Anyone of you out there, have document or picture for SRG 1998, please let me know. I am eager to get in contact with you. If only our competitor see this, I am sure they have our Pinky and the Brain photos taken.

Our developed robot is far superior from our senior. I forgot how we eventually agreed to join into this robotic game category. What we observe in our senior’s demonstration, there are plenty of opportunities for improvement. Our senior’s robot has limited sensor capability and their robot speed and movement is rather slow. For each object blocking their robot path, the robot execute a stop and do rotation, moving forward and rotate movement until the robot negotiated the obstacle “mine”. This wasted a lot of time and speed as time is required to do acceleration and braking.

My job is to write a motor driver firmware to provide ease of control for our main software (sensor algorithm), at the same time control our stepper motor to speed and precision. To improve our robot speed in the competition, we cannot afford to stop the robot. The turning have to be made immediately when obstacle is detected. The motor driver allows full speed control and full degree of left, right turn options. Efficient acceleration and de-acceleration of both the left and right motor are taken care by the driver controller. This ease processing power from the sensing controller which is programmed by my team mate Chin Kwang.

I will write more of this topic in future.

 

written by Siong Boon, 29 Nov 2005

   

 

 

www.pic-control.com, Singapore Research & Development R&D

Singapore Customized, custom made Electronics Circuits & Kits

 

 

My Spotronic  

 

 

Here are some snapshot of the robot I am building. It looks a bit like a trash robot because I did not spent too much money for it. I come across the wheels in a shop and it got me a very long time before I decided to buy the wheel. The coupling between the wheel and motor shaft is custom made, and it cause me about S$120. I had been waiting to resolve this wheel issue until I started working in my first job, and eventually had enough saving to spent some on my robot.

I forgot to mount on another PCB circuit which is the motor and LCD driver. The PCB board shown on the photos consist of the logic circuits. They uses less power and the digital control is run by my favourite microcontroller from Microchip, PIC16F877A.

The robot is in-completed as some of the electronics module is under research phase.

1) Power regulator, DC to DC

2) Wireless FM Transceiver

Other module involved and does not need further improvement are as follows,

1) Microcontroller PIC16F877

2) DC Motor driver L6203

3) Serial communication interface

4) LCD control

I want to make a good robot. Although I had purchase a DC to DC module to supply my electronics, I insist on robot completion using minimum funding. The DC to DC research is completed but I had yet put onto my robot. The DC to DC cost half the price of the module I brought and it provides me with the experience for future higher current application.

The next module I lack of is the wireless transceiver, which I never successfully have it working until recent FM transceiver research. The previous attempt fail, until the discovery of implementing an encoder and decoder for the data transmission. Finally my dream of a remote control robot is on the right path. Parallel digital bits transmission is tested to be working fine. The next step will be to try out serial communication through the transceiver.

Will update on my robot again once I have completed my documentation.

 

written by Siong Boon, 29 Nov 2005

   

www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller



 

 

 

Keyword: remote control robot autonomous robotic Singapore Robotic Games

 

Touch Sensor

Introduction to DIY capacitive touch sensing, and the various type of touch sensor technologies.

Edited by Lim Siong Boon, last dated 14-Jul-09.

 

Topic Discussion Overview

  1. Touch sensor IC and product
  2. Touch sensor circuit
  3. Touch sensor in action
  4. Touch Vibration Motion Sensor
  5. Piezo Touch Sensor
  6.  

     

    1. Touch sensor IC and products

     

     

    Various capacitive touch sensor products

     

     

    Quantum Research Group

    Capacitive touch sensor QT100, QT102, QT110, QT113, QT118H, QT220, QT240, QT1081, QT1103, QT60160, QT60168, QT60240, QT60248, QT60326, QT60486, QT411, QT511, QT1106

    STMicroelectronics

    Capacitive touch sensor: QST108, QST1610, STMPE1208S

    Resistive touch sensor: STMPE811

          Omron

    Capacitive touch sensor: B6TS-04LT, B6TS-08NF, B6TS-16LT

    Sensor Platforms

    Capacitive touch sensor: SSP1401, SSP1492

    Analog Devices

    Capacitive touch sensor: AD7142, AD7143, AD7147, AD7150, AD7151, AD7745, AD7746, AD7747

    The following circuit DIY touch sensor will be focusing oncapacitive sensing method. In case you think that capacitive is the only method to implement touch sensing, I have done some searching and list down the possible method and technology to achieve similar touch effect as the capacitive method. Just a short brief of the various touch sensing technology available in the market for your reference.

    The various types of touch sensor.

    – Capacitive

    – Resistive “4 wire/ 5 wire/ 8 wire”

    S.A.W “surface acoustic wave”, Acoustic

    InfraRed

    – Camera

     

    Capacitive type are normally used in a simpler button switch interface, which are commonly available on portable gadgets like mouse, ipod, and the On/Off switch for your LCD monitor. This method senses the changed of capacitance when the user come in close contact on the switch plate surface.

    Capacitive touch sensor can be implemented using microcontroller with simple interfacing component. You may like to refer to Microchip or Texas Instruments website for implementing touch sensing using a microcontroller, mTouch.

    PDF Article: Layout and Physical Design Guidelines for Capacitive Sensing

    PDF Article: Software Handling for Capacitive Sensing

    PDF Article: Capacitive Multibutton Configurations

    PDF Article: PCB-Based Capacitive Touch Sensing With MSP430

     

     

    Fortunately there are already integrated hardware solution in the form of IC chip, making it easier to integrate touch sensing into your gadget. On the left are some references for the various source of IC chip.

     

     

    The following are some of the touch solution available.

     

     

    Resistive touch sensor is commonly deployed in our touch panel LCD monitor.

     

     

     

    SAW acoustic sensor

     

     

    Piezo touch switch

    http://www.danielsoneurope.com/products/piezo_switches/

     

    Acroustic sound sensing, by sensitive object.

     

     

     

     

    IR touch screen InfraRed

     

     

     

     

    Cherry IR touch panel

    A simple IR emitter and detector for touch sensing.

     

     

     

     

    Another method of detection using IR sensor, by sensing the lights that is being blocked (the IR component looks like a LED).

    http://web.ndak.net/jdgrotte/touchsensor/touchsensor.htm

     

    IR sensor deployed in grid form, creating a IR sensing touch screen.

     

     

     

    Touch technology base on camera.

     

    IR camera.

     

    more: http://www.instructables.com/id/How-to-Make-a-Cheap-Multitouch-Pad/1

     

    Whiteboard using the Wiimote.

    http://uiui.mmdays.com/2008/03/29/johnny-lee/

     

     

    LED Multi-touch panel (click the picture for reference)

     

     

    Comparison references for various touch sensing technology.

    PDF Article: Touch Screen Technology Comparison

    http://www.tvielectronics.com/Touch_Screen.html

    http://www.softtouch.co.in/compareTouch.htm

     

     

     

www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller

    Singapore Customized, custom made Electronics Circuits & Kits

     

     

    2. Touch sensor circuit  
     

    Simplest touch sensor circuit

    The illustration on the left shows a simple touch sensor circuit. It will light up the LED when a person gets in contact with the wire or metal connection to the transistor base. This touch circuit is cheap and easy to construct. All you need is a npn transistor, a resistor, a LED, a metal contact surface and of course the wire connection. It is so simple.

    NOTE: Interface the circuit will requires a bit further improvement to the design. Do not connect the ground reference to the earth. The LED will either not light up or will be very dim.

     

     

     

    Capacitive touch sensor circuit using QT100

     

    Touch sensor schematic. (click for larger image)

    Using QT100

     

    QT100 IC pin out

    QT100 datasheet

    QTouch design

    Touch sensor using spring

    AT42QT1011.pdf

     

    Part no.

    AT42QT1011 (touch on output)

    – AT42QT1012 (touch toggle output)

    – AT42QT1010 (touch pulse output)

     

       

    Touch Sensor Module PIC-116

    click here to
    Buy Mini Touch Sensor
    Available Now at the PIC-store

     

    This touch sensor module PIC-116 from PIC-CONTROL uses QT100 IC to sense touch. You can purchase this from PIC-store. The module is small measuring only about 21x10x3mm, making it easy to deploy for switch or button press application. The voltage supply Vcc required can be from 1.8V to 5.5V.

    There is two output provided. Pin 2 is a digital output logic 0 and logic 1. Logic 1 indicates a touch detected. Logic 0 will be a 0V, while logic 1 is a voltage that is same as Vcc (supply voltage). Pin 1 is a npn output; logic 1 will force this pin 1 to ground, while logic 0 will leave this pin floating. Pin 1 is useful if the application needs to drive directly a load of not more than 40V 0.5A. The load can be a LED indicator or the coil of a relay to drive higher current load. This means that it can be use as a momentary switch to switch on virtually anything.

    The touch sensitivity can be adjusted by changing the capacitor Cs. PIC-116 mini touch sensor module is installed with a Cs value of 8.2nF. The sensitivity can be reduced by using a lower capacitance value Cs; minimum Cs value is about 2nF. A Cs value lower than 2nF can have undetermine output state. To increase the sensitivity, a higher capacitance of Cs can be used. Maximum Cs value is about 50nF.

    The sensor can be so sensitive that it can detect your finger or body a few centimeter away from the sense pad.

    The reverse side of the PIC-116 touch sensor module is completely flat, making it easy to hide and stick behind a glass or plastic plate as a user interface. The intergrated sense pad onboard is on this side of the board labelled by the 3 circled ring with a pad area of about 10x10mm.

    The sensor comes with a soldering pad to allow me to use my own sensor pad. I have coil a length of fine wire wraping wire (thickness 0.5mm) as a touch pad. One end of the fine wire is soldered to the pad labelled as “Ext”, which is also next to the component Rs. This coil allows me to customised my own touch pad with varies size and shape. The coil on the left is about a diameter of 50mm. A big touch pad makes it easy for a user to interact with.

    wire wrapping wire. Fine wire, dia of about 0.5mm

    Alternative, this “Ext” pad can be soldered to copper foil or copper tape (thickness 0.08mm) which can be much thinner than my wire wrapping wire. A flat touch pad can be easily conceal behind poster or PVC stickers, allowing the touch switch to be hidden flat. This is great if you need an odd size/shape/surface switches as a user interface to blend into your designed artifact; which is impossible using a typical off the shelves mechanical push switches. Compare to a mechanical switch, touch switch do not have the problem of mechanical wear and tear. You can get the copper foil from stained-glass shop. Copper foil tape is used as adhesive to allow the solder to hold the glass that was cut to shape.

    copper foil, copper foil tape, easily available from stained-glass shops

    After my external wire coil is soldered onto the “Ext” pad, the sensor becomes more sensitive. This is due to the increase in the pad area. The larger the pad size, the more sensitive it will become. The larger pad surface allows the sensor to capture from a larger area. In order to reduced the sensitively, a smaller capacitance Cs can be use.

    The touch pad should be of a size of the sense target. If the finger is expected to touch the pad, the pad size should be of the finger size which is about 10x10mm. If a palm/hand/leg touch is expected, the sense pad can be larger.

    Sensor will not response when nothing is near its sense pad.

    Sensor detects my finger at a close proximity to the pad. A physical touch is not neccessary; it depends on the sensitivity that was set by the capacitor Cs. The sensitivity can be set lower, so that the sensor gets activated only upon a physical touch on the sense pad.

    Video of the touch sensor PIC-116

    MVI_1615, finger touch switch.AVI
    Video showing the sensor response to a finger at close proximity. Notice the sensor is able to detect the finger even before the finger touches the pad. The sensitivity was set too high. Cs can be lower to reduce the sensitivity so the the sensor gets activated when the finger is in contact with the pad.

    MVI_1616, sensor sensitive to metalic.AVI
    Video showing a piece of aluminium foil material activating the sensor. The sensor is too sensitive in this case. This can be eliminated by lower the capacitance Cs, so that the sensor is robust against such foil at close proximity. Radio radiation and electrical power line can also affect the result if they are placed near the sensor.

    MVI_1620, touch sensor through material.AVI
    The sensor is able to detect my finger touch even through insulated material like plastic or wood. The sensitivty of the sensor will need to increase in order to sense a finger touch across a much thicker insulated material >5mm.

     

     

     

     

     

     

     

     

     

     

    click here to
    Buy Mini Touch Sensor
    Available Now at the PIC-store

       
    Various others touch circuit that I have found on other website:

     

       

     

     

www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller

    Singapore Customized, custom made Electronics Circuits & Kits

     

     

    3. Touch sensor in action

    Testing out with my first touch sensor prototype board. It is actually more sensitive than expected. The sensor board can sense my finger at a distance of about 10mm. The circuit is quite simple to setup with only a few passive resistor and capacitor components.

    I am suppose to make the board a plate for sensing the capacitance, but I only wired the sensing plate in a form of L shape path. It is working well just like a rectangular sensing zone, even though the plate is actually a thin L shape path.

    One thing I found out. It is too sensitive. the sensor also detects if I place the board near my wooden table platform. You can actually fine tune the sensitivity by using a different capacitance component.

    Try reading the datasheet for further information on using QT100 touch sensor. You can find more tips on making your own touch sensing device.

    The following videos demonstrate the signal out put you can expect from QT100 touch sensor IC.

    MVI_4968.AVI

    Touch sensor is sensitive

    MVI_4970.AVI

    MVI_4969.AVI

     

     

     

    4. Touch Vibration Motion Sensor

     

     

    This is a simple vibration detection switch. The switch will make a contact upon slight vibration or motion.

    Typical application for this sensor
    – vibration detection (detect vibrate on an object)
    – touch sensor (motion touch of finger/hand)
    – knock sensor (door knocking)
    – centrifugal force sensor (detect the present of centrifugal force on a machine or motor)
    – detect sudden motion (sudden change in motion)

    click here to
    Buy Vibrate Sensor
    Available Now at the PIC-store

     

    A simple schematic of the vibrate sensor circuit under testing.

     

    The picture and schematic on the left presents a simpe circuit to test the sensor.

    The output signal is a digital on and off signal, like a random noise or glitches. The change of signal’s logic indicate that there is a vibration or knock present. The output state of the sensor at rest will be logic 1 (5V); the sensor is a open switch at rest position.

    When the sensor is subjected to a centrifugal force, the sensor will be at close position, with its output staying constant at logic 0 (0V).

    The output signal is quite raw, but can be easily intepreted from a micrcontroller to detect the vibration event.

    My finger giving the sensor a slight knock.

     

    The sensor is a very sensitive touch switch. Any finger knock on the physical sensor will trigger an output response.

    The following signal is taken from the output signal of the vibrate sensor. The output signal of various knock and vibration. Some slight touch, while some very hard hit on the sensor.

     


    slight knock


    slight knock


    slight knock (zoom in). It is actually a short negative pulse of about 5us.


    slight knock with a double pulse detected.


    harder knock


    harder knock


    vibration


    vibration

    A permanent logic 1 or 5V will occur when the sensor is subject to a centrifugal force.

     

     

     

    5. Piezo Touch Sensor

     

    Touch sensor using piezo was what I would have never though of. I know the many use of piezo, but using it as a touch is over-whelming to me.

    I have searched the website for more information about piezo, and managed to consolidate them below.

    This is how a plain piezo sensor looks like. It consist of two plate which can bend with input voltage (use as a speaker), and generate voltage when bend (use as a microphone).

    Using piezo as a buzzer.

    Alternating voltage is applied to the wire pair which will vibrate the sensor. In simple sense, it works like a speaker.

     

    A illustration of how the piezo sensor, 2 plate generate voltage when bend or how it bends when voltage is applied.

    Throat microphone using piezo.

    Normal microphone depend on the sound wave through the air. Sometimes noise from a distance can be pick up by the mic. A throat mic is held close to the throat, picking up the vibration from our voice. This can prevent the distance noise from being pick up, but it also has its own source of noise. Anything that can vibrate the throat mic will be the potential source of noise for the throat mic.

    Ultrasonic Transducer using piezo plate.

    This sensor is widely deploy on a vehicle as a parking sensor. The sensor will activate a warning buzzer when it detect an object behind the vehicle. The sensor generate an ultrasound wave and any object in the path of the wave will reflected the sound wave back to the sensor. A detection of the reflected sound will indicate an object in front of the sensor. It works is like the bat flying in the dark using their ear to navigate.

    taken from http://piezo-switch.com/index-2.html

     

    Piezo sensor as a touch switch.

    Using piezo as a touch switch has many advantages over other type of sensors.

    – durable, waterproof

    – easy to maintain, long lifespan

    – robust to RF, capacitance interference.

       
    The piezo schematic that I have tried out: My flat and ultra thin user button switch.

    ceramic back side of the plate.

    front side of the plate.

    side view showing the piezo, a very thin plate.

    Schematic making use of piezo plate as a touch button push switch. Switch will get activate with a light tap on the piezo plate.

    A simpler schematic to use the piezo plate as a switch.

       

    Some of the signal taken on the piezo output and also the processed switching signal.

     

    Ch1 (yellow) is the npn transistor output.

    Ch2 (blue) is the signal taken at the piezo out. Signal can reach as high as a few volts. When pressure is applied to the white ceramic back side, the signal will start off with a positive curve, followed by a negative smaller curve. The opposite signal will be generated if the pressure is applied from the front face.

     

    I managed to play around with various design. Some design, the signal decay slowly which result in glitches. Overall the piezo is quite simple to interface. Vibrate can activate the sensor, but not as bad as I had imagine. This undesirable noise can be filtered with proper design.

    Signal taken with my final op-amp schematic design as posted above. The square pulse has a much cleaner cut.
       

    Piezo touch sensor circuit taken from other website

     

     

     


    www.pic-control.com, Singapore Network Ethernet WiFi RS232 RS485 USB I/O Controller



     

     

     

     

     

    Keyword: Touch sensor switch, proximity, capacitance, capacitive touch sensing, surface acoustic wave, resistive 4 wire 5 wire