Skip to content
Home » Hm 10 아두 이노 | [Rc Car] Hm-10 통신 34 개의 새로운 답변이 업데이트되었습니다.

Hm 10 아두 이노 | [Rc Car] Hm-10 통신 34 개의 새로운 답변이 업데이트되었습니다.

당신은 주제를 찾고 있습니까 “hm 10 아두 이노 – [RC Car] HM-10 통신“? 다음 카테고리의 웹사이트 sk.taphoamini.com 에서 귀하의 모든 질문에 답변해 드립니다: https://sk.taphoamini.com/wiki/. 바로 아래에서 답을 찾을 수 있습니다. 작성자 MAKIST 이(가) 작성한 기사에는 조회수 2,420회 및 좋아요 15개 개의 좋아요가 있습니다.

hm 10 아두 이노 주제에 대한 동영상 보기

여기에서 이 주제에 대한 비디오를 시청하십시오. 주의 깊게 살펴보고 읽고 있는 내용에 대한 피드백을 제공하세요!

d여기에서 [RC Car] HM-10 통신 – hm 10 아두 이노 주제에 대한 세부정보를 참조하세요

메이키스트 동영상 강의

hm 10 아두 이노 주제에 대한 자세한 내용은 여기를 참조하세요.

아두이노 나노 스마트폰과 HM-10 연동하기 1 – 초기 설정

시리얼 모니터 결과는 아래 씨리얼 모니터 결과 화면을 참고한다. 글 참고 사이트. 1. 아두이노 블루투스 4.0 BLE HM-10 모듈 / Arduino …

+ 여기에 보기

Source: diymaker.tistory.com

Date Published: 7/8/2022

View: 2195

아두이노 블루투스4.0 BLE HM-10 모듈 / HM10 … – 에듀이노

아두이노 전문 교육쇼핑몰 에듀이노, 아두이노보드, 쉴드, 모듈, 키트, 로봇, … 아두이노 블루투스4.0 BLE HM-10 모듈 / HM10 Arduino BLE / 마스터 슬레이브 변경 …

+ 여기에 자세히 보기

Source: eduino.kr

Date Published: 3/1/2022

View: 9494

아두이노로 비콘을 구현해보자!. HM-10블루투스 모듈을 활용한 …

시작하기에 앞서 준비물을 알아야겠죠. 준비물은 다음과 같습니다. 아두이노 (보드 종류는 크게 신경쓰지 않아요!!) HM-10 블루투스 모듈; Arduino IDE …

+ 더 읽기

Source: berkbach.com

Date Published: 8/3/2021

View: 5530

아두이노 HM-10 블루투스 4.0 모듈 : 다나와 가격비교

컴퓨터/노트북/조립PC>PC주요부품>메인보드, 요약정보 : 임베디드 보드.

+ 여기에 자세히 보기

Source: prod.danawa.com

Date Published: 11/19/2021

View: 3911

아두이노에서 HM-10 다루기 – monotics

아두이노 나노와 HM-10으로 LED와 가변저항을 원격 제어해본다. 안드로이드 폰에서 원격으로 LED를 제어한다. (밝기 조절, 켜고 끄기, 깜박임) …

+ 더 읽기

Source: monotics.tistory.com

Date Published: 8/29/2022

View: 276

How to Use HM-10 BLE Module with Arduino to Control an …

The Arduino Bluetooth Controller (HM-10 Module) is an andro application which is available free on Google Play Store. This app is having easy …

+ 여기에 표시

Source: circuitdigest.com

Date Published: 9/1/2021

View: 838

아두이노 블루투스 모듈 사용하기 (HM-10) – Devbin

Arduino bluetooth 아두이노 UNO 보드와 블루투스 모듈 (HM-10 호환)을 사용하여 기초적인 세팅하기 위 그림과 똑같이 세팅할 필요는 없다.

+ 여기에 자세히 보기

Source: devbin.kr

Date Published: 6/3/2021

View: 5291

주제와 관련된 이미지 hm 10 아두 이노

주제와 관련된 더 많은 사진을 참조하십시오 [RC Car] HM-10 통신. 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.

[RC Car] HM-10 통신
[RC Car] HM-10 통신

주제에 대한 기사 평가 hm 10 아두 이노

  • Author: MAKIST
  • Views: 조회수 2,420회
  • Likes: 좋아요 15개
  • Date Published: 2017. 2. 19.
  • Video Url link: https://www.youtube.com/watch?v=zyeJstJdep8

아두이노 나노 스마트폰과 HM-10 연동하기 1 – 초기 설정

반응형

스마트폰과 HM-10 연동하기 1

가장 먼저 할 일이 블루투스 4.0 BLE HM-10 모듈에 대해 아는 일이다.

블루투스 4.0 BLE HM-10 모듈 이미지를 참고하고 자세한 작동법은 데이터북을 참고하거나 잘 설명해 놓은 링크를 참고한다.

