Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore Arduino documentation

Arduino documentation

Published by gPiO Box, 2018-06-18 04:47:26

Description: Erik Verberne teaches Information and Communication Technology (ICT) in Netherlands and looked into the Arduino platform in an attempt to enhance his department’s curriculum. He diligently documented his research and is now sharing it with the community.

Search

Read the Text Version

Arduino documentation Erik Verberne [email protected] Version: 1.19

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Foreword I work in the Netherlands at a school as a teacher ICT Management. At my department wealso teach Application Developers. In December 2013 I decided to investigate whether itwould be interesting for our Application Developers to take a minor in the subject EmbeddedSoftware and specifically Arduino. So I bought some Arduino boards and a couple of sensorsand actuators to experiment with. I soon found out that I needed to document my findings.This document is the result of experimenting in my free time. Since Arduino is open source, Idecided to donate this document to other Arduino fans in the world. As long as it is clear thatI’m the author of this document, you can use this document for any non-commercial oreducational projects.I derived and simplified most sketches from samples that came with the correspondinglibraries. Most schematics and most photographs are my own work.Have fun with it. I certainly enjoyed writing it.Erik VerberneJanuary 29th 2014Arduino documentation 1.19 2

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Table of contents Foreword ............................................................................................................................................ 2 Table of contents ............................................................................................................................. 3 Introduction ...................................................................................................................................... 9 Version history .............................................................................................................................. 11 Arduino Boards ............................................................................................................................. 17 1. Arduino .................................................................................................................................................. 19 2. Arduino UNO R3 ................................................................................................................................ 22 3. Arduino Mega 2560 R3 ................................................................................................................... 24 4. Arduino Mega 2560 R3 CH340 .................................................................................................... 26 5. Arduino Nano ...................................................................................................................................... 28 6. Sparkfun Pro Micro - 5V/16MHz ................................................................................................ 30 7. Arduino Pro Mini ATmega168U 5v, 16MHz .......................................................................... 32 8. Arduino Pro Mini ATmega328p 3.3V, 8MHz ......................................................................... 34 9. Teensy 3.1 & 3.2 ................................................................................................................................. 36 10. LoRa: Nexus .................................................................................................................................... 41 11. LoRa: Sodaq One ........................................................................................................................... 43 13. Boarduino ........................................................................................................................................ 54 14. AVR Development board as Arduino ................................................................................... 57 15. Arduino on a breadboard ......................................................................................................... 59 16. Attiny45/Attiny85 ....................................................................................................................... 61 17. Attiny85 Digispark board ......................................................................................................... 65 18. ESP8266 MCU ................................................................................................................................ 69 Arduino IDE .................................................................................................................................... 71 19. Arduino IDE .................................................................................................................................... 73 20. Serial Monitor ................................................................................................................................ 75 21. Libraries ........................................................................................................................................... 77 22. Board management ..................................................................................................................... 79 Misc. software ................................................................................................................................ 81 23. Processing ....................................................................................................................................... 83 24. Fritzing .............................................................................................................................................. 86 Programming/ Programmers .................................................................................................. 87 25. Programming an Arduino Board through USB ................................................................ 89 26. USBasp v2.0 programmer ......................................................................................................... 90 27. AVR ISP to ICSP Adapter ........................................................................................................... 92 28. Uploading the bootloader by using an Arduino as ISP ................................................. 94 29. AVR Atmega8/168/328 Development board .................................................................. 95 30. Self-made Attiny 45/85 ISP adapter .................................................................................... 97 Sound ................................................................................................................................................ 99 31. Buzzer ............................................................................................................................................ 101 32. Piezo Speaker .............................................................................................................................. 103 LED displays ................................................................................................................................. 105 33. Onboard LED D13 ..................................................................................................................... 107 34. LED .................................................................................................................................................. 108 35. RGB LED board ........................................................................................................................... 111 36. 8x8 DOT Matrix 1088AS ......................................................................................................... 113 37. 8x8 DOT Matrix 1388ASR ..................................................................................................... 115 Arduino documentation 1.19 3

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 38. 8x8 DOT Matrix 1088AS with MAX7219 chip ............................................................... 117 39. 8x8 DOT matrix on module with MAX7219 chip ......................................................... 120 40. Single Digit 7-Segment Display ........................................................................................... 124 41. 4 Digits 7-Segment Display Common Cathode ............................................................. 128 42. 8 Digits 7-Segment Display with TM1638 chip ............................................................ 132 43. WS2812B RGB LED breakout-board ................................................................................. 135 44. WS2812B RGB LED strip ........................................................................................................ 138 LCD/TFT displays ....................................................................................................................... 141 45. Nokia 5110/3310 LCD ............................................................................................................ 143 46. 16x2 Display 1602A ................................................................................................................. 147 47. 16x2 Display with LCM1602 chip ...................................................................................... 150 48. Adafruit 2.8\" TFT Resistive Touch Shield v2 ................................................................. 153 49. 2.4” TFT LCD Shield Touch Board ................................................................................. 157 Input sensors ............................................................................................................................... 163 50. Switches ........................................................................................................................................ 165 51. Slot Optical Switch ITR8102 ................................................................................................. 176 52. 4x4 Keypad .................................................................................................................................. 178 53. Potentiometer ............................................................................................................................. 181 54. Joystick ........................................................................................................................................... 183 55. Nunchuk with connection board ........................................................................................ 186 56. Nunchuk with connection board on A2..A5 ................................................................... 190 57. Nunchuk without connection board ................................................................................. 196 58. Playstation controller (PSX/PS2) ....................................................................................... 197 59. PS/2 keyboard ............................................................................................................................ 200 60. RGB and Gesture sensor APDS-9960 ................................................................................ 203 Sensors ........................................................................................................................................... 207 61. Temperature Sensor LM35 ................................................................................................... 209 62. Temperature and Humidity sensor board ..................................................................... 211 63. Water sensor ............................................................................................................................... 213 64. Distance Sensor HC-SR04 ...................................................................................................... 215 65. PIR/Motion Sensor HC-SR501 ............................................................................................. 220 66. Photo resistor (LDR) ................................................................................................................ 222 67. Flame Sensor (IR photo transistor) ................................................................................... 224 68. IR proximity sensor board .................................................................................................... 226 69. Sound detection FC-04 ............................................................................................................ 228 70. Sound detection with digital and analog output .......................................................... 230 71. 6DOF MPU-6050 3 Axis Gyro & Accelerometer ........................................................... 232 72. GPS XM37-1612 (GY-NEO6Mv2?) ...................................................................................... 240 73. MQ-3 alcohol gas sensor board ........................................................................................... 243 74. MQ-6 LPG, iso-butane and propane gas sensor ........................................................... 246 75. Load cells ...................................................................................................................................... 249 76. Load cell amplifier HX711 ..................................................................................................... 251 Storage ........................................................................................................................................... 255 77. SD Card .......................................................................................................................................... 257 78. Mifare RFID RC522 ................................................................................................................... 260 Real Time Clock ........................................................................................................................... 263 79. RTC module with DS1302 chip ........................................................................................... 265 80. Tiny RTC I2C module with DS1307 chip .......................................................................... 268 Servo’s, Motors & Steppers ................................................................................. 271 Arduino documentation 1.19 4

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 81. Standard Servo ........................................................................................................................... 273 82. DC/Stepper Motor Driver board L298n .......................................................................... 276 83. Stepper Motor 28BYJ-48 5V with ULN2003 Interface board ................................. 279 84. Adafruit TB6612 Stepper/motor driver ......................................................................... 282 85. Stepper motor NEMA-17 ........................................................................................................ 285 86. Floppy disc drive ....................................................................................................................... 286 Camera triggers ........................................................................................................................... 289 87. Selfmade trigger cable for Canon DSLR camera's ....................................................... 291 88. Selfmade trigger cable for Sony ILCE system camera ............................................... 292 89. Selfmade Canon CHDK/SDM trigger cable ..................................................................... 294 Wired communication .............................................................................................................. 301 90. SoftEasyTransfer communication between 2 Arduino’s .............................. 303 Wireless communication ......................................................................................................... 307 91. IR sensor (receive) .................................................................................................................... 309 92. IR sensor board (receive) ...................................................................................................... 312 93. Keyes IR sensor board (receive) ......................................................................................... 313 94. Various IR remote controls ................................................................................................... 314 95. IR LED (send) .............................................................................................................................. 319 96. 315/330/433 MHz RF Receiver XY-MK-5V ................................................................... 321 97. 433 MHz RF Transmitter FS1000A ................................................................................... 324 98. Silvercrest Wireless Socket set ............................................................................................ 326 99. Flamingo SF-500S/3 Wireless Socket set ....................................................................... 331 100. RF Wireless kit XY-DJM-5V ................................................................................................... 334 101. NRF24L01 2.4GHZ Wireles Transceiver ......................................................................... 336 102. Bluetooth Keyes BT_Board v2.0 .......................................................................................... 342 103. Bluetooth JY-MCU BT_Board v1.06 .................................................................................... 346 104. Bluetooth 4.0 BLE CC41A (CC2541) module ................................................................. 349 105. Keyes Bluetooth 4.0 BLE ........................................................................................................ 353 106. Adafruit Bluefruit LE UART Friend (BLE) ...................................................................... 356 107. GSM/GPRS SIM800L module ............................................................................................... 365 108. LoRa ................................................................................................................................................ 367 Shields ............................................................................................................................................ 369 109. Ethershield ................................................................................................................................... 371 110. USB Host shield .......................................................................................................................... 375 111. Arduino Sensor Shield v5.0 ................................................................................................... 379 112. Proto type shield ....................................................................................................................... 380 113. Nano sensor shield ................................................................................................................... 380 114. Arduino Mega Sensor Shield v 2.0 ..................................................................................... 381 115. Adafruit 2.8\" TFT Resistive Touch Shield v2 ................................................................. 382 116. 2.4” TFT LCD Shield Touch Board ................................................................................. 382 117. LoRa: Shield for HopeRF board ........................................................................................... 382 118. LoRa: Dragino-shield ............................................................................................................... 382 Grove ............................................................................................................................................... 383 119. Grove Base Shield for Arduino ............................................................................................ 385 120. Grove cable ................................................................................................................................... 387 121. Grove to 4 pin Male cable (selfmade) ............................................................................... 388 122. Grove LED Socket Kit v1.4 (=LED) ..................................................................................... 389 123. Grove Buzzer v1.2 (=piëzo speaker) .......................................................... 391 124. Grove Button v1.1 (=switch) ................................................................................................ 393 Arduino documentation 1.19 5

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 125. Grove Touch v1.1 ....................................................................................................................... 395 126. Grove Rotary Angle Sensor v1.2 (=potentiometer) .................................................... 397 127. Grove Light Sensor v1.1 (=LDR) ......................................................................................... 399 128. Grove Temperature Sensor v1.2 ......................................................................................... 401 129. Grove Temperature & Humidity Sensor v1.2 ................................................................ 403 130. Grove Sound Sensor v1.6 ....................................................................................................... 406 131. Grove Ultrasonic Ranger v2.0 (=distance sensor) ...................................................... 408 132. Grove Relay v1.2 ........................................................................................................................ 410 133. Grove LCD RGB Backlight v4.0 ............................................................................................ 412 134. Grove mini Servo ....................................................................................................................... 414 135. Grove Gesture v1.0 ................................................................................................................... 416 Isolation from higher voltages ............................................................................................... 421 136. Relay 5V board ........................................................................................................................... 423 137. 4x Relay 5V Board ..................................................................................................................... 426 138. Optocoupler MOC3023 ........................................................................................................... 430 Logical Level shifters ................................................................................................................. 433 139. 8-bit Logic Level Shifter 74LVC245 ................................................................................... 435 140. Adafruit 4 chan. I2C safe bi-directional Logic Level Convertor ............................ 436 141. 4 channel bi-directional Logic Level Convertor ........................................................... 437 Power supplies ............................................................................................................................ 439 142. Black Wings breadboard power regulator ..................................................................... 441 143. YuRobot breadboard power regulator ............................................................................ 442 144. ATX Power Supply (PSU) ....................................................................................................... 443 145. DC Step-Down Adjustable Power module ...................................................................... 444 146. DC to DC Step-Up Boost Power Supply with USB ....................................................... 445 147. DC to DC Step-Up Boost Power Supply with USB ........................................................ 446 USB to Serial adapters ............................................................................................................... 447 148. PL203HX USB to TTL Serial adapter ................................................................................. 449 149. P203HX USB to TTL Serial cable ......................................................................................... 450 150. CP2102 USB to TTL Serial adapter .................................................................................... 451 151. FTDI friend by AdaFruit (USB to TTL Serial adapter) ............................................... 452 152. FTDI FT232L USB to TTL Serial adapter ......................................................................... 454 153. Counterfeit FTDI FT232RL chips ........................................................................................ 456 Miscellaneous .............................................................................................................................. 465 154. Adafruit Thermal Printer CSN-A2-T ................................................................................. 467 155. Resistor .......................................................................................................................................... 470 156. Inverter 7404 .............................................................................................................................. 476 157. Shift register 74HC595 ........................................................................................................... 477 158. Solderless breadboard ............................................................................................................ 480 ESP8266 Wifi ................................................................................................................................ 481 159. Common ESP8266 .................................................................................................................... 483 160. Connection schemes for ESP8266 modules ................................................................... 485 161. Using AT commands ................................................................................................................ 487 162. Using Lua scripts ....................................................................................................................... 490 163. ESPlorer to use AT commands or LUA scripts .............................................................. 492 164. ESP8266 Firmware ................................................................................................................... 493 165. Programming ESP8266 with Arduino IDE ..................................................................... 498 166. ESP8266 as WiFi to Serial...................................................................................................... 500 167. ESP-module: ESP8266 ESP-01 ............................................................................................ 506 Arduino documentation 1.19 6

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 168. ESP-module: ESP8266 ESP-01 hack .................................................................................. 509 169. Module: USB to ESP-01 ........................................................................................................... 510 170. Module: USB to ESP-01 flash hack v1 ............................................................................... 511 171. Module: USB to ESP-01 flash hack v2 ............................................................................... 512 172. Module: USB to ESP-01 with flash switch ....................................................................... 513 173. Module: ESP-01 5V-3.3V adapter ....................................................................................... 514 174. Module: Open Smart ESP-01 to DIP .................................................................................. 515 175. Module: Open Smart ESP-01 to DIP Hack ....................................................................... 516 176. ESP-module: Adafruit HUZZAH ESP8266 breakout ................................................... 517 177. ESP-module: ESP8266 ESP-07 AI-Thinker .................................................................... 519 178. ESP-module: ESP8266 ESP-07 with IO Adapter Plate .............................................. 520 179. NodeMCU ESP-12E Doit Devkit ........................................................................................... 522 180. Sonoff T1 UK 1 gang ................................................................................................................. 524 ESP32 WiFi .................................................................................................................................... 531 181. TTGO ESP32 WiFi & Bluetooth Battery OLED .............................................................. 532 Raspberry Pi ................................................................................................................................. 535 182. Raspberry Pi ................................................................................................................................ 537 183. Raspberry Pi GPIO .................................................................................................................... 544 184. Sample scripts Raspberry Pi ................................................................................................. 547 185. HAT: Dragino Lora/GPS ......................................................................................................... 553 186. HAT: GrovePi+ ............................................................................................................................ 557 187. HAT: Raspberry pi to Arduino Shields Connection Bridge v1 ............................... 560 188. Add-ons for Raspberry Pi ...................................................................................................... 561 Mindstorms NXT ......................................................................................................................... 565 189. Mindstorms NXT-Brick ........................................................................................................... 567 190. Programming with NXC/NBC .............................................................................................. 569 191. Mindstorms and Arduino ....................................................................................................... 573 192. Mindstorms sensors with Arduino .................................................................................... 577 Non Arduino MCU Boards ........................................................................................................ 579 193. BBC Micro:bit .............................................................................................................................. 581 194. Adafruit Playground Express ............................................................................................... 588 The Things Network .................................................................................................................. 597 195. Basics The Things Network .................................................................................................. 599 196. Single Channel Gateway on Raspberry Pi (J.F. Telkamp) ......................................... 600 197. Single Channel Gateway on ESP8266 (Jaap Braam) .................................................. 606 198. Configuration of applications and devices at TTN ...................................................... 610 The Things Network Nodes .................................................................................................... 615 199. LoRa: RFM95W module .......................................................................................................... 617 200. LoRa: HopeRF Adapter board for RFM95W .................................................................. 620 201. LoRa: Shield for HopeRF board ........................................................................................... 622 202. LoRa: Dragino-shield ............................................................................................................... 626 203. LoRa: RN2483 module ............................................................................................................ 629 204. LoRa: RN2483 Enschede Nano breakout board .......................................................... 635 205. LoRa: Nexus as a TTN node ................................................................................................... 637 206. LoRa: Sodaq One as a TTN node ......................................................................................... 640 The Things Network Data Handling ..................................................................................... 649 207. Data handling .............................................................................................................................. 651 208. Data handling at the TTN Console ..................................................................................... 652 209. Data handling with TTNCTL ................................................................................................. 657 Arduino documentation 1.19 7

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 210. Data handling with MQTT ..................................................................................................... 659 211. Data handling with Node-red ............................................................................................... 661 Projects .......................................................................................................................................... 669 212. High Speed Photography........................................................................................................ 671 Links ................................................................................................................................................ 675 213. Web shops .................................................................................................................................... 677 214. Reference and tutorials .......................................................................................................... 679 215. Overview Libraries ................................................................................................................... 680 To Do ............................................................................................................................................... 683 216. Template Xx ................................................................................................................................. 685 Arduino documentation 1.19 8

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Introduction In this document I’ve described the basic use of some Arduino Boards, Software,Programmer/Programming and several components to be used as input or output devices.Most chapters consist of the following paragraphs: • Specifications Technical information needed when using this component. • Datasheet Links to datasheet(s) related to the component or parts of the component. • Connections Names, description and ports to be used on your Arduino • Libraries needed Download links to 3rd party libraries and names of the standard libraries to be used with this component • Library use explanation Description how to use the library to get you started. No in-depth explanation! • Sample Sample sketch and needed connections to test the component. For every component, the description is composed of all the information you need to getthings started. Use the sample sketch and your own creativity to build more complexsketches/projects.Arduino documentation 1.19 9



