{"id":1099,"date":"2016-02-25T15:42:56","date_gmt":"2016-02-25T13:42:56","guid":{"rendered":"http:\/\/upmsur.ieeespain.org\/?p=1099"},"modified":"2016-02-25T15:42:56","modified_gmt":"2016-02-25T13:42:56","slug":"create-the-most-absurd-chat-of-the-world-with-arduino","status":"publish","type":"post","link":"https:\/\/aetel.etsist.upm.es\/?p=1099","title":{"rendered":"Create the most absurd chat of the world with Arduino"},"content":{"rendered":"<p>Are you bored and looking for some entertainment? Would you like to fastly create a chat to avoid leaving your chair or sofa to talk with your flatmate? Would you like to know more about AT commands and practice with them? Whatever your question or interest, in this tutorial you can learn to create a chat using Arduino and Bluetooth.<\/p>\n<p><!--more--><\/p>\n<p><strong>Required materials:<\/strong><\/p>\n<ul>\n<li>Two Bluetooth modules(e.g. HC-05 and\/or HC-06). One of them must be HC-05 in order to be able to stablish the communication.<\/li>\n<li>Arduino or\u00a0 USB to RS-232 converter. Any of them are valid, being necessary a total of 2.<\/li>\n<li>Arduino software, putty or other software that allows using Windows COM port or \/dev\/tty\/USBX, \/dev\/tty\/ACMX or similar in case of Linux environment.<\/li>\n<li>Prototyping cables to connect the Bluetooth modules with the Arduino board or converter.<\/li>\n<li>USB \u2013 USB\u00a0mini\/micro cable to connect the Arduino or converter with your computer.<\/li>\n<li>Protoboard<\/li>\n<\/ul>\n<p><strong>Steps to follow:<\/strong><\/p>\n<p>If you are using an Arduino, make sure that you upload and empty program. That is, a program containing both setup and loop methods to avoid compilation errors. This way, you make sure that nothing interferes in what you pretend to do.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1070 size-full aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img1-1.png\" alt=\"img1\" width=\"485\" height=\"592\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img1-1.png 485w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img1-1-246x300.png 246w\" sizes=\"auto, (max-width: 485px) 100vw, 485px\" \/><\/p>\n<p>Once the step is done, proceed to connect the different parts:<\/p>\n<ul>\n<li>Connect VCC (5V) with Bluetooth&#8217;s VCC<\/li>\n<li>Connect GND with GND.<\/li>\n<li>In the Bluetooth module which will create the connection, connect Key pin with VCC (that will allow to execute the AT commands).<\/li>\n<li>For TX and RX pins, connectivity will depend on the module use and the Arduino or converter, usually\u00a0 TX to RX and RX to TX. In case of doubt, there are several ways to check:<\/li>\n<li>Depending on the Bluetooth module, you may find arrows indicating if it is input or output.<\/li>\n<li>With or without indication, you can connect your Arduino or converter to Arduino software, open Serial Monitor and send a ramdon character to see if TX LED flashes. If that is the case, the connectivity was done well.<\/li>\n<\/ul>\n<p>Done this step, you will start executing the AT commands that will allow connecting to the other Bluetooth module and communicate with it. In case of using Arduino software:<\/p>\n<ul>\n<li>Go to Tools-&gt;Board and select the board (in case of using a converter, this step is not necessary).<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1073 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img2-1.png\" alt=\"img2\" width=\"452\" height=\"441\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img2-1.png 635w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img2-1-300x293.png 300w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/p>\n<ul>\n<li>Go to Tools-&gt;Port to indicate the port where the device is connected.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1074 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img3-1.png\" alt=\"img3\" width=\"449\" height=\"441\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img3-1.png 604w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img3-1-300x295.png 300w\" sizes=\"auto, (max-width: 449px) 100vw, 449px\" \/><\/p>\n<ul>\n<li>Open Serial Monitor and select a baudrate of 38400 and Both NL&amp;CR as line ending.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1075 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img4-1.png\" alt=\"img4\" width=\"499\" height=\"330\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img4-1.png 652w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img4-1-300x198.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1076 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img5-1.png\" alt=\"img5\" width=\"504\" height=\"383\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img5-1.png 652w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img5-1-300x228.png 300w\" sizes=\"auto, (max-width: 504px) 100vw, 504px\" \/><\/p>\n<p>If these steps were done without problems, you can proceed to create the connection using the AT commands. To do so:<\/p>\n<ul>\n<li>Write AT and press send or Enter key. If everything was ok, you will receive an OK as an answer. If you receive an error, repeat until you get an OK (if nothing appears in the screen, check that RX and TX pins are well connected).<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1082 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img6-1.png\" alt=\"img6\" width=\"534\" height=\"306\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img6-1.png 652w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img6-1-300x172.png 300w\" sizes=\"auto, (max-width: 534px) 100vw, 534px\" \/><\/p>\n<ul>\n<li>Configure the module as master with AT+ROLE=1. As in the previous step, you should receive &#8216;OK&#8217;.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1083 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img7-1.png\" alt=\"img7\" width=\"539\" height=\"310\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img7-1.png 648w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img7-1-300x173.png 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/p>\n<ul>\n<li>Initialize the SPP profile. That will allow the search and connection with another Bluetooth device. To do so, execute AT+INIT.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1084 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img8-1.png\" alt=\"img8\" width=\"536\" height=\"308\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img8-1.png 649w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img8-1-300x172.png 300w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/p>\n<ul>\n<li>Indicate that the device has an access key with AT+IAC=9e8b33.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1085 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img9-1.png\" alt=\"img9\" width=\"539\" height=\"311\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img9-1.png 650w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img9-1-300x173.png 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/p>\n<ul>\n<li>Indicate that the Bluetooth device you are going to connect with is class 0 with AT+CLASS=0.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1086 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img10-1.png\" alt=\"img10\" width=\"538\" height=\"308\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img10-1.png 652w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img10-1-300x172.png 300w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/p>\n<ul>\n<li>Search for device with AT+INQM=1,9,48 (1-&gt;RSSI intention indication, 9-&gt;Maximum number of devices to add to the list, 48-&gt;Multiplied by 1.28 to calculate the maximum search time).<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1087 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img11-1.png\" alt=\"img11\" width=\"546\" height=\"316\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img11-1.png 650w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img11-1-300x174.png 300w\" sizes=\"auto, (max-width: 546px) 100vw, 546px\" \/><\/p>\n<ul>\n<li>List the found devices with AT+INQ:<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1088 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img12-1.png\" alt=\"img12\" width=\"554\" height=\"319\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img12-1.png 649w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img12-1-300x173.png 300w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1089 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img13-1.png\" alt=\"img13\" width=\"555\" height=\"320\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img13-1.png 649w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img13-1-300x173.png 300w\" sizes=\"auto, (max-width: 555px) 100vw, 555px\" \/><\/p>\n<ul>\n<li>Pair with the target device with AT+PAIR=bluetooth_address,max_response_time. For example, if you desire to connect with the one with MAC address 11:9:50114 (some of the zeros are not shown and the rest you can see in the line is not part of the physical address), the command is AT+PAIR=11,9,50114,20 (you have to substitute : by , ). If the pair was done, you will receive &#8216;OK&#8217;.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1091 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img15-1.png\" alt=\"img15\" width=\"560\" height=\"323\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img15-1.png 649w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img15-1-300x173.png 300w\" sizes=\"auto, (max-width: 560px) 100vw, 560px\" \/><\/p>\n<ul>\n<li>Link with the target device with AT+LINK=bluetooth_address (remember to substitute : by , ). If the link is done, you will receive an OK and the blink of the LED will change.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1092 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img16-1.png\" alt=\"img16\" width=\"561\" height=\"323\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img16-1.png 649w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img16-1-300x173.png 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/p>\n<p>Ready! Now you can communicate through Bluetooth!<\/p>\n<p>To finish, open Arduino Software in the other communication side (Note: in case of testing in the same computer both sides of the communication, you must run other software like Energia or Putty, as though Windows opens other Arduino instances, it doesn&#8217;t allow to choose another port in that instance). In that side, open the serial monitor or equivalent with a baudrate of 9600 bps.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1106 aligncenter\" src=\"http:\/\/upmsur.ieeespain.org\/wp-content\/uploads\/2016\/02\/img18-1.png\" alt=\"img18\" width=\"1330\" height=\"371\" srcset=\"https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img18-1.png 1330w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img18-1-300x84.png 300w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img18-1-768x214.png 768w, https:\/\/aetel.etsist.upm.es\/wp-content\/uploads\/2016\/02\/img18-1-1024x286.png 1024w\" sizes=\"auto, (max-width: 1330px) 100vw, 1330px\" \/><\/p>\n<p>If you want to know more about the AT commands, you can have a look at the guide available at <a href=\"http:\/\/www.instructables.com\/id\/AT-command-mode-of-HC-05-Bluetooth-module\/\" target=\"_blank\">Instructables<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you bored and looking for some entertainment? Would you like to fastly create a chat to avoid leaving your chair or sofa to talk with your flatmate? Would you like to know more about AT commands and practice with them? Whatever your question or interest, in this tutorial you can learn to create a [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":1101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[125,131,132,133],"class_list":["post-1099","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-en","tag-arduino-en","tag-bluetooth-en","tag-chat-en","tag-tutorial-en"],"_links":{"self":[{"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=\/wp\/v2\/posts\/1099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1099"}],"version-history":[{"count":0,"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=\/wp\/v2\/posts\/1099\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=\/wp\/v2\/media\/1101"}],"wp:attachment":[{"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aetel.etsist.upm.es\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}