제이펍의 '라즈베리파이 시작하기' 라는 책에 라즈베리파이로 아두이노 구동을 위한 내용이 잘 정리 되어 있습니다.


책의 내용을 다 옮기긴 어렵겠지만 기본적인 것에 대해 말씀드려볼까 합니다.

저는 처음에 둘을 연결하려면 뭔가 선을 따줘야 할거라고 생각했습니다.

물론 제대로 된 통신을 하려면 SPI통신을 이용해야할 거라고 생각합니다.(아직 해보진 않았습니다만..)

하지만, 책을 보니 그냥 시리얼 통신을 이용했더군요.

게다가 시리얼 통신을 위해서 점퍼선을 연결할 필요도 없습니다.

그냥 USB케이블 하나를 연결하면 됩니다.



저는 귀찮아서 샤오미 배터리를 전원으로 쓰고 usb wifi동글로 무선 연결을 해두고 맥북에서 원격 접속으로 작업을 합니다.

여튼 이렇게 선 하나만 연결합니다.



sudo apt-get install arduino 

arduino IDE를 다운 받습니다.

마지막으로 IDE에 uart 출력을 c로 코딩합니다.

-> 버튼을 누르면 알아서 컴파일이 되고 아두이노로 다운로드하고 실행이 됩니다.


라즈베리파이에서 serial 입력을 받아 print하는 코드를 python으로 짭니다.

그리고 실행하면 위의 사진 처럼 아두이노가 보내는 데이터를 출력해줍니다.


간단하네요 ㅋㅋ


자세한 내용은 책을 참조하시거나 인터넷을 뒤져 보시길..


Posted by 공놀이나하여보세
,

출처 : http://www.rasplay.org/?p=5996

아래 파일을 수정하면 끝

sudo nano /etc/network/interfaces

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0

iface wlan0 inet dhcp
wpa-ssid “ssid”
wpa-psk “password”

Posted by 공놀이나하여보세
,

출처 : http://hilpisch.com/rpi/02_data_analytics.html


sudo apt-get install python-pip python-dev build-essential
sudo pip install numpy --upgrade
sudo pip install pandas
sudo easy_install -U distribute
sudo apt-get install libpng-dev libjpeg8-dev libfreetype6-dev
sudo pip install matplotlib
sudo pip install numexpr
sudo pip install cython
sudo apt-get install libhdf5-serial-dev
sudo pip install tables


Posted by 공놀이나하여보세
,

7.GUI

(1) hello world

from Tkinter import *

root = Tk()

Label(root, text='Hello World').pack()

root.mainloop()


Tkinter인데 tkinter로 했다가 고생함


(2) 온도 변환기


Posted by 공놀이나하여보세
,

아래 블로그 참고

http://blog.bitify.co.uk/2013/11/interfacing-raspberry-pi-and-mpu-6050.html


1. sudo raspi-config 를 통해 i2c enable 설정



2. sudo vi /etc/modules 

아래 두 줄 추가 후 재부팅

i2c-bcm2708
i2c-dev



3. 하드웨어 선 연결

라즈베리파이의 pin1, 3, 5, 6을 센서의 VCC, SDA, SCL, GND에 아래와 같이 연결

  • Pin 1 - 3.3V connect to VCC
  • Pin 3 - SDA connect to SDA
  • Pin 5 - SCL connect to SCL
  • Pin 6 - Ground connect to GND

4. 테스트를 위한 파일 다운 및 테스트
sudo apt-get install i2c-tools

- 테스트

sudo i2cdetect -y 0 (라즈베리파이1버전) or
sudo i2cdetect -y 1 (라즈베리파이2)
- 아래와 같이 나오는 것 확인
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


5. 파이썬으로 i2c접근을 위해 아래 파일 다운로드

sudo apt-get install python-smbus 


6. 소스 코드

mpu6050.py로 아래 파일 저장


#!/usr/bin/python

import smbus

import math


# Power management registers


power_mgmt_1 = 0x6b


power_mgmt_2 = 0x6c

def read_byte(adr):

    return bus.read_byte_data(address, adr)