HM-10 모듈에 대한 자세한 설명 링크 – [블루투스4.0BLE]HM-10 Module 사용법(AT 커맨드 포함) http://blog.naver.com/xisaturn/220712028679

연결도를 참고한다. 여기서 HM-10의 RX, TX 핀은 소프트웨어 씨리얼을 사용하므로 아두이노의 7번과 8번 핀을 연결한다. 소스코드에 번호가 나오니 참고한다.

코딩 예제 : 아래 코드를 아두이노 스케치에 입력후 업로드 합니다.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 #include < SoftwareSerial.h > #define BT_RX 7 #define BT_TX 8 SoftwareSerial HM10(BT_RX,BT_TX); // RX핀(7번)은 HM10의 TX에 연결 // TX핀(8번)은 HM10의 RX에 연결 void setup() { Serial. begin ( 9600 ); HM10. begin ( 9600 ); } void loop() { if (HM10.available()) { Serial.write(HM10.read()); } if (Serial.available()) { HM10.write(Serial.read()); } }

연결 상태를 확인하고 AT 명령어를 사용하여 HM-10 정보를 확인하고 이름 설정

– ‘코딩 예제’를 아두이노에 업로드까지 마친 후 시리얼 모니터를 띄워 다음과 같은 AT명령어를 입력하면 HM-10과 아두이노가 정상적으로 연결되었는지 확인할 수 있다. 또한 AT명령어로 HM-10의 이름을 변경할 수 있으며, 스마트폰과 페어링 할 때 유용하도록 이름을 변경한다.

AT : 응답가능여부확인

결과 : OK

AT_NAME? 이름 조회하기

결과 : OK+NAME:HMSoft

AT+NAMExxx : 이름 변경

결과 : OK+Set: xxxx

AT+ADDR? : 블루투스 모듈 주소 읽어오기

결과 : OK+ADDR:XXXXXXXXXXXX

비밀번호(pin code) 확인 AT+PASS?

결과: OK+Get:000000

비밀번호(pin code) 설정 AT+PASSxxxxxx

⇒ OK+Set:xxxxxx

[Para] is Pin Code, 000000~999999

Default: 000000

반드시 하나 더 해주어야 한다. 스마트 폰으로 페어링을 하면 등록거절 되는데 이때

“HM-10 모듈에 시리얼로 연결해서 AT+TYPE3” 라고 입력해서 세팅하면 연결 가능해 집니다. 디바이스를 찾아서 페이링 PIN 넘어 초기에 “000000” (0이 6개) 넣어주면 페어링 완료!

AT+TYPE3 전송

결과 : OK+Set:3 —> 이렇게 해도 페어링이 안되거나 스마트폰에서 블루투스 장치에 등록을 해도 앱에서 안보이는 분????

전원을 껏다가 다시 켠다. 리셋 필요.

모듈 Bond 모드 확인/설정

– AT+TYPE? ⇒OK+Get:[para] None – AT+TYPE[para] ⇒OK+Set:[para] [para]: 0~3 0: Not need PIN Code 1: Pair not need PIN 2: Pair with PIN 3: Pair and bond Default: 0

※ 주의 사항 : 시리얼 모니터로 ‘AT’ 를 입력하면 결과값으로 ‘OK’를 리턴 해야 하지만 제조사마다 옵션 설정이 다르기 때문에 이를 설정해주지 않으면 ‘OK’를 리턴받지 못하는 경우도 있다. 따라서 옵션 설정에 유의하여 사용하셔야 합니다. 여기서는 ‘Both NL & CR’로 설정합니다.

시리얼 모니터 결과는 아래 씨리얼 모니터 결과 화면을 참고한다.

글 참고 사이트

1. 아두이노 블루투스 4.0 BLE HM-10 모듈 / Arduino Bluetooth 4.0 BLE Module https://m.blog.naver.com/eduino/220903237343

2. HM-10 블루투스 테스트(2) https://hnydiy.tistory.com/4

3. [블루투스 4.0 Hm-10 cc2541] 아두이노 우노 R3 연결 http://blog.whoborn.net/%EB%B8%94%EB%A3%A8%ED%88%AC%EC%8A%A4-4-0-hm-10-cc2541-%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8-%EC%9A%B0%EB%85%B8-r3-%EC%97%B0%EA%B2%B0/

4. [블루투스4.0BLE]HM-10 Module 사용법(AT 커맨드 포함) http://blog.naver.com/xisaturn/220712028679

