วันพฤหัสบดีที่ 14 พฤศจิกายน พ.ศ. 2556

How to use at command, use bluetooth HC-05

http://robopoly.epfl.ch/files/content/sites/robopoly/files/Tutoriels/bluetooth/hc-05-at_command_set.pdf
http://taktak.co.uk/2013/bluetooth-module-hc-05-bt_board-1-5-configuration/

minicom program
http://pbxbook.com/other/mac-tty.html


*linux use similar way, I think linux can find the way ^^

For Mac os

Use terminal

Connect computer with bluetooth by
USB to Serial TTL
http://yourduino.com/sunshop2/index.php?l=product_detail&p=164
(eg.)

Wiring
USB                Bluetooth
tx                     tx
rx                     rx
3.3v                 key
3.3v                 vcc
gnd                  gnd

* Importent
pin key need to powering before powering the bluetooth.
bluetooth light will slow blink, if not try again.
 Do not cross tx, rx pin.

Necessary program
minicom (this case use version 2.2)
http://pbxbook.com/other/mac-tty.html#minicom
After install set path
sudo vi /private/etc/paths
Add line /opt/minicom/2.2/bin at the end of file.
Restart terminal.

Download Silicon Labs in above link (http://pbxbook.com/other/mac-tty.html)
install 
After install need restart.

Use command
ls /dev/tty.*
Plug usb that wiring bluetooth to computer.

Use command
ls /dev/tty.*
See the add thing.
eg. /dev/tty.*

tty.SLAB_USBtoUART

Use command
minicom -s

Control program by key pad
Go to Serial port setup
Change "Serial Device" type "a" change to "/dev/tty.SLAB_USBtoUART" or your new serial
Change "Bps/Par/Bits" type "e", "g", "l", "q", "w", "v" -> change to 38400 8N1 
Change "Screen and keyboard" type "q" -> Local echo : YES.
Note that in "Screen and keyboard", "Flow Control" must set to No.

Select Save setup as dfl 
Select "exit" to start or "Exit from Minicom" for exit program
If you want program have color your should select "Exit from Minicom"

Use command
minicom -c on
Type AT 
Your will receive OK. 

/***********************************************************/

http://robopoly.epfl.ch/files/content/sites/robopoly/files/Tutoriels/bluetooth/hc-05-at_command_set.pdf
http://taktak.co.uk/2013/bluetooth-module-hc-05-bt_board-1-5-configuration/

minicom program
http://pbxbook.com/other/mac-tty.html


*linux ใช้วิธีคล้ายๆแต่บางคำสั่งไม่เหมือน คนใช้ linux คงหาวิธีได้ ^^

Mac os นะ
ใช้ terminal แทบทั้งหมดในการใช้งาน

ต่อ computer กับ bluetooth ใช้
USB to Serial TTL
http://yourduino.com/sunshop2/index.php?l=product_detail&p=164
(ตัวอย่าง)

วิธีการต่อ
USB                Bluetooth
tx                     tx
rx                     rx
3.3v                 key
3.3v                 vcc
gnd                  gnd

* สำคัญมาก
pin key จำเป็นต้องต่อไฟก่อนที่จะจ่ายพลังให้ bluetooth ไฟ bluetooth จะกระพริบช้า ถ้าไฟกระพริบเร็วให้ลองใหม่ (เร็วต่อ หลายครั้งต่อ 1 วินาที)
 tx, rx ไม่ได้ต่อสลับเหมือนตอนนำไปใช้ปกติ

โปรแกรมที่จำเป็น
minicom (กรณีนี้ใช้ version 2.2)
http://pbxbook.com/other/mac-tty.html#minicom
ติดตั้งแล้ว set path
sudo vi /private/etc/paths
เพิ่มบรรทัด /opt/minicom/2.2/bin เข้าไป
restart terminal

ดาวโหลด Silicon Labs มีใน link ด้านบน http://pbxbook.com/other/mac-tty.html
ลงโปรแกรม
จำเป็นต้อง restart

ใช้คำสั่ง
ls /dev/tty.*
เสียบ usb ที่ต่อกับ bluetooth เข้าคอมพิวเตอร์

ใช้คำสั่ง
ls /dev/tty.*
จะเห็นสิ่งที่เพิ่มเข้ามา 
เช่น /dev/tty.*
สิ่งที่เพิ่มเข้ามา
tty.SLAB_USBtoUART

ใช้คำสั่ง
minicom -s

บังคับโดยใข้ลูกศรได้
เข้าไปที่ Serial port setup
แก้ Serial Device โดย พิมพ์ a เปลี่ยนเป็น /dev/tty.SLAB_USBtoUART หรือ serial ที่เพื่มเข้ามา
แก้ Bps/Par/Bits โดยพิมพ์ e , g, l, q, w, v -> แก้ให้เป็น 38400 8N1 
แก้ Screen and keyboard โดยพิมพ์ q -> Local echo : YES
ดูด้วยว่า Flow Control ต้องถูก set เป็น no

เลือก Save setup as dfl 
จะกด exit เพื่อเริ่มหรือ Exit from Minicom เพื่อออก
ถ้าอยากให้มีสีให้ออกก่อน

ใช้คำสั่ง
minicom -c on
พิมพ์ AT 
จะได้รับ OK กลับมา

วันพุธที่ 13 พฤศจิกายน พ.ศ. 2556

example ntf24l01


vendors claims it work until 100m
He test and get 30m if payload 16
Decrease payload to 8 get 80m

lower payload size = higher range

Wiring nrf24 to arduino and rasberry pi
http://conoroneill.net/arduino-and-raspberry-pi-communicating-over-2-4ghz-with-cheap-nrf24l01-modules/

code rf24 and example C++ and C (arduino)
https://github.com/stanleyseow/RF24

install (must enable spi)
http://arduino-for-beginners.blogspot.com/2013/02/setup-nordic-nrf24l01-rf-modules-to.html?goback=%2Egde_1268377_member_217339050#%21
http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/

how to enable spi
http://allfakeplus.blogspot.com/2013/11/raspberry-pi-enable-spi.html

In example code shoud config pin before run;
Find this line
RF24 radio(8,9); -> (CE, CSN)
CE pin 8
CSN pin 9
CE is Module Pin 3
CSN is Module Pin 4

git clone https://github.com/stanleyseow/RF24.git

It's ok to leave lcd variable in example code (It's not break the code)
outBuffer variable is data that will send