def read_word(adr):

    high = bus.read_byte_data(address, adr)

    low = bus.read_byte_data(address, adr+1)

    val = (high << 8) + low

    return val


def read_word_2c(adr):

    val = read_word(adr)

    if (val >= 0x8000):

        return -((65535 - val) + 1)

    else:

        return val


def dist(a,b):

    return math.sqrt((a*a)+(b*b))


def get_y_rotation(x,y,z):

    radians = math.atan2(x, dist(y,z))

    return -math.degrees(radians)


def get_x_rotation(x,y,z):

    radians = math.atan2(y, dist(x,z))

    return math.degrees(radians)


bus = smbus.SMBus(0) # or bus = smbus.SMBus(1) for Revision 2 boards

address = 0x68       # This is the address value read via the i2cdetect command


# Now wake the 6050 up as it starts in sleep mode

bus.write_byte_data(address, power_mgmt_1, 0)

print "gyro data"

print "---------"

gyro_xout = read_word_2c(0x43)

gyro_yout = read_word_2c(0x45)

gyro_zout = read_word_2c(0x47)

print "gyro_xout: ", gyro_xout, " scaled: ", (gyro_xout / 131)

print "gyro_yout: ", gyro_yout, " scaled: ", (gyro_yout / 131)

print "gyro_zout: ", gyro_zout, " scaled: ", (gyro_zout / 131)

 

print

print "accelerometer data"

print "------------------"

 

accel_xout = read_word_2c(0x3b)

accel_yout = read_word_2c(0x3d)

accel_zout = read_word_2c(0x3f)


accel_xout_scaled = accel_xout / 16384.0

accel_yout_scaled = accel_yout / 16384.0


accel_zout_scaled = accel_zout / 16384.0

print "accel_xout: ", accel_xout, " scaled: ", accel_xout_scaled

print "accel_yout: ", accel_yout, " scaled: ", accel_yout_scaled

print "accel_zout: ", accel_zout, " scaled: ", accel_zout_scaled

print "x rotation: " , get_x_rotation(accel_xout_scaled, accel_yout_scaled, accel_zout_scaled)

print "y rotation: " , get_y_rotation(accel_xout_scaled, accel_yout_scaled, accel_zout_scaled)


7. 테스트
python mpu6050.py



Posted by 공놀이나하여보세
,

아래 사이트 7page


http://www.slideshare.net/MoamBae/raspberry-pi-35150708

Posted by 공놀이나하여보세
,


1. Anaconda 설치 방법

http://continuum.io/blog/raspberry


아래 명령어로 몇 개 인스톨

$ wget http://repo.continuum.io/miniconda/Miniconda-3.5.5-Linux-armv6l.sh
$ md5sum Miniconda-3.5.5-Linux-armv6l.sh
2f37cb775ec3e482280a7bd6b97ee501
$ /bin/bash Miniconda-3.5.5-Linux-armv6l.sh

PATH environment variable 설정이 되면 cmd를 껐다가 다시 켠다.


이용 가능한게 뭔지 우선 체크한 후 conda를 이용해 추가 packages 인스톨을 한다.

$ conda search 48 matches found compatible with environment /home/pi/anaconda: Packages with available versions and build strings: bitarray 0.8.0 py27_0 bsdiff4 1.1.3 py27_0 conda 1.5.0 py27_0 cubes 0.10.2 py27_0 cython 0.18 py27_0 distribute 0.6.34 py27_1 docutils 0.10 py27_0 ...

bitarray 를 설치한다.

$ conda install bitarray
...
$ python
Python 2.7.3 |Continuum Analytics, Inc.| (default, Mar 21 2013, 01:11:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bitarray
>>> bitarray.test()
installed in: /home/pi/anaconda/lib/python2.7/site-packages/bitarray
bitarray version: 0.8.0
2.7.3 |Continuum Analytics, Inc.| (default, Mar 21 2013, 01:11:54)
[GCC 4.6.3]
......................................................................
...........................................................
----------------------------------------------------------------------
Ran 129 tests in 56.350s

OK
<unittest.runner.TextTestResult run=129 errors=0 failures=0>
>>>

Running the bitarray unittest on a regular machine only takes about a second or two.


2. IPython 설치 방법(python2 기준)

http://www.raspberrypi.org/documentation/usage/python/more.md

sudo apt-get install ipython
sudo apt-get install python-pip
sudo pip install simplejson


3. ipython notebook 설치 방법

- 라즈베라파이 B에서는 좀 느리네요. 라즈베리파이2 구매 예정인데 다시 시도해봐야겠습니다. ㅠㅠ

- 라즈베리파이2에서는 쓸만하네요~ 웹브라우징 빼고 쓸만합니다.

https://arundurvasula.wordpress.com/2014/04/01/remote-ipython-notebook-with-raspberry-pi/

sudo apt-get -y install ipython-notebook
sudo apt-get -y install python-matplotlib python-scipy \
                 python-pandas python-sympy python-nose


Posted by 공놀이나하여보세
,

주의 : 8기가짜리 SD카드를 쓰고 있는데 라즈비안OS외에 XBMC니 뭐니 설치 했더니 용량이 300메가가 남아서 포맷 후 다시 설치 중입니다.

파이썬 개발하실 분은 일단은 라즈비안만 설치하세요.


1. boobs.zip 파일 다운로드

http://www.raspberrypi.org

2. boobs.zip 압축 해제 후 폴더 내 파일을 sd카드로 복사

3. 부팅에서 config파일 수정

http://www.rasplay.org/?p=3786

(1) 한글 설정

en_GB.UTF-8 UTF-8, en_US.UTF-8 UTF-8, ko_kr.UTF-8 UTF-8 세가지 언어를 체크선택 

(2) Time zone설정

asia -> Seoul 설정

(3) 한글 키보드 설정

Generic 105 key (Intl) PC 를 선택 

english(US) 선택

출처 : http://codekin.com/?p=74


맥을 이용한 원격 접속은 아래 주소

다 좋은데 맥을 이용해서 원격접속을 하니 한글 입력이 잘 안되네요 ㅠㅠ

* XRDP 설정법 - 윈도우에서 원격접속하려면 이걸 사용, 맥으로도 CoRD를 깔면 XRDP사용 가능

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install xrdp

출처 : http://cafe.naver.com/openrt/195


맥에 CoRD 설치 주소

http://sourceforge.net/projects/cord/?source=typ_redirect


*tightvncserver로 설정법 - 개인적으로는 XRDP가 더 안정적인 것 같지만 맥에서 접속하려면 어쩔 수 없네요

http://goooodcode.tistory.com/43


고정 ip설정은 아래 주소

http://www.berrycracker.net/archives/512


한글 키보드 설정

아래에서 nabi를 설치하는 것이 더 안정적인 것 같다.

일단 한영키를 먹음

하지만 원격 접속에서는 한글 입력이 잘 안됨 ㅠㅠ


sudo apt-get install nabi

sudo apt-get install im-switch

커맨드 창에서 im-switch 실행 nabi선택

출처 : http://6502.tistory.com/589


한글폰트 설치 필요
$sudo apt-get install ttf-unfonts-core

한글키보드설치
$sudo apt-get install ibus ibus-hangul

http://www.rasplay.org/?p=3786






Posted by 공놀이나하여보세
,


1. 디버거 설정

(1) General Options - Device STM32F10XXG로 설정

(2) Debugger 설정 : RDI로 설정(H-JTAG)

(3) Debugger dll 파일 등록 : c:\program files\H-Jtag\H-Jtag.dll 

(4) Output Convert : Generate additional output 체크, binary로 설정


2. 소스 컴파일

(1) microum에서 uCOS 소스 다운로드

(2) 외부 Crystal에 따른 설정 72Hz로


위 설정만 하면 바로 동작 해야하지만 나의 경우 점퍼 설정을 제대로 해주지 않아 Uart는 동작하지만 task가 생성되지 않는 문제가 발생하였다. 2시간 삽질 끝에 겨우 찾아냄 ㅜㅜ


Posted by 공놀이나하여보세
,