Monday, December 29, 2014

Config WiFi on new Raspbian

To run WiFi Configuration Utility on new Raspbian without icon on desktop, click Menu on Raspbian top banner, click Preferences, and WiFi Configuration.


This view show how:

python3-pygame preinstalled on new Raspbian

python3-pygame preinstalled on new Raspbian

New LXDE look of Raspbian

New LXDE look of Raspbian, 2014-12-24, updated with no icons on the desktop other than the wastebasket.



Related: CHANGES TO THE RASPBIAN USER INTERFACE

New NOOBS and RASPBIAN updated

New version of NOOBS and RASPBIAN, 2014-12-24, is available now, download HERE.

~ Release notes: http://downloads.raspberrypi.org/raspbian/release_notes.txt

Sunday, December 28, 2014

scp copy folder

Linux command scp option -r recursively copy entire directories.  Note that scp follows sym‐bolic links encountered in the tree traversal.


To copy folder from Linux host to Raspberry Pi (or any Linux machine) user home, enter the command:
$ scp -r testscp pi@192.168.1.107:

where testscp is the folder to be copied.

or
$ scp -r testscp pi@192.168.1.107:newfolder

where newfolder will be created.


Thursday, December 25, 2014

Raspberry Pi + Arduino i2c communication, write block and read byte

This example extends work on last example "Raspberry Pi send block of data to Arduino using I2C"; the Raspberry Pi read byte from Arduino Uno after block sent, and the Arduino always send back length of data received.