example of ardruno code locate at ./RF24/examples/
eg. ./RF24/examples/nRF24_sendto_hub/

Install in raspberry pi
code เป็นภาษา c++
ต้องเปิดใช้ spi ก่อนนะ

You must install git first

git clone https://github.com/stanleyseow/RF24.git (like above)
cd RF24/ibrf24-rpi/librf24
make
sudo make install
cd ../examples/
make

Now we get example code
 ls for see all program
 run programs
 sudo ./[name]

 eg.
 sudo ./rpi-hub


If log show RX_ADDR_P0-a is all 0 You should check your wiring again

/*********************************************************/

ระยะประมาณ 100m ตามคู่มือ
ไป test มาบอกว่าได้ 30 เมตรถ้า payload 16
ลด payload เหลือ 8 ได้ 80 เมตร
ชนกำแพงระยะก็ลดลง

lower payload size = higher range

ต่อไฟตามนี้
http://conoroneill.net/arduino-and-raspberry-pi-communicating-over-2-4ghz-with-cheap-nrf24l01-modules/

code rf24 and example
https://github.com/stanleyseow/RF24

install (ต้องลงเปิดใช้ spi ก่อน)
http://arduino-for-beginners.blogspot.com/2013/02/setup-nordic-nrf24l01-rf-modules-to.html?goback=%2Egde_1268377_member_217339050#%21
http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/

วิธีการเปิดใช้ spi
http://allfakeplus.blogspot.com/2013/11/raspberry-pi-enable-spi.html

ใน code ตัวอย่างจะเจอ config pin จะไม่เหมือนกัน
เช่น
RF24 radio(8,9); -> (CE, CSN)
CE pin 8
CSN pin 9

Led ไม่มีก็ไม่เป็นไร code ไม่พัง
ตัวแปร outBuffer คือข้อมูลที่จะส่ง

ตัวอย่าง ardruno อยู่ที่ ./RF24/examples/
เช่น ./RF24/examples/nRF24_sendto_hub/

วิธีการลงของ raspberry pi
code เป็นภาษา c++
ต้องเปิดใช้ spi ก่อนนะ

ลง git ก่อนนะ

git clone https://github.com/stanleyseow/RF24.git
cd RF24/ibrf24-rpi/librf24
make
sudo make install
cd ../examples/
make

จะได้โปรแกรมตัวอย่างมา
 ls เพื่อดูว่ามีตัวอย่างอะไรบ้าง
 run programs
 sudo ./[name]

 เช่น
 sudo ./rpi-hub

 ถ้า log ขึ้น RX_ADDR_P0-a เป็น 0 ทั้งหมด ให้ตรวจสอบสายที่ต่ออีกรอบ

วันพฤหัสบดีที่ 7 พฤศจิกายน พ.ศ. 2556

raspberry pi enable spi

http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c
http://louisthiery.com/spi-python-hardware-spi-for-raspi/

Download
http://www.raspberrypi.org/downloads
install raspberry pi
http://elinux.org/RPi_Easy_SD_Card_Setup

add
  1. i2c-bcm2708 
  2. i2c-dev

  3. in file /etc/modules (use sudo)
  4. sudo vi /etc/modules

install tools
  1. sudo apt-get install python-smbus
  2. sudo apt-get install i2c-tools

close blacklist

add # in front of
i2c-bcm2708
spi-bcm2708
in file /etc/modprobe.d/raspi-blacklist.conf (use sudo)
  1. sudo vi /etc/modprobe.d/raspi-blacklist.conf

restart
sudo init 6

you will see spidev0.0 spidev0.1 i2c-0 i2c-1 in /dev/
ls /dev