Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started with ESP8266

Getting Started with ESP8266

2016年3月26日に開催された、わんくま同盟 福岡勉強会 #36で話した「ESP8266をはじめよう」のスライドです。

Keiichiro

March 29, 2016
Tweet

More Decks by Keiichiro

Other Decks in Technology

Transcript

  1. &41ͱ͸ʁ ্ւͷϑΝϒϨε൒ಋମϝʔΧʔ&TQSFTTJG4ZTUFNT͕ ੡଄͍ͯ͠Δ8J'JϞδϡʔϧͷνοϓηοτٴͼͦͷγϦʔζ &41&9DIJQTFU w 5$1*1ϓϩτίϧελοΫ౥ࡌCJU.$6 w ΞʔΩςΫνϟ3*4$ %JBNPOE4UBOEBSE.JDSP$PSF 

    w ΫϩοΫ.)[ w 3".,# ໋ྩ༻ ,# σʔλ  w 8J'J45" "1 45" "1 w *&&&CHO 81"81" w CJU"%$XJUI)41* 4%*0 6"35 18. *$ BOE*4
  2. ͦ͜ʹొ৔ͨ͠ٹੈओ IUUQFTQSFTTJGDPNFOQSPEVDUTXSPPN &418300. ೥ʹൢച։࢝͞Εͨ &418300.͸ '$$ $& ,$$ 5&-&$ -$*&

     8J'J"MMJBODF$FSUJpDBUJPO ٕద௨ͬͯΔʂ ೔ຊࠃ಺Ͱ໰୊ͳ͘࢖͑Δ ͷͰɺ͜ΕΛ࢖ͬͯΈΑ͏
  3. ଞͷࣅͨ΋ͷͱൺֱ "SEVJOP6/0 NCFE -1$ 3BTQCFSSZ1J &418300. ஋ஈ ԁ͘Β͍ ԁ͘Β͍ "

    ʙ# ԁʙԁ #SFBLPVU#PBSE ʙԁ *0 (1*0     ػೳ 6"35*$41* 18. γʔϧυͰ֦ு 6"35*$41* 18.$"/-"/ 64#ͳͲ 6"35*$41* 18.-"/64# ιϑτͰ৭ʑ 6"35*$*4 41*4%*018. *38J'J ϙςϯγϟϧ େࡶ೺ʹ ;ͭ͏ ͪΐͬͱͭΑ͍ ௒ͭΑ͍ ͭΑ͍ ೉͍͠ʁ ͔ΜͨΜ ͪΐͬͱ೉͍͠ ;ͭ͏ ΘΓͱ͔ΜͨΜ ເ޿͕Δʁ ͓ษڧ༻ Ћ ࢖͍͜ͳͤͨΒ ޿͕Γ·͘Γ ͑ͬɺ͜ͷ஋ஈʜ ͍Ζ͍Ζͳ෺ʹ ૊ΈࠐΜͰωοτ ʹܨ͗ͨ͘ͳΔʂ ˞ݸਓͷײ૝Ͱ͢
  4. Ͳ͜Ͱങ͑Δͷʁ ळ݄ిࢠ௨঎ w8J'JϞδϡʔϧ&418300.%*1ԽΩοτʜԁ ੫ࠐ  IUUQBLJ[VLJEFOTIJDPNDBUBMPHHH, εΠοναΠΤϯε w&418300.ϐονม׵ࡁΈϞδϡʔϧʜԁ ੫ࠐ 

    IUUQTXXXTXJUDITDJFODFDPNDBUBMPH w&418300.։ൃϘʔυʜԁ ੫ࠐ  IUUQTXXXTXJUDITDJFODFDPNDBUBMPH ͳͲͳͲʜ ผ్64#γϦΞϧม׵΍Ϟʔυ ੾Γସ͑༻ͷ఍߅ ޙड़ ͕ෆཁ
  5. "SEVJOPʹ͍ͭͯ ෮श WPJETFUVQ \ʜ^ ిݯ0/ͨ͠ޙʹճ͚࣮ͩߦ͞ΕΔ WPJEMPPQ \ʜ^ TFUVQͷޙʹ܁Γฦ࣮͠ߦ͞ΕΔ γϦΞϧϞχλ ϚΠίϯͱͷγϦΞϧ௨৴

    ίϯύΠϧॻ͖ࠐΈ ϚΠίϯʹॻ͖ࠐΉ ίϯύΠϧ εέονΛϚΠίϯ͕ ࣮ߦͰ͖Δܗʹม׵͢Δ JOUNBJO WPJE \ TFUVQ  XIJMF  \ MPPQ  ^ SFUVSO ^ ࣮ߦ࣌ͷಈ࡞͸ ˡ͜ΜͳΠϝʔδ
  6. &41DPSFGPS"SEVJOP "SEVJOP*%&ʹ&41DPSFGPS"SEVJOPΛಋೖ͢Δ    1SFGFSFODFT ؀ڥઃఆ Λ։͘  ௥ՃͷϘʔυϚωʔδϟͷ63-ͷҰ൪ӈͷϘλϯΛΫϦοΫ

     IUUQBSEVJOPFTQDPNTUBCMFQBDLBHF@FTQDPN@JOEFYKTPOΛίϐϖ 0,ΛΫϦοΫ 0,ΛΫϦοΫͰ؀ڥઃఆΛด͡Δ 2 3 4 5 ͜ΕͰϘʔυϚωʔδϟͰ ΠϯετʔϧՄೳʹͳͬͨ ࣍΁ଓ͘ 1
  7. ϐϯμΠΞάϥϜ ಛఆͷϐϯΛϓϧΞοϓμ΢ϯ ͢Δ͜ͱͰϞʔυ͕੾ΓସΘΔ ESP-WROOM-02 GND GND GND 3V3 EN IO14

    IO12 IO13 IO15 IO2 IO0 IO16 TOUT RST IO5 TXD RXD IO4 GPIO14 GPIO12 GPIO13 GPIO15 GPIO2 GPIO0 GPIO16 ADC GPIO5 GPIO1 GPIO3 GPIO4 4 5 16 12 14 13 U0TXD U0RXD U1TXD CLK MISO MOSI CS SCL SDA PWM-R PWM-B PWM-G 15 2 0 3 1 I2C SPI PWM UART ADC GPIO Arduino Power GND Pin Name UART Download Mode Flash Boot Mode 3.3V GND 3.3V GND IO15 IO2 IO0 IO15 IO2 IO0
  8. εέονΛ࣮ߦ ESP-WROOM-02 '5%*#SFBLPVU7 GND GND GND 0 2 15 3V3

    TX RX LЊ 'MBTI#PPU.PEFͰిݯΛ0/ʹ͢Δͱ࣮ߦ EN
  9. εϚʔτϑΥϯ͔Β-νΧ ϒϥ΢βܦ༝Ͱ-&%Λ఺౮ফ౮ͤ͞Δ TFUVQ ىಈ࣌ʹ౓͚࣮ͩߦ͞ΕΔॲཧ  8J'JNPEF 8*'*@"1 ΞΫηεϙΠϯτ
 Ϟʔυͱͯ͠ಈ࡞͢Δ 8J'JTPGU"1$POpH

    ʜ *1ΞυϨεΛઃఆ 8J'JTPGU"1 44*% 44*%Λઃఆ EOT4FSWFSTUBSU ʜ %/4αʔόىಈ XFC4FSWFSPO ʜ IBOEMFΛ͜͜Ͱొ࿥ XFC4FSWFSCFHJO 8FCαʔόىಈ MPPQ TFUVQޙʹ܁Γฦ࣮͠ߦ͞ΕΔॲཧ  %/4ͱ8FCTFSWFS΁ͷϦΫΤετΛ଴ͭ
  10. צॴ̍ɿిݯ ରॲ๏ ؆୯  ༰ྔͷେ͖͍ίϯσϯαΛೖΕΔ ରॲ๏ ؆୯  ి஑΍όοςϦʔ͔Βిݯڙڅ ରॲ๏

    ͓͢͢Ί  ୺ࢠϨΪϡϨʔλ͔Βిݯڙڅ ͋·Γ͓͢͢ΊͰ͖ͳ͍ 64#γϦΞϧม׵͔Βͷ7͸ ઀ଓ͠ͳ͍Α͏ʹ (/%͚ͩ઀ଓ ଞʹ΋৭ʑηϯαʔܨ͛ΔͳΒ N"͘Β͍͋Δͱ༨༟Ͱ҆৺ 7ͱ(/%ͷؒʹ
  11. εϚʔτϑΥϯ͔ΒؾԹνΣοΫ ϒϥ΢βͰؾԹ࣪౓ΛݟΔ TFUVQ ىಈ࣌ʹ౓͚࣮ͩߦ͞ΕΔॲཧ  8JSFCFHJO   ϐϯΛ4%" Λ4$-Ͱ*$઀ଓ

    JOJU)%$ )%$ΛॳظԽ UJNF$PVOU"SN  ϛϦඵͰλΠϚʔηοτ MPPQ TFUVQޙʹ܁Γฦ࣮͠ߦ͞ΕΔॲཧ  ඵ͝ͱʹSFBE)%$ Λ࣮ߦ SFBE)%$ )%$͔Β஋ΛಡΈࠐΉ  CJUͷσʔλΛ্Ґ ԼҐͰ෼ׂͯ͠ಡΈࠐΈ Ϗοτγϑτ ͯ݁͠߹ JOJU)%$ )%$ΛॳظԽ  σʔλγʔτʹैͬͯɺ)%$ʹରͯ͠ॳظԽΛ࣮ߦ
  12. WPJEMPPQ \ TFSWFSIBOEMF$MJFOU  JG MFE@TX \ EJHJUBM8SJUF -&% )*()

     EFMBZ  ϛϦඵ఺౮ EJHJUBM8SJUF -&% -08  EFMBZ  ϛϦඵফ౮ ^ ^ צॴɿλΠϚʔ EFMBZ ͸શͯͷॲཧΛࢭΊͯ͠·͏ WPJEIBOEMF$POUSPM \ JG TFSWFSNFU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 ࣮ߦ࣌ ESP-WROOM-02 '5%*#SFBLPVU7 GND GND GND 0 2 15

    3V3 TX RX LЊ 12 -&% LЊ ϘλϯΛԡͨ͠Β99͢Δ ֎෦ͷαʔόʹ)551(&51045͢Δ 5 εΠον ిݯ ϨΪϡϨʔλ όοςϦʔ౳ EN
  15. ϦϞίϯ͔ΒίʔυΛऔಘ τΠϨͷϦϞίϯ͕ ૹ৴͍ͯ͠Δ৴߸Λ(&5 ྲྀ͢ খ ྲྀ͢ େ ఀࢭ ఀࢭ ΍ΘΒ͔

    ΍ΘΒ͔ ૹ৴։࢝Ϧʔμ෦ ໿NT NT  σʔλ෦ NT NT͕ଓ͘ ྲྀ͢Ҏ֎ͷίϚϯυ͸ ճʹ෼͚ͯૹ৴͞Ε͍ͯΔ
  16. ϓϩάϥϜΛॻ͘ॻ͖ࠐΉ  ແઢ-"/઀ଓ͢Δ  αʔόىಈ  ϦΫΤετΛड͚Δ  ੺֎ઢૹ৴ &41DPSFGPS"SEVJOP

    IUUQTHJUIVCDPNFTQ"SEVJOP  &418300.Λ୯ମͰ "SEVJOPͷΑ͏ʹ࢖͑Δ  *3SFNPUF&41 IUUQTHJUIVCDPNNBSLT[BCP*3SFNPUF&41  L)[Ͱมௐͯ͠੺֎ઢ-&%Λ ఺໓ͤ͞ΔϥΠϒϥϦ τʔλϧ ߦ͘Β͍
  17. UPJMFUMPDBMXBTIMFU ͓͠ΓΛચড়͍ͨ͠ͱ͖ curl -X POST -d 'c=rear' http://toilet.local/washlet ચড়ΛࢭΊ͍ͨͱ͖ curl

    -X POST -d 'c=stop' http://toilet.local/washlet
 exam ple ® ΢ΥγϡϨοτ, Washlet͸TOTOͷొ࿥঎ඪͰ͢
  18. ϓϦϯτج൘੡଄αʔϏεൺֱ ৚݅ɿNN NN྆໘ ૚ ج൘P[ ЖNಔഩ ɹɹɹNNް͸ΜͩϨϕϥʔϨδετ৭྘ ࠃ಺1ࣾ ࠃ಺4ࣾ ւ֎'ࣾ

    ւ֎&ࣾ ຕ࡞Δ ໿ສઍԁ ໿ԁ υϧ ຕ࡞Δ ໿ສԁ ໿ສԁ ໿υϧ υϧ ϨδετΛ ࠇ৭ʹ ʙ ԁ ໿ԁ υϧ υϧ ૹྉ ࠐΈ ԁ ໿ʙυϧ
 ॏ͞ͱ഑ૹํ๏ͰҟͳΔ αϙʔτ ೔ຊޠ ೔ຊޠ ӳޠ
  19. ͪΌΜͱಧ͘ʁ඼࣭͸ʁ ւ֎&ࣾͷ৔߹ ճ໨ छຕ ɿൃ஫ˠண ೔  ճ໨ छຕ ɿൃ஫ˠண

    ೔  ճ໨ छຕ εςϯγϧ ɿൃ஫ˠண ೔ ɾࠓ·Ͱ஫จͨ͠෼Ͱෆྑ͸θϩ ɾࠃ಺੡଄ͱൺֱͯ͠େࠩͳ͍ ɹ˞ݸਓͷײ૝Ͱ͢ɻ ɹߴप೾ճ࿏ͱ͔Ξφϩάճ࿏ɺΦʔσΟΦ޲͚ ɹͷ৔߹ʹҧ͍͕ग़Δग़ͳ͍ͱ͔͸෼͔Βͳ͍ ˡγϧΫҹ࡮ͱͯ΋ΩϨΠ