i2c_slave_12x6LCD.ino sketch run on Arduino Uno.
/*
 LCD part reference to:
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

#include <LiquidCrystal.h>
#include <Wire.h>

#define LED_PIN 13
boolean ledon = HIGH;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte slave_address = 7;
int echonum = 0;

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print startup message to the LCD.
  lcd.print("Arduino Uno");
  
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  
  Wire.begin(slave_address);
  Wire.onReceive(receiveEvent);
  Wire.onRequest(requestEvent);

}

void loop() {

}

void requestEvent(){
  Wire.write(echonum);
  toggleLED();
}


void receiveEvent(int howMany) {
  lcd.clear();
  
  int numOfBytes = Wire.available();
  //display number of bytes and cmd received, as bytes
  lcd.setCursor(0, 0);
  lcd.print("len:");
  lcd.print(numOfBytes);
  lcd.print(" ");
  
  byte b = Wire.read();  //cmd
  lcd.print("cmd:");
  lcd.print(b);
  lcd.print(" ");

  //display message received, as char
  lcd.setCursor(0, 1);
  for(int i=0; i<numOfBytes-1; i++){
    char data = Wire.read();
    lcd.print(data);
  }
  
  echonum = numOfBytes-1;
}

void toggleLED(){
  ledon = !ledon;
  if(ledon){
    digitalWrite(LED_PIN, HIGH);
  }else{
    digitalWrite(LED_PIN, LOW);
  }
}

i2c_uno.py, python program run on Raspberry Pi.
#have to run 'sudo apt-get install python-smbus'
#in Terminal to install smbus
import smbus
import time
import os

# display system info
print os.uname()

bus = smbus.SMBus(1)

# I2C address of Arduino Slave
i2c_address = 0x07
i2c_cmd = 0x01

def ConvertStringToBytes(src):
    converted = []
    for b in src:
        converted.append(ord(b))
    return converted

# send welcome message at start-up
bytesToSend = ConvertStringToBytes("Hello Uno")
bus.write_i2c_block_data(i2c_address, i2c_cmd, bytesToSend)

# loop to send message
exit = False
while not exit:
    r = raw_input('Enter something, "q" to quit"')
    print(r)
    
    bytesToSend = ConvertStringToBytes(r)
    bus.write_i2c_block_data(i2c_address, i2c_cmd, bytesToSend)
    
    # delay 0.1 second
    # with delay will cause error of:
    # IOError: [Error 5] Input/output error
    time.sleep(0.1)
    number = bus.read_byte(i2c_address)
    print('echo: ' + str(number))
    
    if r=='q':
        exit=True


Next:
Wire.write() multi-byte from Arduino requestEvent


WARNING:
Somebody advise to use I2C Logic Level Converter between Raspberry Pi and Arduino, otherwise the RPi's ports will be burnt! So, please think about it and take your own risk.

Tuesday, December 23, 2014

Thursday, December 18, 2014

Play mp4 on Raspberry Pi

To play mp4 video files on Raspberry Pi, can use omxplayer.

Example: enter the command to play movie.mp4.
omxplayer movie.mp4


Monday, December 15, 2014

Raspberry Jams event around the world

Raspberry Jams are events organised by the community to share knowledge, learn new things, and meet other Pi enthusiasts. They’re a great way to find our more about the Raspberry Pi and what you can do with it, and to find like-minded people.

visit: http://www.raspberrypi.org/jam/


Sunday, December 14, 2014

Raspberry Pi send block of data to Arduino using I2C

In this example, Raspberry Pi programmed using Python with smbus library, act as I2C master, ask user enter something as string, then send to Arduino Uno in blocks of data. In Arduino side, act as I2C slave, interpret received data in number of bytes, command, and body of data, to display on 16x2 LCD display.


Prepare on Raspberry Pi for I2C communication, refer to previous post "Communication between Raspberry Pi and Arduino via I2C, using Python".

Connection between Raspberry Pi, Arduino Uno and 16x2 LCD:


i2c_slave_12x6LCD.ino sketch run on Arduino Uno.
/*
 LCD part reference to:
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

#include <LiquidCrystal.h>
#include <Wire.h>

#define LED_PIN 13
boolean ledon = HIGH;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

byte slave_address = 7;

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print startup message to the LCD.
  lcd.print("Arduino Uno");
  
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  
  Wire.begin(slave_address);
  Wire.onReceive(receiveEvent);
}

void loop() {

}

void receiveEvent(int howMany) {
  lcd.clear();
  
  int numOfBytes = Wire.available();
  //display number of bytes and cmd received, as bytes
  lcd.setCursor(0, 0);
  lcd.print("len:");
  lcd.print(numOfBytes);
  lcd.print(" ");
  
  byte b = Wire.read();  //cmd
  lcd.print("cmd:");
  lcd.print(b);
  lcd.print(" ");

  //display message received, as char
  lcd.setCursor(0, 1);
  for(int i=0; i<numOfBytes-1; i++){
    char data = Wire.read();
    lcd.print(data);
  }
  
  toggleLED();
}

void toggleLED(){
  ledon = !ledon;
  if(ledon){
    digitalWrite(LED_PIN, HIGH);
  }else{
    digitalWrite(LED_PIN, LOW);
  }
}

i2c_uno.py, python program run on Raspberry Pi.
#have to run 'sudo apt-get install python-smbus'
#in Terminal to install smbus
import smbus
import time
import os

# display system info
print os.uname()

bus = smbus.SMBus(1)

# I2C address of Arduino Slave
i2c_address = 0x07
i2c_cmd = 0x01

def ConvertStringToBytes(src):
    converted = []
    for b in src:
        converted.append(ord(b))
    return converted

# send welcome message at start-up
bytesToSend = ConvertStringToBytes("Hello Uno")
bus.write_i2c_block_data(i2c_address, i2c_cmd, bytesToSend)

# loop to send message
exit = False
while not exit:
    r = raw_input('Enter something, "q" to quit"')
    print(r)
    
    bytesToSend = ConvertStringToBytes(r)
    bus.write_i2c_block_data(i2c_address, i2c_cmd, bytesToSend)
    
    if r=='q':
        exit=True


next:
- Raspberry Pi + Arduino i2c communication, write block and read byte


WARNING:
Somebody advise to use I2C Logic Level Converter between Raspberry Pi and Arduino, otherwise the RPi's ports will be burnt! So, please think about it and take your own risk.

Python exercise: read line of input, 'q' to quit

Python example to read line of input, 'q' to quit, using raw_input().



exit = False
while not exit:
    r = raw_input('Enter something, "q" to quit"')
    print(r)
    if r=='q':
        exit=True

Saturday, December 13, 2014

Communication between Raspberry Pi and Arduino via I2C, using Python.

This exercise implement communiation between Raspberry Pi and Arduino using I2C. Here Raspberry Pi, programmed with Python, act as I2C host and Arduino Uno act as slave.

Download the sketch (I2CSlave.ino) to Arduino Uno. It receive I2C data, turn ON LED if 0x00 received, turn OFF LED if 0x01 received.
#include <Wire.h>

#define LED_PIN 13

byte slave_address = 7;
byte CMD_ON = 0x00;
byte CMD_OFF = 0x01;

void setup() {
  // Start I2C Bus as Slave
  Wire.begin(slave_address);
  Wire.onReceive(receiveEvent);
  
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);  

}

void loop() {

}

void receiveEvent(int howMany) {
  byte cmd = Wire.read();
  if (cmd == CMD_ON){
    digitalWrite(LED_PIN, HIGH);
  }else if(cmd == CMD_OFF){
    digitalWrite(LED_PIN, LOW);
  }
}

Prepare on Raspberry Pi, refer to last post "Enable I2C and install tools on Raspberry Pi".

Connection between Raspberry Pi and Arduino.


Then you can varify the I2C connection using i2cdetect command. Refer to below video, the I2C device with address 07 match with slave_address = 7 defined in Arduino sketch.


On Raspberry Pi, run the command to install smbus for Python, in order to use I2C bus.
sudo apt-get install python-smbus


Now create a Python program (i2c_uno.py), act as I2C master to write series of data to Arduino Uno, to turn ON/OFF the LED on Arduino Uno. Where address = 0x07 have to match with the slave_address in Arduino side.
#have to run 'sudo apt-get install python-smbus'
#in Terminal to install smbus
import smbus
import time
bus = smbus.SMBus(1)

# I2C address of Arduino Slave
address = 0x07

LEDst = [0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01]
for s in LEDst:
    bus.write_byte(address, s)
    time.sleep(1)

Finally, run with command:
$ sudo python i2c_uno.py



Next:
Raspberry Pi send block of data to Arduino using I2C
Write block and read byte
Wire.write() multi-byte from Arduino requestEvent


WARNING:
Somebody advise to use I2C Logic Level Converter between Raspberry Pi and Arduino, otherwise the RPi's ports will be burnt! So, please think about it and take your own risk.

Enable I2C and install tools on Raspberry Pi

To enable I2C and install tools on Raspberry Pi, such that you can develop program to communicate with I2C devices.

  • $ sudo apt-get install i2c-tools
  • $ sudo apt-get install libi2c-dev
  • $ sudo nano /etc/modprobe.d/raspi-blacklist.conf
    comment the line of
    #blacklist i2c-bcm2708
  • $ sudo nano /etc/modules
    add the lines:
    i2c-bcm2708
    i2c-dev
  • reboot
After reboot, run i2c-tools to test
run the command with -1 option for rev 2 board, or -0 for rev 1 board.
$ sudo i2cdetect -y 1
$ sudo i2cdetect -y 0

updated@2016-06-21:
Enable I2C on Raspberry Pi running Raspbian Jessie

Related:
Communication between Raspberry Pi and Arduino via I2C, using Python.
Raspberry Pi send block of data to Arduino using I2C.

Friday, December 12, 2014

The MagPi, December 2014,is available

The MagPi issue 29, December 2014, is available. View or download HERE now.

Banana PI M2 (BPI-M2) is available to pre-order now

BPI-M2 Mass production will come out after 50 days, you can pre-order it.
~ link: http://www.aliexpress.com/store/product/Single-Board-Computer-Quad-Core-Banana-PI-wifi-on-Board-BPI-M2/302756_32251903757.html

Banana PI M2:

  • open source hardware platform
  • an quad core version of Banana Pi, same size
  • support WIFI onboard.
  • run Android (4.4), Debian, Ubuntu, Raspberry Pi imange and others imange.
  • 1Ghz ARM7 quad-core processor, 1GB DDR3 SDRAM,
  • with Gigabit ethernet port
  • can easily run with the game it support 1080P high definition video output
  • the GPIO compatible with Raspberry Pi B+ and can run the ROM Image.




Hope it can available at taobao.com ASAP.



Friday, December 5, 2014

Banana Pi-M2 (A31S ARM Cortex-A7 quad-core, Coming soon)

Banana PI M2 is the open source hardware platform,Banana PI M2 is an quad core version of Banana Pi ,Banana PI M2 is the quad core more better than the Banana Pi M1,it support WIFI onboard.

Banana Pi M2 series run Android,Debian linux,Ubuntu linux, Raspberry Pi imange and others imange.


Details: http://bananapi.com/index.php/component/content/article?layout=edit&id=73

Monday, December 1, 2014

Weaved IoT Kit for Raspberry Pi


Weaved, Inc. has launched the public beta version of the first kit that easily allows hobbyists and others to easily add Internet of Things (IoT) capabilities to the Raspberry Pi platform. There have been over 3.8 million Raspberry Pi boards sold and now all of them and any new boards can now be transformed to IoT devices.

source: http://www.weaved.com/archives/2895

Friday, November 28, 2014

OwnCloud installation on Banana Pi- Personal Cloud and NAS


Pumpkin Pi is an mere idea, a seed, of great potential. It aims to bring to your fingertips a personal cloud experience and a fun Do-It-Yourself project. Powered by an embedded board running on Linux, Pumpkin Pi is all the imagination and work of developers and programmer worldwide. To be loaded with an open source cloud software, Pumpkin Pi stores all of your information on a hard drive in your house.

https://pumpkinpi.cu.cc/generic.html

Linux command "$ sudo !!", to run last command with sudo

To run last command with sudo right, enter:
$ sudo !!

Thursday, November 27, 2014

Code Java on the Raspberry Pi, BlueJ on the Raspberry Pi

BlueJ, start from version 3.14, fully supports the Raspberry Pi. BlueJ is a Java development environment that allows development as well as program execution on the Pi.

BlueJ on the Raspberry Pi provides full access to hardware attached to the Raspberry Pi via the open source Pi4J library, from the the familiar Java SE language, including the new Java 8.

link:
http://bluej.org/raspberrypi/index.html



Current issue of Java Magazine, november/december 2014, have a charter of "Code Java on Raspberry Pi" introduce how BlueJ brings Java SE 8 development directly to the Raspberry Pi.



Friday, November 21, 2014

Raspberry Pi Challenge Day @ UKFast

UKFast hosted a challenge day for The Dean Trust Ashton-On-Mersey School to inspire the next generation of software engineers. Guided by our industry experts; the students learned to program the Raspberry Pi to control bedroom lamps with their smartphones and modified Minecraft.

Thursday, November 20, 2014

Banana Pi Camera & LCD

An overview of the LeMaker Banana Pi camera and five inch LCD module, including connection and driver information.

Wednesday, November 12, 2014

How much current does the Raspberry Pi Model A+ need


Raspberry Pi A+ power measurements. How much current does the A+ need to do various things? Comparison with B+ and older model A. Blog article here http://raspi.tv/?p=7238

Tuesday, November 4, 2014

Develop C# program on Raspberry Pi, with mono

Sponsored by Xamarin, Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime. A growing family of solutions and an active and enthusiastic contributing community is helping position Mono to become the leading choice for development of cross platform applications.

To install mono on Raspberry Pi, run the command:
$ sudo apt-get install mono-complete


Currently, the installed version is 3.2.8.


Create a simple console program of HelloWorld using C# language, HelloWorld.cs.
using System;

public class HelloWorld
{
    public static void Main()
    {
        Console.WriteLine("Hello Raspberry Pi...using c#");
    }
}


Compile it with the command:
$ gmcs HelloWorld.cs

And run it:
$ mono HelloWorld.exe



Updated post: Install Mono/MonoDevelop on Raspberry Pi/Raspbian

Wednesday, October 22, 2014

Linux command tree, list contents of directories in a tree-like format

The Linux command tree list contents of directories in a tree-like format.

To install trr on Raspberry Pi, enter the command:
$ sudo apt-get install tree



Linux command free, display amount of free and used memory in the Raspberry Pi system

The Linux command free - Display amount of free and used memory in the system


Thursday, October 16, 2014

Banana Pro Released

New version single board computer, Banana Pro, released.


Banana Pro is an update version of Banana Pi, designed by LeMaker Team and it has more enhanced features. Banana Pro has an excellent compatibility with multiply software supports. Basically all mainstream Linux-based operating system can run on Banana Pro, with the version of Lubuntu, Android, Debian, Bananian, Berryboot, OpenSuse, Scratch, Fedora, Gentoo, Open MediaVault, OpenWRT.Banana Pro also supports BSD system.



Visit: http://www.lemaker.org/

Saturday, October 11, 2014

Check your Raspberry Pi board revision

To find the board revision of your Raspberry Pi, enter the following command:
cat /proc/cpuinfo



The number in Revision identify the board revision. check the revision list here: http://elinux.org/RPi_HardwareHistory#Board_Revision_History


Friday, October 10, 2014

Scan network using nmap command

On host pc running Linux, we can scan network using nmap command to determine the IP of connected Raspberry Pi.

$ sudo nmap -sP 192.168.1.1-254



Friday, September 19, 2014

Display CPU Frequency monitor on Raspberry Pi Task Bar

To enable CPUFreq frontend applet on your Raspberry Pi taskbar to monitor CPU frequency:




  • Right click Task Bar
  • Select Add/Remove Panel Items
  • Select CPU Usage Monitor, click Add.
  • CPUFreq frontend, click Add.

CPUFreq frontend applet will be added on your Task Bar. To monitor your CPU frequency, move mouse hover over the CPUFreq frontend applet.


Tuesday, September 16, 2014

Sunday, September 14, 2014

Python + bottle@Raspberry Pi: Web based GPIO control

This example show how to program in Python with bottle on Raspberry Pi, to implement web base GPIO control.

bottle is a Python web server library. To install bottle on Raspberry Pi, enter the command:
sudo apt-get install python-bottle


Create webled.py
from bottle import route, run
import RPi.GPIO as GPIO

host = '192.168.1.105'

pinButton = 17
pinLed = 18
GPIO.setmode(GPIO.BCM)
# pin 17 as input with pull-up resistor
GPIO.setup(pinButton, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# pin 18 as output
GPIO.setup(pinLed, GPIO.OUT)

LedState = False

def read_button():
    if GPIO.input(pinButton):
        return 'Released'
    else:
        return 'Pressed'

def update_led():
    GPIO.output(pinLed, LedState)
    
def toggleLed():
    global LedState
    LedState = not LedState
    
@route('/')
@route('/<arg>')
def index(arg=""):
    if arg == "toggle":
        toggleLed()
        
    update_led()
    
    response = "<html>\n"
    response += "<body>\n"
    response += "<script>\n"
    response += "function changed()\n"
    response += "{window.location.href='/toggle'}\n"
    response += "</script>\n"
    
    response += "Button: " + read_button() +"\n"
    response += "<br/><br/>\n"
    response += "<input type='button' onClick='changed()' value=' LED '/>\n"
    response += "</body></html>\n"
    return response
    
run(host=host, port=80)

Run it:
$ sudo python webled.py



Related:
- Web control to display on Pi connected LCD Module, with Python and bottle

Python RPi.GPIO: Read Button using GPIO.add_event_detect() with callback

The example show how to detect events of GPIO, to detect button pressed/released. It have the same operation in the post "Python RPi.GPIO: Button and LED".



import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
# pin 17 as input with pull-up resistor
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# pin 18 as output
GPIO.setup(18, GPIO.OUT)

def ButtonCallback(channel):
    if (GPIO.input(17)):
        GPIO.output(18, False)
    else:
        GPIO.output(18, True)
    
GPIO.add_event_detect(17, GPIO.BOTH, callback=ButtonCallback);

while(True):
    #do nothing
    time.sleep(1)

Friday, September 12, 2014

Learn about physical computing with Raspberry Pi

New Raspbian (and NOOBS) available

New release (2014-09-09) of Raspbian, and also New Out Of the Box Software (NOOBS), available.

  • New firmware with various fixes and improvements
  • Minecraft Pi pre-installed
  • Sonic Pi upgraded to 2.0
  • Include Epiphany browser work from Collabora
  • Switch to Java 8 from Java 7
  • Updated Mathematica
  • Misc minor configuration changes

Download: http://www.raspberrypi.org/downloads/


Python RPi.GPIO: Button and LED

This example read button input from pin 17 (set as input with pull-up resister) and set output to pin 18 to turn ON/OFF LED accordingly.



The code GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP) set pin 17 as input with pull-up resistor. If you omit the option pull_up_down=GPIO.PUD_UP, the pin will have no pull-up resistor, and become un-stable.

led.py
import RPi.GPIO as GPIO


GPIO.setmode(GPIO.BCM)
# pin 17 as input with pull-up resistor
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# pin 18 as output
GPIO.setup(18, GPIO.OUT)

while(True):
 if (GPIO.input(17)):
  GPIO.output(18, False)
 else:
  GPIO.output(18, True)


Next:
Read Button using GPIO.add_event_detect() with callback

Wednesday, September 10, 2014

Raspberry Pi Python exercise: Change GPIO LED brightness with GPIO.PWM

Example of Python on Raspberry Pi, to change GPIO LED brightness with GPIO.PWM.



led.py
import RPi.GPIO as GPIO
import time

led_pin = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(led_pin, GPIO.OUT)

#frequency 500 Hz
led_pwm = GPIO.PWM(led_pin, 500)
#duty cycle = 100
led_pwm.start(100)

while(True):
    led_pwm.ChangeDutyCycle(100)
    time.sleep(1)
    led_pwm.ChangeDutyCycle(80)
    time.sleep(1)
    led_pwm.ChangeDutyCycle(60)
    time.sleep(1)
    led_pwm.ChangeDutyCycle(40)
    time.sleep(1)
    led_pwm.ChangeDutyCycle(20)
    time.sleep(1)
    led_pwm.ChangeDutyCycle(0)
    time.sleep(1)


Connection, check lst post of "Toggle LED on GPIO".

Raspberry Pi Python exercise: Toggle LED on GPIO

Python example run on Raspberry Pi, to toggle GPIO pin for LED.

connection:

Example code, led.py:
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)

while(True):
    GPIO.output(18, True)
    time.sleep(1.5)
    GPIO.output(18, False)
    time.sleep(0.5)


Run it with sudo:
$ sudo python led.py

Next:
Change GPIO LED brightness with GPIO.PWM

Saturday, September 6, 2014

java-google-translate-text-to-speech, unofficial API for Google Translate in Java.

java-google-translate-text-to-speech is API unofficial with the main features of Google Translate in Java. I will add text-to-speech (tts) function in my next Yahoo Weather exercise.

This video show how to download jars, and add library to Netbeans Java project.

Install espeak, Text to Speech (Speech Synthesis), on Raspberry Pi

eSpeak is a compact open source software speech synthesizer for English and other languages, for Linux and Windows.   http://espeak.sourceforge.net.

To install espeak on Raspberry Pi, enter the command:
sudo apt-get install espeak

To test:
$ espeak hello




Play mp3 on Raspberry Pi

To play mp3 on Raspberry Pi, using omxplayer command:

example:
$ omxplayer HelloWorld.mp3


scp, easiest way to copy file from Linux PC to Raspberry Pi

Example:

$ scp HelloWorld.mp3 pi@192.168.1.105:~/


Friday, September 5, 2014

Download and add Apache HttpComponents jar to Netbeans Project

In the coming post, I have to use Apache HttpComponents jar in my code. The Apache HttpComponents™ project is responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols.

It can be download here: http://hc.apache.org/.

This video show how to download and add the Apache HttpComponents jar to your project in Netbeans.

Thursday, September 4, 2014

Epiphany browser for Raspberry Pi released

Epiphany released, it is a improved web browser for Raspberry Pi. To install on Raspberry Pi, enter the command in Terminal:

$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install epiphany-browser



Source:
http://www.raspberrypi.org/web-browser-released/

Wednesday, September 3, 2014

Java serial communication with Arduino Uno with jSSC, on Raspberry Pi

jSSC (Java Simple Serial Connector) - library for working with serial ports from Java. jSSC support Win32(Win98-Win8), Win64, Linux(x86, x86-64, ARM), Solaris(x86, x86-64), Mac OS X 10.5 and higher(x86, x86-64, PPC, PPC64).

This post show a Java program run on Raspberry Pi, using jSSC library, to send message to USB connected Arduino Uno board.


The development platform is a PC running Ubuntu with Netbeans 8, and deploy the program to Raspberry Pi remotely.

- To add jSSC library to our Netbeans Java project, read the post "Install and test java-simple-serial-connector with Arduino".

- The program code is almost same as the code on the page. With 3 seconds delay after serialPort.openPort(), to wait Automatic (Software) Reset on Arduino Uno board.
package java_jssc_uno;

import java.util.logging.Level;
import java.util.logging.Logger;
import jssc.SerialPort;
import jssc.SerialPortException;

public class Java_jSSC_Uno {

    public static void main(String[] args) {
        SerialPort serialPort = new SerialPort("/dev/ttyACM0");
        try {
            System.out.println("Port opened: " + serialPort.openPort());

            try {
                Thread.sleep(3000);
            } catch (InterruptedException ex) {
                Logger.getLogger(Java_jSSC_Uno.class.getName()).log(Level.SEVERE, null, ex);
            }
            
            System.out.println("Params setted: " + serialPort.setParams(9600, 8, 1, 0));
            System.out.println("\"Hello World!!!\" successfully writen to port: " + serialPort.writeBytes("Java_jSSC_Uno".getBytes()));
            System.out.println("Port closed: " + serialPort.closePort());
        }
        catch (SerialPortException ex){
            System.out.println(ex);
        }
    }
    
}

- To deploy to Raspberry Pi remotely with Netbeans 8, refer to the post "Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi".


For the sketch (and extra info) on Arduino Uno, read the post in my Arduino blog.


Node.js Chat Server on RPi, send msg to Arduino Uno, display on LCD Module

This example combine the last post of "Node.js Chat application using socket.io, run on Raspberry Pi", and "Node.js send string to Arduino Uno" in my another blog for Arduino. To create a Chat server, and send the received messages to USB connected Arduino Uno board, then display on the equipped 2x16 LCD Module on Arduino.


In order to use serialport in Node.js to send message to serial port, enter the command on Raspberry Pi command line to install serialport.
$ npm install serialport

Modify index.js in last post to add handles for serialport.
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort('/dev/ttyACM0', 
    {   baudrate: 9600
    });
    
serialPort.on("open", function () {
    console.log('open');
});

app.get('/', function(req, res){
  res.sendfile('index.html');
});

io.on('connection', function(socket){
  socket.on('chat message', function(msg){
    io.emit('chat message', msg);
    
    serialPort.write(msg, function(err, results) {
            console.log('err ' + err);
            console.log('results ' + results);
        });
    
  });
});

http.listen(3000, function(){
  console.log('listening on *:3000');
});

For the sketch on Arduino Uno, refer to the post "Read from Arduino Serial port, and write to 2x16 LCD".

Node.js Chat application using socket.io, run on Raspberry Pi

The tutorial Get Started: Chat application describe how to create a basic chat application on Node.js using socket.io.

This video show how I following the tutorial to do the job on Raspberry Pi:

The next post show how to send the received messages to USB connected Arduino Uno using serialport, and display on LCD Module.


Tuesday, September 2, 2014

Web base, remotely visual programming Raspberry Pi/Galileo with Wyliodrin

You can program your embedded devices using a browser on any computer.

Here is a short tutorial on how to program the Raspberry Pi with the new visual interface from Wyliodrin.


https://www.wyliodrin.com/

Tuesday, August 26, 2014

Arduino IDE on Raspberry Pi

Updated@2019-02-19:
Please check the updated post: Install Arduino IDE 1.8.8 on Raspberry Pi/Raspbian Stretch release 2018-11-13.

To install Arduino IDE on Raspberry Pi, enter the command:

$ sudo apt-get install arduino

After installed, run it with command:

$ arduino

This video show how to, and also show how Raspberry Pi connected Arduino Uno run.



Cross post with Arduino-er.

Shell script to check Raspberry Pi temperature

The following command print the Raspberry Pi CPU temperature:

$ cat /sys/class/thermal/thermal_zone0/temp

Shell script, chktemp.sh, with the following content print the CPU temperature:

temp=$(cat /sys/class/thermal/thermal_zone0/temp)
echo CPU Temp.= $(($temp/1000)) C

To make it executable:

$ sudo chmod +x chktemp.sh

Run it:

$ ./chktemp.sh

Shell script to check Raspberry Pi CPU frequency

The following command show the CPU current frequency:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Create a shell script, chkspeed.sh, with content:

cur_freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
echo Current CPU Freq.= $(($cur_freq/1000)) "(Mhz)"

To make it executable:

$ sudo chmod +x chkspeed.sh

Run it:

$ ./chkspeed.sh

Make shell script executable

To make shell scripts executable, enter the command:

sudo chmod +x <your shell script>


Monday, August 25, 2014

How much current Raspberry Pi draw

Shown in the video is a low cost USB Voltage Current Multimeter, it show the voltage and current at USB port alternatively. Maybe it's not a professional equipment, I can use it to monitor monitor and estimate power consumption on my RPi.

In order to eliminate the extra power draw by accessories, the Raspberry Pi connect USB power cable and network cable only, for sure with SD Card also.

Sunday, August 10, 2014

Cross compile Java/Swing program for Raspberry Pi, with Netbeans 8

This video show how to cross compile Java/Swing program for Raspberry Pi, on PC running Netbeans.



Currently, I cannot remote run the Java/Swing program on Raspberry Pi within Netbeans IDE, caused by "No X11 DISPLAY variable was set, but this program performed an operation which requires it". But it can create the runnable jar in Raspberry Pi. You can login Raspberry Pi and run the jar locally.

You need to:
Install JDK 8 on Raspberry Pi
Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi
- and know how to Run/Build JavaFX application on Raspberry Pi remotely from Netbeans 8

Code of this example:
package helloworldswing;

import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class HelloWorldSwing {

    private static void createAndShowGUI() {

        JFrame frame = new JFrame("Hello Swing@Raspberry Pi");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setPreferredSize(new Dimension(400, 300));

        JLabel label = new JLabel();
        label.setText(
            "Hello: " 
            + System.getProperty("os.arch") + "/"
            + System.getProperty("os.name"));
        
        frame.getContentPane().add(label);

        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
    
}



Updated@2015-12-06: Solution of "No X11 DISPLAY variable was set, but this program performed an operation which requires it":

Refer to karczas' comment in YouTube video, The solution of 0:50 error (No X11 DISPLAY variable was set, but this program performed an operation which requires it) which will allow you to run and debug GUI application directly from NetBeans and display their content on your RaspPi (or BeagleBone Black): 
https://mkarczewski.wordpress.com/2015/12/05/netbeans-remote-java-arm-debugging-with-gui



Remote debug Java program on Raspberry Pi using Netbeans 8

With JDK 8 installed on Raspberry Pi, and Set up Java SE 8 Remote Platform on Netbeans 8, you can Run JavaFX application on Raspberry Pi remotely from Netbeans 8, and also debug Java/JavaFX program running on Raspberry Pi remotely on PC with Netbeans 8.

This video show how to debug the last example "Java/JavaFX Client run on Raspberry Pi, link with Android Server" remotely with Netbeans 8.

Java/JavaFX Client run on Raspberry Pi, link with Android Server

It's the Java/JavaFX version of Android client run on Raspberry Pi (via Netbeans 8 Remote Platform), to link with Android Server.

In the video, the VLC Media Player display is the Raspberry Pi RCA video captured with USB Video Adapter.

The program code can be found here:
Java/JavaFX version of Android client
- Android Server

To know how to:
Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi
Run JavaFX application on Raspberry Pi remotely from Netbeans 8


Wednesday, August 6, 2014

Try demo of Java SE 8 for ARM on Raspberry Pi

After Install JDK 8 on Raspberry Pi, you can try the Java SE Development Kit 8 Update 6 Demos and Samples for ARM on Raspberry Pi.

JDK 8 for ARM Downloads (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-arm-downloads-2187472.html) provide download of Java SE Development Kit 8 Update 6 Demos and Samples for ARM.

The video below show the demo of Java2Demo run on Raspberry Pi.
  • This Java2D demo consists of a set of demos housed in one GUI framework that uses a JTabbedPane.  You can access different groups of demos by clicking the tabs at the top of the pane. There are demo groups for Arcs_Curves, Clipping, Colors, Composite, Fonts, Images, Lines, Mix, Paint, Paths and Transforms.  On the right-hand side of the pane, the GUI framework features individual and global controls for changing graphics attributes. There's also a memory-usage monitor, and a monitor for tracking the performance, in frames per second, of animation demos.

Download and unpack the Java SE Development Kit 8 Update 6 Demos and Samples for ARM, copy file /demo/jfc/Java2D/Java2Demo.jar to Raspberry Pi, run the command on Raspberry Pi in Terminal (under X-window environment).

java -jar Java2Demo.jar

Direct run on Raspberry Pi, output to HDMI:

Monday, August 4, 2014

VLC Media Player on Linux to capture Raspberry Pi RCA video output

The post "Capture Raspberry Pi RCA video output with USB Video Adapter" show how to run on Windows. On Linux platform, we can do the same thing to capture video from Easy CAPture USB Video Adapter with VLC Media Player.

Install and install VLC Media Player on Ubuntu, search vlc in Ubuntu Software Center.


Start VLC media player (Sound & Video -> VLC media player)

Media -> Open Capture Device...

- Select Video camera in Capture mode.
- Try select Video and Audio device name.
- Select NTSC in Video standard.
- Play.



Sunday, August 3, 2014

Run JavaFX application on Raspberry Pi remotely from Netbeans 8

With Remote Platform set up on Netbeans 8, we can also develop JavaFX application on host computer running Netbeans, run the application remotely on Raspberry Pi. In case of Java FX application running on Raspberry Pi, it will display on Raspberry Pi monitor, instead of console.

Set up Java SE 8 Remote Platform on Netbeans 8 for Raspberry Pi

With Netbeans 8 installed on host computer and Java SE 8 on Raspberry Pi, we can set up remote platform on Netbeans 8. Such that we can develop Java application using Netbeans on host and deploy on Raspberry Pi remotely, all within Netbeans IDE.

It's assumed Java SE 8 have been installed on your Raspberry Pi as in last post "Install JDK 8 on Raspberry Pi and set JAVA_HOME and PATH".

In host PC (Ubuntu in my case) start Netbeans 8.

Click Tools -> Java Platforms

Click Add Platform...


Select Remote Java Standard Edition and click Next >


Name your new Remote Platform, and enter other information:
- 192.168.1.104 is the IP address of your remote Raspberry Pi.
- pi, the user in Raspberry Pi, and also enter password.
- /opt/jdk1.8.0_06 in Remote JRE Path is the JDK 8 installed location on Raspberry Pi, in last post.

(Updated@2014-09-17) for New Raspbian (2014-09-09) come with Java 8, set Remote JRE Path to default location /usr. ~ Setup Netbeans Remote Platform for default Java 8 in new Raspbian

Then finish.



This video show the steps:


Deploy Java application on Raspberry Pi remotely from Netbeans 8

Create Java Application in Netbeans as normal case. To Run it using the Remote Platform (created in previous steps):

Right click on Project -> Propertiers.

Select Run tab. Select the new created Remote Platform in Runtime Platform, and name the new Configuration.


Then you can run the application on remote Raspberry Pi by running it in this new configuration.



Once Remote Platform setup in your Netbeans IDE, you can also
development JavaFX application on Nerbeans 8, and run it remotely on Raspberry Pi
- remote debug Java program on Raspberry Pi
Cross compile Java/Swing program for Raspberry Pi



Install JDK 8 on Raspberry Pi and set JAVA_HOME and PATH


Updated@2015-03-24:
The new Raspbian come with java 1.8.0 with path set, but no JAVA_HOME.
If you need set JAVA_HOME for the preload java in new Raspbian, refer to my updated post "Set JAVA_HOME for Raspbian pre-loaded java 1.8.0".



This post show how to download JDK 8 on a host computer running Ubuntu Linux (not on Raspberry Pi), then copy to Raspberry Pi, ssh to Pi to setup JDK 8 and set JAVA_HOME and PATH in .bashrc.



To download JDK 8 on a host computer, visit: http://www.oracle.com/technetwork/java/javase/downloads/index.html, follow the steps to download Java SE Development Kit (JDK) for ARM.

In the following steps,
  • jdk-8u6-linux-arm-vfp-hflt.tar.gz is the downloaded file
  • 192.168.1.104 is the IP address of Raspberry Pi
  • pi is the user in Raspberry Pi
Open Terminal, switch to the download folder.

Run the command to copy the downloaded file to Raspberry Pi:
$ scp jdk-8u6-linux-arm-vfp-hflt.tar.gz pi@192.168.1.104:

Log-in Raspberry Pi via ssh:
$ ssh -X 192.168.1.104 -l pi
(-X is option)

Un-pack the file to /opt
$ sudo tar -zxvf jdk-8u6-linux-arm-vfp-hflt.tar.gz -C /opt

Edit .bashrc, to set JAVA_HOME and PATH:
$ nano .bashrc

Add the two line
export JAVA_HOME=/opt/jdk1.8.0_06
export PATH=$JAVA_HOME/bin:$PATH

where /opt/jdk1.8.0_06 is the unpacked folder of the new JDK.

Finally reboot Raspberry Pi.



Related:
- Try demo of Java SE 8 for ARM on Raspberry Pi

Saturday, August 2, 2014

The MagPi magazine issue 26 released, with introduction of The Model B+

This month’s MagPi contains another great selection of hardware, software and programming articles. Michael Giles explains how to turn your Raspberry Pi into a magic wand with a fun hardware project that demonstrates the persistence of vision effect, while John Mahorney from Suncoast Science Center in Florida shows how a Raspberry Pi is used to display dynamic art. Big news this month is the launch of the Model B+ and MagPi writer Aaron Shaw has all the details for you on page 22.

Robotics is always a popular theme and Harry Gee continues on from last month’s article and shows how to add speech, voice control and facial recognition to your robot. Additionally, Rishi Deshpande describes how to use the SmartDrive controller board to easily control high current motors.

Another popular topic is beer and Sebastian Duell explains his hardware and software “Mashberry” project which he uses to optimise the mashing process. Karl-Ludwig Butte continues his series on using a Raspberry Pi and BitScope for electronic measurement plus we have an interesting article by Walberto Abad on how to set up your own VoIP telephone system.

Last, but definitely not least, Jon Silvera continues his series on learning how to program with FUZE BASIC. This is an exciting article with lots to discover. I certainly don’t remember ever being able to control sprites this easily with BASIC!

Visit: http://www.themagpi.com/issue/issue-26/

Friday, August 1, 2014

Java 8 and Embedded JavaFX

Presentation on using the new embedded features in Java 8, including JavaFX on devices like the Raspberry Pi and Lego Mindstorms EV3. Also covers JavaFX on tablets and smartphones.

Friday, July 25, 2014

Introducing the Catapults

Catapults are centres of technology and innovation where the best engineers, researchers and businesses work side by side to help accelerate the journey of new products and services to the market. There are seven Catapults which focus on high value manufacturing, offshore renewable energy, cell therapy, connected digital economy, transport systems, future cities and satellite applications.

The Catapult centres are being established by the Technology Strategy Board

Find out about the work of the Catapults in this video. For further information on this programme access https://www.catapult.org.uk/ or https://www.innovateuk.org/-/catapult-centres.

Introduce Quantum Computing, by Microsoft

An introduction to the mind-bending world of quantum computing.

Learn how Microsoft is blending quantum physics with computer science at http://www.microsoft.com/StationQ.

Saturday, July 19, 2014

Allwinner A80T's Solution Development Cycle

This video shows the progression of 5 PCBA designs throughout Allwinner A80T's solution development cycle:
  1. Initial dev board: a fully-expandable performance evaluation board used for early-stage driver development and IC performance optimization.
  2. A80 OptimusBoard: a small-size development board used for non-tablet application SDK development.
  3. Tablet form factor reference board: a development platform used primarily for Android porting optimization, early-stage reliability testing, and solution reference design.
  4. Customer tablet boards: a mass-production tablet designed by customer based on Allwinner reference design.
  5. CubieBoard 8: a development board designed by customer based on Allwinner reference design.
Allwinner A80T's Solution Development Cycle


Wednesday, July 16, 2014

Node.js to read Raspberry Pi temperature

Last post show that we can get Raspberry Pi temperature via /sys/class/thermal/thermal_zone0/temp. This example show how to read it in Node.js.




var http = require("http");
var fs =  require("fs");

var server = http.createServer(function(request, response) {
    
    var temp = fs.readFileSync("/sys/class/thermal/thermal_zone0/temp");
    var temp_c = temp/1000;
    
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write("Raspberry Pi cpu temperature: ");
    response.write("\n" + temp);
    response.write("\n" + temp_c);
    response.end();
});
server.listen(8080);


Read Raspberry Pi CPU temperature

In Raspbian, the file /sys/class/thermal/thermal_zone0/temp keep the CPU temperature, in 1000 (C degree). We can read Raspberry Pi CPU temperature with the command:

$ cat /sys/class/thermal/thermal_zone0/temp


Tuesday, July 15, 2014

List installed package with dpkg

Enter the dpkg command with -l option to list installed packabe:

$ dpkg -l


/etc/apt/sources.list, packages sources

As part of its operation, Apt uses a file that lists the 'sources' from which packages can be obtained. This file is /etc/apt/sources.list.

Source and details: https://wiki.debian.org/SourcesList

Monday, July 14, 2014

Setting up Raspberry Pi Model B+



Raspberry Pi Model B+ (B Plus) 512MB

Raspberry Pi Model B+ (B Plus) 512MB

The latest edition to the Raspberry Pi family - The Raspberry Pi B+ (B Plus) brings some much anticipated additions to the original Raspberry Pi Model B


Technical Specification:
• 700MHz Broadcom BCM2835 CPU with 512MB RAM
• 40pin extended GPIO
• 4 x USB 2 ports
• 4 pole Stereo output and Composite video port
• Full size HDMI
• CSI camera port for connecting the Raspberry Pi camera
• DSI display port for connecting the Raspberry Pi touch screen display
• Micro SD port for loading your operating system and storing data
• Micro USB power source

Model B+ Features:
• 40pin extended GPIO to enhance your "real world" projects
• Connect a Raspberry Pi camera and touch screen display (each sole separately)
• Stream and watch Hi-definition video output at 1080P
• Connect more to your Raspberry Pi using the 4 x USB ports

Raspberry Pi Model B+ launched

Raspberry Pi Model B+ launched, immediately available, at $35 – it’s still the same price, of what we’re calling the Raspberry Pi Model B+.



The Model B+ uses the same BCM2835 application processor as the Model B. It runs the same software, and still has 512MB RAM; but James and the team have made the following key improvements:

  • More GPIO. The GPIO header has grown to 40 pins, while retaining the same pinout for the first 26 pins as the Model B.
  • More USB. We now have 4 USB 2.0 ports, compared to 2 on the Model B, and better hotplug and overcurrent behaviour.
  • Micro SD. The old friction-fit SD card socket has been replaced with a much nicer push-push micro SD version.
  • Lower power consumption. By replacing linear regulators with switching ones we’ve reduced power consumption by between 0.5W and 1W.
  • Better audio. The audio circuit incorporates a dedicated low-noise power supply.
  • Neater form factor. We’ve aligned the USB connectors with the board edge, moved composite video onto the 3.5mm jack, and added four squarely-placed mounting holes.


Friday, July 11, 2014

PiFm, turning the Raspberry Pi Into an FM Transmitter

The project PiFm turn the Raspberry Pi Into an FM Transmitter, by switching GPIO to generate FM radio signal at 103.3Mhz (default) without extra hardware.

To install PiFm, download and extract the module from http://omattos.com/pifm.tar.gz.

Run the code to play the wav in Python:
$ sudo python
>>> import PiFm
>>> PiFm.play_sound("sound.wav")



This below video show how it run, tune your FM radio to 103.3Mhz to listen. In this example, no antenna used. The FM signal emit from the pin on Raspberry Pi board. remark: the background noise recorded by camera from environment, not from radio.


To achieve better performance, connect a 20cm or so plain wire to GPIO 4 (which is pin 7 on header P1) to act as an antenna.

Saturday, July 5, 2014

NVIDIA Jetson TK1

Although you might think it's the same as other Arduino based Dev Boards out there, you would be quite surprised to find out that it has a lot more packed inside. Check out the video to find out more.

NVIDIA Jetson TK1 Interview - Newegg TV

NOOBS and Rasobian released 2014-06-20

NOOBS and Rasobian (Debian Wheezy) released at 2014-06-20, this new firmware updated with various fixes, and kernel bugfix.

Visit: http://www.raspberrypi.org/downloads/


Friday, July 4, 2014

Mopidy - music server, support Raspberry Pi

Mopidy is a music server which can play music both from multiple sources, like your local hard drive, radio streams, and from Spotify and SoundCloud. Searches combines results from all music sources, and you can mix tracks from all sources in your play queue. Your playlists from Spotify or SoundCloud are also available for use.

To control your Mopidy music server, you can use one of Mopidy’s web clients, the Ubuntu Sound Menu, any device on the same network which can control UPnP MediaRenderers, or any MPD client. MPD clients are available for many platforms, including Windows, OS X, Linux, Android and iOS.

Mopidy runs nicely on a Raspberry Pi. As of January 2013, Mopidy will run with Spotify support on both the armel (soft-float) and armhf (hard-float) architectures, which includes the Raspbian distribution.

Read Installation on Raspberry Pi.