참고로 윗 부분의 코드를 아래 소스코드와 같이 수정하여 커스터마이징하여 사용할 수 있도록 수정하여 사용하면 된다. 참고하세요.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 #include < SoftwareSerial.h > /** * RX_PIN은 HC 모듈의 TX 핀과 연결될 핀 * TX_PIN은 HC 모듈의 RX 핀과 연결될 핀 */ #define RX_PIN 3 #define TX_PIN 2 #define SERIAL_BAUD 9600 #define HC_BAUD 9600 SoftwareSerial HCSerial(RX_PIN, TX_PIN); void setup() { Serial. begin (SERIAL_BAUD); HCSerial. begin (HC_BAUD); } void loop() { if (HCSerial.available()) { // HC 모듈로부터 데이터가 들어온 경우 수행 루틴 HCFunction(); } if (Serial.available()) { // 시리얼 모니터로부터 데이터가 들어온 경우 수행 루틴 SerialFunction(); } } void HCFunction() { /** * Init routine * HC 모듈로부터 들어온 데이터를 시리얼 모니터로 출력 * 커스터마이징할 함수 영역 */ Serial.write(HCSerial.read()); } void SerialFunction() { /** * Init routine * 시리얼 모니터로부터 들어온 데이터를 HC 모듈로 출력 * 커스터마이징할 함수 영역 */ HCSerial.write(Serial.read()); }

반응형

에듀이노-코딩교육 전문 쇼핑몰

상품결제정보 고액결제의 경우 안전을 위해 카드사에서 확인전화를 드릴 수도 있습니다. 확인과정에서 도난 카드의 사용이나 타인 명의의 주문등 정상적인 주문이 아니라고 판단될 경우 임의로 주문을 보류 또는 취소할 수 있습니다.

무통장 입금은 상품 구매 대금은 PC뱅킹, 인터넷뱅킹, 텔레뱅킹 혹은 가까운 은행에서 직접 입금하시면 됩니다.

주문시 입력한 입금자명과 실제입금자의 성명이 반드시 일치하여야 하며, 7일 이내로 입금을 하셔야 하며 입금되지 않은 주문은 자동취소 됩니다.

배송정보 배송 방법 : 택배

배송 지역 : 전국지역

배송 비용 : 3,000원

배송 기간 : 1일 ~ 2일

배송 안내 : – 제주도, 산간벽지나 도서지방은 별도의 추가금액을 지불하셔야 하는 경우가 있습니다.

고객님께서 주문하신 상품은 입금 확인후 배송해 드립니다. 다만, 상품종류에 따라서 상품의 배송이 다소 지연될 수 있습니다.

교환 및 반품정보 교환 및 반품이 가능한 경우

– 상품을 공급 받으신 날로부터 7일이내 단, 가전제품의

경우 포장을 개봉하였거나 포장이 훼손되어 상품가치가 상실된 경우에는 교환/반품이 불가능합니다.

– 공급받으신 상품 및 용역의 내용이 표시.광고 내용과

다르거나 다르게 이행된 경우에는 공급받은 날로부터 3월이내, 그사실을 알게 된 날로부터 30일이내

교환 및 반품이 불가능한 경우

– 고객님의 책임 있는 사유로 상품등이 멸실 또는 훼손된 경우. 단, 상품의 내용을 확인하기 위하여

포장 등을 훼손한 경우는 제외

– 포장을 개봉하였거나 포장이 훼손되어 상품가치가 상실된 경우

(예 : 가전제품, 식품, 음반 등, 단 액정화면이 부착된 노트북, LCD모니터, 디지털 카메라 등의 불량화소에

따른 반품/교환은 제조사 기준에 따릅니다.)

– 고객님의 사용 또는 일부 소비에 의하여 상품의 가치가 현저히 감소한 경우 단, 화장품등의 경우 시용제품을

제공한 경우에 한 합니다.

– 시간의 경과에 의하여 재판매가 곤란할 정도로 상품등의 가치가 현저히 감소한 경우

– 복제가 가능한 상품등의 포장을 훼손한 경우

(자세한 내용은 고객만족센터 1:1 E-MAIL상담을 이용해 주시기 바랍니다.)

※ 고객님의 마음이 바뀌어 교환, 반품을 하실 경우 상품반송 비용은 고객님께서 부담하셔야 합니다.

(색상 교환, 사이즈 교환 등 포함)

아두이노 HM-10 블루투스 4.0 모듈 : 다나와 가격비교

No.1 가격비교사이트 다나와 앱으로

간편하게 최저가를 확인하세요.

언제 어디서나 빠르고 간편하게 상품을 팔거나 살 수 있는

스마트한 모바일 장터입니다.

PC조립을 위한 최고의 어플

실시간 최저가로 손쉽게 조립PC를 구성해보세요.

항시 100개 이상의 이벤트를 언제 어디서든

자유롭고 편리하게 응모 할 수 있습니다.

대한민국 최대 규모의 정보를 자랑하는 신차견적, 견적평가,

중고차 매물 검색, 자동차 뉴스, 커뮤니티 등 자동차 관련

소식을 받아보실 수 있습니다.

문자로 앱 설치 URL 받기 – – 보내기 QR코드