©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Version history This chapter describes changes made to this document:Ver. Changes Date May 8th1.0 First version shared 2014 Sep 14th1.1 • Added this Version History. • Added “28 Uploading the bootloader by using an Arduino as 2015ISP”. • Added “48 “Adafruit 2.8\" TFT Resistive Touch Shield v2” • Corrected some small typo’s. Sep 22nd1.11 • Added 49 “2.4” TFT LCD Shield Touch Board “ 2015• Changed the orientation of the “48 “Adafruit 2.8\" TFT Resistive Touch Shield v2”, thus simplifying the use of the library and the sample sketch. • Corrected some small typos. • Added links to datasheets for several components. • Added specifications for several components. • Correction made to both Bluetooth modules. A voltage divider has been added to the RxD port of the Bluetooth module, creating an input voltage of 3.3V instead of 5V. • Added an extra Sample to the Keyes Bluetooth module, Using D10 and D11 through SoftwareSerial. 1.12 • Correction made to “16.4 First time preparation of Arduino Nov 1st 2015IDE for Attiny45/85” for Arduino IDE 1.6.5. • Added “17 Attiny85 Digispark board”. • Added a sample of PWM output (LED fade sample) in: “34.4 Sample LED“. • Added “43 WS2812B RGB LED breakout-board” • Added “56 Nunchuk with connection board on A2..A5” • Added a Processing sample to Nunchuk in “56.3 Sample Nunchuk with connection board on A2..A5”. • Added “90 SoftEasyTransfer” • Added “94.6 IR Remote Control 4” • Added “101 NRF24L01 2.4GHZ Wireles Transceiver” • Moved Sections Wired and Wireless communication down, just before section Shields • Moved Section Isolation from higher voltages down, just before section Shields. • Added Section ESP8266 Wi-Fi. • Added Chapters for using the ESP8266. • Added Section “Raspberry Pi. • Added Section Mindstorms NXT in To-do. • Corrected a truckload of small typo’s Arduino documentation 1.19 11

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Ver. Changes Date1.13 • Finished Mindstorms NXT connection to Arduino (description Publishe of sample program and special connector). d at Nov.• Added description how to program the Boarduino. 29th 2015• Changed errors in pin diagram and sample connections for “41 4 Digits 7-Segment Display Common Cathode” • Changed errors in sample connections for “101 NRF24L01 2.4GHZ Wireles Transceiver” • Replaced RCSwitch library in “96 315/330/433 MHz RF Receiver XY-MK-5V” with Virtual Wire, so it is possible to Transmit text strings instead of codes. • Updated libraries and made changes to samples where needed. Most libraries were installed through Library Manager, some were replaced, some were updated to newer version. • Added a section about Arduino IDE • Added a chapter about Libraries • Added a chapter about board management • Added “215 Overview Libraries”, with a table showing all libraries used in this document. This way it is easier to maintain accessibility and to prevent 404-errors when following the links. FAILED • Added a chapter about the Serial Monitor. Sample sketches for both Output (from Arduino to computer) and Input (from computer to Arduino). • Added “178 ESP-module: ESP8266 ESP-07 with IO Adapter Plate”. • Added “179 NodeMCU ESP-12E Doit Devkit”. • Added description of the tool esptool-ck ESP8266 section. • Documented a problem with the USB-Serial cable with the PL203HX chip in combination with flashing firmware and uploading sketches to the ESP8266 modules. • Added remarks about maximum current per port Arduino. Dec. 30th1.14 • Added \"149 P203HX USB to TTL Serial cable\". 2015• Added \"150 CP2102 USB to TTL Serial adapter\". • Added \"152 FTDI FT232L USB to TTL Serial adapter\" • Added \"153 Counterfeit FTDI FT232RL chips\", describing the problem about bricking it and a solution to de-brick it. • Added \"44 WS2812B RGB LED strip\". Arduino documentation 1.19 12

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Ver. Changes Date1.15 • Re-added “215 Overview Libraries”, somehow this chapter Nov. 12thgot missing in version 1.14. 2016• Added pin diagram in Raspberry Pi Section • Added missing photo’s • Added \"200 LoRa: HopeRF Adapter board for RFM95W\" • Added \"202 LoRa: Dragino-shield\" • Added \"201 LoRa: Shield for HopeRF board\" • Added \"185 HAT: Dragino Lora/GPS\" • Added \"10 LoRa: Nexus\" • Added \"9 Teensy 3.1\" • Added \"46 16x2 Display 1602A\" • Added \"119 Grove Base Shield for Arduino\" • Added \"186 HAT: GrovePi+\" • Added \"120 Grove cable\" • Added \"121 Grove to 4 pin Male cable (selfmade)\" • Added \"122 Grove LED Socket Kit v1.4 (=LED)\" • Added \"123 Grove Buzzer v1.2 (=piëzo speaker)\" • Added \"124 Grove Button v1.1 (=switch)\" • Added \"125 Grove Touch\" • Added \"126 Grove Rotary Angle Sensor v1.2 (=potentiometer)\" • Added \"127 Grove Light Sensor v1.1 (=LDR)\" • Added \"128 Grove Temperature Sensor\" • Added \"129 Grove Temperature & Humidity Sensor\" • Added \"130 Grove Sound Sensor\" • Added \"131 Grove Ultrasonic Ranger v2.0 (=distance sensor)\" • Added \"132 Grove Relay v1.2\" • Added \"133 Grove LCD RGB Backlight\" • Added \"134 Grove mini Servo\" • Added \"135 Grove Gesture v1.0\" • Added \"110 USB Host shield\" • Added \"58 Playstation controller\" • Added \"106 Adafruit Bluefruit LE UART Friend (BLE)\" • Added A section for non-Arduino MCU boards. • Added \"193 BBC Micro:bit\" • Added a section about the Internet Of Things (IOT) for The Things Network, with instructions on how to configure an application at the TTN, build your own Single Channel Gateway and building a node. • Changed page layout so it can be printed double sided. Section starting at odd pages and a blank page break after the start of every section. Arduino documentation 1.19 13

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Ver. Changes Date Nov 1st1.17 • Added 6DOF MPU-6050 3 Axis Gyro With Accelerometer 2017 Sensor Module • Added separate sketches for working with switches: o External pulldown resistor o External pullup resistor o Intern pullup resistor • Added Logic Level Convertor bidirectional • Added Adafruit SPI/I2C save 5-3.3V level shifter • Added 74LVC245 5-3.3 level shifter • Added “3 Arduino Mega 2560 R3” • Added \"11 LoRa: Sodaq One\" in the Arduino Boards section • Added \"65 PIR/Motion Sensor HC-SR501\" • Added \"72 GPS XM37-1612 (GY-NEO6Mv2?)\" • Added \"73 MQ-3 alcohol gas sensor board\" • Added \"74 MQ-6 LPG, iso-butane and propane gas sensor\" • Changed stepper motor wire colors used in sample at \"84 Adafruit TB6612 Stepper/motor driver\" • Added \"84 Adafruit TB6612 Stepper/motor driver\" • Added \"85 Stepper motor NEMA-17\" • Added \"104 Bluetooth 4.0 BLE CC41A (CC2541) module\" • Added \"105 Keyes Bluetooth 4.0 BLE\" • Added \"107 GSM/GPRS SIM800L module\" • Adding “167 ESP-module: ESP8266 ESP-01” • Added \"197 Single Channel Gateway on ESP8266\" • Added \"206 LoRa: Sodaq One as a TTN node\" in The Things Network Nodes section. • Rearranged IOT section in three new sections o The Things Network o The Things Network Nodes o The Things Network Data Handling Arduino documentation 1.19 14

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Ver. Changes Date Nov 22nd1.18 • Added \"6 Sparkfun Pro Micro - 5V/16MHz\" 2017• Added \"7 Arduino Pro Mini ATmega168U 5v, 16MHz\" • Added \"8 Arduino Pro Mini ATmega328p 3.3V, 8MHz\" • Added \"60 RGB and Gesture sensor APDS-9960 \" • Added “114 Arduino Mega Sensor Shield v 2.0“ • Added “143 YuRobot breadboard power regulator” • Added \"169 Module: USB to ESP-01\" • Added \"170 Module: USB to ESP-01 flash hack\" • Added \"171 Module: USB to ESP-01 flash hack v2\" • Added \"172 Module: USB to ESP-01 with flash switch\" • Added “173 Module: ESP-01 5V-3.3V adapter” • Added “174 Module: Open Smart ESP-01 to DIP” • Added “175 Module: Open Smart ESP-01 to DIP Hack” • Replaced Photo from shield with Hope RF board, because orientation was not correct: \"201 LoRa: Shield for HopeRF board\" • Corrected Breakout pin-numbers in \"204 LoRa: RN2483 Enschede Nano breakout board\" • Changed order of the Section about ESP8266. Moved background chapters in front of description of ESP Modules. 1.19 • Added \"75 Load cells\" Jun 2018• Added \"76 Load cell amplifier HX711\" current• Added \"98 Silvercrest Wireless Socket set\" a 433 MHz set versionfrom 'Lidl' • Added \"99 Flamingo SF-500S/3 Wireless Socket set\" a 433 MHz Click-On/Click-Off set from 'Action' • Added \"180 Sonoff T1 UK 1 gang\" • Changed \"193.3 How to program the micro:bit\" • Added \"194 Adafruit Playground Express\" • Added \"187 HAT: Raspberry pi to Arduino Shields Connection Bridge v1\" • Added \"154 Adafruit Thermal Printer CSN-A2-T\" • Adding section for ESP32 Arduino documentation 1.19 15

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Ver. Changes Date1.20 • Add Photo’s: Nextdraft o Load cell 3 KG version o Load cell 10 kg o Silvercrest Wireless Socket + remote o Flamingo Wireless Socket + remote o Sonoff T1 UK 1 gang o Adafruit Playground Express o Raspberry pi to Arduino Shield o Adafruit Thermal Printer o HEF4050BP chip • Add MAX7219 chip • Add Sample sketch \"107 GSM/GPRS SIM800L module\" • Add Robbe Futaba FP-R118F 40 MHz FM receiver • Add Robbe Futaba 40 MHz transmitter • Add photo, library description, datasheet, specs for IR send • Add Laser module • Add Laser sensor board DS18820 • Add HEF4050BP Hex non-inverting buffer as a logic level converter from up to 15 V to standard TTL levels Arduino documentation 1.19 16

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Arduino Boards This section describes the Arduino boards I’ve been using, like the Arduino UNO, the NANO. I even added some boards that aren't real Arduino, like the Attiny45/85. All these boards can be programmed with the Arduino IDE. For each board you will find specifications, connections and protocols. Arduino documentation 1.19 17

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Arduino documentation 1.19 18

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 1. Arduino “ARDUINO IS AN OPEN-SOURCE ELECTRONICS PROTOTYPING PLATFORM BASEDON FLEXIBLE, EASY-TO-USE HARDWARE AND SOFTWARE. IT'S INTENDED FORARTISTS, DESIGNERS, HOBBYISTS AND ANYONE INTERESTED IN CREATINGINTERACTIVE OBJECTS OR ENVIRONMENTS1”Since Arduino is Open Source, the CAD and PCB design is freely available. Everyone canbuy a pre-assembled original Arduino board2 or a cloned board from another company. Youcan also build an Arduino for yourself or for selling. Although it is allowed to build and sellcloned Arduino boards, it’s not allowed to use the name Arduino and the corresponding logo.Most boards are designed around the Atmel Atmega328.1.1. Popular Arduino boards There are several different Arduino boards on the market (both original and cloned). • Arduino UNO o Most popular board. Ideal for starters. o Standard USB for data and power and programming. o Power Input connector. o female headers. o 14 digital I/O ports (of which 6 PWM). o 6 analog input ports. o 1 hardware serial port (UART). • Arduino Nano o Much smaller than the UNO (only 18x43 mm). o Mini USB for data and power and programming. o Input 6-20 V on Vin (6-12 recommended). o Male headers at the bottom side, so ideal to use on a solder less breadboard. o 14 digital I/O ports (of which 6 PWM). o 8 analog input ports. o 1 hardware serial port (UART). • Arduino Mini o Smallest Arduino board, used in small sized projects. o No USB connector, you need a USB to TTL Serial convertor to program it. o No separate power connector (you must use +9V header pins) o Input 7-9 V. o Male headers at the bottom side, so ideal to use on a solder less breadboard. o 14 digital I/O ports (of which 6 PWM). o 8 analog input ports (4 of them are not connected to header pins). o No hardware serial port (UART). 1 Quote from the arduino.cc website. 2 Most original Arduino boards are made by SmartProjects in Italy. The Arduino Pro, Lilypad and Pro Mini are made and designed by Sparkfun in the US. The original Arduino Nano is build by Gravitech. Arduino documentation 1.19 19

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino • Arduino Mega o Largest Arduino board for large number of I/O ports. o Normal size USB for data and power and programming. o Power input connector. o Input 6-20 V (7-12 recommended). o Female headers at the top side. o 54 digital I/O ports (of which 15 PWM). o 16 analog input ports. o 4 serial ports. Arduino documentation 1.19 20

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 1.2. Connections The following connections are available on most Arduino boards. Differences can be found inthe number of Digital I/O and Analog Inputs.Common connections Name DescriptionGND Ground5V Regulated 5V output Regulated 5V input (not recommended)3.3V Regulated 3.3V output (from FTDI)VIN Non-regulated input (6-12 V)RESETIOREFAREFDx Digital Input/Output. Two values: LOW, HIGHDx~ Digital Input/Output PWM. Values: 0..255 through PWM (Pulse Width Modulation)Ax Analog Input. Values: 0..1023Shared connections Shared with DescriptionName D0 TTL Serial ReceiveRX D1 TTL Serial TransmitDX D13 SPI Serial ClockSCK D12 SPI Master In Slave OutMISO D11 SPI Master Out Slave InMOSI D10 SPI Slave SelectSS A4 I2C / TWI DataSDA A5 I2C / TWI ClockSCLICSP header All SPI headers are also available on a separate double row of header pins. GND 6 5 RST MOSI 4 3 SCK +VCC 2 1 MISO ICSP Arduino documentation 1.19 21

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 2. Arduino UNO R3 2.1. Specifications Atmega328Microcontroller 7-12 V recommended, 6-20 V limitsOperating Voltage 14 (of which 6 PWM)Digital I/O pins 6Analog input pins 40 mADC current per I/O pin 50 mADC current for 3.3V pin 32 KBFlash memory Atmega16U2USB to TTL Serial converter 1UART available3VThe following remarks were made by user ‘68ths’ on the Arduino Forum: One regret: you indicate Imax = 40 mA per pinThis is what is indicated on the Arduino website but it is absolutely not in line with Atmel's datasheet.Datasheet :40 mA are \"Absolute Maximum Rating\".QuoteStresses beyond those listed under \"Absolute Maximum Ratings\" may cause permanent damage to the device. This is a stress ratingonly and functional operation of the device at these or other conditions beyond those indicated in the operational sections of thisspecification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.The value indicated by Atmel in continuous operation only 20 mA per pin.And simultaneously:- max 200 mA on Vcc --> max current in the bondings- max 200 mA on GND --> max current in the bondings- max 150 mA per portSo it is unthinkable to use more than three or four outputs simultaneously at 20 mA.It is not finished :With a current of 20 mA and @ 25 ° C, high level is no longer 5V but 4.5V ( ohm law apply to Rdon)and the low level is not 0V but + 0,5V.These results are degraded when the chip temperature increases.I think it is necessary to advise beginners on this subject.Arduino documentation 1.19 22

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 2.2. Layout/connections Arduino UNO R3 32 SCL 31 SDA 30 AREF 29 GND ? 1 28 D13 S PI SCK o nboard LED IOREF 2 27 D12 SPI MISO RESET 3 26 D11~ SPI MOSI 3.3V 4 25 D10~ SPI SS 5V 5 24 D9~ GND 6 Atmega328 23 D8 GND 7 Vin 8 2 2 D 7 21 D6~ A0 9 20 D5~ A1 10 19 D4 RST SDA A2 11 SCK 18 D3~ I RQ 1 SCL MISO A3 12 17 D2 IRQ 0 A4 13 5 3 1 ICSP 16 D1 TTL serial Tx A5 14 6 4 2 15 D0 TTL serial Rx GND MOSI +VCC 2 .3. Program m in g a ske tch on the Arduin o U NO Follow the following steps to program an Arduino UNO:• Connect your Arduino UNO to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the ARDUINO UNO. • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. Arduino documentation 1.19 23

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 3. Arduino Mega 2560 R3 3.1. Specifications Arduino Mega 2560 R3 Microcontroller Atmega2560Clock Speed 16 MHzOperating Voltage 7-12 V recommended, 6-20 V limitsDigital I/O pins 54 (of which 15 PWM)Analog input pins 16DC current per I/O pin 20 mADC current for 3.3V pin 50 mAFlash memory 256 KBUSB to TTL Serial converter Atmega16U2UART 43V AvailableExternal Interrupts 53.2. Layout/connections Arduino Mega 2560R3 Arduino documentation 1.19 24

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 3.3. Programming a sketch on the Arduino Mega 2560 R3 Follow the following steps to program an Arduino Mega: • Connect your Arduino Mega to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the ARDUINO Mega. • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. Arduino documentation 1.19 25

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 4. Arduino Mega 2560 R3 CH340 4.1. Specifications Arduino Mega 2560 R3 CH340 Microcontroller Atmega2560Clock Speed 16 MHzOperating Voltage 7-12 V recommended, 6-20 V limitsDigital I/O pins 54 (of which 15 PWM)Analog input pins 16DC current per I/O pin 20 mADC current for 3.3V pin 50 mAFlash memory 256 KBUSB to TTL Serial converter CH340UART 43V AvailableExternal Interrupts 54.2. Layout/connections Arduino Mega 2560R3 CH340 Arduino documentation 1.19 26

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 4.3. Programming a sketch on the Arduino Mega 2560 R3 CH340 Follow the following steps to program an Arduino Mega: • Connect your Arduino Mega to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the ARDUINO Mega. • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. Arduino documentation 1.19 27

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 5. Arduino Nano 5.1. Specifications Arduino Nano Be careful not to buy an adapter with a counterfeit FTDI chip1 Microcontroller Atmega328Operating Voltage 7-12 V recommended, 6-20 V limitsDigital I/O pins 14 (of which 6 PWM)Analog input pins 8DC current per I/O pin 40 mADC current for 3.3V pin 50 mAFlash memory 32 KBUSB to TTL serial convertor FTDI FT232RLUART 13.3V Only available through FTDI, so only when powered through USB!5.2. Layout/connections Arduino Nano onboard LED SPI SCK D13 1 30 D12 SPI MISO 3.3V 2 29 D11~ SPI MOSI AREF 3 28 D10~ SPI SS A0 4 27 D9~ A1 5 26 D8 25 D7 A2 6 24 D6~ A3 7 23 D5~ SDA A4 8 22 D4 SCL A5 9 21 D3~ I RQ 1 A6 10 20 D2 IRQ 0 A7 11 19 GND 5V 12 +VCC 18 RESET RESET 13 MOSI 17 D0 TTL serial Rx GND 16 D1 TTL serial Tx GND 14 2 4 6 ICSP Vin 15 1 3 5 MISO SCK RST 1 FTDI is fighting a war against counterfeit chips, in chapter \"153 Counterfeit FTDI FT232RL chips\" you'll find information about this problem and possible solutions. Arduino documentation 1.19 28

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 5.3. Programming a sketch on the Arduino Nano Follow the following steps to program an Arduino Nano: • Connect your Arduino Nano to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the ARDUINO NANO. • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. Arduino documentation 1.19 29

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 6. Sparkfun Pro Micro - 5V/16MHz This is a very small Arduino and it even comes with real USB port than can be programmedto act as a HID (like a keyboard, mouse, joystick or MIDI device).6.1. Specifications Sparkfun Pro Micro - 5V/16MHz Microcontroller Atmega32U4 16 MHzOperating Voltage 5-12 V recommendedDigital I/O pins 12 (of which 5 PWM)Analog input pins 9 these pins are also digital I/OFlash memory 32 KBUSB to TTL serial convertor ATmega32U4UART 1Onboard user LED noneHardware interrupts 5DC current I/O pins 10mA (5 recommended) 150mA entire package6.2. Layout/connections Sparkfun Pro Micro - 5V/16MHz 6.3. First time preparation of Arduino IDE for Sparkfun Pro Micro - 5V/16MHz This section describes how to add support for the Attiny45/85 to the Arduino IDE. Moredetails can be found at: https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide. • Open Arduino IDE and go to FILE, PREFERENCES. • Cut and paste the following link in the box ADDITIONAL BOARDS MANAGER URL’S. (You can add multiple links here, by using a ‘;’ as separator. https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Boa rd_Manager/package_sparkfun_index.json • Close PREFERENCES by clicking on the OK button. Arduino documentation 1.19 30

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino • Go to TOOLS, BOARD, BOARDS MANAGER. • Search for Pro Micro (this could take a few seconds) and select the SPARKFUN AVR BOARDS BY SPARKFUN ELECTRONICS. • Click on the INSTALL button • Press the CLOSE button. • Sparkfun Pro Micro is now listed at TOOLS, BOARD 6.4. Programming a sketch on the Sparkfun Pro Micro - 5V/16MHz Follow the following steps to program an Pro Micro: • Connect your Pro Micro to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the SPARKFUN PRO MICRO. • Choose TOOLS, PROCESSOR, then select ATMEGA32U4 (5V , 16MHz) don't choose the default 3.3V, 8MHz, or you will damage the bootloader.1 • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. 1 After damaging the bootloader, the USB port was not recognized any more. By using an USB to ISP programmer I was able to upload the bootloader again with the Arduino IDE. Arduino documentation 1.19 31

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 7. Arduino Pro Mini ATmega168U 5v, 16MHz This board is about the same size as the Sparkfun Pro Micro, but it lacks an USB to TTLSerial adapter.7.1. Specifications Arduino Pro Mini ATmega168U 5v, 16MHz Microcontroller Atmega168U 16 MHzOperating Voltage 5,5-12 V recommendedDigital I/O pins 14 (of which 6 PWM)Analog input pins 8Flash memory 16 KBUSB to TTL serial convertor noneUART 1Onboard user LED D13Hardware interrupts 22DC current I/O pins 40mA (20 recommended) 200mA entire package (150mA when RAW powered)7.2. Layout/connections Arduino Pro Mini ATmega168U 5v, 16MHz Arduino documentation 1.19 32

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 7.3. Programming a sketch on the Arduino Pro Mini ATmega168U 5v, 16MHz Follow the following steps to program an Pro Micro: • Make the following connections between an USB to TTL Connect your Pro Micro to your computer using an USB to TTL Serial adapter (any will do). • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the Arduino Pro or Pro Mini. • Choose TOOLS, PROCESSOR, then select ATMEGA168U (5V , 16MHz). • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. • Press and release the reset button during compilation, but before the sketch gets uploaded. Arduino documentation 1.19 33

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 8. Arduino Pro Mini ATmega328p 3.3V, 8MHz This board is about the same size as the Sparkfun Pro Micro, but it lacks an USB to TTLSerial adapter.8.1. Specifications Arduino Pro Mini ATmega328p 3.3V, 8MHz Microcontroller Atmega328p 8 MHzOperating Voltage 3,5-12 V recommendedDigital I/O pins 14 (of which 6 PWM)Analog input pins 8Flash memory 32 KBUSB to TTL serial convertor noneUART 1Onboard user LED D13Hardware interrupts 22DC current I/O pins 40mA (20 recommended) 200mA entire package (150mA when RAW powered)8.2. Layout/connections Arduino Pro Mini ATmega328p 3.3V, 8MHz 8.3. Programming a sketch on the Arduino Pro Mini ATmega328p 3.3V, 8MHz Follow the following steps to program an Pro Micro: • Make the following connections between an USB to TTL Connect your Pro Micro to your computer using an USB to TTL Serial adapter (any will do). • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the Arduino Pro or Pro Mini. • Choose TOOLS, PROCESSOR, then select ATMEGA328 (3.3V , 8MHz). • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. • Press and release the reset button during compilation, but before the sketch gets uploaded. Arduino documentation 1.19 34

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Arduino documentation 1.19 35

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 9. Teensy 3.1 & 3.2 Teensy is not an Arduino, but can be programmed through the Teenduino add-on for ArduinoIDE. Although the Teensy is much smaller than most Arduino's, it is much more powerful. Itis faster, has more memory (FLASH and RAM), more pins, more interrupts and it even comeswith an USB port than can be programmed to act as a HID (like a keyboard, mouse, joystickor MIDI device).9.1. Specifications Teensy 3.1 & 3.2 Microcontroller MK20DX256VLH7, Cortex-M4, 72 MHz (overclockable: 96 MHz)Operating Voltage 3.3 V (5V tolerant)Vin Teensy 3.1: 3.7V to 5.5V Teensy 3.2: 3.6V to 6.0VFlash memory 256 KBRAM 64 KBEEPROM 2 KBDMA 16 channelsDigital IO 34 pins (12 PWM)Analog Input 21 pins/16 bits (12 touch sensing)Analog output 1 pin / 12 bitsUSB (HID) 1Serial (UART) 3SPI 1I2C 2CAN bus 1Onboard LED port 13Power regulator Teensy 3.1: 100mA Teensy 3.2: 250 mA (powerful enough to feed an ESP8266)Arduino documentation 1.19 36

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino Connections Teensy 3.1 & 3.2 This picture is for the Teensy 3.1. There are 2 differences between version 3.1 & 3.2, that isthe better power regulator for the latter, capable of delivering more current and working witha broader input voltage range.9.2. FIrst time preparation Arduino IDE Before you can use your Teensy with the Arduino IDE, you first need to install theTeensyduino add-on to the Arduino IDE. You can find a tutorial a t the following URL:http://www.pjrc.com/teensy/td_download.htmlAt this moment Teensyduino only has beta support for Arduino IDE 1.6.12. This will soon befixed I hope.During the install of Teensyduino you can select which modified libraries you want to installto be used with the Teensy.Arduino documentation 1.19 37

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 9.3. Programming a sketch on the Teensy Sincy the Teensy can be programmed with HID functionality, programming can be difficultsome times. For example, if your Teensy was programmed to move your mouse in circles, itcan be very difficult to move the mouse pointer to the Upload button. Therefore follow thefollowing steps when you need to program your Teensy. 1. Move the cursor to an empty line below the last line of code you are working on. 2. Select the correct Teensy board in the Arduino IDE, through TOOLS, BOARD. 3. If you are using HID functionality (like keyboard, mouse etc..) choose the correct USB type through TOOLS, USB TYPE. Your sketch will not compile correctly, if you omit this step and you will see the following message: sketch_oct17b:7: error: 'Keyboard' was not declared in this scope To make a USB Keyboard, use the Tools > USB Type menu Keyboard.println(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\"); ^ 'Keyboard' was not declared in this scope 4. You don't need to select a port, since the Arduino IDE is calling for Teensyduino and not a USB to serial device. Teensyduino is using other techniques to upload the code to your Teensy. 5. Connect your Teensy and immediately press the program button on your Teensy. This is to prevent the HID functionality (that could've been programmed in the Teensy) to come in action. Arduino documentation 1.19 38

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 6. Press the UPLOAD button. After compiling, Arduino IDE will call Teensyduino to upload the compiled sketch to the Teensy, reboot the Teensy, and the sketch will start running. That's why it is nice to have your cursor somewhere below the last line of code. 7. To stop this code from running, perform the following steps: a. Click on the AUTO button in Teensyduino so it will be grayed out. b. Press the Program button on your Teensy. 8. After modifying your code, repeat from step 6. Summary: 1. Cursor on empty line. 2. TOOLS, BOARD, Teensy … 3. TOOLS, USB Type, …. 4. Leave Port as is. 5. Connect Teensy and immediately press program button 6. Press Upload 7. Stop code from running: a. Click on AUTO button in Teensyduino b. Press Program button on Teensy 8. Repeat from step 6 after modifying your sketch. 9.4. Compatiblity Arduino Libraries Use the following link to check a list of compatible Arduino libraries.https://www.pjrc.com/teensy/td_libs.html9.5. HID Samples You can program the Teensy with almost the same sketches as a real Arduino. The maindifference between a Teensy and an Arduino is the HID functionality. You can program theTeensy to act as a keyboard, mouse, joystick etc..This paragraph contains two samples in which the Teensy is programmed as a HID.Keyboard sample The following code will type the text \" Lorem ipsum dolor sit amet.\" every 5 seconds.Arduino documentation 1.19 39

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino • Copy the code below. • Make sure to select a USB type that includes keyboard functionality (TOOLS, USB TYPE, …). • Upload sketch (see previous paragraph about programming the Teensy). More about using the Teensy as a keyboard device can be found at: https://www.pjrc.com/teensy/td_keyboard.htmlvoid setup(){}void loop(){ Keyboard.println(\"Lorem ipsum dolor sit amet.\"); delay(5000);}Mouse sample • The following code moves your mouse in a square and repeats this every 5 seconds. • Make sure to select a USB type that includes mouse functionality (TOOLS, USB TYPE, …). • Upload sketch (see previous paragraph about programming the Teensy). More about using the Teensy as a mouse device can be found at: https://www.pjrc.com/teensy/td_mouse.htmlvoid setup(){}void loop(){ Mouse.move(0, 127); delay(1000); Mouse.move(127, 0); delay(1000); Mouse.move(0, -127); delay(1000); Mouse.move(-127, 0); delay(5000);}Arduino documentation 1.19 40

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 10. LoRa: Nexus This specialized board was developed by Ideetron in The Netherlands and is based on anArduino Mini and a RFM95W or RFM98W LoRa module.10.1. Specifications LoRa Nexus Atmega328P-AUMicrocontrollerOperating Voltage 14Digital I/O pins 8Analog input pins 32 KB / 2 MB??Flash memory noneUSB to TTL serial convertor 1UART U.Fl antenna connectorSpecial connectors RFM95W or RFM98WLoRa module10.2. Layout/connections LoRa Nexus J1 J3 J2 U.FL GND A0 1 1 3 5 1 R ESET 3.3V A1 2 0 2 D2 I RQ 0 AREF SDA A2 3 A3 4 3 D3~ IRQ 1 SCL A4 5 4 D4 A5 6 5 D5~ A6 7 6 D6~ TTL serial Rx A7 8 7 D7 TTL serial Tx D0 9 8 D8 D1 10 9 D9~ o nboard LED 3.3V 11 10 D10~ SPI SS PWR 12 6 11 D11~ SPI MOSI GND 13 12 D12 SPI MISO J4 13 D13 SPI SCK 5 4 3 2 1 RTS# RxD TxD +3.3V nc GND FTDI GREE YELN LO ORWA N RGEE D nc BLAC K Arduino documentation 1.19 41

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 1 0.3. Datasheets Nexus http://webshop.ideetron.nl/Files/3/1000/1211/Attachments/Product/4778I8m8OV005G7UF6f3815000Fu1Z48.pdfDatasheet RFM95W http://webshop.ideetron.nl/Files/3/1000/1211/Attachments/Product/38C8M4K5j578I7Go79331xub2L8Dr2Al.pdf10.4. Connections between RFM95W and Nexus The RFM95W is presoldered on the back of the Nexus board and according to the datasheetof the Nexus, the following Nexus pins are used.Pin nr Name Description Nexus pin1 GND GND2 MISO Ground D123 MOSI SPI Data output D114 SCK D135 nSS SPI Data input D106 RST RST7 DIO5 SPI Clock input D68 GND SPI Chip Select input GND9 ANT n.a.10 GND Reset trigger input GND11 DIO3 Digital I/O software n.c.12 DIO4 Ground n.c. Antenna13 3.3V 3.3V14 DIO0 Ground D415 DIO1 Digital I/O software D5 configured16 DIO2 D7 Digital I/O software configured Power Supply Digital I/O software configured Digital I/O software configured Digital I/O software configured10.5. Programming a sketch on the Nexus Follow the following steps to program an Nexus: • Connect your Nexus to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the ARDUINO PRO OR PRO MINI. • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. Arduino documentation 1.19 42

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11. LoRa: Sodaq One This board is based on Sodaq's Autonomo 32 bits Arduino compatible platform. It comeswith a presoldered LoRa RN2483 module, a solar charge controller a GPS module an even aAccelerometer/Magnetometer. It runs on either a LiPo battery, or on USB power.More information about the Sodaq One, can be found at the following URL: • http://support.sodaq.com/sodaq-one/ 11.1. Specification LoRa: Sodaq One Description Sodaq ONE v1 Sodaq ONE v2Microcontroller ATSAMD21G18, 32-Bit ARM Cortex M0+ Arduino MO compatible same as v1Clock Speed 48 MHzOperating Voltage 3.3V same as v1Power Supply USB (5V) or LiPo (3.7V) same as v1Charging Solar Panel Charging controller, up to 500 same as v1 mA charge CurrentDigital I/O pins 14, all can be used for digital and analog with same as v1 PWM, UART, SPI and TWI (I2C)Internal I/O ports 8 same as v1External Interrupts All 14 pins same as v1Analog Input 10-bit DAC same as v1DC current per I/O pin 7mA same as v1Flash memory 256 KB same as v1LED RGB LED same as v1Lora Reset line Not connectAntenna connector U.Fl or SMA ConnectedLoRa module RN2483 868/433 or 915 MHz same as v1GPS module uBlox EVA-7M RN2483Other modules 868 or 915 LSM303D MHz Accelerometer/Mangetometer uBlox EVA- 8M LIS3DE AccelerometerArduino documentation 1.19 43

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.2. Layout/connections LoRa: Sodaq One 3.7V Li-ion battery + 1 3.3V Output (1A GND 2 Micro USB 24 max) Solar Panel + (6V 23 GND max) 3 22 D11/A11 External Switch 4 21 D10/A10 3.7V Li-ion battery + 5 20 D9/A9 RESET 6 19 D8/A8 18 D7/A7 17 D6/A6 16 SCL 15 SDA SWCLK 7 14 D3/A3 13 D2/A2 SWDIO 8 TX D12/A12 9 RX D13/A13 10 D0/A0 11 DAC D1/A1 12 Antenna AREF Next to these external pins, the Sodaq One also has 8 extra internal I/O portsName Internal Definition in DescriptionRed LED Pin/Port Arduino IDEGreen LED D14 LED_RED Set this pin LOW to turnBlue LED ON the RED LEDGPS Timepulse OUTPUT LED_GREEN Set this pin LOW to turnGPS Switch ON the Green LEDUser Button D15 LED_BLUE Set this pin LOW to turnPower Enable ON the Blue LEDExternal Switch OUTPUT GPS_TIMEPULSE D16 GPS_ENABLE Set this pin high turn on BUTTON the GPS module OUTPUT ENABLE_PIN_IO High when not pressed, D17 low when pressed INPUT SWITCH_SENSE Used to sense the position of an external D18 switch connected between the External OUTPUT Switch pin and the battery. D19 INPUT D22 OUTPUT D23 INPUTArduino documentation 1.19 44

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.3. Layout/connections Sodaq One Base Board You can use the Sodaq One directly on a breadboard leaving, or use the Sodaq One BaseBoard. • 7 Grove compatible connectors exposing all 14 I/O pins o 2x I2C o 4x digital/analog port couples (0/1, 2/3, 6/7 and 8/9) o 1x Tx/Rx • Solar panel connector • LiPo connector (3.7V) • Power switch • Reset switch Solar LiPo 1 1 30 30 I2C 2 2 29 29 8/9 3 3 28 28 4 4 27 27 5 5 26 26 I2C 6 6 Sodaq One 25 25 6/7 7 7 24 24 8 8 23 23 9 9 22 22 Tx/Rx 10 10 21 21 2/3 11 11 20 20 12 12 19 19 0/1 P ow er Re set Arduino documentation 1.19 45

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.4. Datasheets Sodaq One schematics • http://support.sodaq.com/sodaq-one/schema-sodaq-one/ RN2483 LoRa module • The datasheet for the RN2483 can be found at: http://www.farnell.com/datasheets/1947946.pdf?_ga=1.80085719.1148387527 .1482060915 • Command reference guide: http://ww1.microchip.com/downloads/en/DeviceDoc/40001784B.pdf • Several other interesting documents can be found at: http://www.microchip.com/wwwproducts/en/RN2483 Sodaq One v1 module • LSM303D Acceleromter/ magnetometer o https://www.pololu.com/file/download/LSM303D.pdf?file_id=0J703 • uBlox EVA-7M o https://www.u-blox.com/sites/default/files/products/documents/EVA- 7M_DataSheet_(UBX-13000581).pdf Sodaq One v2 modules • LIS3DE Accelerometer (Soda o http://www.st.com/content/ccc/resource/technical/document/datashee t/group3/10/aa/64/5a/f1/cc/49/7f/DM00066267/files/DM00066267.p df/jcr:content/translations/en.DM00066267.pdf • uBlox EVA-8M o https://www.u-blox.com/sites/default/files/EVA-8M_DataSheet_(UBX- 16009928).pdf 11.5. First time preparation of Arduino IDE for Sodaq One This section describes how to add support for the Sodaq One to the Arduino IDE. Moredetails can be found at: http://support.sodaq.com/sodaq-one/#one-vs-one-v2 in the section\"Setting up your Arduino IDE\". • Open Arduino IDE and go to FILE, PREFERENCES. • Cut and past the following link in the box ADDITIONAL BOARDS MANAGER URL’S. (You can add multiple links here, by using a ‘;’ as separator. ) http://downloads.sodaq.net/package_sodaq_index.json • Close PREFERENCES by clicking on the OK button. • Go to TOOLS, BOARD, BOARDS MANAGER. • Search for Sodaq (this could take a few seconds) and select the SODAQ SAMD BOARDS BY SODAQ. • Click on the INSTALL button • Press the CLOSE button. • Sodaq One is now listed at TOOLS, BOARD. Arduino documentation 1.19 46

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.6. Programming a sketch on the Sodaq One Follow the following steps to program a Sodaq One: • Connect your Sodaq One to your computer using an USB cable. • Load the sketch you want to compile and upload. • Choose TOOLS, BOARD, then select the SODAQ ONE. • Choose TOOLS, PROGRAMMER, AVRISP mkll. • Choose TOOLS, SERIAL PORT, then select the correct Serial Port • Choose FILE, UPLOAD. Arduino documentation 1.19 47

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.7. Sample Sodaq One: RGB LED1 The following sketch shows how to use the onboard RGB LED. These LED's are connectedto D14, D15 and D16 and can be addressed with the predefined variables LED_RED,LED_GREEN and LED_BLUE.The LED's are active when the corresponding lines are LOW.void setup(){ pinMode(LED_RED, OUTPUT); pinMode(LED_GREEN, OUTPUT); pinMode(LED_BLUE, OUTPUT);}void loop(){ digitalWrite(LED_RED, LOW); digitalWrite(LED_GREEN, HIGH); digitalWrite(LED_BLUE, HIGH); delay(500); digitalWrite(LED_RED, HIGH); digitalWrite(LED_GREEN, LOW); digitalWrite(LED_BLUE, HIGH); delay(500); digitalWrite(LED_RED, HIGH); digitalWrite(LED_GREEN, HIGH); digitalWrite(LED_BLUE, LOW); delay(500);}1 The original script was copied from the Sodaq website and can be found at: http://support.sodaq.com/sodaq-one/ at SODAQ ONE, TUTORIALS. Arduino documentation 1.19 48

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.8. Sample Sodaq One: Serials The Sodaq One has 3 hardware serials: • SerialUSB is connected to your computer through the USB cable. Opening the serial monitor will not reset the sketch. You could use the following code to wait for the serial monitor to open. while ((!SerialUSB) && (millis() < 30000)) {} • Serial is connected to pin D12/A12/TX and D13/A13/RX. • Serial1 is connected to the RN2483 LoRaWan module and is used to send commands to the RN2483. The following sketch prints the text \"Hello, World\" to the serial monitor.void setup(){ SerialUSB.begin(9600);}void loop(){ SerialUSB.println(\"Hello, world!\"); delay(1000);}Most sketches found on the Internet, use Serial instead of SerialUSB for writing to the serialmonitor. By adding the line #define Serial SerialUSB to those sketches, you can usethem with your Sodaq One.#define Serial SerialUSBvoid setup(){ Serial.begin(9600);}void loop(){ Serial.println(\"Hello, world!\"); delay(1000);}Arduino documentation 1.19 49

©Erik Verberne ([email protected]) http://bit.ly/eve_arduino 11.9. Sample Sodaq One: Sample Button1 On top of the Sodaq One, there is a user button. This button is no a reset button, but isconnected to the internal port D19 and can be addressed with the predefined variableBUTTON. This button is connected to an internal pull-up resistor, so it is LOW when pressed.void setup(){ pinMode(BUTTON, INPUT_PULLUP); pinMode(LED_GREEN, OUTPUT);}void loop(){ int sensorVal = digitalRead(BUTTON); if (sensorVal == HIGH) { digitalWrite(LED_GREEN, HIGH); } else { digitalWrite(LED_GREEN, LOW); }}1 The original script was copied from the Sodaq website and can be found at: http://support.sodaq.com/sodaq-one/ at SODAQ ONE, TUTORIALS. Arduino documentation 1.19 50


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook