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