다나와 앱 서비스 목록 닫기

아두이노에서 HM-10 다루기

아두이노 나노와 HM-10으로 LED와 가변저항을 원격 제어해본다.

안드로이드 폰에서 원격으로 LED를 제어한다. (밝기 조절, 켜고 끄기, 깜박임)

가변저항의 아날로그 값을 안드로이드 폰으로 보낸다.

HM-10은 Bluetooth 4.0으로 BLE를 지원한다. 알리에서 $4 정도의 싼 가격에 구매할 수 있다. HM-10과 호환되면서 더 저가의 모듈인 AT-09도 있다. HM-10은 센트럴(Central)과 페리페럴(Peripheral) 역할 모두 지원한다. 여기서는 HM-10을 페리페럴 역할로, 안드로이드 폰을 센트롤 역할로 사용한다.

LED와 가변저항을 아두이노 나노와 연결하여 입출력을 원격으로 제어해본다. LED는 원격의 커맨드를 받아 밝기 조절, 켜고 끄기 그리고 깜박임을 제어해보고 가변저항으로는 아날로그 값을 입력받아 원격의 안드로이드 폰으로 전송해본다.

먼저 준비물부터 살펴보자.

준비물

Arduino Nano

HM-10 BLE module : 내부 레벨 컨버터가 있는 제품으로 구매하면 따로 레벨 컨버터가 필요 없다.

가변저항 (B10K)

LED와 330Ω 저항

브레드보드 및 와이어

HM-10

결선

아두이노 나노를 중심에 두고 HM-10, LED, 가변저항을 연결한다.

아두이노 나노 주변 모듈 설명 D9 HM-10의 Tx 핀 SoftwareSerial을 사용하므로 임의의 디지털 핀에 연결한다. D10 HM-10의 Rx 핀 ~D3 LED 밝기 조절을 위해 PWM이 가능한 ~D3에 연결한다. A0 가변저항의 가운데 핀 아날로그 값을 입력으로 받는다.

아두이노 나노, HM-10, LED, 가변저항 결선

프로젝트 생성

개발은 Visual Studio Code에 PlatformIO 확장을 설치하여 진행하였다. 그럼 PlatformIO에서 프로젝트를 생성해 보자.

PlatformIO 홈 > 좌측 ‘Projects’ 탭 클릭 > 우측 상단의 ‘Create New Project’ 클릭

‘Project Wizard’ 창에 아래와 같이 설정

• ‘Name’ 필드에 원하는 프로젝트 이름을 입력한다.

• ‘Board’ 필드에 ‘Arduino Nano ATmega328’ 선택한다.

• ‘Framework’ 필드에 ‘Arduino’ 선택한다.

• ‘Location’을 uncheck 하여 원하는 위치에 프로젝트를 생성할 수 있다.

• ‘Finish’ 버튼 클릭하여 프로젝트 생성한다.

코드

코드는 각 기능을 담당하는 cpp 파일로 분리하여 작성하였다.

main.cpp : HM-10을 초기화하고 루프를 돌면서 커맨드 처리와 데이터 전송을 처리한다.

ble.cpp : SoftwareSerial을 이용하여 HM-10을 다룬다.

led.cpp : LED를 제어한다.

control.cpp : HM-10을 통해 받은 커맨드를 처리한다.

코드의 중요 부분들을 살펴보자.

SoftwareSerial와 AT Command를 사용하여 HM-10을 초기화한다. AT Command는 센터랄 장치와 연결되기 전에 유효하므로 초기화 때 수행해야 한다.

#include SoftwareSerial mySerial(PIN_TX, PIN_RX); // D9, D10 void sendCommand(const char * command) { mySerial.println(command); // wait some time delay(500); } void initBle() { mySerial.begin(9600); sendCommand(“AT”); sendCommand(“AT+ROLE0”); // Role : 0 -> Peripheral(Slave) (Default) sendCommand(“AT+UUID0xFFE0”); // Service UUID : 0xFFE0 (Default) sendCommand(“AT+CHAR0xFFE1”); // Characteristic UUID : 0xFFE1 (Default) sendCommand(“AT+NAMEBleTest”); // Device Name : “BleTest” }

센트럴로부터 커맨드 데이터를 받기 위해서는 서로 약속을 정해야 한다. 여기서는 아래 표와 같이 커맨드를 4개의 부분으로 정한다. 시작은 항상 CMD_START(0x01)로 시작하며 원하는 기능은 ‘COMMAND TYPE’으로 정한다. ‘DATA’는 가변 길이이므로 길이 정보를 위해 ‘DATA LENGTH’ 필드를 사용한다.

LED 제어의 경우 TYPE_LED_SW, TYPE_LED_DIM, TYPE_LED_BLINK 커맨드 타입들이 있다.

TYPE_LED_SW : LED의 On/Off 한다. Data 값이 1이면 LED를 On, 0이면 Off 시킨다.

TYPE_LED_DIM : LED의 밝기를 조절한다. 0~255의 Data 값으로 LED의 밝기 값으로 사용한다.

TYPE_LED_BLINK : LED의 깜박임을 제어한다. Data의 첫 번째 바이트로는 깜박이는 횟수를 지정하고 나머지 두 바이트는 깜박이는 주기를 지정한다.

START COMMAND TYPE DATA LENGTH DATA 0x01 : CMD_START 0x11 : TYPE_LED_SW

0x12 : TYPE_LED_DIM

0x13 : TYPE_LED_BLINK DATA의 길이 가변 길이 DATA

#define CMD_START 0x1 #define BIT_START 0 #define BIT_TYPE 1 #define BIT_LENGTH 2 #define BIT_DATA 3 #define TYPE_LED_SW 0x11 #define TYPE_LED_DIM 0x12 #define TYPE_LED_BLINK 0x13

void executeCommand(int cmd[]) { switch(cmd[BIT_TYPE]) { case TYPE_LED_SW: ledSwitch(cmd[BIT_DATA]); break; case TYPE_LED_DIM: ledDim(cmd[BIT_DATA]); break; case TYPE_LED_BLINK: ledBlink(cmd[BIT_DATA], cmd[BIT_DATA+1] << 8 | cmd[BIT_DATA+2]); break; } } loop() 함수에서는 가변저항의 아날로그 값을 읽어 센터랄 장치인 안드로이드 폰으로 보낸다. loop()가 호출될 때마다 이 과정을 실행하면 너무 자주 수행되므로 millis()를 사용하여 매 500ms마다 처리되도록 한다. 또한 아날로그 값이 이전 값과 같다면 스킵한다. 한 바이트를 보내기 위해 map() 함수로 0~1023 값을 0~255 값으로 변환하였다. // send analog value to central every 500ms currTime = millis(); if(currTime - prevTime > 500) { prevTime = currTime; int data = analogRead(A0); data = map(data, 0, 1023, 0, 255); if (data != prevData) { sendBleData(data); // send 1 byte prevData = data; } }

전체 코드는 github에 올려두었다.

테스트

코드를 모두 작성했다면 PlatformIO의 하단 툴바에서 ‘⩗’를 클릭하여 코드를 빌드한다. 빌드에 성공하면 ‘→’를 클릭하여 바이너리를 업로드한다. 아직 센트럴 장치와 연결되기 전이라 HM-10의 LED가 깜박인다. 그리고 하단의 플러그 모양을 클릭하면 시리얼 모니터가 열리고 AT command들이 출력되는 것을 볼 수 있다. PlatformIO는 연결된 시리얼 포트를 자동으로 감지하여 연결한다. 만약 PC에 2개 이상의 시리얼 장치가 연결되어 있다면 하나를 선택할 수 있도록 가이드가 나오는데 맞는 포트를 선택하면 된다.

PlatformIO의 하단 툴바에는 개발에 필요한 버튼들을 제공한다.

PlatformIO 하단 툴바

테스트를 위해서는 HM-10과 연결하여 데이터를 주고받을 안드로이드 앱이 있어야 한다. 구글 플레이 스토어에서 nRF Connect for Mobile 앱을 설치한다. 이 앱은 블루투스 칩으로 유명한 ‘노르딕 세미컨덕터(Nordic Semiconductor)’에서 만든 앱으로 범용으로 사용할 수 있다. 앱을 실행시키면 자동으로 스캔을 시작한다. 앞에서 AT Command로 설정한 HM-10의 장치 명인 ‘BleTest’가 검색된 것을 볼 수 있다. ‘CONNECT’ 버튼을 클릭하면 HM-10의 BLE Service UUID로 설정한 ‘0xFFE0’가 하단에 보인다. 이 Service를 클릭하면 Characteristic UUID로 설정한 ‘0xFFE1’이 보인다.

HM-10과 연결

데이터를 원격의 HM-10으로 보내보자.

Characteristic의 ‘↥’ 버튼을 클릭하면 ‘Write value’ 창이 나타난다. 드롭다운 리스트에서 Data Type을 ‘BYTE ARRAY’로 지정한다. 예를 들어, LED를 ON 시키기 위해 ‘0x01110101’을 입력하고 ‘SEND’ 버튼을 클릭하면 LED가 켜진다. 동일한 값을 나중에 다시 사용하고 싶다면 ‘SAVE’ 버튼을 클릭하여 명령을 저장하면 된다.

LED On command

LED 테스트를 위한 커멘드들은 아래와 같다.

LED 테스트 Command START CMD TYPE LENGTH DATA0 DATA1 DATA2 On 0x01110101 0x01 0x11 0x01 (길이 1) 0x01 (On) Off 0x01110100 0x01 0x11 0x01 (길이 1) 0x00 (Off) 밝기 50% 0x01120180 0x01 0x12 0x01 (길이 1) 0x80 (50%) 500ms 주기로 5회 깜박이기 0x0113030501C0 0x01 0x13 0x03 (길이 3) 0x05 (5회) 0x01C0 (500ms)

HM-10으로부터 데이터를 읽어보자.

보드의 가변저항 노브를 돌리면 ‘Value’ 필드의 값이 변하는 것을 볼 수 있다.

아날로그 값 읽기

참고 사이트

Arduino Nano와 HM-10 사용한 프로젝트:

HM-10 자료:

HM-10의 자세한 사용 설명:

How to Use HM-10 BLE Module with Arduino to Control an LED using Android App

Bluetooth is one of the most popular and easy to use wireless technology. Over the few years there have been many upgrades of Bluetooth standard to keep pace with the current ongoing technology with future technology and to satisfy needs of users. Starting from the Bluetooth version 1.0 to Bluetooth version 5.0, there are many things changed including higher data rates, the ability to be used for IoT with low current consumption, improved security, etc. To learn Bluetooth communication there are many modules available which can be interfaced with microcontrollers. Such a Bluetooth module is HM10 which is based on Bluetooth 4.0.

What is HM10 BLE 4.0 Module?

The HM10 is a serial BLE module (Bluetooth-Low-Energy) which is intended to use for the low power consumption applications and can last long even with a coin-sized battery. The HM10 is a Bluetooth 4.0 module based on the Texas Instruments CC2540 or CC2541 BLE System SoC (System on Chip). The firmware and design of the module is made and managed by Jinan Huamao Technology. The module comes with serial/UART layer which makes the device to be able to interface with different microcontrollers. The HM10 is ideal for creating simple connections and using it with or as an iBeacon.

The HM10 has become a very popular Bluetooth 4.0 BLE module. The HM10 is a Bluetooth 4.0 based module only, so it will not connect with Bluetooth 2/2.1 module such as HC-05, HC-06 and other Bluetooth modules. The HM10 is controlled via AT commands sent over the serial UART connection. HM-10 is a Bluetooth Low Energy (BLE) module, to know more about BLE follow the link. Also learn how an nRF24L01 module can be used as BLE module with Arduino.

Difference between HM10 and other Bluetooth Module

The major difference HM10 possess is the Bluetooth Version. The HM10 is Bluetooth 4.0 module, so it comes with all Bluetooth Version 4.0 features such as speed, throughput and range. The HM10 offers a data rate of up to 24 Mbps with low-energy/low-power consumption. Along with this the HM10 offers a distance range of 100 meters in open space. Compare to other Bluetooth modules such as HC-05 which is a Bluetooth 2.0 based module, the HM10 certainly performs better than the HC-05. The HC-05 only offers 3 Mbps compared to HM10 which is quite less.

Bluetooth module HC-05 and HC-06 are still very popular among makers and hobbyists as they are cheap and easy to interface. We also made many projects using HC-05/06 and interfaced them with many other microcontrollers:

All the Bluetooth related projects can be found at this link.

Today we will interface HM-10 BLE Module with Arduino Uno to control an LED wirelessly using Bluetooth protocol. The On/Off commands will be sent by Smartphone.

Components Required

Hardware:

Arduino UNO

HM10 Bluetooth Module

Resistors(1 kΩ, 470 Ω)

Jumper Wires

Software:

Arduino IDE

Arduino Bluetooth Controller(HM-10 Module) Android App

Android Smart phone

Circuit Diagram

Circuit diagram for connecting Arduino and HM-10 Bluetooth module is very simple as shown below.

Before starting with the project make sure that your HM-10 module is a genuine HM-10 module. There are widely Chinese cloned HM-10 modules available. To identify the difference between Genuine and Cloned HM-10 module, just look the presence of Crystal Oscillator of 32KHz on the HM-10 Board. If the Crystal Oscillator is present then it is a genuine HM-10 Module and you don’t need to change the Firmware. But if you cannot see the Crystal Oscillator in place of it then it is a Cloned HM10 module and you need to change the Firmware of the Cloned HM-10 Module. Without changing the HM-10 firmware, you can neither access the HM-10 module with AT commands nor you can pair it with smartphones. Here we are also using the clone module so we flashed its firmware before connecting it with Ardruino. In order to change the Firmware of Cloned HM-10 module, simply follow our tutorial on How to change or flash the Firmware of Clone HM-10 module.

Arduino Bluetooth Controller (HM-10 Module) Android Application

The Arduino Bluetooth Controller (HM-10 Module) is an android application which is available free on Google Play Store. This app is having easy and simple interface for HM-10 BLE Module. While testing, it was able to find HM-10 quickly and it connected instantly with HM-10. The app has some cool feature like you can create a button and customize it with custom name and functions. Here we will how to create two buttons in this Bluetooth controller app to turn on and off the LED connected with Arduino.

How to setup Arduino Bluetooth Controller (HM-10 Module) Android App:

Download the app from Google Play Store.

The Home page of the app will look like below where you can find features like, connect Device, Search Icon, Delete Icon, Device Status, Send Text, Add Template etc. Start with searching the Device either by clicking on Search Icon or by clicking to three dots on the upper right corner and choose connect Device.

All available devices will be shown in the screen. Choose the correct HM-10 Module.

Now the HM-10 will be successfully connected and you will be able to see the status of HM-10 in the Top of Screen.

Now either you can directly send a text or String by writing on the text section and hit arrow to send or you can create a custom template.

To create a custom template to save time. Click on the “+” icon on upper right corner and fill the details. The “Name” is button name, the “Text” field is for texts or string which will be sent to HM-10 and “Description” is just the button description that how the button will function.

Firstly, create a button for turn LED ON and give it a Green Color. The Button will send “N” letter to HM-10 which will turn on the LED connected to Arduino. Similarly create a button for LED OFF and give it a Red Color. . The Button will send “F” letter to HM-10 which will turn off the LED connected to Arduino.

Now you can see the two buttons created just below the Text Field. Now if you want to control LED then just click on the Buttons.

This finishes the setting up android app to control the HM-10 module. Now we will start with the programming Arduino Uno to get the characters from Android App.

Programming Arduino UNO to Control LED using HM-10 Bluetooth Module

As always complete program with demonstration video can be found at the end of this tutorial. Programming Arduino UNO for this project neither requires much effort nor any library. You can use hardware serial and software serial library. If you are using software serial then just include software serial library else proceed with hardware serial. In this project we are using SoftwareSerial. So start with including Software Serial Library. The pins Rx and Tx are connected at 2 and 3 Pins of Arduino.

#include SoftwareSerial HM10(2, 3); // RX = 2, TX = 3

The two variables are used to store the data received from HM10 and android app.

char appData; String inData = “”;

Just start the Hardware and Software Serial at 9600 baud rate and print some debugging statements. The LED pin is set as output and initially it is off.

Serial.begin(9600); Serial.println(“HM10 serial started at 9600”); HM10.begin(9600); // set HM10 serial at 9600 baud rate pinMode(13, OUTPUT); // onboard LED digitalWrite(13, LOW); // switch OFF LED

Start listening the HM10 port and read the string until the HM10 is available and sends the data. Save the data in string.

HM10.listen(); // listen the HM10 port while (HM10.available() > 0) { // if HM10 sends something then read appData = HM10.read(); inData = String(appData); // save the data in string format Serial.write(appData); }

For debugging the HM10 with AT commands just write the below code line which will send the string to HM10.

if (Serial.available()) { // Read user input if available. delay(10); HM10.write(Serial.read()); }

If the received string is “F” then print a message on serial monitor and turn OFF the led else if the received string is “N” then print a message on serial monitor and Blink led with a delay of 500ms.

if ( inData == “F”) { Serial.println(“LED OFF”); digitalWrite(13, LOW); // switch OFF LED delay(500); } if ( inData == “N”) { Serial.println(“LED ON”); digitalWrite(13, HIGH); // switch OFF LED delay(500); digitalWrite(13, LOW); // switch OFF LED delay(500); }

This finishes the complete tutorial on how to control LED using Arduino and BLE HM10 Blutooth 4.0 module. Again remember that, if you have a genuine HM10 module then you don’t need to flash its firmware, it can be used straight away. But If you are using a cloned HM-10 module then flash the firmware on clone HM10 BLE module. If you have any doubt or suggestion then please comment below or write to our forum.

아두이노 블루투스 모듈 사용하기 (HM-10)

Arduino bluetooth

아두이노 UNO 보드와 블루투스 모듈 (HM-10 호환)을 사용하여 기초적인 세팅하기

위 그림과 똑같이 세팅할 필요는 없다. 자신이 사용하는 모듈이 몇 볼트에서 동작하는지, TX와 RX를 어떤 핀에 입력했는지가 중요하다.

글쓴이가 갖고 있는 Bluetooth Module은 3.3V에서 동작해서 빨간색 전선을 UNO 보드의 3.3V와 Bluetooth Module의 VCC에 연결했고, 검은색 전선으로 각각의 GND에 연결했다. 마지막으로 TX는 디지털 8번, RX는 디지털 10번에 입력했다.

HM-10 모듈은 0xFFE0 이라는 UUID를 갖는다. 사실 글쓴이는 문자열 데이터를 주고받을 수 있어서 단순 문자 통신 서비스인 줄 알았지만 온도 센서의 값을 주고받는 UUID이다. 사실 자세히 알 필요가 없다.

예제 소스

#include //Initial pin number const int bluetoothRX = 10; const int bluetoothTX = 8; //Define to use bluetooth module SoftwareSerial ble ( bluetoothTX, bluetoothRX ); void setup() { Serial.begin ( 9600 ); ble.begin ( 9600 ); } void loop() { if ( Serial.available() ) { ble.write( Serial.read() ); } if ( ble.available() ) { Serial.write( ble.read() ); } }

먼저 Bluetooth Module을 이용하기 위해 “SoftwareSerial” 라이브러리를 사용한다. 해당 라이브러리는 단순 문자열 데이터를 보내고 받는 함수를 제공해주는 것 같다. (read, write)

해당 라이브러리를 include 시킨 후 몇 번 핀에 꽂았는지 초기화를 해준다. 글쓴이는 확실하게 하기 위해 const를 넣어 상수로 만들어 선언했다.

그 후 SoftwareSerial 클래스를 생성해준다. 글쓴이는 객체 이름을 “ble”라고 했고 2개의 인자가 들어가는데 차례대로 RX, TX이다. 이는 우노보드 입장에서의 RX, TX이므로 RX에는 Bluetooth Module의 TX, TX에는 블루투스 모듈의 RX를 넣어주면 된다.

참고로 Rx는 Receive Data (수신 데이터), Tx는 Transmit Data (송신 데이터)이다.

setup() 함수에는 말 그대로 아두이노 보드가 loop() 함수를 실행하기 전 초기화를 시켜주는 함수이다. Arduino Serial과 Bluetooth Serial을 사용할 것이기 때문에 포트를 열어주는 함수(begin)을 사용하여 열어준다. 숫자는 전송 속도이다.

아두이노가 본격적으로 작동되는 loop() 함수이다. 함수의 이름대로 아두이노에 전원이 들어가면 해당 함수를 계속 반복한다. 위 소스의 내용은 Arduino Serial을 사용했다면 Bluetooth Serial을 이용해 Write, 반대로 Bluetooth Serial을 사용했다면 Arduino Serial에 Write 한다.

AT Command를 이용하여 응답확인

AT Command를 사용하기 위해 먼저 Arduino IDE의 Serial Monitor를 실행해야 한다.

전송 옆에 “AT”를 쓴 후 전송을 누르면 OK라는 메세지를 받을 수 있다. 만약 OK 메세지를 받지 못한다면 제대로 연결을 안했다거나 핀 번호가 틀렸을 수 있다.

자주쓰는 AT Command를 소개한다.

AT : Bluetooth Module을 확인할 때 사용한다. AT+ADDR? : Bluetooth Module의 MAC주소를 확인하는데 사용한다. AT+NAME? : Master Device가 Bluetooth Module을 검색할 때 어떤 이름인지 확인하는데 사용한다. AT+TYPE? : Bluetooth Module가 어떤 타입을 사용하는지 확인하는데 사용한다. 보통 1번이 default로 되어있는데 3번으로 바꿔야 안드로이드와 연결이 된다. AT+MODE? : Bluetooth 통신 방법 중 “Connection”인지 “Broadcast”인지 확인한다. Connection이 보통 사용하는 방법이고 Broadcast가 “Beacon”이다. AT+RESET : 재시작할 때 사용한다. AT+RENEW : 공장초기화 할 때 사용한다.

참고 자료

Bluetooth UUID Service – https://www.u-blox.com/sites/default/files/products/documents/BluetoothLowEnergyGATT-Examples_AppNote_%28cB-23035914%29.pdf

SoftwareSerial Reference – https://www.arduino.cc/en/Reference/SoftwareSerial

HM-10 모듈 AT Command 모음 – http://blog.naver.com/PostView.nhn?blogId=xisaturn&logNo=220712028679

이 글 공유하기: 트위터

Facebook

Telegram

인쇄

키워드에 대한 정보 hm 10 아두 이노

다음은 Bing에서 hm 10 아두 이노 주제에 대한 검색 결과입니다. 필요한 경우 더 읽을 수 있습니다.

이 기사는 인터넷의 다양한 출처에서 편집되었습니다. 이 기사가 유용했기를 바랍니다. 이 기사가 유용하다고 생각되면 공유하십시오. 매우 감사합니다!

사람들이 주제에 대해 자주 검색하는 키워드 [RC Car] HM-10 통신

  • Makist
[RC #Car] #HM-10 #통신


YouTube에서 hm 10 아두 이노 주제의 다른 동영상 보기

주제에 대한 기사를 시청해 주셔서 감사합니다 [RC Car] HM-10 통신 | hm 10 아두 이노, 이 기사가 유용하다고 생각되면 공유하십시오, 매우 감사합니다.

See also  전소민 윤현민 백진희 박서준 | 전소민, 러브라인에 진심인 그녀가 겪은 숨겨진 연애사 20276 투표 이 답변

Leave a Reply

Your email address will not be published. Required fields are marked *