├── 3_misc ├── example_http11.txt ├── IchigaJam_LED.txt ├── MixJuice_Ambient.txt ├── cygwin_install.pdf ├── IchigaJam_LED_http.txt ├── MixJuice_Ambient1.txt ├── MixJuice_Ambient2.txt ├── MixJuice_Ambient3.txt ├── IchigaJam_RaspPi_trigC.txt ├── IchigaJam_RaspPi_trigS.txt ├── sound │ ├── se_maoudamashii_chime10.wav │ ├── se_maoudamashii_voice_bird02.wav │ └── README_license.txt ├── example_http02.txt ├── example_http01.txt ├── enoc_logger.sh └── enoc_stm431j.sh ├── 2_example ├── example25a_fs │ ├── README.txt │ ├── ESP8266FtpServer_library.properties │ └── ESP8266FtpServer_README.md ├── example64_photo │ ├── cam.bmp │ ├── tgv.jpg │ ├── README_JPEGDecoder.txt │ ├── gfxfont.h │ ├── license_Adafruit-GFX.txt │ ├── license_Adafruit-SSD1331.txt │ └── README_Adafruit-SSD1331.txt ├── example22a_jam │ ├── README.txt │ ├── ESP8266FtpServer_library.properties │ ├── TvOutput.bas │ ├── utf_del_uni.ino │ └── ESP8266FtpServer_README.md ├── example36_le │ └── ref_adconv.jpg ├── example64_photo_m5 │ ├── README.md │ ├── README_JPEGDecoder.txt │ ├── gfxfont.h │ ├── license_Adafruit-GFX.txt │ └── README_Adafruit-ILI9341.md ├── example29u_dash │ ├── uart_mon_dash.bas │ └── promiscuous.h ├── example61u_dash │ └── uart_mon_dash.bas ├── example63_google │ ├── GoogleCalendar.js │ ├── HTTPSRedirectREADME.md │ ├── HTTPSRedirect.h │ └── utf_del_uni.ino ├── example28_lcdkey │ ├── LiquidCrystalDFR_README.txt │ ├── utf_del_uni.ino │ ├── README.md │ ├── sendNTPpacket.ino │ └── trUri2txt.ino ├── example10c_hpa │ ├── Ambient_README.md │ └── Ambient.h ├── example09c_hum │ ├── Ambient_README.md │ ├── Ambient.h │ └── i2c_hdc.ino ├── example09m_hum │ ├── Ambient_README.md │ ├── Ambient.h │ └── i2c_hdc.ino ├── example09c_hum_sht31 │ ├── Ambient_README.md │ ├── Ambient.h │ └── i2c_sht31.ino ├── example09c_hum_si7021 │ ├── Ambient_README.md │ └── Ambient.h ├── example60_lcdkey │ ├── readButtons.h │ ├── utf_del_uni.ino │ ├── Ambient.h │ └── trUri2txt.ino ├── example22_jam │ ├── TvOutput.bas │ └── utf_del_uni.ino ├── example54_jam │ ├── TvOutput.bas │ └── utf_del_uni.ino ├── example32_test │ └── README.md ├── example23_raspi │ └── utf_del_uni.ino ├── example55_raspi │ └── utf_del_uni.ino ├── example04c_le │ └── Ambient.h ├── example17_bell │ └── chimeBells.ino ├── example13c_ntp │ ├── Ambient.h │ └── sendNTPpacket.ino ├── example36c_le │ └── Ambient.h ├── example31_demo │ └── README.md ├── example16_led │ └── ledCtrl.ino ├── example16w_led │ ├── ledCtrl.ino │ └── html.ino ├── example47_camG │ └── README.md ├── example16f_led │ └── ledCtrl.ino ├── setWifiSSID.sh ├── example52_camG │ └── README.md ├── example15_camG │ └── README.md ├── example15f_camG │ └── README.md ├── example13_ntp │ └── sendNTPpacket.ino ├── example45_ntp │ └── sendNTPpacket.ino ├── example18t_lcd_ntp │ ├── sendNTPpacket.ino │ └── trUri2txt.ino ├── example59_env │ ├── README.md │ └── i2c_sht31.ino ├── example09_hum_sht31 │ └── i2c_sht31.ino ├── example20_camG │ └── README.md ├── example15_camL │ └── README.md ├── example15f_camL │ └── README.md ├── example20_camL │ └── README.md ├── example09_hum │ └── i2c_hdc.ino ├── example41_hum │ └── i2c_hdc.ino ├── example26_tftp │ └── README.md ├── example29_dash │ └── promiscuous.h ├── example48w_led │ └── html.ino ├── example18_lcd │ └── trUri2txt.ino ├── example18t_lcd │ └── trUri2txt.ino ├── example21_talk │ └── trUri2txt.ino ├── example50_lcd │ └── trUri2txt.ino ├── example53_talk │ └── trUri2txt.ino ├── example41_hum_sht31 │ └── i2c_sht31.ino ├── example27_env │ └── README.md ├── example58_tftp │ └── README.md └── example09_hum_si7021 │ └── i2c_si7021.ino ├── 5_learn32 ├── esp32_26_photof │ ├── cam.bmp │ ├── tgv.jpg │ ├── README_JPEGDecoder.txt │ ├── gfxfont.h │ ├── license_Adafruit-GFX.txt │ ├── license_Adafruit-SSD1331.txt │ └── README_Adafruit-SSD1331.txt ├── esp32_01_uart │ └── esp32_01_uart.ino ├── esp32_02_led │ └── esp32_02_led.ino ├── esp32_27_goo_lcd │ ├── HTTPSRedirectREADME.md │ └── HTTPSRedirect.h ├── esp32_27_goo_lcd2 │ ├── HTTPSRedirectREADME.md │ └── HTTPSRedirect.h ├── esp32_27_goo_lcd3 │ ├── HTTPSRedirectREADME.md │ └── HTTPSRedirect.h ├── esp32_04_adc │ └── esp32_04_adc.ino ├── esp32_02_led2 │ └── esp32_02_led2.ino ├── esp32_23_rtr_lcd │ ├── Ambient.h │ ├── lcdisp4.ino │ └── lcdisp.ino ├── esp32_05_i2c │ ├── esp32_05_i2c.ino │ └── i2c_sht31.ino ├── esp32_18_voice │ ├── uspeech_LICENSE.txt │ ├── uspeech_phoneme.cpp │ └── uspeech_README.md ├── esp32_18_voice_ok │ ├── uspeech_LICENSE.txt │ ├── uspeech_phoneme.cpp │ └── uspeech_README.md ├── esp32_06_uart_rx │ └── esp32_06_uart_rx.ino ├── esp32_03_sw │ └── esp32_03_sw.ino ├── esp32_21_bell_lcd │ └── lcdisp.ino ├── esp32_22_sens_lcd │ └── lcdisp.ino ├── esp32_24_ntp_lcd │ └── lcdisp.ino ├── esp32_25_wtr_lcd │ └── lcdisp.ino ├── esp32_16_hum │ └── i2c_sht31.ino └── esp32_02_led2t │ └── esp32_02_led2t.ino ├── docs └── _config.yml ├── tools ├── ftp_uninstall.sh ├── automail_rc.local ├── ftp_setup.sh ├── ping_all ├── backup_log_setup.sh ├── backup_log.sh ├── ping_all2.sh ├── automail.txt ├── automail_cam.txt ├── aquestalk_tsig.sh ├── automail_setup.sh ├── gmail_setup.sh ├── index.html ├── soracom_setupAK020.sh ├── udp_logger_cygwin.sh ├── soracom ├── sonet_setupL02C.sh ├── soracom_setupL02C.sh ├── udp_sender.py ├── udp_logger_plus.sh ├── aquestalk_setup.sh ├── udp_logger.sh ├── udp_logger.py ├── get_photo.sh └── get_sound.sh ├── .gitignore ├── download_i.MyMimamori.sh ├── 1_practice ├── practice01_uart │ └── practice01_uart.ino ├── practice02_led │ └── practice02_led.ino ├── practice33_uart │ └── practice33_uart.ino ├── practice34_led │ └── practice34_led.ino ├── practice03_sw │ └── practice03_sw.ino ├── practice35_sw │ └── practice35_sw.ino ├── practice07_led.sh ├── practice04_var │ └── practice04_var.ino ├── practice36_var │ └── practice36_var.ino ├── practice05_calc │ └── practice05_calc.ino └── practice37_calc │ └── practice37_calc.ino └── LICENSE /3_misc/example_http11.txt: -------------------------------------------------------------------------------- 1 | HTTP/1.1 200 OK 2 | Content-Length: 6 3 | 4 | hello! 5 | -------------------------------------------------------------------------------- /3_misc/IchigaJam_LED.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/IchigaJam_LED.txt -------------------------------------------------------------------------------- /3_misc/MixJuice_Ambient.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/MixJuice_Ambient.txt -------------------------------------------------------------------------------- /3_misc/cygwin_install.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/cygwin_install.pdf -------------------------------------------------------------------------------- /3_misc/IchigaJam_LED_http.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/IchigaJam_LED_http.txt -------------------------------------------------------------------------------- /3_misc/MixJuice_Ambient1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/MixJuice_Ambient1.txt -------------------------------------------------------------------------------- /3_misc/MixJuice_Ambient2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/MixJuice_Ambient2.txt -------------------------------------------------------------------------------- /3_misc/MixJuice_Ambient3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/MixJuice_Ambient3.txt -------------------------------------------------------------------------------- /2_example/example25a_fs/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example25a_fs/README.txt -------------------------------------------------------------------------------- /2_example/example64_photo/cam.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example64_photo/cam.bmp -------------------------------------------------------------------------------- /2_example/example64_photo/tgv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example64_photo/tgv.jpg -------------------------------------------------------------------------------- /3_misc/IchigaJam_RaspPi_trigC.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/IchigaJam_RaspPi_trigC.txt -------------------------------------------------------------------------------- /3_misc/IchigaJam_RaspPi_trigS.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/IchigaJam_RaspPi_trigS.txt -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/cam.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/5_learn32/esp32_26_photof/cam.bmp -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/tgv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/5_learn32/esp32_26_photof/tgv.jpg -------------------------------------------------------------------------------- /2_example/example22a_jam/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example22a_jam/README.txt -------------------------------------------------------------------------------- /2_example/example36_le/ref_adconv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example36_le/ref_adconv.jpg -------------------------------------------------------------------------------- /2_example/example64_photo_m5/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example64_photo_m5/README.md -------------------------------------------------------------------------------- /3_misc/sound/se_maoudamashii_chime10.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/sound/se_maoudamashii_chime10.wav -------------------------------------------------------------------------------- /2_example/example29u_dash/uart_mon_dash.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example29u_dash/uart_mon_dash.bas -------------------------------------------------------------------------------- /2_example/example61u_dash/uart_mon_dash.bas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example61u_dash/uart_mon_dash.bas -------------------------------------------------------------------------------- /2_example/example63_google/GoogleCalendar.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example63_google/GoogleCalendar.js -------------------------------------------------------------------------------- /3_misc/sound/se_maoudamashii_voice_bird02.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/3_misc/sound/se_maoudamashii_voice_bird02.wav -------------------------------------------------------------------------------- /3_misc/example_http02.txt: -------------------------------------------------------------------------------- 1 | AT+CIPSTART="TCP","ntp-a1.nict.go.jp",80 2 | AT+CIPSEND=55 3 | GET /cgi-bin/time HTTP/1.0 4 | Host: ntp-a1.nict.go.jp 5 | 6 | -------------------------------------------------------------------------------- /2_example/example28_lcdkey/LiquidCrystalDFR_README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bokunimowakaru/esp/HEAD/2_example/example28_lcdkey/LiquidCrystalDFR_README.txt -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman 2 | show_downloads: true 3 | plugins: 4 | - jekyll-sitemap 5 | url: "https://git.bokunimo.com" 6 | baseurl: "/" 7 | -------------------------------------------------------------------------------- /3_misc/example_http01.txt: -------------------------------------------------------------------------------- 1 | AT+CIPSTART="TCP","www.bokunimo.net",80 2 | AT+CIPSEND=67 3 | GET /bokunimowakaru/cq/esp.txt HTTP/1.0 4 | Host: www.bokunimo.net 5 | 6 | -------------------------------------------------------------------------------- /2_example/example10c_hpa/Ambient_README.md: -------------------------------------------------------------------------------- 1 | # Ambient_ESP8266_lib 2 | AmbientはIoT用のクラウドサービスです。 マイコンから送られたデーターを受信し、蓄積し、可視化(グラフ化)します。ここではArduino ESP8266用のライブラリーとサンプルを示しています。サンプルではESP8266と気圧センサ LPS25Hを使い、温度、気圧を測定し、Ambientに送信しています。 3 | -------------------------------------------------------------------------------- /2_example/example09c_hum/Ambient_README.md: -------------------------------------------------------------------------------- 1 | # Ambient_ESP8266_lib 2 | AmbientはIoT用のクラウドサービスです。 マイコンから送られたデーターを受信し、蓄積し、可視化(グラフ化)します。ここではArduino ESP8266用のライブラリーとサンプルを示しています。サンプルではESP8266と温度、湿度センサーのHDC1000を使い、温度、湿度を測定し、Ambientに送信しています。 3 | -------------------------------------------------------------------------------- /2_example/example09m_hum/Ambient_README.md: -------------------------------------------------------------------------------- 1 | # Ambient_ESP8266_lib 2 | AmbientはIoT用のクラウドサービスです。 マイコンから送られたデーターを受信し、蓄積し、可視化(グラフ化)します。ここではArduino ESP8266用のライブラリーとサンプルを示しています。サンプルではESP8266と温度、湿度センサーのHDC1000を使い、温度、湿度を測定し、Ambientに送信しています。 3 | -------------------------------------------------------------------------------- /2_example/example09c_hum_sht31/Ambient_README.md: -------------------------------------------------------------------------------- 1 | # Ambient_ESP8266_lib 2 | AmbientはIoT用のクラウドサービスです。 マイコンから送られたデーターを受信し、蓄積し、可視化(グラフ化)します。ここではArduino ESP8266用のライブラリーとサンプルを示しています。サンプルではESP8266と温度、湿度センサーのHDC1000を使い、温度、湿度を測定し、Ambientに送信しています。 3 | -------------------------------------------------------------------------------- /2_example/example09c_hum_si7021/Ambient_README.md: -------------------------------------------------------------------------------- 1 | # Ambient_ESP8266_lib 2 | AmbientはIoT用のクラウドサービスです。 マイコンから送られたデーターを受信し、蓄積し、可視化(グラフ化)します。ここではArduino ESP8266用のライブラリーとサンプルを示しています。サンプルではESP8266と温度、湿度センサーのHDC1000を使い、温度、湿度を測定し、Ambientに送信しています。 3 | -------------------------------------------------------------------------------- /tools/ftp_uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ftp_setup.shを使ってインストールしたFTPサーバ(vsftpd)を削除します。 4 | # 5 | # FTPではユーザ名やパスワード、データーが平文で転送されます。 6 | # インターネット上で扱う場合は、セキュリティに対する配慮が必要です。 7 | # 8 | # 2018/11/17 国野亘 9 | 10 | echo "vsftpdを削除します" 11 | sudo service vsftpd stop 12 | sleep 1 13 | sudo apt-get remove vsftpd 14 | -------------------------------------------------------------------------------- /2_example/example22a_jam/ESP8266FtpServer_library.properties: -------------------------------------------------------------------------------- 1 | name=ESP8266FtpServer 2 | version=1.0.1 3 | author= 4 | maintainer=david@paivahome.com 5 | sentence=Very Simple FTP server for SPIFFS on esp8266 6 | paragraph=Very Simple FTP server for SPIFFS on esp8266 7 | category=Communication 8 | url= 9 | architectures=esp8266 10 | -------------------------------------------------------------------------------- /2_example/example25a_fs/ESP8266FtpServer_library.properties: -------------------------------------------------------------------------------- 1 | name=ESP8266FtpServer 2 | version=1.0.1 3 | author= 4 | maintainer=david@paivahome.com 5 | sentence=Very Simple FTP server for SPIFFS on esp8266 6 | paragraph=Very Simple FTP server for SPIFFS on esp8266 7 | category=Communication 8 | url= 9 | architectures=esp8266 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.BAK 34 | 35 | *.log 36 | *.csv 37 | *.xlsx 38 | tools/photo/* 39 | -------------------------------------------------------------------------------- /2_example/example64_photo/README_JPEGDecoder.txt: -------------------------------------------------------------------------------- 1 | /* 2 | ソースリストJPEGDecoderは2017/11/2に下記からダウンロードしたものを、国野亘が改変したものです。 3 | 改変部以外は原作者の権利が継続します。 4 | 5 | https://github.com/MakotoKurauchi/JPEGDecoder 6 | 7 | 2017/11/2 国野 亘 8 | */ 9 | 10 | JPEGDecoder 11 | =========== 12 | 13 | JPEG Decoder for Arduino 14 | 15 | 概要 16 | ---- 17 | Arduino 用 JPEG デコーダです。デコーダ部には [picojpeg](https://code.google.com/p/picojpeg/) を使用しています。 18 | 19 | サンプルコード 20 | ---- 21 | ###SerialCsvOut 22 | 23 | SD カード上の JPEG ファイルをブロックごとにデコードし、シリアルから CSV を出力します。 24 | 25 | 変更履歴 26 | ---- 27 | V0.01 - 最初のリリース -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/README_JPEGDecoder.txt: -------------------------------------------------------------------------------- 1 | /* 2 | ソースリストJPEGDecoderは2017/11/2に下記からダウンロードしたものを、国野亘が改変したものです。 3 | 改変部以外は原作者の権利が継続します。 4 | 5 | https://github.com/MakotoKurauchi/JPEGDecoder 6 | 7 | 2017/11/2 国野 亘 8 | */ 9 | 10 | JPEGDecoder 11 | =========== 12 | 13 | JPEG Decoder for Arduino 14 | 15 | 概要 16 | ---- 17 | Arduino 用 JPEG デコーダです。デコーダ部には [picojpeg](https://code.google.com/p/picojpeg/) を使用しています。 18 | 19 | サンプルコード 20 | ---- 21 | ###SerialCsvOut 22 | 23 | SD カード上の JPEG ファイルをブロックごとにデコードし、シリアルから CSV を出力します。 24 | 25 | 変更履歴 26 | ---- 27 | V0.01 - 最初のリリース -------------------------------------------------------------------------------- /download_i.MyMimamori.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -e ~/RaspberryPi/network/i.myMimamoriPi ]; then 3 | cd ~/RaspberryPi/ 4 | git pull 5 | echo "更新しました" 6 | else 7 | if [ -e ~/RaspberryPi ]; then 8 | mv ~/RaspberryPi ~/RaspberryPi_`date +%Y%m%d_%H%M` 9 | echo "RaspberryPiフォルダのバックアップを作成しました(日時を付与)" 10 | fi 11 | cd 12 | git clone https://www.github.com/bokunimowakaru/RaspberryPi.git 13 | fi 14 | echo "ダウンロードを終了しました。" 15 | echo "i.MyMimamori Piをセットアップするには以下のコマンドを実行してください。" 16 | echo "cd ~/RaspberryPi/network/i.myMimamoriPi/" 17 | echo "./setup.sh" 18 | exit 19 | -------------------------------------------------------------------------------- /2_example/example64_photo_m5/README_JPEGDecoder.txt: -------------------------------------------------------------------------------- 1 | /* 2 | ソースリストJPEGDecoderは2017/11/2に下記からダウンロードしたものを、国野亘が改変したものです。 3 | 改変部以外は原作者の権利が継続します。 4 | 5 | https://github.com/MakotoKurauchi/JPEGDecoder 6 | 7 | 2017/11/2 国野 亘 8 | */ 9 | 10 | JPEGDecoder 11 | =========== 12 | 13 | JPEG Decoder for Arduino 14 | 15 | 概要 16 | ---- 17 | Arduino 用 JPEG デコーダです。デコーダ部には [picojpeg](https://code.google.com/p/picojpeg/) を使用しています。 18 | 19 | サンプルコード 20 | ---- 21 | ###SerialCsvOut 22 | 23 | SD カード上の JPEG ファイルをブロックごとにデコードし、シリアルから CSV を出力します。 24 | 25 | 変更履歴 26 | ---- 27 | V0.01 - 最初のリリース -------------------------------------------------------------------------------- /2_example/example60_lcdkey/readButtons.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ESP32用 アナログ入力関数 readButtons mvAnalogIn 3 | Copyright (c) 2017 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | #define BUTTON_UP 0x08 7 | #define BUTTON_DOWN 0x04 8 | #define BUTTON_LEFT 0x10 9 | #define BUTTON_RIGHT 0x02 10 | #define BUTTON_SELECT 0x01 11 | 12 | uint8_t readButtons(uint8_t PIN); 13 | float mvAnalogIn(uint8_t PIN); 14 | -------------------------------------------------------------------------------- /tools/automail_rc.local: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # rc.local 4 | # 5 | # This script is executed at the end of each multiuser runlevel. 6 | # Make sure that the script will "exit 0" on success or any other 7 | # value on error. 8 | # 9 | # In order to enable or disable this script just change the execution 10 | # bits. 11 | # 12 | # By default this script does nothing. 13 | 14 | # Print the IP address 15 | 16 | _IP=$(hostname -I) || true 17 | if [ "$_IP" ]; then 18 | printf "My IP address is %s\n" "$_IP" 19 | fi 20 | 21 | sudo -u pi /bin/bash /home/pi/esp/tools/automail.sh 22 | -------------------------------------------------------------------------------- /tools/ftp_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # FTPサーバをセットアップします。 4 | # 5 | # FTPではユーザ名やパスワード、データーが平文で転送されます。 6 | # インターネット上で扱う場合は、セキュリティに対する配慮が必要です。 7 | # 8 | # 実験を終えたら Raspberry Pi の電源を切っておく、もしくはftp_uninstall.shを実行して 9 | # vsftpdを削除してください。(FTPによる不正アクセスを防止するため) 10 | # 11 | # 2016/12/14 国野亘 12 | 13 | echo "vsftpdをインストールします" 14 | sudo apt-get install vsftpd 15 | sudo service vsftpd stop 16 | cat /etc/vsftpd.conf|sed -e "s/#write_enable=YES/write_enable=YES/g" > vsftpd.tmp 17 | sudo mv -b vsftpd.tmp /etc/vsftpd.conf 18 | sudo chown root:root /etc/vsftpd.conf 19 | sudo service vsftpd start 20 | -------------------------------------------------------------------------------- /tools/ping_all: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LAN内の機器にPINGを打って情報を収集する 3 | # Copyright (c) 2016-2019 Wataru KUNINO 4 | 5 | IP=`hostname -I|tr " " "\n"|grep -Eo '([0-9]*\.){3}[0-9]*'|grep -v "127.0."|head -1|cut -d. -f1-3` 6 | OS=`uname` 7 | i=1 8 | while [ ${i} -le 254 ]; do 9 | # echo ${IP}.${i} 10 | if [ "$OS" = "Linux" ]; then 11 | sudo ping -c1 -W1 ${IP}.${i}|grep "time=" & 12 | sleep 0.01 13 | PID=`pidof ping` 14 | if [ -n "$PID" ];then 15 | sudo kill $PID 16 | fi 17 | else 18 | sudo ping -n 1 -w 100 ${IP}.${i}|grep -a 'ms TTL=' 19 | fi 20 | (( i++ )) 21 | done 22 | #arp|grep ":" 23 | exit 0 24 | -------------------------------------------------------------------------------- /tools/backup_log_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # backup_log.shを自動起動するように設定します。 4 | # sudo を付けて実行してください。 5 | # 6 | # sudo ./backup_log_setup.sh 7 | # 8 | # 2017/06/10 国野亘 9 | 10 | echo "-------------------------------------------------------------------------" 11 | echo "backup_log.shを1日に1度、自動実行するように設定しますか?" 12 | echo "「yes」を入力してください。" 13 | echo -n "yes/no >" 14 | read yes 15 | if [ "$yes" != "yes" ]; then 16 | echo "キャンセルしました" 17 | exit 18 | fi 19 | 20 | cat << EOF > /etc/cron.daily/backup_log 21 | #!/bin/bash 22 | cd `pwd` 23 | ./backup_log.sh 24 | EOF 25 | chmod a+x /etc/cron.daily/backup_log 26 | sudo service cron restart 27 | -------------------------------------------------------------------------------- /3_misc/sound/README_license.txt: -------------------------------------------------------------------------------- 1 | 本フォルダ内には下記のサイトからダウンロードしたフリー音楽素材のファイルが含まれています。 2 | 3 | 魔王魂 4 | http://maoudamashii.jokersounds.com/ 5 | 6 | se_maoudamashii_*.wav 7 | 8 | 以下は、権利者である「魔王魂」の使用許諾内容です。 9 | ---------------------------------------------------------------------------- 10 | 素材の利用に関する報告は不要です。 11 | http://maoudamashii.jokersounds.com/music_fq.html 12 | 13 | 素材を利用される方は著作の表記をお願いします。 14 | 15 | 例:音楽:魔王魂 16 | 17 | 著作表記箇所は完全に自由です。 18 | 作品内、サイト上、付属テキスト等ご都合の良い場所に記載下さい。 19 | また、可能であれば当サイトへのリンクをよろしくお願いします。 20 | →バナー画像、リンクについての詳細ページ 21 | http://maoudamashii.jokersounds.com/link.html 22 | 23 | TV番組や学園祭でのご利用等で著作表記が不可能な場合に限り、著作表記無しで素材を利用して頂いて結構です。この場合も報告不要です。 24 | -------------------------------------------------------------------------------- /1_practice/practice01_uart/practice01_uart.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 1: シリアル出力する 3 | Copyright (c) 2016-2019 Wataru KUNINO 4 | ***********************************************************************/ 5 | 6 | void setup() { // 起動時に一度だけ実行される関数 7 | Serial.begin(9600); // シリアル通信速度を9600bpsに設定する 8 | } 9 | 10 | void loop() { // setup実行後に繰り返し実行される関数 11 | Serial.print("Hello, "); // シリアルへ「Hello,」を出力する 12 | delay(200); // 時間待ち(200ms) 13 | Serial.println("world!"); // シリアルへ「world!」と改行を出力する 14 | delay(200); // 時間待ち(200ms) 15 | } 16 | -------------------------------------------------------------------------------- /5_learn32/esp32_01_uart/esp32_01_uart.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 1: シリアル出力する 3 | Copyright (c) 2016-2019 Wataru KUNINO 4 | ***********************************************************************/ 5 | 6 | void setup() { // 起動時に一度だけ実行される関数 7 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 8 | } 9 | 10 | void loop() { // setup実行後に繰り返し実行される関数 11 | Serial.print("Hello, "); // シリアルへ「Hello,」を出力する 12 | delay(200); // 時間待ち(200ms) 13 | Serial.println("world!"); // シリアルへ「world!」と改行を出力する 14 | delay(200); // 時間待ち(200ms) 15 | } 16 | -------------------------------------------------------------------------------- /2_example/example22_jam/TvOutput.bas: -------------------------------------------------------------------------------- 1 | new 2 | rem IchigoJam用 テレビ出力表示プログラム 3 | rem CC by Wataru Kunino @ IchigoJam-FAN Group (Facebook) 4 | rem https://www.facebook.com/groups/ichigojam/permalink/581632705309820/ 5 | 6 | 1 cls:?"TvOutput":?"forESP15" 7 | 2 gosub 950 8 | 100 'SETUP 9 | 110 X=0:Y=0 10 | 120 poke #900,0,0,0,0,0,0,0,0 11 | 130 poke #920,0,0,0,0,0,0,0,0 12 | 200 'LOOP 13 | 210 I=inkey() 14 | 220 ifI=10andX+Ygosub950:goto100 15 | 225 ifI=13andX+Ygosub950:goto100 16 | 230 ifI<=32orI=39orY>1goto200 17 | 240 poke #900+X+Y*32,I 18 | 250 X=X+1:ifX>7letX,0:Y=Y+1 19 | 260 goto200 20 | 950 'TV 21 | 960 let[0],#80,#8A,#85,#8F:lc0,5:forY=0to15:forX=0to7 22 | 970 C=peek(vpeek(X,Y/8)*8+Y%8):?chr$([C>>6&3],[C>>4&3],[C>>2&3],[C&3]); 23 | 980 next:next:return 24 | -------------------------------------------------------------------------------- /2_example/example54_jam/TvOutput.bas: -------------------------------------------------------------------------------- 1 | new 2 | rem IchigoJam用 テレビ出力表示プログラム 3 | rem CC by Wataru Kunino @ IchigoJam-FAN Group (Facebook) 4 | rem https://www.facebook.com/groups/ichigojam/permalink/581632705309820/ 5 | 6 | 1 cls:?"TvOutput":?"forESP15" 7 | 2 gosub 950 8 | 100 'SETUP 9 | 110 X=0:Y=0 10 | 120 poke #900,0,0,0,0,0,0,0,0 11 | 130 poke #920,0,0,0,0,0,0,0,0 12 | 200 'LOOP 13 | 210 I=inkey() 14 | 220 ifI=10andX+Ygosub950:goto100 15 | 225 ifI=13andX+Ygosub950:goto100 16 | 230 ifI<=32orI=39orY>1goto200 17 | 240 poke #900+X+Y*32,I 18 | 250 X=X+1:ifX>7letX,0:Y=Y+1 19 | 260 goto200 20 | 950 'TV 21 | 960 let[0],#80,#8A,#85,#8F:lc0,5:forY=0to15:forX=0to7 22 | 970 C=peek(vpeek(X,Y/8)*8+Y%8):?chr$([C>>6&3],[C>>4&3],[C>>2&3],[C&3]); 23 | 980 next:next:return 24 | -------------------------------------------------------------------------------- /2_example/example22a_jam/TvOutput.bas: -------------------------------------------------------------------------------- 1 | new 2 | rem IchigoJam用 テレビ出力表示プログラム 3 | rem CC by Wataru Kunino @ IchigoJam-FAN Group (Facebook) 4 | rem https://www.facebook.com/groups/ichigojam/permalink/581632705309820/ 5 | 6 | 1 cls:?"TvOutput":?"forESP15" 7 | 2 gosub 950 8 | 100 'SETUP 9 | 110 X=0:Y=0 10 | 120 poke #900,0,0,0,0,0,0,0,0 11 | 130 poke #920,0,0,0,0,0,0,0,0 12 | 200 'LOOP 13 | 210 I=inkey() 14 | 220 ifI=10andX+Ygosub950:goto100 15 | 225 ifI=13andX+Ygosub950:goto100 16 | 230 ifI<=32orI=39orY>1goto200 17 | 240 poke #900+X+Y*32,I 18 | 250 X=X+1:ifX>7letX,0:Y=Y+1 19 | 260 goto200 20 | 950 'TV 21 | 960 let[0],#80,#8A,#85,#8F:lc0,5:forY=0to15:forX=0to7 22 | 970 C=peek(vpeek(X,Y/8)*8+Y%8):?chr$([C>>6&3],[C>>4&3],[C>>2&3],[C&3]); 23 | 980 next:next:return 24 | -------------------------------------------------------------------------------- /5_learn32/esp32_02_led/esp32_02_led.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 2: LEDを点滅させる 3 | Copyright (c) 2016-2019 Wataru KUNINO 4 | ***********************************************************************/ 5 | 6 | #define PIN_LED 2 // IO 2にLEDを接続 7 | 8 | void setup() { // 起動時に一度だけ実行される関数 9 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に設定する 10 | } 11 | 12 | void loop() { // setup実行後に繰り返し実行される関数 13 | digitalWrite(PIN_LED,HIGH); // ポートをHレベル(3.3V)に設定(点灯) 14 | delay(200); // 時間待ち(200ms) 15 | digitalWrite(PIN_LED,LOW); // ポートをLレベル(0V)に設定(消灯) 16 | delay(200); // 時間待ち(200ms) 17 | } 18 | -------------------------------------------------------------------------------- /1_practice/practice02_led/practice02_led.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 2: LEDを点滅させる 3 | Copyright (c) 2013-2019 Wataru KUNINO 4 | ***********************************************************************/ 5 | 6 | #define PIN_LED 13 // IO 13(5番ピン) にLEDを接続する 7 | 8 | void setup() { // 起動時に一度だけ実行される関数 9 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に設定する 10 | } 11 | 12 | void loop() { // setup実行後に繰り返し実行される関数 13 | digitalWrite(PIN_LED,HIGH); // ポートをHレベル(3.3V)に設定(点灯) 14 | delay(200); // 時間待ち(200ms) 15 | digitalWrite(PIN_LED,LOW); // ポートをLレベル(0V)に設定(消灯) 16 | delay(200); // 時間待ち(200ms) 17 | } 18 | -------------------------------------------------------------------------------- /1_practice/practice33_uart/practice33_uart.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 33(Practice 1+32): シリアル出力する 3 | 4 | シリアルモニタのビット・レート設定を115200 bpsに設定してください。 5 | Copyright (c) 2016-2019 Wataru KUNINO 6 | ***********************************************************************/ 7 | 8 | void setup() { // 起動時に一度だけ実行される関数 9 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 10 | } 11 | 12 | void loop() { // setup実行後に繰り返し実行される関数 13 | Serial.print("Hello, "); // シリアルへ「Hello,」を出力する 14 | delay(200); // 時間待ち(200ms) 15 | Serial.println("world!"); // シリアルへ「world!」と改行を出力する 16 | delay(200); // 時間待ち(200ms) 17 | } 18 | -------------------------------------------------------------------------------- /2_example/example63_google/HTTPSRedirectREADME.md: -------------------------------------------------------------------------------- 1 | # ESP8266-Google-Calendar-Arduino 2 | Interaction between an ESP8266 and the Google Calendar. 3 | 4 | Instructions: 5 | Add the googlescript to your google account, set your calendar and publish it. 6 | 7 | Copy the id and paste it in the arduino file. 8 | 9 | Set your wifi settings. 10 | 11 | *The code is not the nicest - but it works :) 12 | 13 | /* HTTPS with follow-redirect 14 | * Created by Sujay S. Phadke, 2016 15 | * All rights reserved. 16 | * 17 | * Modified by Daniel Willi, 2016 18 | 19 | Google Calendar Integration ESP8266 20 | Created by Daniel Willi, 2016 21 | https://github.com/wilda17/ESP8266-Google-Calendar-Arduino 22 | 23 | * Modified for ESP32 24 | * by Wataru KUNINO, 2017 25 | */ 26 | -------------------------------------------------------------------------------- /5_learn32/esp32_27_goo_lcd/HTTPSRedirectREADME.md: -------------------------------------------------------------------------------- 1 | # ESP8266-Google-Calendar-Arduino 2 | Interaction between an ESP8266 and the Google Calendar. 3 | 4 | Instructions: 5 | Add the googlescript to your google account, set your calendar and publish it. 6 | 7 | Copy the id and paste it in the arduino file. 8 | 9 | Set your wifi settings. 10 | 11 | *The code is not the nicest - but it works :) 12 | 13 | /* HTTPS with follow-redirect 14 | * Created by Sujay S. Phadke, 2016 15 | * All rights reserved. 16 | * 17 | * Modified by Daniel Willi, 2016 18 | 19 | Google Calendar Integration ESP8266 20 | Created by Daniel Willi, 2016 21 | https://github.com/wilda17/ESP8266-Google-Calendar-Arduino 22 | 23 | * Modified for ESP32 24 | * by Wataru KUNINO, 2017 25 | */ 26 | -------------------------------------------------------------------------------- /5_learn32/esp32_27_goo_lcd2/HTTPSRedirectREADME.md: -------------------------------------------------------------------------------- 1 | # ESP8266-Google-Calendar-Arduino 2 | Interaction between an ESP8266 and the Google Calendar. 3 | 4 | Instructions: 5 | Add the googlescript to your google account, set your calendar and publish it. 6 | 7 | Copy the id and paste it in the arduino file. 8 | 9 | Set your wifi settings. 10 | 11 | *The code is not the nicest - but it works :) 12 | 13 | /* HTTPS with follow-redirect 14 | * Created by Sujay S. Phadke, 2016 15 | * All rights reserved. 16 | * 17 | * Modified by Daniel Willi, 2016 18 | 19 | Google Calendar Integration ESP8266 20 | Created by Daniel Willi, 2016 21 | https://github.com/wilda17/ESP8266-Google-Calendar-Arduino 22 | 23 | * Modified for ESP32 24 | * by Wataru KUNINO, 2017 25 | */ 26 | -------------------------------------------------------------------------------- /5_learn32/esp32_27_goo_lcd3/HTTPSRedirectREADME.md: -------------------------------------------------------------------------------- 1 | # ESP8266-Google-Calendar-Arduino 2 | Interaction between an ESP8266 and the Google Calendar. 3 | 4 | Instructions: 5 | Add the googlescript to your google account, set your calendar and publish it. 6 | 7 | Copy the id and paste it in the arduino file. 8 | 9 | Set your wifi settings. 10 | 11 | *The code is not the nicest - but it works :) 12 | 13 | /* HTTPS with follow-redirect 14 | * Created by Sujay S. Phadke, 2016 15 | * All rights reserved. 16 | * 17 | * Modified by Daniel Willi, 2016 18 | 19 | Google Calendar Integration ESP8266 20 | Created by Daniel Willi, 2016 21 | https://github.com/wilda17/ESP8266-Google-Calendar-Arduino 22 | 23 | * Modified for ESP32 24 | * by Wataru KUNINO, 2017 25 | */ 26 | -------------------------------------------------------------------------------- /2_example/example32_test/README.md: -------------------------------------------------------------------------------- 1 | Example 32 2 | # 最新IoTモジュール ESP32-WROOM-32用 スイッチ早押し 3 | 4 | ストップウォッチのSTART/STOPボタンを2度連続押しして、どれだけ早くボタンが押せるかを競った経験はあるでしょうか? 5 | 純正のESP32用 DevKit C 開発ボードや DOIT製ESP32用 DEV KIT V1 開発ボード上のBOOT(SW2)ボタンを連続押下したときの速度を、IoTセン 6 | サ用クラウド・サービスAmbientへ送信します。 7 | 速度値(Hz)は、インターネット上に公開されます。 8 | 9 | ## IoTセンサ用クラウドサービスAmbient 10 | 11 | https://ambidata.io/bd/board.html?id=133 12 | 13 | ## 関連ブログ(筆者) 14 | 15 | http://blogs.yahoo.co.jp/bokunimowakaru/55622707.html 16 | 17 | ## 製作方法 18 | 19 | 純正のESP32用 DevKitC 開発ボード、またはDOIT製ESP32用 DEV KIT V1 開発ボードなどへスケッチを書き込んでください。 20 | 予め、本スケッチ内の#defineのSSIDとPASSに、お手持ちの無線LANアクセスポイントの設定が必要です。 21 | 22 | ## 操作方法 23 | 24 | 各開発ボードのBOOTボタンで早押しが行えます。 25 | 26 | Copyright (c) 2016-2019 Wataru KUNINO 27 | 28 | -------------------------------------------------------------------------------- /1_practice/practice34_led/practice34_led.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 34(Practice 2+32): LEDを点滅させる 3 | 4 | GPIO 2 へ LEDを接続してください。 5 | Copyright (c) 2016-2019 Wataru KUNINO 6 | ***********************************************************************/ 7 | 8 | #define PIN_LED 2 // IO 2にLEDを接続 9 | 10 | void setup() { // 起動時に一度だけ実行される関数 11 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に設定する 12 | } 13 | 14 | void loop() { // setup実行後に繰り返し実行される関数 15 | digitalWrite(PIN_LED,HIGH); // ポートをHレベル(3.3V)に設定(点灯) 16 | delay(200); // 時間待ち(200ms) 17 | digitalWrite(PIN_LED,LOW); // ポートをLレベル(0V)に設定(消灯) 18 | delay(200); // 時間待ち(200ms) 19 | } 20 | -------------------------------------------------------------------------------- /tools/backup_log.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ログファイルを圧縮してUSBメモリへ保存します。 4 | # 5 | # バックアップ元のログファイル名の例 log_xxxxx_1.csv xxxxx:5文字 6 | # バックアップ先のログファイル名の例 log20170610.csv 数字は日付を表す 7 | # 8 | # 2017/06/10 国野亘 9 | 10 | BU_FROM="" 11 | BU_TO="" 12 | 13 | if [ -z ${BU_FROM} ]; then 14 | BU_FROM="log_?????_?.csv" 15 | fi 16 | if [ -z ${BU_TO} ]; then 17 | BU_TO=`df|grep media|grep /dev/|grep -v SETTINGS|tail -1|sed -E 's/\s+/,/g'|cut -d, -f6` 18 | fi 19 | BU_TO=${BU_TO}"/log"`date "+%Y%m%d"`".tgz" 20 | #echo "backup from "${BU_FROM}" to "${BU_TO} 21 | PID=`ps a|grep "tar cvfz ${BU_TO}"|grep -v grep|sed -E 's/\s+/,/g'|cut -d, -f2` 22 | if [ "$PID" != "" ];then 23 | echo "kill "${PID} 24 | kill $PID 25 | sleep 1 26 | fi 27 | nice -n 15 tar cvfz ${BU_TO} ${BU_FROM} &> log_bakup_z.log & 28 | ps a|grep "tar cvfz ${BU_TO}"|grep -v grep 29 | -------------------------------------------------------------------------------- /2_example/example22_jam/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example22a_jam/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example23_raspi/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example28_lcdkey/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example54_jam/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example55_raspi/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example60_lcdkey/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void utf_del_uni(char *s){ 12 | unsigned int i=0; 13 | unsigned int j=0; 14 | while(s[i]!='\0'){ 15 | if((byte)s[i]==0xEF){ 16 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 17 | i+=2; 18 | } 19 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 20 | s[j]=s[i]; 21 | j++; 22 | } 23 | i++; 24 | } 25 | s[j]='\0'; 26 | } 27 | -------------------------------------------------------------------------------- /2_example/example63_google/HTTPSRedirect.h: -------------------------------------------------------------------------------- 1 | /* HTTPS with follow-redirect 2 | * Created by Sujay S. Phadke, 2016 3 | * All rights reserved. 4 | * 5 | * Modified by Daniel Willi, 2016 6 | * 7 | */ 8 | 9 | #include 10 | 11 | class HTTPSRedirect : public WiFiClientSecure { 12 | private: 13 | const int httpsPort; 14 | const char* redirFingerprint; 15 | bool fpCheck = false; 16 | bool keepAlive = true; 17 | bool verboseInfo = false; 18 | 19 | public: 20 | HTTPSRedirect(const int, const char*, bool); 21 | HTTPSRedirect(const int); 22 | ~HTTPSRedirect(); 23 | 24 | String getData(const char*, const char*, const char*); 25 | String getData(String&, const char*, const char*); 26 | String createRequest(const char*, const char*); 27 | void fetchData(bool, bool); 28 | 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /5_learn32/esp32_27_goo_lcd/HTTPSRedirect.h: -------------------------------------------------------------------------------- 1 | /* HTTPS with follow-redirect 2 | * Created by Sujay S. Phadke, 2016 3 | * All rights reserved. 4 | * 5 | * Modified by Daniel Willi, 2016 6 | * 7 | */ 8 | 9 | #include 10 | 11 | class HTTPSRedirect : public WiFiClientSecure { 12 | private: 13 | const int httpsPort; 14 | const char* redirFingerprint; 15 | bool fpCheck = false; 16 | bool keepAlive = true; 17 | bool verboseInfo = false; 18 | 19 | public: 20 | HTTPSRedirect(const int, const char*, bool); 21 | HTTPSRedirect(const int); 22 | ~HTTPSRedirect(); 23 | 24 | String getData(const char*, const char*, const char*); 25 | String getData(String&, const char*, const char*); 26 | String createRequest(const char*, const char*); 27 | void fetchData(bool, bool); 28 | 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /5_learn32/esp32_27_goo_lcd2/HTTPSRedirect.h: -------------------------------------------------------------------------------- 1 | /* HTTPS with follow-redirect 2 | * Created by Sujay S. Phadke, 2016 3 | * All rights reserved. 4 | * 5 | * Modified by Daniel Willi, 2016 6 | * 7 | */ 8 | 9 | #include 10 | 11 | class HTTPSRedirect : public WiFiClientSecure { 12 | private: 13 | const int httpsPort; 14 | const char* redirFingerprint; 15 | bool fpCheck = false; 16 | bool keepAlive = true; 17 | bool verboseInfo = false; 18 | 19 | public: 20 | HTTPSRedirect(const int, const char*, bool); 21 | HTTPSRedirect(const int); 22 | ~HTTPSRedirect(); 23 | 24 | String getData(const char*, const char*, const char*); 25 | String getData(String&, const char*, const char*); 26 | String createRequest(const char*, const char*); 27 | void fetchData(bool, bool); 28 | 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /5_learn32/esp32_27_goo_lcd3/HTTPSRedirect.h: -------------------------------------------------------------------------------- 1 | /* HTTPS with follow-redirect 2 | * Created by Sujay S. Phadke, 2016 3 | * All rights reserved. 4 | * 5 | * Modified by Daniel Willi, 2016 6 | * 7 | */ 8 | 9 | #include 10 | 11 | class HTTPSRedirect : public WiFiClientSecure { 12 | private: 13 | const int httpsPort; 14 | const char* redirFingerprint; 15 | bool fpCheck = false; 16 | bool keepAlive = true; 17 | bool verboseInfo = false; 18 | 19 | public: 20 | HTTPSRedirect(const int, const char*, bool); 21 | HTTPSRedirect(const int); 22 | ~HTTPSRedirect(); 23 | 24 | String getData(const char*, const char*, const char*); 25 | String getData(String&, const char*, const char*); 26 | String createRequest(const char*, const char*); 27 | void fetchData(bool, bool); 28 | 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /tools/ping_all2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LAN内の機器にPINGを打って情報を収集する 3 | # ~/.maclist.txtにMACアドレスとデバイス名(タブ区切り)の対応表を保存しておく 4 | # 類似の方法として nbtscan も便利 5 | # 6 | # Copyright (c) 2016-2019 Wataru KUNINO 7 | 8 | IP=`hostname -I|tr " " "\n"|grep -Eo '([0-9]*\.){3}[0-9]*'|grep -v "127.0."|head -1|cut -d. -f1-3` 9 | OS=`uname` 10 | i=1 11 | while [ ${i} -le 254 ]; do 12 | # echo ${IP}.${i} 13 | if [ "$OS" = "Linux" ]; then 14 | sudo ping -c1 -W1 ${IP}.${i}|grep "time="|awk '{ printf("%s\n",$4)}'|tr -d ':'|while read in; do 15 | mac=`arp ${in}|tail -1|awk '{ printf("%s",$3)}'` 16 | echo ${in} ${mac} `grep -i ${mac} ~/.maclist.txt|cut -f2-` 17 | done & 18 | sleep 0.01 19 | PID=`pidof ping` &> /dev/null 20 | if [ -n "$PID" ];then 21 | sudo kill $PID 22 | fi 23 | else 24 | sudo ping -n 1 -w 100 ${IP}.${i}|grep -a 'ms TTL=' 25 | fi 26 | (( i++ )) 27 | done 28 | exit 0 29 | -------------------------------------------------------------------------------- /tools/automail.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | IP=$(hostname -I) || true 3 | if [ "$IP" ]; then 4 | printf "My IP address is %s\n" "$IP" 5 | else 6 | IP="127.0.0.1" 7 | fi 8 | 9 | MAILTO="" 10 | date > /home/pi/start.log 11 | /home/pi/esp/tools/soracom start >> /home/pi/start.log 2>&1 12 | NTP=`ntpq -p|grep \*` >> /home/pi/start.log 2>&1 13 | if [ "$NTP" = "" ]; then 14 | DATE="数分前" 15 | else 16 | sleep 1 17 | DATE=`date "+%Y/%m/%d %R"` 18 | fi 19 | echo $DATE >> /home/pi/start.log 20 | IP_G=`cat /home/pi/start.log |grep "local IP address"|cut -d' ' -f6|tail -1` 21 | echo -e "`hostname` が $DATE に起動しました。\n$IP\n$IP_G"\ 22 | | mutt -s "自動起動通知" $MAILTO >> /home/pi/start.log 2>&1 23 | /home/pi/esp/tools/soracom stop >> /home/pi/start.log 2>&1 24 | wall "The system is going down for power-off (シャットダウンを開始)" 25 | sleep 10 26 | sudo shutdown -h # now オプションを付与することですぐにシャットダウンする 27 | exit 0 28 | -------------------------------------------------------------------------------- /3_misc/enoc_logger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # EnOcean 用 データロガー 4 | # 5 | # このスクリプトを実行すると、EnOceanから得られたデータをファイルに保存し 6 | # 続けます。 7 | # 8 | # ファイル名: log_ocean_0.csv 9 | # 10 | 11 | DEV="ocean_0" # デバイス名を定義 12 | stty -F /dev/ttyUSB0 57600 -icanon # シリアル設定 13 | while true; do # 永久ループの開始 14 | data=`timeout 1 cat /dev/ttyUSB0|od -An -v -tx1 -w1` # データ取得 15 | data=`echo $data|tr " " ","` # カンマ区切りに変換 16 | if [ -n "$data" ]; then # データがあった場合 17 | DATE=`date "+%Y/%m/%d %R"` # 日時を取得 18 | echo -E $DATE, $data|tee -a log_${DEV}.csv # 日時の表示と保存 19 | fi # ifの終了 20 | done # 永久に繰り返す 21 | exit # 終了 22 | -------------------------------------------------------------------------------- /5_learn32/esp32_04_adc/esp32_04_adc.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 4: アナログ入力 3 | Copyright (c) 2016-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | #define PIN_AIN 33 // アナログ入力 IO 33をADC入力として使用 7 | 8 | void setup() { // 起動時に一度だけ実行される関数 9 | pinMode(PIN_AIN,INPUT); // アナログ入力端子の設定 10 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 11 | } 12 | 13 | void loop() { // setup実行後に繰り返し実行される関数 14 | int adc; // AD変換値保存用の整数型変数adcを定義 15 | 16 | adc=analogRead(PIN_AIN); // IO 33の電圧に応じたアナログ値を取得 17 | Serial.println(adc); // 変数adcの値をシリアル出力表示 18 | delay(3000); // 3秒間(3000ms)の待ち時間処理 19 | } 20 | -------------------------------------------------------------------------------- /tools/automail_cam.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | IP=$(hostname -I) || true 3 | if [ "$IP" ]; then 4 | printf "My IP address is %s\n" "$IP" 5 | else 6 | IP="127.0.0.1" 7 | fi 8 | 9 | MAILTO="" 10 | date > /home/pi/start.log 11 | /usr/bin/fswebcam /home/pi/cam.jpg >> /home/pi/start.log 2>&1 12 | /home/pi/esp/tools/soracom start >> /home/pi/start.log 2>&1 13 | NTP=`ntpq -p|grep \*` >> /home/pi/start.log 2>&1 14 | if [ "$NTP" = "" ]; then 15 | DATE="数分前" 16 | else 17 | sleep 1 18 | DATE=`date "+%Y/%m/%d %R"` 19 | fi 20 | echo $DATE >> /home/pi/start.log 21 | IP_G=`cat /home/pi/start.log |grep "local IP address"|cut -d' ' -f6|tail -1` 22 | echo -e "`hostname` が $DATE に起動しました。\n$IP\n$IP_G"\ 23 | | mutt -s "自動起動通知" -a /home/pi/cam.jpg -- $MAILTO >> /home/pi/start.log 2>&1 24 | /home/pi/esp/tools/soracom stop >> /home/pi/start.log 2>&1 25 | wall "The system is going down for power-off (シャットダウンを開始)" 26 | sleep 10 27 | sudo shutdown -h # now オプションを付与することですぐにシャットダウンする 28 | exit 0 29 | -------------------------------------------------------------------------------- /tools/aquestalk_tsig.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 現在の時刻を再生します。 3 | # 4 | # 本プログラムを実行するには、AQUEST社の AquesTalkPiが必要です。 5 | # 6 | # AquesTalkPi のインストール方法 7 | # ./aquestalk_setup.sh 8 | 9 | TIME_START=6 # 時報の開始時刻(6:00~) 10 | TIME_END=23 # 時報の終了時刻(~23:59) 11 | HOUR=`date "+%_H"` # 現在の時刻(時) 12 | MIN=`date "+%_M"` # 現在の時刻(分) 13 | if [ ${HOUR} -ge ${TIME_START} ] && [ ${HOUR} -le ${TIME_END} ]; then 14 | if [ ${MIN} -eq 0 ]; then 15 | # 毎時0分のときは「分」を省略して再生 16 | TALK=${HOUR}"時です。" 17 | else 18 | # 毎時0分以外の時は「時」と「分」を再生 19 | TALK=${HOUR}"時"${MIN}"分です。" 20 | fi 21 | # 再生の実行と、5秒後にaplayプロセスの終了 22 | echo ${TALK} 23 | aplay /home/pi/esp/3_misc/sound/se_maoudamashii_voice_bird02.wav & 24 | sleep 0.2 25 | /home/pi/esp/tools/aquestalkpi/AquesTalkPi "${TALK}"|aplay & 26 | (sleep 5; kill `pidof aplay`) &> /dev/null & 27 | fi 28 | -------------------------------------------------------------------------------- /2_example/example04c_le/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example17_bell/chimeBells.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | チャイム 3 | 4 | int chimeBells(int output, int count); 5 | 6 | int output LEDを接続したIOピン番号 7 | int count チャイム音が終わるまでのカウントダウン値(0で終了) 8 | int 戻り値 count-1(0以上) 9 | 10 | 処理時間:約1秒 11 | 12 | Copyright (c) 2016-2019 Wataru KUNINO 13 | *******************************************************************************/ 14 | 15 | int chimeBells(int output, int count) { 16 | int t; 17 | if(count==0)return 0; 18 | if(!(count%2)){ 19 | tone(output,NOTE_CS6,800); 20 | for(t=0;t<8;t++) delay(100); 21 | noTone(output); 22 | for(t=0;t<2;t++) delay(100); 23 | }else{ 24 | tone(output,NOTE_A5,800); 25 | for(t=0;t<8;t++) delay(100); 26 | noTone(output); 27 | for(t=0;t<2;t++) delay(100); 28 | } 29 | count--; 30 | if(count<0) count=0; 31 | return(count); 32 | } 33 | -------------------------------------------------------------------------------- /2_example/example09c_hum/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example09m_hum/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example10c_hpa/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example13c_ntp/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example09c_hum_sht31/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example09c_hum_si7021/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example36c_le/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include // ESP32用WiFiライブラリ 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /2_example/example60_lcdkey/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include // ESP32用WiFiライブラリ 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /5_learn32/esp32_02_led2/esp32_02_led2.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 2: 2個のLEDを点滅させる 3 | Copyright (c) 2016-2019 Wataru KUNINO 4 | ***********************************************************************/ 5 | 6 | #define PIN_LED1 2 // IO 2にLED1を接続 7 | #define PIN_LED2 23 // IO 23にLED2を接続 8 | 9 | void setup() { // 起動時に一度だけ実行される関数 10 | pinMode(PIN_LED1,OUTPUT); // LEDを接続したポートを出力に設定する 11 | pinMode(PIN_LED2,OUTPUT); // LEDを接続したポートを出力に設定する 12 | } 13 | 14 | void loop() { // setup実行後に繰り返し実行される関数 15 | if(hallRead() < 30)return; // ホールセンサ値30以下時は実行しない 16 | digitalWrite(PIN_LED1,HIGH);// LED1をHレベル(3.3V)に設定(点灯) 17 | digitalWrite(PIN_LED2,LOW); // LED2をLレベル(0V)に設定(消灯) 18 | delay(100); // 時間待ち(100ms) 19 | digitalWrite(PIN_LED1,LOW); // LED1をLレベル(0V)に設定(消灯) 20 | digitalWrite(PIN_LED2,HIGH);// LED2をHレベル(3.3V)に設定(点灯) 21 | delay(100); // 時間待ち(100ms) 22 | } 23 | -------------------------------------------------------------------------------- /5_learn32/esp32_23_rtr_lcd/Ambient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ambient.h - Library for sending data to Ambient 3 | * Created by Takehiko Shimojima, April 21, 2016 4 | */ 5 | #ifndef Ambient_h 6 | #define Ambient_h 7 | 8 | #include "Arduino.h" 9 | #include // ESP32用WiFiライブラリ 10 | 11 | #define AMBIENT_WRITEKEY_SIZE 18 12 | #define AMBIENT_MAX_RETRY 5 13 | #define AMBIENT_DATA_SIZE 24 14 | #define AMBIENT_NUM_PARAMS 11 15 | 16 | class Ambient 17 | { 18 | public: 19 | 20 | Ambient(void); 21 | 22 | void begin(unsigned int channelId, const char * writeKey, WiFiClient * c, int dev = 0); 23 | bool set(int field, char * data); 24 | bool clear(int field); 25 | 26 | bool send(); 27 | 28 | private: 29 | 30 | WiFiClient * client; 31 | unsigned int channelId; 32 | char writeKey[AMBIENT_WRITEKEY_SIZE]; 33 | int dev; 34 | char host[18]; 35 | int port; 36 | 37 | struct { 38 | int set; 39 | char item[AMBIENT_DATA_SIZE]; 40 | } data[AMBIENT_NUM_PARAMS]; 41 | }; 42 | 43 | #endif // Ambient_h 44 | -------------------------------------------------------------------------------- /5_learn32/esp32_05_i2c/esp32_05_i2c.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 5: I2Cインタフェース接続 湿度センサ 3 | Copyright (c) 2017-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | #define PIN_EN 2 // IO 2をセンサの電源に 7 | 8 | void setup() { 9 | pinMode(PIN_EN,OUTPUT); // センサ用の電源を出力に 10 | digitalWrite(PIN_EN,HIGH); // センサ用の電源をONに 11 | shtSetup(); 12 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 13 | } 14 | 15 | void loop() { 16 | float temp,hum; // 温度値と湿度値を保持する変数を定義 17 | temp=getTemp(); // 温度値を取得し、変数tempへ代入 18 | hum =getHum(); // 湿度値を変数humへ代入 19 | Serial.print(temp,2); // 変数tempの値をシリアル出力 20 | Serial.print(", "); // カンマとスペースをシリアル出力 21 | Serial.println(hum,2); // 変数tempの値をシリアル出力 22 | delay(3000); // 3秒間(3000ms)の待ち時間処理 23 | } 24 | -------------------------------------------------------------------------------- /5_learn32/esp32_18_voice/uspeech_LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012-2014 Arjo Chakravarty 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /5_learn32/esp32_18_voice_ok/uspeech_LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012-2014 Arjo Chakravarty 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /2_example/example31_demo/README.md: -------------------------------------------------------------------------------- 1 | Example 31 2 | # 最新IoTモジュール ESP32-WROOM-32用 ESP32 DEMO (HTTP版) デモ用 3 | 4 | 展示会などでPCやスマホから直接ESPモジュールへ接続する場合のサンプルです。 5 | ESP32内に内蔵されているホール効果素子センサと、タッチセンサの検出値をスマホのウェブブラウザへ表示します。 6 | 7 | ## 製作方法 8 | 9 | 純正のESP32用 DevKitC 開発ボード、またはDOIT製ESP32用 DEV KIT V1 開発ボードなどへスケッチを書き込んでください。 10 | 11 | ## ESP32内蔵 Wi-Fiアクセスポイント機能 12 | 13 | Wi-Fiモジュール使ったデモでは、ネットワークを組んだり、PC やスマホを接続したりする際の手間が課題となることがあります。 14 | そこで、ESP32に内蔵されている無線LAN アクセスポイント機能を使用し、一時的なネットワーク環境下でESP32に内蔵されているホール効果素子センサとタッチセンサの読み値を確認できるサンプルを作成しました。 15 | 16 | ## ESP32内蔵 ホール効果素子センサ 17 | 18 | ホール効果素子センサは磁界を検出することができます。 19 | 磁石をESP32 モジュールへ接触させたり遠ざけたりするとプラスまたはマイナス方向へ読み値が変化します. 20 | 21 | ## ESP32内蔵 タッチセンサ 22 | 23 | タッチセンサ用に使用可能なピンはIO 0,2,4,12~15,27,32 ~ 33 の10 ポートです。 24 | これらのポートを指で触れると、センサ状態(ONまたはOFF)が変化します。 25 | 26 | ## スマホでセンサ値を確認する 27 | 28 | スマホからESP32の無線LANへ接続し、ウェブブラウザでホール効果素子センサとタッチセンサの値を確認することが出来ます。 29 | スマホ側のIP アドレスはESP モジュール側のDHCP サーバが自動的に割り振りふります。 30 | ESPモジュール側のIPアドレスは固定(192.168.1.2)です。二次元バーコードなどから簡単にアクセスできるでしょう。 31 | 32 | Copyright (c) 2016-2019 Wataru KUNINO 33 | 34 | -------------------------------------------------------------------------------- /2_example/example63_google/utf_del_uni.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去します(UTF8をASCIIカナ文字へ変換するときに使用) 6 | 7 | Copyright (c) 2014-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | char _utf_del_uni_buf[65]; 12 | 13 | char * utf_del_uni(char *in){ 14 | char *s=_utf_del_uni_buf; 15 | unsigned int i=0; 16 | unsigned int j=0; 17 | 18 | strncpy(s,in,64); 19 | s[64]=0; 20 | while(s[i]!='\0'){ 21 | if((byte)s[i]==0xEF){ 22 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 23 | i+=2; 24 | } 25 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 26 | s[j]=s[i]; 27 | j++; 28 | } 29 | i++; 30 | } 31 | s[j]='\0'; 32 | return s; 33 | } 34 | 35 | char * utf_del_uni(String &in){ 36 | in.toCharArray(_utf_del_uni_buf,65); 37 | return utf_del_uni(_utf_del_uni_buf); 38 | } 39 | -------------------------------------------------------------------------------- /tools/automail_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | MAILTO="pi@localhost" # メール送信先 3 | 4 | echo "Raspberry Pi 起動後にメールを自動送信するための設定を行うスクリプトです。" 5 | echo "注意:設定後は、起動しても自動的にシャットダウンしてしまいます。" 6 | if [ -e /etc/ssmtp/ssmtp.conf ] && [ -e ~/.muttrc ]; then 7 | echo "メール設定済みと判断しました。" 8 | else 9 | ./gmail_setup.sh 10 | fi 11 | echo "-------------------------------------------------------------------------" 12 | echo "USBカメラ用のソフトウェアfswebcamをインストールしますか?" 13 | echo "詳細:https://www.sanslogic.co.uk/fswebcam/" 14 | echo "インストールする場合は「yes」を入力してください。" 15 | echo -n "yes/no >" 16 | read yes 17 | if [ "$yes" = "yes" ]; then 18 | sudo apt-get install fswebcam 19 | fi 20 | 21 | echo "-------------------------------------------------------------------------" 22 | echo "自動メール送信を設定します。" 23 | echo "自動メールの送信先を入力してください" 24 | read MAILTO 25 | if [ "$yes" = "yes" ]; then 26 | cat automail_cam.txt|sed "s/MAILTO=\"\"/MAILTO=\"$MAILTO\"/g" > automail.sh 27 | else 28 | cat automail.txt|sed "s/MAILTO=\"\"/MAILTO=\"$MAILTO\"/g" > automail.sh 29 | fi 30 | sudo chmod a+x automail.sh 31 | sudo cp -b automail_rc.local /etc/rc.local 32 | sudo chmod a+x /etc/rc.local 33 | echo "設定を完了しました。" 34 | -------------------------------------------------------------------------------- /tools/gmail_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Gmail(Google のメール) セットアップ 4 | # 2016/07/02 国野亘 5 | # 6 | # このスクリプトは下記のサイトの情報を参考にして作成しました。 7 | # http://www.tapun.net/raspi/raspberry-pi-ssmtp-mutt 8 | 9 | echo "Gmail(Google のメール) セットアップ" 10 | echo "Gmailのアカウントを入力してください" 11 | read MAIL 12 | echo "Gmailのパスワードを入力してください" 13 | read PASS 14 | 15 | echo 16 | echo "sSMTPとMuttのインストールを開始します" 17 | sudo apt-get install -y ssmtp 18 | sudo apt-get install -y mutt 19 | 20 | echo 21 | echo "設定ファイルを作成します" 22 | cat << EOF > ssmtp.conf 23 | root=MAIL@gmail.com 24 | mailhub=smtp.gmail.com:587 25 | hostname=raspberrypi 26 | AuthUser=MAIL@gmail.com 27 | AuthPass=PASS 28 | UseSTARTTLS=YES 29 | EOF 30 | 31 | cat ssmtp.conf|sed s/MAIL/${MAIL}/g|sed s/PASS/${PASS}/g > ssmtp.conf~ 32 | sudo mv /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf~ >& /dev/null 33 | sudo mv ssmtp.conf~ /etc/ssmtp/ssmtp.conf 34 | 35 | cat << EOF > .muttrc 36 | set sendmail="/usr/sbin/ssmtp" 37 | set realname="My Raspberry Pi" 38 | set from="MAIL@gmail.com" 39 | EOF 40 | 41 | cat .muttrc|sed s/MAIL/${MAIL}/g > .muttrc~ 42 | mv ~/.muttrc ~/.muttrc~ >& /dev/null 43 | mv .muttrc~ ~/.muttrc 44 | echo 45 | echo "セットアップが完了しました" 46 | -------------------------------------------------------------------------------- /2_example/example16_led/ledCtrl.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | LEDの輝度制御 3 | 4 | int ledCtrl(int start,int end,int speed); 5 | 6 | int start 現在の輝度 (0~1023) 7 | int end 制御後の輝度(0~1023) 8 | int speed 制御速度 (1~100程度・1で約1秒、10で約0.1秒) 9 | int 戻り値 制御後の輝度 10 | 11 | Copyright (c) 2016-2019 Wataru KUNINO 12 | *******************************************************************************/ 13 | 14 | int ledCtrl(int start,int end,int speed){ // ledのアナログ制御用の関数 15 | int i; // (startからendへ輝度を推移する) 16 | if(speed<1)speed=1; 17 | if(start<=end){ 18 | if(start<1) start=1; 19 | if(end>1023) end=1023; 20 | for(i=start;i1023) start=1023; 26 | if(end<0) end=0; 27 | for(i=start;i>end;i>>=1){ 28 | analogWrite(PIN_LED,i); 29 | delay(100/speed); 30 | } 31 | } 32 | analogWrite(PIN_LED,end); 33 | return(end); 34 | } 35 | -------------------------------------------------------------------------------- /2_example/example16w_led/ledCtrl.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | LEDの輝度制御 3 | 4 | int ledCtrl(int start,int end,int speed); 5 | 6 | int start 現在の輝度 (0~1023) 7 | int end 制御後の輝度(0~1023) 8 | int speed 制御速度 (1~100程度・1で約1秒、10で約0.1秒) 9 | int 戻り値 制御後の輝度 10 | 11 | Copyright (c) 2016-2019 Wataru KUNINO 12 | *******************************************************************************/ 13 | 14 | int ledCtrl(int start,int end,int speed){ // ledのアナログ制御用の関数 15 | int i; // (startからendへ輝度を推移する) 16 | if(speed<1)speed=1; 17 | if(start<=end){ 18 | if(start<1) start=1; 19 | if(end>1023) end=1023; 20 | for(i=start;i1023) start=1023; 26 | if(end<0) end=0; 27 | for(i=start;i>end;i>>=1){ 28 | analogWrite(PIN_LED,i); 29 | delay(100/speed); 30 | } 31 | } 32 | analogWrite(PIN_LED,end); 33 | return(end); 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2021 Wataru KUNINO https://bokunimo.net/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /2_example/example47_camG/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## シリアルのTXDとRXDはクロス接続 10 | カメラのTXDをESPモジュールのRXD(本サンプルではGPIO16(27番ピン))に、 11 | カメラのRXDをESPモジュールのTXD(本サンプルではGPIO17(28番ピン))に 12 | 接続してください。 13 | 14 | ## LCDに「ESP32 eg15 Cam」が表示されたまま動作しない 15 | SPIFFSが無効になっています。 16 | コンパイル時に128KB以上のSPIFFS(最新SDKではFSと表示)を設定して 17 | ください。 18 | 19 | ## LCDに「Cam Init」が表示されたまま動作しない① 20 | Wi-Fiアクセスポイントとの接続に失敗しています。 21 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 22 | #define SSIDとPASSに設定して下さい。 23 | 24 | ## LCDに「Cam Init」が表示されたまま動作しない② 25 | カメラとの通信に失敗しています。 26 | カメラの電源電圧、シリアル配線などを確認してください。 27 | 28 | ## Raspberry Piで受信できない 29 | しばらく待って、LCDに「Sleeping」「zzz...」と表示されることを 30 | 確認してください。表示されたら、ENボタンを押して、再送信して 31 | みて下さい。 32 | それでも、動作しない場合は、 33 | ネットワーク内のDHCPサーバが動作していない、 34 | 異なる無線LANアクセスポイントへ接続されている、 35 | 異なるIPアドレスが設定されている、 36 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 37 | パケットが破棄されているなどが考えられます。 38 | 39 | ## 動作ログの確認方法(ご参考) 40 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 41 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 42 | 115200に設定すると、動作ログが表示されます。 43 | -------------------------------------------------------------------------------- /tools/index.html: -------------------------------------------------------------------------------- 1 | Test Page 2 | 3 | 4 | 5 | 6 | 7 |

Test Page for ESP8266 Sensors

8 | 9 | 10 | 12 | 14 | 15 | 16 | 18 | 20 | 21 | 22 | 24 | 31 | 32 |
ワイヤレス・温湿度センサ humid_1
11 |
ワイヤレス・気圧センサ press_1
13 |
ワイヤレス・照度センサ illum_1
17 |
ワイヤレス・温度センサ temp._1
19 |
ワイヤレス・ドアスイッチ rd_sw_1
23 |
25 |

サポート情報

33 |
34 | 35 | -------------------------------------------------------------------------------- /2_example/example64_photo_m5/gfxfont.h: -------------------------------------------------------------------------------- 1 | /* 2 | 本ソースリストは2017/11/2に下記からダウンロードしたものです。 3 | 4 | https://learn.adafruit.com/096-mini-color-oled/wiring 5 | 6 | 2017/11/2 国野 亘 7 | */ 8 | 9 | // Font structures for newer Adafruit_GFX (1.1 and later). 10 | // Example fonts are included in 'Fonts' directory. 11 | // To use a font in your Arduino sketch, #include the corresponding .h 12 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 13 | // revert to 'classic' fixed-space bitmap font. 14 | 15 | #ifndef _GFXFONT_H_ 16 | #define _GFXFONT_H_ 17 | 18 | typedef struct { // Data stored PER GLYPH 19 | uint16_t bitmapOffset; // Pointer into GFXfont->bitmap 20 | uint8_t width, height; // Bitmap dimensions in pixels 21 | uint8_t xAdvance; // Distance to advance cursor (x axis) 22 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 23 | } GFXglyph; 24 | 25 | typedef struct { // Data stored for FONT AS A WHOLE: 26 | uint8_t *bitmap; // Glyph bitmaps, concatenated 27 | GFXglyph *glyph; // Glyph array 28 | uint8_t first, last; // ASCII extents 29 | uint8_t yAdvance; // Newline distance (y axis) 30 | } GFXfont; 31 | 32 | #endif // _GFXFONT_H_ 33 | -------------------------------------------------------------------------------- /2_example/example16f_led/ledCtrl.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | LEDの輝度制御 3 | 4 | int ledCtrl(int start,int end,int speed); 5 | 6 | int pin LEDを接続したポート番号 7 | int start 現在の輝度 (0~1023) 8 | int end 制御後の輝度(0~1023) 9 | int speed 制御速度 (1~100程度・1で約1秒、10で約0.1秒) 10 | int 戻り値 制御後の輝度 11 | 12 | Copyright (c) 2016-2019 Wataru KUNINO 13 | *******************************************************************************/ 14 | 15 | int ledCtrl(int pin,int start,int end,int speed){ // ledのアナログ制御用の関数 16 | int i; // (startからendへ輝度を推移する) 17 | if(speed<1)speed=1; 18 | if(start<=end){ 19 | if(start<1) start=1; 20 | if(end>1023) end=1023; 21 | for(i=start;i1023) start=1023; 27 | if(end<0) end=0; 28 | for(i=start;i>end;i>>=1){ 29 | analogWrite(pin,i); 30 | delay(100/speed); 31 | } 32 | } 33 | analogWrite(pin,end); 34 | return(end); 35 | } 36 | -------------------------------------------------------------------------------- /tools/soracom_setupAK020.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # j3tm0t0/AK-020_setup.sh 4 | # run as root to configure your raspbian to use AK-020 with SORACOM Air SIM 5 | # 6 | # このスクリプトは下記のサイトからダウンロードしたものを修正しました。 7 | # 2016/06/08 国野亘 8 | # https://gist.githubusercontent.com/j3tm0t0/2a126ba2592202ba5de4498d8a56cfb2 9 | 10 | # install required packages 11 | apt-get install -y eject wvdial 12 | 13 | # add wvdial config 14 | cat << EOF > /etc/wvdial.conf 15 | [Dialer Defaults] 16 | Init1 = ATZ 17 | Init2 = AT+CFUN=1 18 | Init3 = AT+CGDCONT=1,"IP","soracom.io" 19 | Dial Attempts = 3 20 | Modem Type = Analog Modem 21 | Dial Command = ATD 22 | Stupid Mode = yes 23 | Baud = 460800 24 | New PPPD = yes 25 | Modem = /dev/ttyUSB0 26 | ISDN = 0 27 | APN = soracom.io 28 | Phone = *99***1# 29 | Username = sora 30 | Password = sora 31 | Carrier Check = no 32 | Auto DNS = 1 33 | Check Def Route = 1 34 | EOF 35 | 36 | # add replacedefaultroute option to ppp config 37 | cat << EOF > /etc/ppp/peers/wvdial 38 | noauth 39 | name wvdial 40 | usepeerdns 41 | replacedefaultroute 42 | EOF 43 | 44 | # 接続コマンドsoracomのUSB ID設定 45 | cat soracom|sed "s/vendor=0x.*$/vendor=0x15eb product=0x7d0e/g">soracom~ 46 | mv soracom~ soracom 47 | chmod a+rwx soracom 48 | -------------------------------------------------------------------------------- /2_example/example64_photo/gfxfont.h: -------------------------------------------------------------------------------- 1 | /* 2 | 本ソースリストは2017/11/2に下記からダウンロードしたものです。 3 | 改変部以外は原作者の権利が継続します。 4 | 5 | https://learn.adafruit.com/096-mini-color-oled/wiring 6 | 7 | 2017/11/2 国野 亘 8 | */ 9 | 10 | // Font structures for newer Adafruit_GFX (1.1 and later). 11 | // Example fonts are included in 'Fonts' directory. 12 | // To use a font in your Arduino sketch, #include the corresponding .h 13 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 14 | // revert to 'classic' fixed-space bitmap font. 15 | 16 | #ifndef _GFXFONT_H_ 17 | #define _GFXFONT_H_ 18 | 19 | typedef struct { // Data stored PER GLYPH 20 | uint16_t bitmapOffset; // Pointer into GFXfont->bitmap 21 | uint8_t width, height; // Bitmap dimensions in pixels 22 | uint8_t xAdvance; // Distance to advance cursor (x axis) 23 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 24 | } GFXglyph; 25 | 26 | typedef struct { // Data stored for FONT AS A WHOLE: 27 | uint8_t *bitmap; // Glyph bitmaps, concatenated 28 | GFXglyph *glyph; // Glyph array 29 | uint8_t first, last; // ASCII extents 30 | uint8_t yAdvance; // Newline distance (y axis) 31 | } GFXfont; 32 | 33 | #endif // _GFXFONT_H_ 34 | -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/gfxfont.h: -------------------------------------------------------------------------------- 1 | /* 2 | 本ソースリストは2017/11/2に下記からダウンロードしたものです。 3 | 改変部以外は原作者の権利が継続します。 4 | 5 | https://learn.adafruit.com/096-mini-color-oled/wiring 6 | 7 | 2017/11/2 国野 亘 8 | */ 9 | 10 | // Font structures for newer Adafruit_GFX (1.1 and later). 11 | // Example fonts are included in 'Fonts' directory. 12 | // To use a font in your Arduino sketch, #include the corresponding .h 13 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 14 | // revert to 'classic' fixed-space bitmap font. 15 | 16 | #ifndef _GFXFONT_H_ 17 | #define _GFXFONT_H_ 18 | 19 | typedef struct { // Data stored PER GLYPH 20 | uint16_t bitmapOffset; // Pointer into GFXfont->bitmap 21 | uint8_t width, height; // Bitmap dimensions in pixels 22 | uint8_t xAdvance; // Distance to advance cursor (x axis) 23 | int8_t xOffset, yOffset; // Dist from cursor pos to UL corner 24 | } GFXglyph; 25 | 26 | typedef struct { // Data stored for FONT AS A WHOLE: 27 | uint8_t *bitmap; // Glyph bitmaps, concatenated 28 | GFXglyph *glyph; // Glyph array 29 | uint8_t first, last; // ASCII extents 30 | uint8_t yAdvance; // Newline distance (y axis) 31 | } GFXfont; 32 | 33 | #endif // _GFXFONT_H_ 34 | -------------------------------------------------------------------------------- /2_example/example22a_jam/ESP8266FtpServer_README.md: -------------------------------------------------------------------------------- 1 | # esp8266FTPServer 2 | Simple FTP Server for using esp8266 SPIFFs 3 | 4 | 5 | I've modified a FTP server from arduino/wifi shield to work with esp8266.... 6 | 7 | This allows you to FTP into your esp8266 and access/modify the spiffs folder/data...it only allows one ftp connection at a time....very simple for now... 8 | 9 | I've tested it with Filezilla, and the basics work (update/download/rename/delete). There's no create/modify directory support(no directory support in SPIFFS yet). 10 | 11 | You need to setup Filezilla(or other client) to only allow 1 connection.. 12 | To force FileZilla to use the primary connection for data transfers: 13 | Go to File/Site Manager then select your site. 14 | In Transfer Settings, check "Limit number of simultaneous connections" and set the maximum to 1 15 | 16 | only supports Passive ftp mode.... 17 | 18 | It does NOT support any encryption, so you'll have to disable any form of encryption... 19 | 20 | feel free to try it out (sample provided)....unzip into your arduino library directory (and restart arduino ide). 21 | 22 | 23 | this is the original project on github I worked from: https://github.com/gallegojm/Arduino-Ftp-Server/tree/master/FtpServer 24 | -------------------------------------------------------------------------------- /2_example/example25a_fs/ESP8266FtpServer_README.md: -------------------------------------------------------------------------------- 1 | # esp8266FTPServer 2 | Simple FTP Server for using esp8266 SPIFFs 3 | 4 | 5 | I've modified a FTP server from arduino/wifi shield to work with esp8266.... 6 | 7 | This allows you to FTP into your esp8266 and access/modify the spiffs folder/data...it only allows one ftp connection at a time....very simple for now... 8 | 9 | I've tested it with Filezilla, and the basics work (update/download/rename/delete). There's no create/modify directory support(no directory support in SPIFFS yet). 10 | 11 | You need to setup Filezilla(or other client) to only allow 1 connection.. 12 | To force FileZilla to use the primary connection for data transfers: 13 | Go to File/Site Manager then select your site. 14 | In Transfer Settings, check "Limit number of simultaneous connections" and set the maximum to 1 15 | 16 | only supports Passive ftp mode.... 17 | 18 | It does NOT support any encryption, so you'll have to disable any form of encryption... 19 | 20 | feel free to try it out (sample provided)....unzip into your arduino library directory (and restart arduino ide). 21 | 22 | 23 | this is the original project on github I worked from: https://github.com/gallegojm/Arduino-Ftp-Server/tree/master/FtpServer 24 | -------------------------------------------------------------------------------- /2_example/setWifiSSID.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "################################################################################" 3 | echo "全サンプルスケッチの SSID と PASS を 自動的に設定します。" 4 | echo "書き換えた SSID と PASS を修正する場合は、resetで戻してから、yesで変更して下さい" 5 | echo " Copyright (c) 2016-2019 Wataru KUNINO" 6 | echo "################################################################################" 7 | # 1234567890123 456789012 3 8 | SSID_old="#define SSID \"1234ABCD\" // 無線LANアクセスポイントのSSID" 9 | PASS_old="#define PASS \"password\" // パスワード" 10 | 11 | echo -n "「yes」を入力するとSSIDとPASSを書き換えます。(yes/no/reset) ? " 12 | read yes 13 | if [ "$yes" = "yes" ];then 14 | echo -n "SSID = "; read SSID 15 | echo -n "PASS = "; read PASS 16 | sed -i -e "s/${SSID_old::23}/${SSID_old::14}${SSID}\"/g" -e "s/${PASS_old::23}/${PASS_old::14}${PASS}\"/g" */example*.ino 17 | fi 18 | if [ "$yes" = "reset" ];then 19 | sed -i -e "/${SSID_old::14}/c${SSID_old}" -e "/${PASS_old::14}/c${PASS_old}" */example*.ino 20 | fi 21 | ls */example*.ino | while read file_ino; do 22 | echo -n $file_ino" " 23 | grep "${SSID_old::13}" $file_ino|cut -d" " -f1-3|tr -d "\n" 24 | echo -n "," 25 | grep "${PASS_old::13}" $file_ino|cut -d" " -f3 26 | if [ $? != 0 ];then echo; fi 27 | done 28 | -------------------------------------------------------------------------------- /2_example/example52_camG/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## シリアルのTXDとRXDはクロス接続 10 | カメラのTXDをESPモジュールのRXD(本サンプルではGPIO16(27番ピン))に、 11 | カメラのRXDをESPモジュールのTXD(本サンプルではGPIO17(28番ピン))に 12 | 接続してください。 13 | 14 | ## LCDに「Example 20 cam」が表示されたまま動作しない① 15 | Wi-Fiアクセスポイントとの接続に失敗しています。 16 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 17 | #define SSIDとPASSに設定して下さい。 18 | 19 | ## LCDに「Example 20 cam」が表示されたまま動作しない② 20 | カメラとの通信に失敗しています。 21 | カメラの電源電圧、シリアル配線などを確認してください。 22 | 23 | ## ブラウザに「防犯カメラ STATUS」の画面が表示されない 24 | ネットワーク内のDHCPサーバが動作していない、 25 | 異なる無線LANアクセスポイントへ接続されている、 26 | 異なるIPアドレスが設定されている、 27 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 28 | パケットが破棄されているなどが考えられます。 29 | 30 | ## ブラウザの互換性・ブラウザのセキュリティ対策 31 | ブラウザのバージョンアップやセキュリティ対策により、表示でき 32 | なくなることがあります。 33 | また、ブラウザのバージョンアップで表示できるようになることも 34 | あります。 35 | 例えば、IPアドレスによるアクセスを危険と見なす場合もあれば、 36 | 同一LAN内のコンテンツは安全と見なす場合など、ブラウザや、その 37 | バージョン、設定、ブラウザを開発する会社の方針などによって 38 | 状況が変化します。 39 | 一例として、以下のような複数のブラウザで試してみて下さい。 40 | (IE、Edge、Safari、Chrome、FireFoxなど) 41 | 42 | ## 動作ログの確認方法(ご参考) 43 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 44 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 45 | 115200bpsに設定すると、動作ログが表示されます。 46 | -------------------------------------------------------------------------------- /2_example/example28_lcdkey/README.md: -------------------------------------------------------------------------------- 1 | Example 28: 2 | # LCDへ表示する(HTTP版・時刻表示機能・NTP受信機能付き・棒グラフ機能) 3 | 4 | ESP-WROOM-02を搭載した ESPduino または WEMOS D1 へ、Arduino 用 LCD Keypad Shield を装着して使用するWi-Fi LCD端末です。 5 | 6 | ## ボタン操作 7 | 8 | ### SELECTボタン 9 | 10 | 本機のIPアドレスを表示します。また、長押しで棒グラフ表示モードへ切り換えます。 11 | 12 | ### UP/DOWNボタン 13 | 14 | 過去に受信した履歴データを表示します。時刻部に「!」が表示されます。履歴表示を解除するときは SELECTボタンを押してください。 15 | 16 | ### LEFT/RIGHTボタン 17 | 18 | 受信したデータが表示しきれないときに左右に文字を移動させて内容を確認することが出来ます。 19 | 20 | ## 製作に必要なデバイス 21 | 22 | * ESPduino または WEMOS D1 23 | * Arduino 用 LCD Keypad Shield 24 | * その他、周辺部品など 25 | 26 | ## 動作方法 27 | 28 | ソースリスト中の#define部へ無線LANアクセスポイントのSSIDとパスワード(PASS)を設定して下さい。 29 | また、マイコンボードに応じて以下のどちらかを選択してください。 30 | 31 | LiquidCrystal lcd(14,15,4,5,12,13); // ESPduino用 32 | LiquidCrystal lcd(0,2,4,14,12,13); // WEMOS D1用 33 | 34 | 起動時にアクセスポイントへ接続できなかった場合は、本機が無線アクセスポイントとなって動作します。 35 | 詳細な操作はインターネットブラウザから本機にアクセスして設定して下さい。 36 | 37 | ## ご注意 38 | 39 | * リセットもしくは電源を切る前に、ファイル出力をOFFに設定してください(インターネット・ブラウザから設定) 40 | * ログを保存したい場合は、はじめにSPIFFSを初期化する必要があります(インターネット・ブラウザで操作) 41 | * 本機のアクセスポイントモード動作時はブロードキャストの中継が出来ません 42 | ** ESP32で使用している IPスタックlwIP(lightweight IP)の仕様です 43 | ** 本機でのブロードキャストの送受信は可能です 44 | 45 | Copyright (c) 2016-2019 Wataru KUNINO 46 | 47 | -------------------------------------------------------------------------------- /tools/udp_logger_cygwin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # UDPを受信する 3 | # Copyright (c) 2016 Wataru KUNINO 4 | 5 | echo "UDP Logger (usage: ${0} port)" # タイトル表示 6 | if [ ${#} = 1 ] # 入力パラメータ数の確認 7 | then # 1つだった時 8 | if [ ${1} -ge 1 ] && [ ${1} -le 65535 ] # ポート番号の範囲確認 9 | then # 1以上65535以下の時 10 | PORT=${1} # ポート番号を設定 11 | else # 範囲外だった時 12 | PORT=1024 # UDPポート番号を1024に 13 | fi # ifの終了 14 | else # 1つでは無かった時 15 | PORT=1024 # UDPポート番号を1024に 16 | fi # ifの終了 17 | echo "Listening UDP port "${PORT}"..." # ポート番号表示 18 | while true # 永遠に 19 | do # 繰り返し 20 | UDP=`nc -luw0 ${PORT}` # UDPパケットを取得 21 | DATE=`date "+%Y/%m/%d %R"` # 日時を取得 22 | echo -E $DATE, $UDP # 取得日時とデータを表示 23 | done # 繰り返しここまで 24 | -------------------------------------------------------------------------------- /tools/soracom: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SORACOM Air 接続用スクリプト 4 | # 5 | # このスクリプトを実行する前にsoracom_setupAK020またはsoracom_setupL02Cを 6 | # 実行して必要なソフトのインストールと設定ファイルの作成を行ってください。 7 | # 8 | # 2016/06/08 国野亘 9 | 10 | # このスクリプトは下記のサイトからダウンロードしたものの一部を改変しました。 11 | # https://gist.github.com/j3tm0t0/65367f971c3d770557f3 12 | # j3tm0t0/soracomair 13 | # SORACOM Air + FS01BU を、Raspberry Pi や Intel Edison 14 | # (debianインストール&USB-OTGケーブルで接続) で使用するための接続スクリプト 15 | # (要: wvdial / usb-modeswitch)と、init用スクリプト by dietposter 16 | 17 | start(){ 18 | echo "connect air..." 19 | eject sr0 2> /dev/null 20 | sudo modprobe usbserial vendor=0x1004 product=0x618f 21 | echo waiting for modem device 22 | for i in `seq 0 10`; do 23 | [ -e "/dev/ttyUSB0" ] && break 24 | echo -n . 25 | sleep 1 26 | done 27 | if [ -e "/dev/ttyUSB0" ]; then 28 | sudo wvdial & 29 | else 30 | echo modem not found 31 | exit 1 32 | fi 33 | return 0 34 | } 35 | stop(){ 36 | echo "stopping connect air..." 37 | sudo killall wvdial 38 | 39 | return 0 40 | } 41 | 42 | case $1 in 43 | start) 44 | start 45 | sleep 14 46 | ;; 47 | stop) 48 | stop 49 | sleep 3 50 | ;; 51 | *) 52 | echo "Usage: $0 {start|stop}" 53 | exit 2 54 | ;; 55 | esac 56 | exit 0 57 | -------------------------------------------------------------------------------- /tools/sonet_setupL02C.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # docomo L02C用 セットアップ 4 | # 2016/06/08 国野亘 5 | # 6 | # このスクリプトは下記のサイトの情報を参考にして作成しました。 7 | # https://gist.githubusercontent.com/j3tm0t0/2a126ba2592202ba5de4498d8a56cfb2 8 | # http://www.okahiro.info/gd/2016/03/18/post-1249/ 9 | 10 | # install required packages 11 | apt-get install -y eject wvdial 12 | 13 | # add wvdial config 14 | cat << EOF > /etc/wvdial.conf 15 | [Dialer Defaults] 16 | Init1 = ATZ 17 | Init2 = ATH 18 | Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 19 | Dial Attempts = 3 20 | Modem Type = Analog Modem 21 | Dial Command = ATD 22 | Stupid Mode = yes 23 | Baud = 460800 24 | New PPPD = yes 25 | Modem = /dev/ttyUSB2 26 | ISDN = 0 27 | APN = so-net.jp 28 | Phone = *99***1# 29 | Username = nuro 30 | Password = nuro 31 | Carrier Check = no 32 | Auto DNS = 1 33 | Check Def Route = 1 34 | EOF 35 | 36 | # add replacedefaultroute option to ppp config 37 | cat << EOF > /etc/ppp/peers/wvdial 38 | noauth 39 | name wvdial 40 | usepeerdns 41 | replacedefaultroute 42 | EOF 43 | 44 | # 接続コマンドsoracomのUSB ID設定 45 | cat soracom|sed "s/vendor=0x.*$/vendor=0x1004 product=0x618f/g">soracom~ 46 | mv soracom~ soracom 47 | chmod a+rwx soracom 48 | 49 | #終了メッセージ 50 | echo "------------------------------------------------" 51 | echo "設定が完了しました" 52 | echo "モデム L-02C をPCに接続し、L-02C接続先(APN)設定ツールを使って設定してください。" 53 | echo "APN = so-net.jp" 54 | echo "Phone = *99***1#" 55 | echo "設定後のL-02CをRaspberry Piに接続し、./soracom start を実行してください。" 56 | exit 57 | -------------------------------------------------------------------------------- /2_example/example15_camG/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## シリアルのTXDとRXDはクロス接続 10 | カメラのTXDをESPモジュールのRXD(本サンプルではIO12(4番ピン))に、 11 | カメラのRXDをESPモジュールのTXD(本サンプルではIO14(3番ピン))に 12 | 接続してください。 13 | 14 | ## LCDに「Example 15 Cam」が表示されたまま動作しない 15 | SPIFFSが無効になっています。 16 | コンパイル時に128KB以上のSPIFFS(最新SDKではFSと表示)を設定して 17 | ください。 18 | 19 | ## LCDに「Cam Init」が表示されたまま動作しない① 20 | Wi-Fiアクセスポイントとの接続に失敗しています。 21 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 22 | #define SSIDとPASSに設定して下さい。 23 | 24 | ## LCDに「Cam Init」が表示されたまま動作しない② 25 | カメラとの通信に失敗しています。 26 | カメラの電源電圧、シリアル配線などを確認してください。 27 | 28 | ## 写真データが(得られるが)表示できない/ノイズが入る 29 | コンパイル時に「ツール」メニュー内の「CPU Frequency」で160MHz 30 | を設定してください。 31 | ただし、CPU(マイコン)の周波数を160MHzすることで、消費電力が 32 | 増大し、電源によっては電流容量が不足することがあります。 33 | 致命的な問題が無い限り、80MHzで使用することをお奨めします。 34 | CPUの周波数変更で改善できない場合は、シリアル接続や電源などに 35 | ノイズが混入している可能性が考えられます。 36 | 37 | ## Raspberry Piで受信できない 38 | しばらく待って、LCDに「Sleeping」「zzz...」と表示されることを 39 | 確認してください。表示されたら、ENボタンを押して、再送信して 40 | みて下さい。 41 | それでも、動作しない場合は、 42 | ネットワーク内のDHCPサーバが動作していない、 43 | 異なる無線LANアクセスポイントへ接続されている、 44 | 異なるIPアドレスが設定されている、 45 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 46 | パケットが破棄されているなどが考えられます。 47 | 48 | ## 動作ログの確認方法(ご参考) 49 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 50 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 51 | 9600bpsに設定すると、動作ログが表示されます。 52 | -------------------------------------------------------------------------------- /2_example/example15f_camG/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## シリアルのTXDとRXDはクロス接続 10 | カメラのTXDをESPモジュールのRXD(本サンプルではIO12(4番ピン))に、 11 | カメラのRXDをESPモジュールのTXD(本サンプルではIO14(3番ピン))に 12 | 接続してください。 13 | 14 | ## LCDに「Example 15 Cam」が表示されたまま動作しない 15 | SPIFFSが無効になっています。 16 | コンパイル時に128KB以上のSPIFFS(最新SDKではFSと表示)を設定して 17 | ください。 18 | 19 | ## LCDに「Cam Init」が表示されたまま動作しない① 20 | Wi-Fiアクセスポイントとの接続に失敗しています。 21 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 22 | #define SSIDとPASSに設定して下さい。 23 | 24 | ## LCDに「Cam Init」が表示されたまま動作しない② 25 | カメラとの通信に失敗しています。 26 | カメラの電源電圧、シリアル配線などを確認してください。 27 | 28 | ## 写真データが(得られるが)表示できない/ノイズが入る 29 | コンパイル時に「ツール」メニュー内の「CPU Frequency」で160MHz 30 | を設定してください。 31 | ただし、CPU(マイコン)の周波数を160MHzすることで、消費電力が 32 | 増大し、電源によっては電流容量が不足することがあります。 33 | 致命的な問題が無い限り、80MHzで使用することをお奨めします。 34 | CPUの周波数変更で改善できない場合は、シリアル接続や電源などに 35 | ノイズが混入している可能性が考えられます。 36 | 37 | ## Raspberry Piで受信できない 38 | しばらく待って、LCDに「Sleeping」「zzz...」と表示されることを 39 | 確認してください。表示されたら、ENボタンを押して、再送信して 40 | みて下さい。 41 | それでも、動作しない場合は、 42 | ネットワーク内のDHCPサーバが動作していない、 43 | 異なる無線LANアクセスポイントへ接続されている、 44 | 異なるIPアドレスが設定されている、 45 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 46 | パケットが破棄されているなどが考えられます。 47 | 48 | ## 動作ログの確認方法(ご参考) 49 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 50 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 51 | 9600bpsに設定すると、動作ログが表示されます。 52 | -------------------------------------------------------------------------------- /tools/soracom_setupL02C.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # docomo L02C用 セットアップ 4 | # 2016/06/08 国野亘 5 | # 6 | # このスクリプトは下記のサイトの情報を参考にして作成しました。 7 | # https://gist.githubusercontent.com/j3tm0t0/2a126ba2592202ba5de4498d8a56cfb2 8 | # http://www.okahiro.info/gd/2016/03/18/post-1249/ 9 | 10 | # install required packages 11 | apt-get install -y eject wvdial 12 | 13 | # add wvdial config 14 | cat << EOF > /etc/wvdial.conf 15 | [Dialer Defaults] 16 | Init1 = ATZ 17 | Init2 = ATH 18 | Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 19 | Dial Attempts = 3 20 | Modem Type = Analog Modem 21 | Dial Command = ATD 22 | Stupid Mode = yes 23 | Baud = 460800 24 | New PPPD = yes 25 | Modem = /dev/ttyUSB2 26 | ISDN = 0 27 | APN = soracom.io 28 | Phone = *99***1# 29 | Username = sora 30 | Password = sora 31 | Carrier Check = no 32 | Auto DNS = 1 33 | Check Def Route = 1 34 | EOF 35 | 36 | # add replacedefaultroute option to ppp config 37 | cat << EOF > /etc/ppp/peers/wvdial 38 | noauth 39 | name wvdial 40 | usepeerdns 41 | replacedefaultroute 42 | EOF 43 | 44 | # 接続コマンドsoracomのUSB ID設定 45 | cat soracom|sed "s/vendor=0x.*$/vendor=0x1004 product=0x618f/g">soracom~ 46 | mv soracom~ soracom 47 | chmod a+rwx soracom 48 | 49 | #終了メッセージ 50 | echo "------------------------------------------------" 51 | echo "設定が完了しました" 52 | echo "モデム L-02C をPCに接続し、L-02C接続先(APN)設定ツールを使って設定してください。" 53 | echo "APN = soracom.io" 54 | echo "Phone = *99***1#" 55 | echo "設定後のL-02CをRaspberry Piに接続し、./soracom start を実行してください。" 56 | exit 57 | -------------------------------------------------------------------------------- /2_example/example64_photo/license_Adafruit-GFX.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /2_example/example64_photo_m5/license_Adafruit-GFX.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/license_Adafruit-GFX.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /1_practice/practice03_sw/practice03_sw.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 3: スイッチ入力 3 | Copyright (c) 2013-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | #define PIN_SW 4 // IO 4(10番ピン) にスイッチを接続する 7 | #define PIN_LED 13 // IO 13(5番ピン) にLEDを接続する 8 | int prev = 0; // 整数型変数prevを定義し、初期値0を代入 9 | 10 | void setup() { // 起動時に一度だけ実行される関数 11 | pinMode(PIN_SW,INPUT_PULLUP); // スイッチを接続したポートを入力に設定 12 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に設定する 13 | Serial.begin(9600); // シリアル通信速度を9600bpsに設定する 14 | } 15 | 16 | void loop() { // setup実行後に繰り返し実行される関数 17 | int in; // 整数型変数inを定義 18 | 19 | in = digitalRead(PIN_SW); // デジタル入力値を変数inに代入 20 | 21 | if( in == 0 ){ // in値が0、すなわちLレベル(0V)入力の時 22 | digitalWrite(PIN_LED,1); // ポートをHレベル(3.3V)に設定(点灯) 23 | }else{ // そうでは無い時 24 | digitalWrite(PIN_LED,0); // ポートをLレベル(0V)に設定(点灯) 25 | } 26 | 27 | if( in != prev ){ // inの値がprevと異なる時 28 | Serial.println(in); // inの値をシリアル出力 29 | prev = in; // prevにin値を代入 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /2_example/example13_ntp/sendNTPpacket.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Udp NTP Client 4 | 5 | Get the time from a Network Time Protocol (NTP) time server 6 | Demonstrates use of UDP sendPacket and ReceivePacket 7 | For more on NTP time servers and the messages needed to communicate with them, 8 | see http://en.wikipedia.org/wiki/Network_Time_Protocol 9 | 10 | created 4 Sep 2010 11 | by Michael Margolis 12 | modified 9 Apr 2012 13 | by Tom Igoe 14 | 15 | This code is in the public domain. 16 | 17 | */ 18 | 19 | // send an NTP request to the time server at the given address 20 | void sendNTPpacket(const char* address) 21 | { 22 | // set all bytes in the buffer to 0 23 | memset(packetBuffer, 0, NTP_PACKET_SIZE); 24 | // Initialize values needed to form NTP request 25 | // (see URL above for details on the packets) 26 | packetBuffer[0] = 0b11100011; // LI, Version, Mode 27 | packetBuffer[1] = 0; // Stratum, or type of clock 28 | packetBuffer[2] = 6; // Polling Interval 29 | packetBuffer[3] = 0xEC; // Peer Clock Precision 30 | // 8 bytes of zero for Root Delay & Root Dispersion 31 | packetBuffer[12] = 49; 32 | packetBuffer[13] = 0x4E; 33 | packetBuffer[14] = 49; 34 | packetBuffer[15] = 52; 35 | 36 | // all NTP fields have been given values, now 37 | // you can send a packet requesting a timestamp: 38 | udp.beginPacket(address, 123); //NTP requests are to port 123 39 | udp.write(packetBuffer, NTP_PACKET_SIZE); 40 | udp.endPacket(); 41 | } 42 | -------------------------------------------------------------------------------- /2_example/example13c_ntp/sendNTPpacket.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Udp NTP Client 4 | 5 | Get the time from a Network Time Protocol (NTP) time server 6 | Demonstrates use of UDP sendPacket and ReceivePacket 7 | For more on NTP time servers and the messages needed to communicate with them, 8 | see http://en.wikipedia.org/wiki/Network_Time_Protocol 9 | 10 | created 4 Sep 2010 11 | by Michael Margolis 12 | modified 9 Apr 2012 13 | by Tom Igoe 14 | 15 | This code is in the public domain. 16 | 17 | */ 18 | 19 | // send an NTP request to the time server at the given address 20 | void sendNTPpacket(const char* address) 21 | { 22 | // set all bytes in the buffer to 0 23 | memset(packetBuffer, 0, NTP_PACKET_SIZE); 24 | // Initialize values needed to form NTP request 25 | // (see URL above for details on the packets) 26 | packetBuffer[0] = 0b11100011; // LI, Version, Mode 27 | packetBuffer[1] = 0; // Stratum, or type of clock 28 | packetBuffer[2] = 6; // Polling Interval 29 | packetBuffer[3] = 0xEC; // Peer Clock Precision 30 | // 8 bytes of zero for Root Delay & Root Dispersion 31 | packetBuffer[12] = 49; 32 | packetBuffer[13] = 0x4E; 33 | packetBuffer[14] = 49; 34 | packetBuffer[15] = 52; 35 | 36 | // all NTP fields have been given values, now 37 | // you can send a packet requesting a timestamp: 38 | udp.beginPacket(address, 123); //NTP requests are to port 123 39 | udp.write(packetBuffer, NTP_PACKET_SIZE); 40 | udp.endPacket(); 41 | } 42 | -------------------------------------------------------------------------------- /2_example/example45_ntp/sendNTPpacket.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Udp NTP Client 4 | 5 | Get the time from a Network Time Protocol (NTP) time server 6 | Demonstrates use of UDP sendPacket and ReceivePacket 7 | For more on NTP time servers and the messages needed to communicate with them, 8 | see http://en.wikipedia.org/wiki/Network_Time_Protocol 9 | 10 | created 4 Sep 2010 11 | by Michael Margolis 12 | modified 9 Apr 2012 13 | by Tom Igoe 14 | 15 | This code is in the public domain. 16 | 17 | */ 18 | 19 | // send an NTP request to the time server at the given address 20 | void sendNTPpacket(const char* address) 21 | { 22 | // set all bytes in the buffer to 0 23 | memset(packetBuffer, 0, NTP_PACKET_SIZE); 24 | // Initialize values needed to form NTP request 25 | // (see URL above for details on the packets) 26 | packetBuffer[0] = 0b11100011; // LI, Version, Mode 27 | packetBuffer[1] = 0; // Stratum, or type of clock 28 | packetBuffer[2] = 6; // Polling Interval 29 | packetBuffer[3] = 0xEC; // Peer Clock Precision 30 | // 8 bytes of zero for Root Delay & Root Dispersion 31 | packetBuffer[12] = 49; 32 | packetBuffer[13] = 0x4E; 33 | packetBuffer[14] = 49; 34 | packetBuffer[15] = 52; 35 | 36 | // all NTP fields have been given values, now 37 | // you can send a packet requesting a timestamp: 38 | udp.beginPacket(address, 123); //NTP requests are to port 123 39 | udp.write(packetBuffer, NTP_PACKET_SIZE); 40 | udp.endPacket(); 41 | } 42 | -------------------------------------------------------------------------------- /tools/udp_sender.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # coding: utf-8 3 | # UDPを送信する 4 | # Copyright (c) 2018 Wataru KUNINO 5 | 6 | from __future__ import print_function 7 | import sys 8 | import socket 9 | 10 | argc = len(sys.argv) # 引数の数をargcへ代入 11 | print('UDP Sender (usage: '+sys.argv[0]+' port < data)')# タイトル表示 12 | if argc == 2: # 入力パラメータ数の確認 13 | port = int(sys.argv[1]) # ポート番号を設定 14 | if port < 1 or port > 65535: # ポート1未満or65535超の時 15 | port = 1024 # UDPポート番号を1024に 16 | else: 17 | port = 1024 18 | 19 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # ソケットを作成 20 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,1) 21 | if sock: # 作成に成功したとき 22 | for line in sys.stdin: # 標準入力から変数lineへ 23 | udp='' # 表示用の文字列変数udp 24 | for c in line: # 入力行内 25 | if ord(c) >= ord(' '): # 表示可能文字 26 | udp += c # 文字列strへ追加 27 | print('send : ' + udp) # 受信データを出力 28 | udp=(udp + '\n').encode() # バイト列に変換 29 | sock.sendto(udp,('255.255.255.255',port)) # UDPブロードキャスト送信 30 | sock.close() # ソケットの切断 31 | -------------------------------------------------------------------------------- /5_learn32/esp32_06_uart_rx/esp32_06_uart_rx.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 5: UARTでLED制御コマンドを受信する 3 | Copyright (c) 2017-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | #define PIN_LED 2 // GPIO 2にLEDを接続 7 | 8 | void setup(){ // 起動時に一度だけ実行する関数 9 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に 10 | Serial.begin(115200); // 動作確認のためのシリアル出力開始 11 | Serial.println("Practice32 06 uart RX"); // Practice32 06をシリアル出力 12 | } 13 | 14 | void loop(){ // 繰り返し実行する関数 15 | char s[65]; // 文字列変数を定義 65バイト64文字 16 | int i,len = Serial.available(); // 受信データ長を変数lenに代入 17 | if(len==0)return; // 未受信時にloop()先頭へ 18 | if(len>64) len=64; // 最大受信長は64文字 19 | for(i=0;i 46 | 47 | ## むすび 48 | 49 | Copyright (c) 2017-2021 Wataru KUNINO 50 | 51 | -------------------------------------------------------------------------------- /2_example/example09_hum_sht31/i2c_sht31.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SENSIRION社 SHT31 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_sht 0x45 // SHT31 の I2C アドレス 13 | 14 | float _i2c_sht31_hum; 15 | 16 | float getTemp(){ 17 | int temp,hum; 18 | _i2c_sht31_hum=-999.; 19 | Wire.beginTransmission(I2C_sht); 20 | Wire.write(0x2C); 21 | Wire.write(0x06); 22 | if(Wire.endTransmission()) return -998.; 23 | delay(18); // 15ms以上 24 | Wire.requestFrom(I2C_sht,6); 25 | if(Wire.available() != 6) return -997.0; 26 | temp = Wire.read(); 27 | temp <<= 8; 28 | temp += Wire.read(); 29 | Wire.read(); 30 | hum = Wire.read(); 31 | hum <<= 8; 32 | hum += Wire.read(); 33 | Wire.read(); // 未使用 not used 34 | _i2c_sht31_hum = (float)hum / 65535. * 100.; 35 | return (float)temp / 65535. * 175. - 45.; 36 | } 37 | 38 | float getHum(){ 39 | return _i2c_sht31_hum; 40 | } 41 | 42 | void shtSetup(){ 43 | delay(2); // 1ms以上 44 | Wire.begin(); // I2Cインタフェースの使用を開始 45 | delay(18); // 15ms以上 46 | } 47 | -------------------------------------------------------------------------------- /2_example/example09c_hum_sht31/i2c_sht31.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SENSIRION社 SHT31 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_sht 0x45 // SHT31 の I2C アドレス 13 | 14 | float _i2c_sht31_hum; 15 | 16 | float getTemp(){ 17 | int temp,hum; 18 | _i2c_sht31_hum=-999.; 19 | Wire.beginTransmission(I2C_sht); 20 | Wire.write(0x2C); 21 | Wire.write(0x06); 22 | if(Wire.endTransmission()) return -998.; 23 | delay(18); // 15ms以上 24 | Wire.requestFrom(I2C_sht,6); 25 | if(Wire.available() != 6) return -997.0; 26 | temp = Wire.read(); 27 | temp <<= 8; 28 | temp += Wire.read(); 29 | Wire.read(); 30 | hum = Wire.read(); 31 | hum <<= 8; 32 | hum += Wire.read(); 33 | Wire.read(); // 未使用 not used 34 | _i2c_sht31_hum = (float)hum / 65535. * 100.; 35 | return (float)temp / 65535. * 175. - 45.; 36 | } 37 | 38 | float getHum(){ 39 | return _i2c_sht31_hum; 40 | } 41 | 42 | void shtSetup(){ 43 | delay(2); // 1ms以上 44 | Wire.begin(); // I2Cインタフェースの使用を開始 45 | delay(18); // 15ms以上 46 | } 47 | -------------------------------------------------------------------------------- /1_practice/practice35_sw/practice35_sw.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 35(Practice 3+32): スイッチ入力 3 | 4 | GPIO 0 へ スイッチを、 5 | GPIO 2 へ LEDを接続してください。 6 | Copyright (c) 2016-2019 Wataru KUNINO 7 | *******************************************************************************/ 8 | 9 | #define PIN_SW 0 // IO 0にスイッチを接続 10 | #define PIN_LED 2 // IO 2にLEDを接続 11 | int prev = 0; // 整数型変数prevを定義し、初期値0を代入 12 | 13 | void setup() { // 起動時に一度だけ実行される関数 14 | pinMode(PIN_SW,INPUT_PULLUP); // スイッチを接続したポートを入力に設定 15 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に設定する 16 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 17 | } 18 | 19 | void loop() { // setup実行後に繰り返し実行される関数 20 | int in; // 整数型変数inを定義 21 | 22 | in = digitalRead(PIN_SW); // デジタル入力値を変数inに代入 23 | 24 | if( in == 0 ){ // in値が0、すなわちLレベル(0V)入力の時 25 | digitalWrite(PIN_LED,1); // ポートをHレベル(3.3V)に設定(点灯) 26 | }else{ // そうでは無い時 27 | digitalWrite(PIN_LED,0); // ポートをLレベル(0V)に設定(点灯) 28 | } 29 | 30 | if( in != prev ){ // inの値がprevと異なる時 31 | Serial.println(in); // inの値をシリアル出力 32 | prev = in; // prevにin値を代入 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /5_learn32/esp32_03_sw/esp32_03_sw.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 3: スイッチ入力 3 | Copyright (c) 2016-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | #define PIN_LED 2 // IO 2にLEDを接続 7 | #define PIN_SW 0 // IO 0にスイッチを接続 8 | 9 | boolean button=1; // スイッチ状態を保存するための変数 10 | 11 | void setup() { // 起動時に一度だけ実行される関数 12 | pinMode(PIN_SW,INPUT_PULLUP); // スイッチを接続したポートを入力に設定 13 | pinMode(PIN_LED,OUTPUT); // LEDを接続したポートを出力に設定する 14 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 15 | } 16 | 17 | void loop() { // setup実行後に繰り返し実行される関数 18 | boolean b=button; // 前回のスイッチ状態を変数bに保持 19 | 20 | while(b==button){ // 前回の値bと同じ値の間に繰り返し実行 21 | button = digitalRead(PIN_SW); // スイッチ状態の読み取り 22 | } // 異なる値となったときに繰り返しを終了 23 | if(button==0){ // スイッチが押されLOWレベルだった時 24 | Serial.println("Ping"); // シリアルへPingを出力表示 25 | digitalWrite(PIN_LED,1); // ポートをHレベル(3.3V)に設定(点灯) 26 | }else{ 27 | Serial.println("Pong"); // そうでないときに「Pong」を出力表示 28 | digitalWrite(PIN_LED,0); // ポートをLレベル(0V)に設定(点灯) 29 | } 30 | delay(10); // 10msの時間待ち(チャタリング防止策) 31 | } 32 | -------------------------------------------------------------------------------- /1_practice/practice07_led.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 天気をLEDの状態で表示する 3 | 4 | IP_LED="192.168.0.2" # ワイヤレスLEDのIP 5 | 6 | city_id=130000 # 気象庁=130000(東京地方など) 7 | # 大阪管区気象台=270000(大阪府など) 8 | # 京都地方気象台=260000(南部など) 9 | # 横浜地方気象台=140000(東部など) 10 | # 銚子地方気象台=120000(北西部など) 11 | # 名古屋地方気象台=230000(西部など) 12 | # 福岡管区気象台=400000(福岡地方など) 13 | 14 | #WEATHER=`curl -s rss.weather.yahoo.co.jp/rss/days/43.xml\ 15 | #|cut -d'<' -f17|cut -d'>' -f2|tail -1\ 16 | #|cut -d' ' -f5|cut -c1-3` # 天気を取得する 17 | WEATHER=`curl -s https://www.jma.go.jp/bosai/forecast/data/forecast/{$city_id}.json\ 18 | |tr "," "\n"|grep weathers|head -1|cut -d'"' -f4|sed "s/ /\t/g"|cut -f1` 19 | echo -n `date "+%Y/%m/%d %R"`", "$WEATHER", " # テキスト表示 20 | case $WEATHER in # 天気に応じた処理 21 | "晴" ) LED=1;; # 晴の時は明るく点灯 22 | "くもり" ) LED=-1;; # 曇の時は暗く点灯 23 | * ) LED=5;; # その他の時は点滅 24 | esac # caseの終了 25 | curl -s $IP_LED -XPOST -d"L=$LED"|grep "

"|grep -v "http"\ 26 | |cut -d'>' -f2|cut -d'<' -f1 # ワイヤレスLED制御 27 | -------------------------------------------------------------------------------- /1_practice/practice04_var/practice04_var.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 4: 変数の使い方 3 | Copyright (c) 2015-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | void setup() { // 起動時に一度だけ実行される関数 7 | Serial.begin(9600); // シリアル通信速度を9600bpsに設定する 8 | } 9 | 10 | void loop() { // setup実行後に繰り返し実行される関数 11 | int a = 12345; // 整数型の変数aを定義 12 | char c = 'R'; // 文字変数cを定義 13 | char s[] = "Hello, world!"; // 文字列変数sを定義 14 | float v = 1.2345; // 浮動小数点数型変数v 15 | int size; // 変数sizeを定義 16 | 17 | Serial.println("Practice 03"); // 「Practice 03」を表示 18 | 19 | Serial.print("a="); 20 | Serial.println(a,DEC); // 整数値変数aの値を表示 21 | 22 | Serial.print("c="); 23 | Serial.write(c); // 文字変数cの値を表示 24 | Serial.println(); // 改行する 25 | 26 | Serial.print("s="); 27 | Serial.println(s); // 文字列変数sの値を表示 28 | 29 | size = sizeof(s); // sのサイズをsizeに代入 30 | Serial.print("sizeof(s)="); 31 | Serial.println(size,DEC); // sizeの値を表示して改行 32 | 33 | Serial.print("v="); 34 | Serial.println(v,3); // 浮動小数点数型変数vの値を表示 35 | 36 | for(a=0;a<10;a++) delay(100); // 1秒の待ち時間処理 37 | Serial.println(); 38 | } 39 | -------------------------------------------------------------------------------- /2_example/example20_camG/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## シリアルのTXDとRXDはクロス接続 10 | カメラのTXDをESPモジュールのRXD(本サンプルではIO12(4番ピン))に、 11 | カメラのRXDをESPモジュールのTXD(本サンプルではIO14(3番ピン))に 12 | 接続してください。 13 | 14 | ## LCDに「Example 20 cam」が表示されたまま動作しない① 15 | Wi-Fiアクセスポイントとの接続に失敗しています。 16 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 17 | #define SSIDとPASSに設定して下さい。 18 | 19 | ## LCDに「Example 20 cam」が表示されたまま動作しない② 20 | カメラとの通信に失敗しています。 21 | カメラの電源電圧、シリアル配線などを確認してください。 22 | 23 | 24 | ## ブラウザに「防犯カメラ STATUS」の画面が表示されない 25 | ネットワーク内のDHCPサーバが動作していない、 26 | 異なる無線LANアクセスポイントへ接続されている、 27 | 異なるIPアドレスが設定されている、 28 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 29 | パケットが破棄されているなどが考えられます。 30 | 31 | ## ブラウザに画面は表示されるが、写真データが(得られるが)表示できない/ノイズが入る 32 | コンパイル時に「ツール」メニュー内の「CPU Frequency」で160MHz 33 | を設定してください。 34 | ただし、CPU(マイコン)の周波数を160MHzすることで、消費電力が 35 | 増大し、電源によっては電流容量が不足することがあります。 36 | 致命的な問題が無い限り、80MHzで使用することをお奨めします。 37 | CPUの周波数変更で改善できない場合は、シリアル接続や電源などに 38 | ノイズが混入している可能性が考えられます。 39 | 40 | ## ブラウザの互換性・ブラウザのセキュリティ対策 41 | ブラウザのバージョンアップやセキュリティ対策により、表示でき 42 | なくなることがあります。 43 | また、ブラウザのバージョンアップで表示できるようになることも 44 | あります。 45 | 例えば、IPアドレスによるアクセスを危険と見なす場合もあれば、 46 | 同一LAN内のコンテンツは安全と見なす場合など、ブラウザや、その 47 | バージョン、設定、ブラウザを開発する会社の方針などによって 48 | 状況が変化します。 49 | 一例として、以下のような複数のブラウザで試してみて下さい。 50 | (IE、Edge、Safari、Chrome、FireFoxなど) 51 | 52 | ## 動作ログの確認方法(ご参考) 53 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 54 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 55 | 9600bpsに設定すると、動作ログが表示されます。 56 | -------------------------------------------------------------------------------- /2_example/example15_camL/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## カメラの電源電圧は5V 10 | Adafruit 1386 の電源入力電圧は5Vです。古いバージョンの基板には 11 | 「3.3V」と書かれていますが、基板上にLDOが実装されているので、 12 | およそ4~5V程度を入力する必要があります。 13 | 14 | ## シリアルのTXDとRXDはクロス接続 15 | カメラのTXDをESPモジュールのRXD(本サンプルではIO12(4番ピン))に、 16 | カメラのRXDをESPモジュールのTXD(本サンプルではIO14(3番ピン))に 17 | 接続してください。 18 | 19 | ## LCDに「Example 15 Cam」が表示されたまま動作しない 20 | SPIFFSが無効になっています。 21 | コンパイル時に128KB以上のSPIFFS(最新SDKではFSと表示)を設定して 22 | ください。 23 | 24 | ## LCDに「Cam Init」が表示されたまま動作しない① 25 | Wi-Fiアクセスポイントとの接続に失敗しています。 26 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 27 | #define SSIDとPASSに設定して下さい。 28 | 29 | ## LCDに「Cam Init」が表示されたまま動作しない② 30 | カメラとの通信に失敗しています。 31 | カメラの電源電圧、シリアル配線などを確認してください。 32 | 33 | ## 写真データが(得られるが)表示できない/ノイズが入る 34 | コンパイル時に「ツール」メニュー内の「CPU Frequency」で160MHz 35 | を設定してください。 36 | ただし、CPU(マイコン)の周波数を160MHzすることで、消費電力が 37 | 増大し、電源によっては電流容量が不足することがあります。 38 | 致命的な問題が無い限り、80MHzで使用することをお奨めします。 39 | CPUの周波数変更で改善できない場合は、シリアル接続や電源などに 40 | ノイズが混入している可能性が考えられます。 41 | 42 | ## Raspberry Piで受信できない 43 | しばらく待って、LCDに「Sleeping」「zzz...」と表示されることを 44 | 確認してください。表示されたら、ENボタンを押して、再送信して 45 | みて下さい。 46 | それでも、動作しない場合は、 47 | ネットワーク内のDHCPサーバが動作していない、 48 | 異なる無線LANアクセスポイントへ接続されている、 49 | 異なるIPアドレスが設定されている、 50 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 51 | パケットが破棄されているなどが考えられます。 52 | 53 | ## 動作ログの確認方法(ご参考) 54 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 55 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 56 | 9600bpsに設定すると、動作ログが表示されます。 57 | -------------------------------------------------------------------------------- /2_example/example15f_camL/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## カメラの電源電圧は5V 10 | Adafruit 1386 の電源入力電圧は5Vです。古いバージョンの基板には 11 | 「3.3V」と書かれていますが、基板上にLDOが実装されているので、 12 | およそ4~5V程度を入力する必要があります。 13 | 14 | ## シリアルのTXDとRXDはクロス接続 15 | カメラのTXDをESPモジュールのRXD(本サンプルではIO12(4番ピン))に、 16 | カメラのRXDをESPモジュールのTXD(本サンプルではIO14(3番ピン))に 17 | 接続してください。 18 | 19 | ## LCDに「Example 15 Cam」が表示されたまま動作しない 20 | SPIFFSが無効になっています。 21 | コンパイル時に128KB以上のSPIFFS(最新SDKではFSと表示)を設定して 22 | ください。 23 | 24 | ## LCDに「Cam Init」が表示されたまま動作しない① 25 | Wi-Fiアクセスポイントとの接続に失敗しています。 26 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 27 | #define SSIDとPASSに設定して下さい。 28 | 29 | ## LCDに「Cam Init」が表示されたまま動作しない② 30 | カメラとの通信に失敗しています。 31 | カメラの電源電圧、シリアル配線などを確認してください。 32 | 33 | ## 写真データが(得られるが)表示できない/ノイズが入る 34 | コンパイル時に「ツール」メニュー内の「CPU Frequency」で160MHz 35 | を設定してください。 36 | ただし、CPU(マイコン)の周波数を160MHzすることで、消費電力が 37 | 増大し、電源によっては電流容量が不足することがあります。 38 | 致命的な問題が無い限り、80MHzで使用することをお奨めします。 39 | CPUの周波数変更で改善できない場合は、シリアル接続や電源などに 40 | ノイズが混入している可能性が考えられます。 41 | 42 | ## Raspberry Piで受信できない 43 | しばらく待って、LCDに「Sleeping」「zzz...」と表示されることを 44 | 確認してください。表示されたら、ENボタンを押して、再送信して 45 | みて下さい。 46 | それでも、動作しない場合は、 47 | ネットワーク内のDHCPサーバが動作していない、 48 | 異なる無線LANアクセスポイントへ接続されている、 49 | 異なるIPアドレスが設定されている、 50 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 51 | パケットが破棄されているなどが考えられます。 52 | 53 | ## 動作ログの確認方法(ご参考) 54 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 55 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 56 | 9600bpsに設定すると、動作ログが表示されます。 57 | -------------------------------------------------------------------------------- /tools/udp_logger_plus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # UDPを受信し、保存する 3 | # Copyright (c) 2016 Wataru KUNINO 4 | 5 | echo "UDP Logger (usage: ${0} port)" # タイトル表示 6 | if [ ${#} = 1 ] # 入力パラメータ数の確認 7 | then # 1つだった時 8 | if [ ${1} -ge 1 ] && [ ${1} -le 65535 ] # ポート番号の範囲確認 9 | then # 1以上65535以下の時 10 | PORT=${1} # ポート番号を設定 11 | else # 範囲外だった時 12 | PORT=1024 # UDPポート番号を1024に 13 | fi # ifの終了 14 | else # 1つでは無かった時 15 | PORT=1024 # UDPポート番号を1024に 16 | fi # ifの終了 17 | echo "Listening UDP port "${PORT}"..." # ポート番号表示 18 | while true # 永久に 19 | do # 繰り返し 20 | UDP=`nc -luw0 ${PORT}|tr -d [:cntrl:]|\ 21 | tr -d "\!\"\$\%\&\'\(\)\*\+\;\<\=\>\?\[\\\]\^\{\|\}\~/"` 22 | # UDPパケットを取得 23 | DATE=`date "+%Y/%m/%d %R"` # 日時を取得 24 | DEV=${UDP#,*} # デバイス名を取得(前方) 25 | DEV=${DEV%%,*} # デバイス名を取得(後方) 26 | echo -E $DATE, $UDP|tee -a log_${DEV}.csv # 取得日時とデータを表示 27 | done # 繰り返しここまで 28 | -------------------------------------------------------------------------------- /2_example/example64_photo/license_Adafruit-SSD1331.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/license_Adafruit-SSD1331.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012, Adafruit Industries 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 1. Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 3. Neither the name of the copyright holders nor the 14 | names of its contributors may be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /tools/aquestalk_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # AQUEST社の AquesTalkをダウンロードし、インストールします。 3 | # 4 | # http://www.a-quest.com/products/aquestalkpi.html 5 | 6 | if [ ! -e "./aquestalkpi/AquesTalkPi" ]; then 7 | echo "AquesTalkのウェブサイトにアクセスして、ライセンスを確認してください。" 8 | echo "http://www.a-quest.com/products/aquestalkpi.html" 9 | echo "上記のライセンスに同意する場合は「yes」を入力してください。" 10 | echo -n "yes/no >" 11 | read yes 12 | case $yes in 13 | yes) 14 | echo "ダウンロードを実行中です。" 15 | # wget http://www.a-quest.com/download/package/aquestalkpi-20130827.tgz 16 | # wget https://www.a-quest.com/archive/package/aquestalkpi-20130827.tgz 17 | wget https://www.a-quest.com/archive/package/aquestalkpi-20201010.tgz 18 | echo "インストールを実行中です。" 19 | tar xzvf aquestalkpi-*.tgz 20 | echo "セットアップ完了です。" 21 | echo "詳細はこちら:http://blog-yama.a-quest.com/?eid=970157" 22 | ;; 23 | *) 24 | echo "ダウンロードをキャンセルしました。" 25 | ;; 26 | esac 27 | fi 28 | echo "時報をセットします。セットしたくない場合は「no」を入力してください。" 29 | echo -n "yes/no >" 30 | read yes 31 | 32 | #if [ ! -e "/etc/cron.daily/talk_time_signal" ]; then 33 | if [ $yes != "no" ]; then 34 | DIR=`pwd` 35 | EXIST=`grep aquestalk_tsig.sh /etc/crontab` 36 | if [ -z "$EXIST" ]; then 37 | echo "0 * * * * pi "${DIR}"/aquestalk_tsig.sh" | sudo tee -a /etc/crontab 38 | sleep 0.1 39 | sudo /etc/init.d/rsyslog restart 40 | echo "/etc/crontab へ aquestalk_tsig.sh を設定しました。" 41 | # cat /etc/crontab 42 | fi 43 | echo "再生テストを行います。" 44 | aquestalkpi/AquesTalkPi -f aquestalkpi/test.txt |aplay 45 | echo "再生できればセットアップ完了です。" 46 | fi 47 | echo "終了" 48 | exit 49 | -------------------------------------------------------------------------------- /1_practice/practice36_var/practice36_var.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 4: 変数の使い方 3 | 4 | シリアルモニタのビット・レート設定を115200 bpsに設定してください。 5 | Copyright (c) 2015-2019 Wataru KUNINO 6 | *******************************************************************************/ 7 | 8 | void setup() { // 起動時に一度だけ実行される関数 9 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 10 | } 11 | 12 | void loop() { // setup実行後に繰り返し実行される関数 13 | int a = 12345; // 整数型の変数aを定義 14 | char c = 'R'; // 文字変数cを定義 15 | char s[] = "Hello, world!"; // 文字列変数sを定義 16 | float v = 1.2345; // 浮動小数点数型変数v 17 | int size; // 変数sizeを定義 18 | 19 | Serial.println("Practice 03"); // 「Practice 03」を表示 20 | 21 | Serial.print("a="); 22 | Serial.println(a,DEC); // 整数値変数aの値を表示 23 | 24 | Serial.print("c="); 25 | Serial.write(c); // 文字変数cの値を表示 26 | Serial.println(); // 改行する 27 | 28 | Serial.print("s="); 29 | Serial.println(s); // 文字列変数sの値を表示 30 | 31 | size = sizeof(s); // sのサイズをsizeに代入 32 | Serial.print("sizeof(s)="); 33 | Serial.println(size,DEC); // sizeの値を表示して改行 34 | 35 | Serial.print("v="); 36 | Serial.println(v,3); // 浮動小数点数型変数vの値を表示 37 | 38 | for(a=0;a<10;a++) delay(100); // 1秒の待ち時間処理 39 | Serial.println(); 40 | } 41 | -------------------------------------------------------------------------------- /tools/udp_logger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # UDPを受信する 3 | # Copyright (c) 2016 Wataru KUNINO 4 | 5 | echo "UDP Logger (usage: ${0} port)" # タイトル表示 6 | if [ ${#} = 1 ] # 入力パラメータ数の確認 7 | then # 1つだった時 8 | if [ ${1} -ge 1 ] && [ ${1} -le 65535 ] # ポート番号の範囲確認 9 | then # 1以上65535以下の時 10 | PORT=${1} # ポート番号を設定 11 | else # 範囲外だった時 12 | PORT=1024 # UDPポート番号を1024に 13 | fi # ifの終了 14 | else # 1つでは無かった時 15 | PORT=1024 # UDPポート番号を1024に 16 | fi # ifの終了 17 | echo "Listening UDP port "${PORT}"..." # ポート番号表示 18 | while true # 永遠に 19 | do # 繰り返し 20 | if [ ${PORT} -lt 1024 ] # ポート番号を確認 21 | then # 1024未満の時 22 | UDP=`sudo netcat -luw0 ${PORT}` # UDPパケットを取得 23 | else # ポート番号が1024以上の時 24 | UDP=`netcat -luw0 ${PORT}` # UDPパケットを取得 25 | fi # ifの終了 26 | DATE=`date "+%Y/%m/%d %R"` # 日時を取得 27 | echo -E $DATE, $UDP # 取得日時とデータを表示 28 | done # 繰り返しここまで 29 | -------------------------------------------------------------------------------- /5_learn32/esp32_23_rtr_lcd/lcdisp4.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | LCDへの4分割表示用関数 6 | 7 | Copyright (c) 2018 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | void lcdisp4(const char *s,int num){ // LCDへの4分割表示用関数の定義 12 | char lc[7]; // LCD表示用の6文字配列変数lcの定義 13 | strncpy(lc,s,6); // 文字列を6文字まで変数lcへコピー 14 | if(lc[5]=='_') lc[5]=s[6]; // 6文字目が_のときは7文字目をコピー 15 | for(int i=strlen(lc);i<6;i++) lc[i]=' ';// 6文字に満たない場合に空白を代入 16 | lc[6]='\0'; // 文字列の終端(文字列の最後は'\0') 17 | lcd.setCursor(8*((num/2)%2),(num%2)); // num=0:左上,1:左下,2:右上,3:右下 18 | lcd.print(num+1); // num+1の値を表示 19 | lcd.print(':'); // 「:」を表示 20 | lcd.print(lc); // 文字列を表示 21 | } 22 | 23 | void lcdisp4(int val,int num){ // 整数1値入力時の表示用関数の定義 24 | char lc[7]; // LCD表示用の6文字配列変数lcの定義 25 | itoa(val,lc,10); // 数値valを文字列変数lcへ代入 26 | lcdisp4(lc,num); // 前記lcdisp4を呼び出す 27 | } 28 | 29 | void lcdisp4(int val1,int val2,int num){ // 整数2値入力時の表示用関数の定義 30 | char lc[7]; // LCD表示用の6文字配列変数lcの定義 31 | snprintf(lc,7,"%d,%d",val1,val2); // 数値val1と2を文字列変数lcへ代入 32 | lcdisp4(lc,num); // 前記lcdisp4を呼び出す 33 | } 34 | -------------------------------------------------------------------------------- /2_example/example59_env/i2c_sht31.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SENSIRION社 SHT31 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_sht 0x45 // SHT31 の I2C アドレス 13 | // #define I2C_sht 0x44 // M5用SHT30 の I2C アドレス 14 | 15 | float _i2c_sht31_hum; 16 | 17 | float sht31_getTemp(){ 18 | int temp,hum; 19 | _i2c_sht31_hum=-999.; 20 | Wire.beginTransmission(I2C_sht); 21 | Wire.write(0x2C); 22 | Wire.write(0x06); 23 | delay(18); // 15ms以上 24 | if( Wire.endTransmission() ) return -999.; 25 | if( Wire.requestFrom(I2C_sht,6) >= 5){ 26 | temp = Wire.read(); 27 | temp <<= 8; 28 | temp += Wire.read(); 29 | Wire.read(); 30 | hum = Wire.read(); 31 | hum <<= 8; 32 | hum += Wire.read(); 33 | Wire.read(); 34 | _i2c_sht31_hum = (float)hum / 65535. * 100.; 35 | return (float)temp / 65535. * 175. - 45.; 36 | }else return -999.; 37 | } 38 | 39 | float sht31_getHum(){ 40 | return _i2c_sht31_hum; 41 | } 42 | 43 | boolean sht31_Setup(){ 44 | delay(2); // 1ms以上 45 | Wire.begin(); // I2Cインタフェースの使用を開始 46 | delay(18); // 15ms以上 47 | float temp = sht31_getTemp(); 48 | if(temp >= -45) return true; else return false; 49 | } 50 | -------------------------------------------------------------------------------- /2_example/example20_camL/README.md: -------------------------------------------------------------------------------- 1 | # トラブルシューティング 2 | 3 | ## 電源が安定しているかどうか 4 | 電源が不安定だと、ESPモジュールが起動しない、または起動しても 5 | 正しく動作しないことがあります。 6 | 起動時やWi-Fi接続時、カメラ動作時は、多くの電流を消費するので、 7 | 目安として600mA程度の電流が流せる電源回路を使用してください。 8 | 9 | ## カメラの電源電圧は5V 10 | Adafruit 1386 の電源入力電圧は5Vです。古いバージョンの基板には 11 | 「3.3V」と書かれていますが、基板上にLDOが実装されているので、 12 | およそ4~5V程度を入力する必要があります。 13 | 14 | ## シリアルのTXDとRXDはクロス接続 15 | カメラのTXDをESPモジュールのRXD(本サンプルではIO12(4番ピン))に、 16 | カメラのRXDをESPモジュールのTXD(本サンプルではIO14(3番ピン))に 17 | 接続してください。 18 | 19 | ## LCDに「Example 20 cam」が表示されたまま動作しない① 20 | Wi-Fiアクセスポイントとの接続に失敗しています。 21 | 無線LANアクセスポイントのSSIDとパスワードをプログラム内の 22 | #define SSIDとPASSに設定して下さい。 23 | 24 | ## LCDに「Example 20 cam」が表示されたまま動作しない② 25 | カメラとの通信に失敗しています。 26 | カメラの電源電圧、シリアル配線などを確認してください。 27 | 28 | 29 | ## ブラウザに「防犯カメラ STATUS」の画面が表示されない 30 | ネットワーク内のDHCPサーバが動作していない、 31 | 異なる無線LANアクセスポイントへ接続されている、 32 | 異なるIPアドレスが設定されている、 33 | 無線LANアクセスポイントやRaspberry Piのファイヤーウォール等で 34 | パケットが破棄されているなどが考えられます。 35 | 36 | ## ブラウザに画面は表示されるが、写真データが(得られるが)表示できない/ノイズが入る 37 | コンパイル時に「ツール」メニュー内の「CPU Frequency」で160MHz 38 | を設定してください。 39 | ただし、CPU(マイコン)の周波数を160MHzすることで、消費電力が 40 | 増大し、電源によっては電流容量が不足することがあります。 41 | 致命的な問題が無い限り、80MHzで使用することをお奨めします。 42 | CPUの周波数変更で改善できない場合は、シリアル接続や電源などに 43 | ノイズが混入している可能性が考えられます。 44 | 45 | ## ブラウザの互換性・ブラウザのセキュリティ対策 46 | ブラウザのバージョンアップやセキュリティ対策により、表示でき 47 | なくなることがあります。 48 | また、ブラウザのバージョンアップで表示できるようになることも 49 | あります。 50 | 例えば、IPアドレスによるアクセスを危険と見なす場合もあれば、 51 | 同一LAN内のコンテンツは安全と見なす場合など、ブラウザや、その 52 | バージョン、設定、ブラウザを開発する会社の方針などによって 53 | 状況が変化します。 54 | 一例として、以下のような複数のブラウザで試してみて下さい。 55 | (IE、Edge、Safari、Chrome、FireFoxなど) 56 | 57 | ## 動作ログの確認方法(ご参考) 58 | Arduino IDEのウィンドウ右上にある虫眼鏡のアイコンをクリックし、 59 | 「シリアルモニタ」を起動し、シリアルモニタの右下のボーレートを 60 | 9600bpsに設定すると、動作ログが表示されます。 61 | -------------------------------------------------------------------------------- /2_example/example09_hum/i2c_hdc.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | TI社 HDC1000 7 | Copyright (c) 2015-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_hdc 0x40 // HDC1000 の I2C アドレス 13 | 14 | float getTemp(){ 15 | int ret; 16 | Wire.beginTransmission(I2C_hdc); 17 | Wire.write(0x00); // 温度レジスタ 00 18 | if( Wire.endTransmission() == 0){ 19 | delay(9); // 6.5ms以上 20 | Wire.requestFrom(I2C_hdc,2); 21 | if(Wire.available()==0) return -999.; 22 | ret = Wire.read(); 23 | ret <<= 8; 24 | if(Wire.available()==0) return -999.; 25 | ret += Wire.read(); 26 | return (float)ret / 65536. * 165. - 40.; 27 | }else return -999.; 28 | } 29 | 30 | float getHum(){ 31 | int ret; 32 | Wire.beginTransmission(I2C_hdc); 33 | Wire.write(0x01); // 湿度レジスタ 01 34 | if( Wire.endTransmission() == 0){ 35 | delay(9); // 6.5ms以上 36 | Wire.requestFrom(I2C_hdc,2); 37 | if(Wire.available()==0) return -999.; 38 | ret = Wire.read(); 39 | ret <<= 8; 40 | if(Wire.available()==0) return -999.; 41 | ret += Wire.read(); 42 | return (float)ret / 65536. * 100.; 43 | }else return -999.; 44 | } 45 | 46 | void hdcSetup(){ 47 | Wire.begin(); // I2Cインタフェースの使用を開始 48 | delay(18); // 15ms以上 49 | Wire.beginTransmission(I2C_hdc); 50 | Wire.write(0x02); // 設定レジスタ 02 51 | Wire.write(0x00); 52 | Wire.write(0x00); 53 | Wire.endTransmission(); 54 | } 55 | -------------------------------------------------------------------------------- /2_example/example09c_hum/i2c_hdc.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | TI社 HDC1000 7 | Copyright (c) 2015-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_hdc 0x40 // HDC1000 の I2C アドレス 13 | 14 | float getTemp(){ 15 | int ret; 16 | Wire.beginTransmission(I2C_hdc); 17 | Wire.write(0x00); // 温度レジスタ 00 18 | if( Wire.endTransmission() == 0){ 19 | delay(9); // 6.5ms以上 20 | Wire.requestFrom(I2C_hdc,2); 21 | if(Wire.available()==0) return -999.; 22 | ret = Wire.read(); 23 | ret <<= 8; 24 | if(Wire.available()==0) return -999.; 25 | ret += Wire.read(); 26 | return (float)ret / 65536. * 165. - 40.; 27 | }else return -999.; 28 | } 29 | 30 | float getHum(){ 31 | int ret; 32 | Wire.beginTransmission(I2C_hdc); 33 | Wire.write(0x01); // 湿度レジスタ 01 34 | if( Wire.endTransmission() == 0){ 35 | delay(9); // 6.5ms以上 36 | Wire.requestFrom(I2C_hdc,2); 37 | if(Wire.available()==0) return -999.; 38 | ret = Wire.read(); 39 | ret <<= 8; 40 | if(Wire.available()==0) return -999.; 41 | ret += Wire.read(); 42 | return (float)ret / 65536. * 100.; 43 | }else return -999.; 44 | } 45 | 46 | void hdcSetup(){ 47 | Wire.begin(); // I2Cインタフェースの使用を開始 48 | delay(18); // 15ms以上 49 | Wire.beginTransmission(I2C_hdc); 50 | Wire.write(0x02); // 設定レジスタ 02 51 | Wire.write(0x00); 52 | Wire.write(0x00); 53 | Wire.endTransmission(); 54 | } 55 | -------------------------------------------------------------------------------- /2_example/example09m_hum/i2c_hdc.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | TI社 HDC1000 7 | Copyright (c) 2015-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_hdc 0x40 // HDC1000 の I2C アドレス 13 | 14 | float getTemp(){ 15 | int ret; 16 | Wire.beginTransmission(I2C_hdc); 17 | Wire.write(0x00); // 温度レジスタ 00 18 | if( Wire.endTransmission() == 0){ 19 | delay(9); // 6.5ms以上 20 | Wire.requestFrom(I2C_hdc,2); 21 | if(Wire.available()==0) return -999.; 22 | ret = Wire.read(); 23 | ret <<= 8; 24 | if(Wire.available()==0) return -999.; 25 | ret += Wire.read(); 26 | return (float)ret / 65536. * 165. - 40.; 27 | }else return -999.; 28 | } 29 | 30 | float getHum(){ 31 | int ret; 32 | Wire.beginTransmission(I2C_hdc); 33 | Wire.write(0x01); // 湿度レジスタ 01 34 | if( Wire.endTransmission() == 0){ 35 | delay(9); // 6.5ms以上 36 | Wire.requestFrom(I2C_hdc,2); 37 | if(Wire.available()==0) return -999.; 38 | ret = Wire.read(); 39 | ret <<= 8; 40 | if(Wire.available()==0) return -999.; 41 | ret += Wire.read(); 42 | return (float)ret / 65536. * 100.; 43 | }else return -999.; 44 | } 45 | 46 | void hdcSetup(){ 47 | Wire.begin(); // I2Cインタフェースの使用を開始 48 | delay(18); // 15ms以上 49 | Wire.beginTransmission(I2C_hdc); 50 | Wire.write(0x02); // 設定レジスタ 02 51 | Wire.write(0x00); 52 | Wire.write(0x00); 53 | Wire.endTransmission(); 54 | } 55 | -------------------------------------------------------------------------------- /2_example/example41_hum/i2c_hdc.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | TI社 HDC1000 7 | Copyright (c) 2015-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_hdc 0x40 // HDC1000 の I2C アドレス 13 | 14 | float getTemp(){ 15 | int ret; 16 | Wire.beginTransmission(I2C_hdc); 17 | Wire.write(0x00); // 温度レジスタ 00 18 | if( Wire.endTransmission() == 0){ 19 | delay(9); // 6.5ms以上 20 | Wire.requestFrom(I2C_hdc,2); 21 | if(Wire.available()==0) return -999.; 22 | ret = Wire.read(); 23 | ret <<= 8; 24 | if(Wire.available()==0) return -999.; 25 | ret += Wire.read(); 26 | return (float)ret / 65536. * 165. - 40.; 27 | }else return -999.; 28 | } 29 | 30 | float getHum(){ 31 | int ret; 32 | Wire.beginTransmission(I2C_hdc); 33 | Wire.write(0x01); // 湿度レジスタ 01 34 | if( Wire.endTransmission() == 0){ 35 | delay(9); // 6.5ms以上 36 | Wire.requestFrom(I2C_hdc,2); 37 | if(Wire.available()==0) return -999.; 38 | ret = Wire.read(); 39 | ret <<= 8; 40 | if(Wire.available()==0) return -999.; 41 | ret += Wire.read(); 42 | return (float)ret / 65536. * 100.; 43 | }else return -999.; 44 | } 45 | 46 | void hdcSetup(){ 47 | Wire.begin(); // I2Cインタフェースの使用を開始 48 | delay(18); // 15ms以上 49 | Wire.beginTransmission(I2C_hdc); 50 | Wire.write(0x02); // 設定レジスタ 02 51 | Wire.write(0x00); 52 | Wire.write(0x00); 53 | Wire.endTransmission(); 54 | } 55 | -------------------------------------------------------------------------------- /2_example/example26_tftp/README.md: -------------------------------------------------------------------------------- 1 | Example 26: 2 | # センサデバイス用 TFTPクライアント 設定 3 | 4 | TFTPサーバ上から設定ファイルをダウンロードし、モジュール内の設定を変更します。 5 | 本サンプルではESP-WROOM-02モジュールのディープスリープ時間を設定することが出来ます。 6 | 7 | ## TFTPとは 8 | 9 | TFTPはネットワーク機器などの設定ファイルやファームウェアを転送するときなどに使用されているデータ転送プロトコルです。 10 | 使い勝手が簡単で、プロトコルも簡単なので、機器のメンテナンスに向いています。 11 | 認証や暗号化は行わないので、転送時のみ有効にする、もしくは侵入・ファイル転送されても問題の無い用途で利用します。 12 | 13 | TFTPについて、より詳しいサンプルも公開しました(2021/01/16) 14 | 複数ブロック受信,SDカードへの保存に対応: 15 | https://github.com/bokunimowakaru/tftp 16 | 17 | ## 本サンプルの仕様 18 | 19 | 「SLEEP_SEC=時間(秒)」をTFTPで受信すると、ESPモジュールのスリープ間隔を変更することが出来ます。 20 | 21 | ## Raspberry PiへのTFTPサーバのインストール方法 22 | 23 | $ sudo apt-get install tftpd-hpa 24 | 25 | ## 設定ファイル(/etc/default/tftpd-hpa) の例 26 | 27 | # /etc/default/tftpd-hpa 28 | TFTP_USERNAME="tftp" 29 | TFTP_DIRECTORY="/srv/tftp" 30 | TFTP_ADDRESS="0.0.0.0:69" 31 | 32 | ## TFTPサーバの起動と停止 33 | 34 | $ chmod 755 /srv/tftp 35 | $ sudo /etc/init.d/tftpd-hpa start 36 | $ sudo /etc/init.d/tftpd-hpa stop 37 | 38 | ## 転送用のファイルを保存 39 | 40 | $ sudo echo "; Hello! This is from RasPi" | sudo tee /srv/tftp/tftpc_1.ini 41 | $ sudo echo "SLEEP_SEC=50" | sudo tee -a /srv/tftp/tftpc_1.ini 42 | $ sudo chmod 644 /srv/tftp/tftpc_1.ini 43 | $ cat /srv/tftp/tftpc_1.ini 44 | ; Hello! This is from RasPi 45 | SLEEP_SEC=50 46 | 47 | ## 注意事項 48 | 49 | * TFTPクライアント(ESP側)やTFTPサーバ(PCやRaspberry Pi側)起動すると、各機器がセキュリティの脅威にさらされた状態となります。 50 | * また、ウィルスやワームが侵入すると、同じネットワーク上の全ての機器へ感染する恐れが高まります。 51 | * インターネットに接続すると外部からの侵入される場合があります。 52 | * TFTPクライアントは少なくともローカルネット内のみで動作させるようにして下さい。 53 | * TFTPが不必要なときは、停止させてください。 54 | 55 | Copyright (c) 2016-2021 Wataru KUNINO 56 | 57 | -------------------------------------------------------------------------------- /2_example/example29_dash/promiscuous.h: -------------------------------------------------------------------------------- 1 | /* 2 | 下記の情報およびソースコードを利用させていただきました(2017/9/16)。 3 | 4 | プロミスキャスモードを用いたESP8266でのAmazon Dash Buttonのイベント取得 5 | http://qiita.com/kat-kai/items/3b1d5c74138d77a27c4d 6 | 7 | ライセンス:Qiita利用規約に基づく 8 | 権利者:kat-kai http://qiita.com/kat-kai (2016年12月29日~2017年01月08日) 9 | */ 10 | 11 | struct RxControl { 12 | signed rssi:8; 13 | unsigned rate:4; 14 | unsigned is_group:1; 15 | unsigned:1; 16 | unsigned sig_mode:2; 17 | unsigned legacy_length:12; 18 | unsigned damatch0:1; 19 | unsigned damatch1:1; 20 | unsigned bssidmatch0:1; 21 | unsigned bssidmatch1:1; 22 | unsigned MCS:7; 23 | unsigned CWB:1; 24 | unsigned HT_length:16; 25 | unsigned Smoothing:1; 26 | unsigned Not_Sounding:1; 27 | unsigned:1; 28 | unsigned Aggregation:1; 29 | unsigned STBC:2; 30 | unsigned FEC_CODING:1; 31 | unsigned SGI:1; 32 | unsigned rxend_state:8; 33 | unsigned ampdu_cnt:8; 34 | unsigned channel:4; 35 | unsigned:12; 36 | }; 37 | 38 | struct LenSeq { 39 | uint16_t length; 40 | uint16_t seq; 41 | uint8_t address3[6]; 42 | }; 43 | 44 | struct sniffer_buf { 45 | struct RxControl rx_ctrl; 46 | uint8_t buf[36]; 47 | uint16_t cnt; 48 | struct LenSeq lenseq[1]; 49 | }; 50 | 51 | struct sniffer_buf2{ 52 | struct RxControl rx_ctrl; 53 | uint8_t buf[112]; 54 | uint16_t cnt; 55 | uint16_t len; 56 | }; 57 | 58 | struct MAC_header { 59 | uint16_t frameControl; 60 | uint16_t duration; 61 | uint8_t addr1[6]; 62 | uint8_t addr2[6]; 63 | uint8_t addr3[6]; 64 | uint16_t sequenceControl; 65 | uint8_t addr4[6]; 66 | uint16_t qos; 67 | uint8_t hit[4]; 68 | }; 69 | -------------------------------------------------------------------------------- /2_example/example29u_dash/promiscuous.h: -------------------------------------------------------------------------------- 1 | /* 2 | 下記の情報およびソースコードを利用させていただきました(2017/9/16)。 3 | 4 | プロミスキャスモードを用いたESP8266でのAmazon Dash Buttonのイベント取得 5 | http://qiita.com/kat-kai/items/3b1d5c74138d77a27c4d 6 | 7 | ライセンス:Qiita利用規約に基づく 8 | 権利者:kat-kai http://qiita.com/kat-kai (2016年12月29日~2017年01月08日) 9 | */ 10 | 11 | struct RxControl { 12 | signed rssi:8; 13 | unsigned rate:4; 14 | unsigned is_group:1; 15 | unsigned:1; 16 | unsigned sig_mode:2; 17 | unsigned legacy_length:12; 18 | unsigned damatch0:1; 19 | unsigned damatch1:1; 20 | unsigned bssidmatch0:1; 21 | unsigned bssidmatch1:1; 22 | unsigned MCS:7; 23 | unsigned CWB:1; 24 | unsigned HT_length:16; 25 | unsigned Smoothing:1; 26 | unsigned Not_Sounding:1; 27 | unsigned:1; 28 | unsigned Aggregation:1; 29 | unsigned STBC:2; 30 | unsigned FEC_CODING:1; 31 | unsigned SGI:1; 32 | unsigned rxend_state:8; 33 | unsigned ampdu_cnt:8; 34 | unsigned channel:4; 35 | unsigned:12; 36 | }; 37 | 38 | struct LenSeq { 39 | uint16_t length; 40 | uint16_t seq; 41 | uint8_t address3[6]; 42 | }; 43 | 44 | struct sniffer_buf { 45 | struct RxControl rx_ctrl; 46 | uint8_t buf[36]; 47 | uint16_t cnt; 48 | struct LenSeq lenseq[1]; 49 | }; 50 | 51 | struct sniffer_buf2{ 52 | struct RxControl rx_ctrl; 53 | uint8_t buf[112]; 54 | uint16_t cnt; 55 | uint16_t len; 56 | }; 57 | 58 | struct MAC_header { 59 | uint16_t frameControl; 60 | uint16_t duration; 61 | uint8_t addr1[6]; 62 | uint8_t addr2[6]; 63 | uint8_t addr3[6]; 64 | uint16_t sequenceControl; 65 | uint8_t addr4[6]; 66 | uint16_t qos; 67 | uint8_t hit[4]; 68 | }; 69 | -------------------------------------------------------------------------------- /5_learn32/esp32_21_bell_lcd/lcdisp.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去して(UTF8をASCIIカナ文字へ変換するときに使用) 6 | LCD(16文字2桁)へ表示します 7 | 8 | Copyright (c) 2014-2019 Wataru KUNINO 9 | https://bokunimo.net/bokunimowakaru/ 10 | *********************************************************************/ 11 | 12 | void _utf_del_uni(char *s){ 13 | unsigned int i=0; 14 | unsigned int j=0; 15 | while(s[i]!='\0'){ 16 | if((byte)s[i]==0xEF){ 17 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 18 | i+=2; 19 | } 20 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 21 | s[j]=s[i]; 22 | j++; 23 | } 24 | i++; 25 | } 26 | s[j]='\0'; 27 | } 28 | 29 | void lcdisp(const char *s){ 30 | lcdisp(s,0); 31 | } 32 | 33 | void lcdisp(const char *s,int y){ 34 | char lc[17]; // LCD表示用の文字列変数 35 | char utf[129]; 36 | int i; 37 | memset(lc,0,17); // 文字列変数lcの初期化(17バイト) 38 | memset(utf,0,129); 39 | strncpy(utf,s,128); 40 | 41 | if(y<0 || y>1)return; 42 | _utf_del_uni(utf); 43 | strncpy(lc,utf,16); 44 | lcd.setCursor(0,y); // カーソル位置を左へ 45 | lcd.print(lc); // 液晶へ転送 46 | for(i=strlen(utf);i<16;i++)lcd.print(' '); 47 | if( strlen(utf)<=16) return; 48 | strncpy(lc,utf+16,16); 49 | lcd.setCursor(0,1); 50 | lcd.print(lc); // 液晶へ転送 51 | for(i=strlen(utf+16);i<16;i++)lcd.print(' '); 52 | } 53 | -------------------------------------------------------------------------------- /5_learn32/esp32_22_sens_lcd/lcdisp.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去して(UTF8をASCIIカナ文字へ変換するときに使用) 6 | LCD(16文字2桁)へ表示します 7 | 8 | Copyright (c) 2014-2019 Wataru KUNINO 9 | https://bokunimo.net/bokunimowakaru/ 10 | *********************************************************************/ 11 | 12 | void _utf_del_uni(char *s){ 13 | unsigned int i=0; 14 | unsigned int j=0; 15 | while(s[i]!='\0'){ 16 | if((byte)s[i]==0xEF){ 17 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 18 | i+=2; 19 | } 20 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 21 | s[j]=s[i]; 22 | j++; 23 | } 24 | i++; 25 | } 26 | s[j]='\0'; 27 | } 28 | 29 | void lcdisp(const char *s){ 30 | lcdisp(s,0); 31 | } 32 | 33 | void lcdisp(const char *s,int y){ 34 | char lc[17]; // LCD表示用の文字列変数 35 | char utf[129]; 36 | int i; 37 | memset(lc,0,17); // 文字列変数lcの初期化(17バイト) 38 | memset(utf,0,129); 39 | strncpy(utf,s,128); 40 | 41 | if(y<0 || y>1)return; 42 | _utf_del_uni(utf); 43 | strncpy(lc,utf,16); 44 | lcd.setCursor(0,y); // カーソル位置を左へ 45 | lcd.print(lc); // 液晶へ転送 46 | for(i=strlen(utf);i<16;i++)lcd.print(' '); 47 | if( strlen(utf)<=16) return; 48 | strncpy(lc,utf+16,16); 49 | lcd.setCursor(0,1); 50 | lcd.print(lc); // 液晶へ転送 51 | for(i=strlen(utf+16);i<16;i++)lcd.print(' '); 52 | } 53 | -------------------------------------------------------------------------------- /5_learn32/esp32_23_rtr_lcd/lcdisp.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去して(UTF8をASCIIカナ文字へ変換するときに使用) 6 | LCD(16文字2桁)へ表示します 7 | 8 | Copyright (c) 2014-2019 Wataru KUNINO 9 | https://bokunimo.net/bokunimowakaru/ 10 | *********************************************************************/ 11 | 12 | void _utf_del_uni(char *s){ 13 | unsigned int i=0; 14 | unsigned int j=0; 15 | while(s[i]!='\0'){ 16 | if((byte)s[i]==0xEF){ 17 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 18 | i+=2; 19 | } 20 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 21 | s[j]=s[i]; 22 | j++; 23 | } 24 | i++; 25 | } 26 | s[j]='\0'; 27 | } 28 | 29 | void lcdisp(const char *s){ 30 | lcdisp(s,0); 31 | } 32 | 33 | void lcdisp(const char *s,int y){ 34 | char lc[17]; // LCD表示用の文字列変数 35 | char utf[129]; 36 | int i; 37 | memset(lc,0,17); // 文字列変数lcの初期化(17バイト) 38 | memset(utf,0,129); 39 | strncpy(utf,s,128); 40 | 41 | if(y<0 || y>1)return; 42 | _utf_del_uni(utf); 43 | strncpy(lc,utf,16); 44 | lcd.setCursor(0,y); // カーソル位置を左へ 45 | lcd.print(lc); // 液晶へ転送 46 | for(i=strlen(utf);i<16;i++)lcd.print(' '); 47 | if( strlen(utf)<=16) return; 48 | strncpy(lc,utf+16,16); 49 | lcd.setCursor(0,1); 50 | lcd.print(lc); // 液晶へ転送 51 | for(i=strlen(utf+16);i<16;i++)lcd.print(' '); 52 | } 53 | -------------------------------------------------------------------------------- /5_learn32/esp32_24_ntp_lcd/lcdisp.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去して(UTF8をASCIIカナ文字へ変換するときに使用) 6 | LCD(16文字2桁)へ表示します 7 | 8 | Copyright (c) 2014-2019 Wataru KUNINO 9 | https://bokunimo.net/bokunimowakaru/ 10 | *********************************************************************/ 11 | 12 | void _utf_del_uni(char *s){ 13 | unsigned int i=0; 14 | unsigned int j=0; 15 | while(s[i]!='\0'){ 16 | if((byte)s[i]==0xEF){ 17 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 18 | i+=2; 19 | } 20 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 21 | s[j]=s[i]; 22 | j++; 23 | } 24 | i++; 25 | } 26 | s[j]='\0'; 27 | } 28 | 29 | void lcdisp(const char *s){ 30 | lcdisp(s,0); 31 | } 32 | 33 | void lcdisp(const char *s,int y){ 34 | char lc[17]; // LCD表示用の文字列変数 35 | char utf[129]; 36 | int i; 37 | memset(lc,0,17); // 文字列変数lcの初期化(17バイト) 38 | memset(utf,0,129); 39 | strncpy(utf,s,128); 40 | 41 | if(y<0 || y>1)return; 42 | _utf_del_uni(utf); 43 | strncpy(lc,utf,16); 44 | lcd.setCursor(0,y); // カーソル位置を左へ 45 | lcd.print(lc); // 液晶へ転送 46 | for(i=strlen(utf);i<16;i++)lcd.print(' '); 47 | if( strlen(utf)<=16) return; 48 | strncpy(lc,utf+16,16); 49 | lcd.setCursor(0,1); 50 | lcd.print(lc); // 液晶へ転送 51 | for(i=strlen(utf+16);i<16;i++)lcd.print(' '); 52 | } 53 | -------------------------------------------------------------------------------- /5_learn32/esp32_25_wtr_lcd/lcdisp.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | UTF8の制御コードを除去して(UTF8をASCIIカナ文字へ変換するときに使用) 6 | LCD(16文字2桁)へ表示します 7 | 8 | Copyright (c) 2014-2019 Wataru KUNINO 9 | https://bokunimo.net/bokunimowakaru/ 10 | *********************************************************************/ 11 | 12 | void _utf_del_uni(char *s){ 13 | unsigned int i=0; 14 | unsigned int j=0; 15 | while(s[i]!='\0'){ 16 | if((byte)s[i]==0xEF){ 17 | if((byte)s[i+1]==0xBE) s[i+2] += 0x40; 18 | i+=2; 19 | } 20 | if(isprint(s[i]) || ((byte)s[i] >=0xA0 && (byte)s[i] <= 0xDF)){ 21 | s[j]=s[i]; 22 | j++; 23 | } 24 | i++; 25 | } 26 | s[j]='\0'; 27 | } 28 | 29 | void lcdisp(const char *s){ 30 | lcdisp(s,0); 31 | } 32 | 33 | void lcdisp(const char *s,int y){ 34 | char lc[17]; // LCD表示用の文字列変数 35 | char utf[129]; 36 | int i; 37 | memset(lc,0,17); // 文字列変数lcの初期化(17バイト) 38 | memset(utf,0,129); 39 | strncpy(utf,s,128); 40 | 41 | if(y<0 || y>1)return; 42 | _utf_del_uni(utf); 43 | strncpy(lc,utf,16); 44 | lcd.setCursor(0,y); // カーソル位置を左へ 45 | lcd.print(lc); // 液晶へ転送 46 | for(i=strlen(utf);i<16;i++)lcd.print(' '); 47 | if( strlen(utf)<=16) return; 48 | strncpy(lc,utf+16,16); 49 | lcd.setCursor(0,1); 50 | lcd.print(lc); // 液晶へ転送 51 | for(i=strlen(utf+16);i<16;i++)lcd.print(' '); 52 | } 53 | -------------------------------------------------------------------------------- /5_learn32/esp32_18_voice/uspeech_phoneme.cpp: -------------------------------------------------------------------------------- 1 | #include "uspeech.h" 2 | /** 3 | * The recognizer function: takes 1-4ms to execute 4 | */ 5 | char signal::getPhoneme() 6 | { 7 | #ifdef ARDUINO_ENVIRONMENT 8 | sample(); 9 | #endif 10 | unsigned int pp =power(); 11 | //Serial.print(F("pp=")); Serial.println(pp); 12 | // if (pp>SILENCE) { 13 | if (pp > micPowerThreshold * 32) { 14 | //Perform Division 15 | int k = complexity(pp); 16 | //Low pass filter for noise removal 17 | overview[6] = overview[5]; 18 | overview[5] = overview[4]; 19 | overview[4] = overview[3]; 20 | overview[3] = overview[2]; 21 | overview[2] = overview[1]; 22 | overview[1] = overview[0]; 23 | overview[0] = k; 24 | 25 | int coeff = 0; 26 | for (uint8_t f=0; f<6; f++) { 27 | coeff += overview[f]; 28 | } 29 | coeff /= 7; 30 | 31 | micPower = 0.05 * maxPower() + (1 - 0.05) * micPower; 32 | 33 | testCoeff = coeff; 34 | //Serial.print(F("coeff: ")); Serial.println(coeff); //Use this for debugging 35 | 36 | //Twiddle with the numbers here if your getting false triggers 37 | //This is the main classifier part 38 | 39 | if (coeff fconstant) { 54 | return 'f'; 55 | } 56 | } 57 | 58 | return phoneme; 59 | 60 | } 61 | else{ 62 | micPower = 0; 63 | testCoeff = 0; 64 | return ' '; 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /2_example/example16w_led/html.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | HTMLコンテンツ LEDの輝度制御 3 | 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *******************************************************************************/ 6 | 7 | void getHtml(char *html, int target){ 8 | char s[65],s_ip[16]; 9 | uint32_t ip = WiFi.localIP(); 10 | 11 | sprintf(s_ip,"%d.%d.%d.%d", 12 | ip & 255, 13 | ip>>8 & 255, 14 | ip>>16 & 255, 15 | ip>>24 16 | ); 17 | snprintf(html,2047,"\n\nWi-Fi コンシェルジェ 照明担当\n\n\n\n

LED STATUS

\n"); 18 | if(target==0) sprintf(s,"

0 (LED OFF)

"); 19 | if(target==1) sprintf(s,"

1 (LED ON)

"); 20 | if(target>1) sprintf(s,"

%d (キャンドル)

",target); 21 | if(target<0) sprintf(s,"

%d (輝度=%d%%)

",target,-target*10); 22 | snprintf(html,2047,"%s\n%s\n
\n

HTTP GET

\n

http://%s/?L=n
\n(n: 0=OFF, 1=ON, 2~10=キャンドル, -1~-10=輝度)

",html,s,s_ip); 23 | sprintf(s,"
",s_ip); 24 | snprintf(html,2047,"%s\n%s\n\n\n\n\n
\n",html,s); 25 | snprintf(html,2047,"%s\n%s\n\n\n\n\n",html,s); 26 | sprintf(s,"LED=%d",target); // 変数sに「LED=」とtarget値を代入 27 | Serial.println(s); // シリアルへコンテンツを出力 28 | } 29 | -------------------------------------------------------------------------------- /2_example/example48w_led/html.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | HTMLコンテンツ LEDの輝度制御 3 | 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *******************************************************************************/ 6 | 7 | void getHtml(char *html, int target){ 8 | char s[65],s_ip[16]; 9 | uint32_t ip = WiFi.localIP(); 10 | 11 | sprintf(s_ip,"%d.%d.%d.%d", 12 | ip & 255, 13 | ip>>8 & 255, 14 | ip>>16 & 255, 15 | ip>>24 16 | ); 17 | snprintf(html,2047,"\n\nWi-Fi コンシェルジェ 照明担当\n\n\n\n

LED STATUS

\n"); 18 | if(target==0) sprintf(s,"

0 (LED OFF)

"); 19 | if(target==1) sprintf(s,"

1 (LED ON)

"); 20 | if(target>1) sprintf(s,"

%d (キャンドル)

",target); 21 | if(target<0) sprintf(s,"

%d (輝度=%d%%)

",target,-target*10); 22 | snprintf(html,2047,"%s\n%s\n
\n

HTTP GET

\n

http://%s/?L=n
\n(n: 0=OFF, 1=ON, 2~10=キャンドル, -1~-10=輝度)

",html,s,s_ip); 23 | sprintf(s,"
",s_ip); 24 | snprintf(html,2047,"%s\n%s\n\n\n\n\n
\n",html,s); 25 | snprintf(html,2047,"%s\n%s\n\n\n\n\n",html,s); 26 | sprintf(s,"LED=%d",target); // 変数sに「LED=」とtarget値を代入 27 | Serial.println(s); // シリアルへコンテンツを出力 28 | } 29 | -------------------------------------------------------------------------------- /5_learn32/esp32_18_voice_ok/uspeech_phoneme.cpp: -------------------------------------------------------------------------------- 1 | #include "uspeech.h" 2 | /** 3 | * The recognizer function: takes 1-4ms to execute 4 | */ 5 | char signal::getPhoneme() 6 | { 7 | #ifdef ARDUINO_ENVIRONMENT 8 | sample(); 9 | #endif 10 | unsigned int pp =power(); 11 | //Serial.print(F("pp=")); Serial.println(pp); 12 | // if (pp>SILENCE) { 13 | if (pp > micPowerThreshold * 32) { 14 | //Perform Division 15 | int k = complexity(pp); 16 | //Low pass filter for noise removal 17 | overview[6] = overview[5]; 18 | overview[5] = overview[4]; 19 | overview[4] = overview[3]; 20 | overview[3] = overview[2]; 21 | overview[2] = overview[1]; 22 | overview[1] = overview[0]; 23 | overview[0] = k; 24 | 25 | int coeff = 0; 26 | for (uint8_t f=0; f<6; f++) { 27 | coeff += overview[f]; 28 | } 29 | coeff /= 7; 30 | 31 | micPower = 0.05 * maxPower() + (1 - 0.05) * micPower; 32 | 33 | testCoeff = coeff; 34 | //Serial.print(F("coeff: ")); Serial.println(coeff); //Use this for debugging 35 | 36 | //Twiddle with the numbers here if your getting false triggers 37 | //This is the main classifier part 38 | 39 | if (coeff fconstant) { 54 | return 'f'; 55 | } 56 | } 57 | 58 | return phoneme; 59 | 60 | } 61 | else{ 62 | micPower = 0; 63 | testCoeff = 0; 64 | return ' '; 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /2_example/example18_lcd/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /2_example/example18t_lcd/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /2_example/example21_talk/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /2_example/example50_lcd/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /2_example/example53_talk/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /2_example/example18t_lcd_ntp/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /2_example/example28_lcdkey/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | 5 | Copyright (c) 2016-2019 Wataru KUNINO 6 | *********************************************************************/ 7 | 8 | 9 | int ahex2i(char c){ 10 | if(c>='0' && c<='9') return c-'0'; 11 | if(c>='a' && c<='f') return c-'a'+10; 12 | if(c>='A' && c<='F') return c-'A'+10; 13 | return -1; 14 | } 15 | 16 | int trUri2txt(char *s){ 17 | int i,j; 18 | int len; 19 | 20 | for(i=0;i j=5 s[3]=s[5] 45 | len=7 -> len=5 46 | s[5]=null 47 | 48 | test 49 | !"#$%&'() ok 50 | |@`[{}]; ok 51 | :+*<>?_, ok 52 | ./~^-= ok 53 | 54 | 0!!!!!!78!!!!!!F OK 55 | 0!!!!!!78!!!!!!F0!!!! OK 56 | 57 | 64バイトの場合 58 | 記号だけのとき=64バイト÷3=21文字まで 59 | カタカナの場合=64バイト÷12=5文字まで 60 | */ 61 | -------------------------------------------------------------------------------- /2_example/example60_lcdkey/trUri2txt.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。 3 | HTTPクエリ内のコードを文字に戻す 4 | Copyright (c) 2016-2019 Wataru KUNINO 5 | *********************************************************************/ 6 | 7 | 8 | int ahex2i(char c){ 9 | if(c>='0' && c<='9') return c-'0'; 10 | if(c>='a' && c<='f') return c-'a'+10; 11 | if(c>='A' && c<='F') return c-'A'+10; 12 | return -1; 13 | } 14 | 15 | int trUri2txt(char *s){ 16 | int i,j; 17 | int len; 18 | 19 | for(i=0;i j=5 s[3]=s[5] 44 | len=7 -> len=5 45 | s[5]=null 46 | 47 | test 48 | !"#$%&'() ok 49 | |@`[{}]; ok 50 | :+*<>?_, ok 51 | ./~^-= ok 52 | 53 | 0!!!!!!78!!!!!!F OK 54 | 0!!!!!!78!!!!!!F0!!!! OK 55 | 56 | 64バイトの場合 57 | 記号だけのとき=64バイト÷3=21文字まで 58 | カタカナの場合=64バイト÷12=5文字まで 59 | */ 60 | -------------------------------------------------------------------------------- /tools/udp_logger.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # coding: utf-8 3 | # UDPを受信する 4 | # Copyright (c) 2018-2019 Wataru KUNINO 5 | 6 | from __future__ import print_function 7 | import sys 8 | import socket 9 | import datetime 10 | 11 | buf_n= 128 # 受信バッファ容量(バイト) 12 | argc = len(sys.argv) # 引数の数をargcへ代入 13 | print('UDP Logger (usage: '+sys.argv[0]+' port)') # タイトル表示 14 | if argc == 2: # 入力パラメータ数の確認 15 | port = int(sys.argv[1]) # ポート番号を設定 16 | if port < 1 or port > 65535: # ポート1未満or65535超の時 17 | port = 1024 # UDPポート番号を1024に 18 | else: 19 | port = 1024 20 | print('Listening UDP port', port, '...') # ポート番号表示 21 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # ソケットを作成 22 | sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)# オプション設定 23 | if sock: # 作成に成功したとき 24 | sock.bind(('', port)) # ソケットに接続 25 | while sock: # 永遠に繰り返す 26 | udp=sock.recv(buf_n).decode() # UDPパケットを取得 27 | str='' # 表示用の文字列変数str 28 | for c in udp: # UDPパケット内 29 | if ord(c) >= ord(' '): # 表示可能文字 30 | str += c # 文字列strへ追加 31 | date=datetime.datetime.today() # 日付を取得 32 | print(date.strftime('%Y/%m/%d %H:%M'), end='') # 日付を出力 33 | print(', '+str) # 受信データを出力 34 | sock.close() # ソケットの切断 35 | -------------------------------------------------------------------------------- /1_practice/practice05_calc/practice05_calc.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 5: 良く使う演算子 3 | Copyright (c) 2015-2019 Wataru KUNINO 4 | *******************************************************************************/ 5 | 6 | void setup() { // 起動時に一度だけ実行される関数 7 | Serial.begin(9600); // シリアル通信速度を9600bpsに設定する 8 | } 9 | 10 | void loop() { // setup実行後に繰り返し実行される関数 11 | int a = 12345; // 整数型の変数aを定義 12 | float v; // 浮動小数点数型変数v 13 | 14 | Serial.println("Practice 04"); // 「Practice 04」を表示 15 | 16 | Serial.print(a,DEC); // 整数値変数aの値を表示 17 | a = a - 345; // a-345を計算してaに代入 18 | Serial.print(" - 345 = "); 19 | Serial.println(a,DEC); // 整数値変数aの値を表示 20 | 21 | Serial.print(a,DEC); // 整数値変数aの値を表示 22 | a = a / 1000; // a÷1000をaに代入 23 | Serial.print(" / 1000 = "); 24 | Serial.println(a,DEC); // 整数値変数aの値を表示 25 | 26 | v = (float) a; // 浮動小数変数vにaを代入 27 | Serial.print("(int) "); 28 | Serial.print(a,DEC); // 整数値変数aの値を表示 29 | a = a / 10; // a÷10をaに代入 30 | Serial.print(" / 10 = "); 31 | Serial.println(a,DEC); // 整数値変数aの値を表示 32 | 33 | Serial.print("(float) "); 34 | Serial.print(v,3); // 浮動小数点数型変数vの値を表示 35 | v = v / 10; // v÷10をvに代入 36 | Serial.print(" / 10 = "); 37 | Serial.println(v,3); // 浮動小数点数型変数vの値を表示 38 | 39 | for(a=0;a<10;a++) delay(100); // 1秒の待ち時間処理 40 | Serial.println(); 41 | } 42 | -------------------------------------------------------------------------------- /2_example/example64_photo_m5/README_Adafruit-ILI9341.md: -------------------------------------------------------------------------------- 1 | # Adafruit ILI9341 Arduino Library [![Build Status](https://travis-ci.org/adafruit/Adafruit_ILI9341.svg?branch=master)](https://travis-ci.org/adafruit/Adafruit_ILI9341) 2 | 3 | This is a library for the Adafruit ILI9341 display products 4 | 5 | This library works with the Adafruit 2.8" Touch Shield V2 (SPI) 6 | * http://www.adafruit.com/products/1651 7 | 8 | Adafruit 2.4" TFT LCD with Touchscreen Breakout w/MicroSD Socket - ILI9341 9 | * https://www.adafruit.com/product/2478 10 | 11 | 2.8" TFT LCD with Touchscreen Breakout Board w/MicroSD Socket - ILI9341 12 | * https://www.adafruit.com/product/1770 13 | 14 | 2.2" 18-bit color TFT LCD display with microSD card breakout - ILI9340 15 | * https://www.adafruit.com/product/1480 16 | 17 | TFT FeatherWing - 2.4" 320x240 Touchscreen For All Feathers 18 | * https://www.adafruit.com/product/3315 19 | 20 | Check out the links above for our tutorials and wiring diagrams. 21 | These displays use SPI to communicate, 4 or 5 pins are required 22 | to interface (RST is optional). 23 | 24 | Adafruit invests time and resources providing this open source code, 25 | please support Adafruit and open-source hardware by purchasing 26 | products from Adafruit! 27 | 28 | Written by Limor Fried/Ladyada for Adafruit Industries. 29 | MIT license, all text above must be included in any redistribution 30 | 31 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ILI9341. Check that the Adafruit_ILI9341 folder contains Adafruit_ILI9341.cpp and Adafruit_ILI9341. 32 | 33 | Place the Adafruit_ILI9341 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE 34 | 35 | Also requires the Adafruit_GFX library for Arduino. 36 | -------------------------------------------------------------------------------- /5_learn32/esp32_05_i2c/i2c_sht31.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SENSIRION社 SHT31 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_sht 0x45 // SHT31 の I2C アドレス 13 | 14 | float _i2c_sht31_hum; 15 | 16 | float getTemp(){ 17 | int temp,hum; 18 | _i2c_sht31_hum=-999.; 19 | Wire.beginTransmission(I2C_sht); 20 | Wire.write(0x2C); 21 | Wire.write(0x06); 22 | delay(18); // 15ms以上 23 | if( Wire.endTransmission() == 0){ 24 | Wire.requestFrom(I2C_sht,6); 25 | if(Wire.available()==0) return -999.; 26 | temp = Wire.read(); 27 | temp <<= 8; 28 | if(Wire.available()==0) return -999.; 29 | temp += Wire.read(); 30 | if(Wire.available()==0) return -999.; 31 | Wire.read(); 32 | if(Wire.available()==0) return -999.; 33 | hum = Wire.read(); 34 | hum <<= 8; 35 | if(Wire.available()==0) return -999.; 36 | hum += Wire.read(); 37 | if(Wire.available()==0) return -999.; 38 | Wire.read(); 39 | _i2c_sht31_hum = (float)hum / 65535. * 100.; 40 | return (float)temp / 65535. * 175. - 45.; 41 | }else return -999.; 42 | } 43 | 44 | float getHum(){ 45 | return _i2c_sht31_hum; 46 | } 47 | 48 | void shtSetup(){ 49 | delay(2); // 1ms以上 50 | Wire.begin(); // I2Cインタフェースの使用を開始 51 | delay(18); // 15ms以上 52 | } 53 | -------------------------------------------------------------------------------- /5_learn32/esp32_16_hum/i2c_sht31.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SENSIRION社 SHT31 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_sht 0x45 // SHT31 の I2C アドレス 13 | 14 | float _i2c_sht31_hum; 15 | 16 | float getTemp(){ 17 | int temp,hum; 18 | _i2c_sht31_hum=-999.; 19 | Wire.beginTransmission(I2C_sht); 20 | Wire.write(0x2C); 21 | Wire.write(0x06); 22 | delay(18); // 15ms以上 23 | if( Wire.endTransmission() == 0){ 24 | Wire.requestFrom(I2C_sht,6); 25 | if(Wire.available()==0) return -999.; 26 | temp = Wire.read(); 27 | temp <<= 8; 28 | if(Wire.available()==0) return -999.; 29 | temp += Wire.read(); 30 | if(Wire.available()==0) return -999.; 31 | Wire.read(); 32 | if(Wire.available()==0) return -999.; 33 | hum = Wire.read(); 34 | hum <<= 8; 35 | if(Wire.available()==0) return -999.; 36 | hum += Wire.read(); 37 | if(Wire.available()==0) return -999.; 38 | Wire.read(); 39 | _i2c_sht31_hum = (float)hum / 65535. * 100.; 40 | return (float)temp / 65535. * 175. - 45.; 41 | }else return -999.; 42 | } 43 | 44 | float getHum(){ 45 | return _i2c_sht31_hum; 46 | } 47 | 48 | void shtSetup(){ 49 | delay(2); // 1ms以上 50 | Wire.begin(); // I2Cインタフェースの使用を開始 51 | delay(18); // 15ms以上 52 | } 53 | -------------------------------------------------------------------------------- /tools/get_photo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # カメラからの配信画像を取得する 3 | # Copyright (c) 2016 Wataru KUNINO 4 | 5 | DEVICE="cam_a_1" # 配信デバイス名(必須) 6 | PORT=1024 # UDPポート番号を1024に 7 | 8 | echo "UDP Logger (usage: ${0} port)" # タイトル表示 9 | if [ ${#} = 1 ]; then # 入力パラメータ数が1つ 10 | if [ ${1} -ge 1 ] && [ ${1} -le 65535 ]; then # ポート番号の範囲確認 11 | PORT=${1} # ポート番号を設定 12 | fi # ifの終了 13 | fi # ifの終了 14 | echo "Listening UDP port "${PORT}"..." # ポート番号表示 15 | mkdir photo >& /dev/null # 写真保存用フォルダ作成 16 | while true # 永遠に 17 | do # 繰り返し 18 | UDP=`sudo netcat -luw0 ${PORT}|tr -d [:cntrl:]|\ 19 | tr -d "\!\"\$\%\&\'\(\)\*\+\-\;\<\=\>\?\[\\\]\^\{\|\}\~"` 20 | # UDPパケットを取得 21 | DATE=`date "+%Y/%m/%d %R"` # 日時を取得 22 | DEV=${UDP#,*} # デバイス名を取得(前方) 23 | DEV=${DEV%%,*} # デバイス名を取得(後方) 24 | echo -E $DATE, $UDP|tee -a log_${DEV}.csv # 取得日時とデータを保存 25 | if [ ${DEVICE} = ${DEV} ]; then # カメラからの配信画像時 26 | DATE=`date "+%Y%m%d-%H%M"` # 日時を取得 27 | URL=`echo -E $UDP|cut -d' ' -f2` # スペース区切りの2番目 28 | echo -n "Get "${URL} # 画像取得t実行表示 29 | wget -qT10 ${URL} -Ophoto/${DEVICE}"_"${DATE}.jpg # wget実行 30 | echo " Done" # 終了表示 31 | fi 32 | done # 繰り返し範囲:ここまで 33 | -------------------------------------------------------------------------------- /2_example/example41_hum_sht31/i2c_sht31.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SENSIRION社 SHT31 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_sht 0x45 // SHT31 の I2C アドレス 13 | 14 | float _i2c_sht31_hum; 15 | 16 | float getTemp(){ 17 | int temp,hum; 18 | _i2c_sht31_hum=-999.; 19 | Wire.beginTransmission(I2C_sht); 20 | Wire.write(0x2C); 21 | Wire.write(0x06); 22 | delay(18); // 15ms以上 23 | if( Wire.endTransmission() == 0){ 24 | Wire.requestFrom(I2C_sht,6); 25 | if(Wire.available()==0) return -999.; 26 | temp = Wire.read(); 27 | temp <<= 8; 28 | if(Wire.available()==0) return -999.; 29 | temp += Wire.read(); 30 | if(Wire.available()==0) return -999.; 31 | Wire.read(); 32 | if(Wire.available()==0) return -999.; 33 | hum = Wire.read(); 34 | hum <<= 8; 35 | if(Wire.available()==0) return -999.; 36 | hum += Wire.read(); 37 | if(Wire.available()==0) return -999.; 38 | Wire.read(); 39 | _i2c_sht31_hum = (float)hum / 65535. * 100.; 40 | return (float)temp / 65535. * 175. - 45.; 41 | }else return -999.; 42 | } 43 | 44 | float getHum(){ 45 | return _i2c_sht31_hum; 46 | } 47 | 48 | void shtSetup(){ 49 | delay(2); // 1ms以上 50 | Wire.begin(); // I2Cインタフェースの使用を開始 51 | delay(18); // 15ms以上 52 | } 53 | -------------------------------------------------------------------------------- /2_example/example64_photo/README_Adafruit-SSD1331.txt: -------------------------------------------------------------------------------- 1 | /* 2 | 本ソースリストは2017/11/2に下記からダウンロードしたものを、国野亘が改変したものです。 3 | 4 | https://learn.adafruit.com/096-mini-color-oled/wiring 5 | 6 | ダウンロード時点ではESP32に対応していませんでしたので、ESP32で動作するように修正しました。 7 | 将来的には元の権利者であるAdafruitによってESP32対応が図られると思われるため、最小限度の 8 | 修正に止めています。動作に問題が生じる可能性もあります。 9 | 10 | Adafruitによる最新の情報は、下記に掲載されると思います。 11 | 12 | https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/issues/10 13 | 14 | 2017/11/2 国野 亘 15 | */ 16 | -------------------------------------------------------------------------------- 17 | 18 | This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip 19 | 20 | Pick one up today in the adafruit shop! 21 | ------> http://www.adafruit.com/products/684 22 | 23 | These displays use SPI to communicate, 4 or 5 pins are required to 24 | interface 25 | 26 | Adafruit invests time and resources providing this open source code, 27 | please support Adafruit and open-source hardware by purchasing 28 | products from Adafruit! 29 | 30 | Written by Limor Fried/Ladyada for Adafruit Industries. 31 | BSD license, check license.txt for more information 32 | All text above must be included in any redistribution 33 | 34 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1131. Check that the Adafruit_SSD1331 folder contains Adafruit_SSD1331.cpp and Adafruit_SSD1331.h 35 | 36 | Place the Adafruit_SSD1331 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 37 | 38 | You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from 39 | https://github.com/adafruit/Adafruit-GFX-Library 40 | and download/install that library as well 41 | -------------------------------------------------------------------------------- /5_learn32/esp32_26_photof/README_Adafruit-SSD1331.txt: -------------------------------------------------------------------------------- 1 | /* 2 | 本ソースリストは2017/11/2に下記からダウンロードしたものを、国野亘が改変したものです。 3 | 4 | https://learn.adafruit.com/096-mini-color-oled/wiring 5 | 6 | ダウンロード時点ではESP32に対応していませんでしたので、ESP32で動作するように修正しました。 7 | 将来的には元の権利者であるAdafruitによってESP32対応が図られると思われるため、最小限度の 8 | 修正に止めています。動作に問題が生じる可能性もあります。 9 | 10 | Adafruitによる最新の情報は、下記に掲載されると思います。 11 | 12 | https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/issues/10 13 | 14 | 2017/11/2 国野 亘 15 | */ 16 | -------------------------------------------------------------------------------- 17 | 18 | This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip 19 | 20 | Pick one up today in the adafruit shop! 21 | ------> http://www.adafruit.com/products/684 22 | 23 | These displays use SPI to communicate, 4 or 5 pins are required to 24 | interface 25 | 26 | Adafruit invests time and resources providing this open source code, 27 | please support Adafruit and open-source hardware by purchasing 28 | products from Adafruit! 29 | 30 | Written by Limor Fried/Ladyada for Adafruit Industries. 31 | BSD license, check license.txt for more information 32 | All text above must be included in any redistribution 33 | 34 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_SSD1131. Check that the Adafruit_SSD1331 folder contains Adafruit_SSD1331.cpp and Adafruit_SSD1331.h 35 | 36 | Place the Adafruit_SSD1331 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. 37 | 38 | You will also have to download the Adafruit GFX Graphics core which does all the circles, text, rectangles, etc. You can get it from 39 | https://github.com/adafruit/Adafruit-GFX-Library 40 | and download/install that library as well 41 | -------------------------------------------------------------------------------- /tools/get_sound.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # マイクからの音声データを取得する 3 | # Copyright (c) 2016-2019 Wataru KUNINO 4 | 5 | DEVICE="sound_1" # 配信デバイス名(必須) 6 | PORT=1024 # UDPポート番号を1024に 7 | 8 | echo "UDP Logger (usage: ${0} port)" # タイトル表示 9 | if [ ${#} = 1 ]; then # 入力パラメータ数が1つ 10 | if [ ${1} -ge 1 ] && [ ${1} -le 65535 ]; then # ポート番号の範囲確認 11 | PORT=${1} # ポート番号を設定 12 | fi # ifの終了 13 | fi # ifの終了 14 | echo "Listening UDP port "${PORT}"..." # ポート番号表示 15 | mkdir sound >& /dev/null # 音声保存用フォルダ作成 16 | while true # 永遠に 17 | do # 繰り返し 18 | UDP=`sudo netcat -luw0 ${PORT}|tr -d [:cntrl:]|\ 19 | tr -d "\!\"\$\%\&\'\(\)\*\+\-\;\<\=\>\?\[\\\]\^\{\|\}\~"` 20 | # UDPパケットを取得 21 | DATE=`date "+%Y/%m/%d %R"` # 日時を取得 22 | DEV=${UDP#,*} # デバイス名を取得(前方) 23 | DEV=${DEV%%,*} # デバイス名を取得(後方) 24 | echo -E $DATE, $UDP|tee -a log_${DEV}.csv # 取得日時とデータを保存 25 | if [ ${DEVICE} = ${DEV} ]; then # マイクからの配信画像時 26 | DATE=`date "+%Y%m%d-%H%M"` # 日時を取得 27 | URL=`echo -E $UDP|cut -d' ' -f2` # スペース区切りの2番目 28 | echo -n "Get "${URL} # 音声取得実行表示 29 | wget -qT10 ${URL} -Osound/${DEVICE}"_"${DATE}.wav # wget実行 30 | echo " Done" # 終了表示 31 | fi 32 | done # 繰り返し範囲:ここまで 33 | -------------------------------------------------------------------------------- /1_practice/practice37_calc/practice37_calc.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Practice 5: 良く使う演算子 3 | 4 | シリアルモニタのビット・レート設定を115200 bpsに設定してください。 5 | Copyright (c) 2015-2019 Wataru KUNINO 6 | *******************************************************************************/ 7 | 8 | void setup() { // 起動時に一度だけ実行される関数 9 | Serial.begin(115200); // シリアル通信速度を115200bpsに設定する 10 | } 11 | 12 | void loop() { // setup実行後に繰り返し実行される関数 13 | int a = 12345; // 整数型の変数aを定義 14 | float v; // 浮動小数点数型変数v 15 | 16 | Serial.println("Practice 04"); // 「Practice 04」を表示 17 | 18 | Serial.print(a,DEC); // 整数値変数aの値を表示 19 | a = a - 345; // a-345を計算してaに代入 20 | Serial.print(" - 345 = "); 21 | Serial.println(a,DEC); // 整数値変数aの値を表示 22 | 23 | Serial.print(a,DEC); // 整数値変数aの値を表示 24 | a = a / 1000; // a÷1000をaに代入 25 | Serial.print(" / 1000 = "); 26 | Serial.println(a,DEC); // 整数値変数aの値を表示 27 | 28 | v = (float) a; // 浮動小数変数vにaを代入 29 | Serial.print("(int) "); 30 | Serial.print(a,DEC); // 整数値変数aの値を表示 31 | a = a / 10; // a÷10をaに代入 32 | Serial.print(" / 10 = "); 33 | Serial.println(a,DEC); // 整数値変数aの値を表示 34 | 35 | Serial.print("(float) "); 36 | Serial.print(v,3); // 浮動小数点数型変数vの値を表示 37 | v = v / 10; // v÷10をvに代入 38 | Serial.print(" / 10 = "); 39 | Serial.println(v,3); // 浮動小数点数型変数vの値を表示 40 | 41 | for(a=0;a<10;a++) delay(100); // 1秒の待ち時間処理 42 | Serial.println(); 43 | } 44 | -------------------------------------------------------------------------------- /5_learn32/esp32_02_led2t/esp32_02_led2t.ino: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | Practice 2: 磁界や温度に応じて2個のLEDを点滅させる 3 | 4 | ・温度が上昇するとLED1が点灯し、下降すると消灯する 5 | ・N極の磁石を近づけると点灯し、S極だと点滅する 6 | 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | ***********************************************************************/ 9 | 10 | #define PIN_LED1 2 // IO 2にLED1を接続 11 | #define PIN_LED2 23 // IO 23にLED2を接続 12 | 13 | float temp=99.9; // 温度を保持するための変数定義 14 | 15 | void setup() { // 起動時に一度だけ実行される関数 16 | pinMode(PIN_LED1,OUTPUT); // LEDを接続したポートを出力に設定 17 | pinMode(PIN_LED2,OUTPUT); // LEDを接続したポートを出力に設定 18 | } 19 | 20 | void loop() { // 繰り返し実行される関数 21 | float tp=temperatureRead(); // 内蔵の温度センサから値を取得 22 | int hall=hallRead(); // 内蔵のホールセンサから値を取得 23 | if( tp - temp > 1.0 ){ // 1℃を超える温度上昇があったとき 24 | digitalWrite(PIN_LED1,HIGH);// LED1をHレベル(3.3V)に設定(点灯) 25 | temp=tp; // 今回の測定温度を保存 26 | } 27 | if( temp - tp > 1.0 ){ // 1℃を超える温度下降があったとき 28 | digitalWrite(PIN_LED1,LOW); // LED1をLレベル(0V)に設定(消灯) 29 | temp=tp; // 今回の測定温度を保存 30 | } 31 | if( hall < 30 ){ // 磁石のN極を近づけたとき(磁界-) 32 | digitalWrite(PIN_LED2,HIGH);// LED2をHレベル(3.3V)に設定(点灯) 33 | }else if( hall > 60 ){ // 磁石のS極を近づけたとき(磁界+) 34 | digitalWrite(PIN_LED2,HIGH);// LED2をHレベル(3.3V)に設定(点灯) 35 | delay(100); // 時間待ち(100ms) 36 | digitalWrite(PIN_LED2,LOW); // LED2をLレベル(0V)に設定(消灯) 37 | }else{ // 磁石が近くに無いとき 38 | digitalWrite(PIN_LED2,LOW); // LED2をLレベル(0V)に設定(消灯) 39 | } 40 | delay(100); // 時間待ち(100ms) 41 | } 42 | -------------------------------------------------------------------------------- /2_example/example27_env/README.md: -------------------------------------------------------------------------------- 1 | Example 27: 2 | # 乾電池駆動可能なCO2センサ AMS CCS811+温度・湿度・気圧センサ Bosch BME280 3 | 4 | 二酸化炭素や有機ガスなどによる室内の空気環境状態を測定するガスセンサ ams製 CCS811と、温度・湿度・気圧を測定する環境センサ Bosch製 BME280を使った、乾電池駆動が可能なワイヤレスCO2センサです。 5 | 6 | ## 解決した課題 7 | 8 | ガスセンサの課題は、消費電力が大きいことです。 9 | 一例として、一般的なガスセンサにはヒーターが内蔵されており、ヒーターの過熱のために 500mW くらいの電力を消費します。また、適正値が得られるまでの加熱時間も必要です。 10 | 一方、単4電池3本で3か月間の動作をさせようとすると、ガスセンサの消費電力を約 0.3mW 以下にする必要があります。 11 | 12 | ## 間欠駆動 13 | 14 | 本例では、超小型で超低消費電力なガスセンサams製のCCS811を使用します。 15 | しかし、それでも 20mW~60mW 程度の電力を消費します。また、適正値が得られるまで電源を入れっぱなしにしておく必要があり、0.3mW以下にすることは困難です。 16 | そこで、本サンプルでは、センサをONしてから測定を開始し、測定値の変化が5%以内となったときの値を測定結果とする方法を用いました。多くの場合、10秒以内に測定を完了し、次の測定まで電源を切った状態にすることが出来ます。 17 | また、Wi-Fi接続を開始する前に、センサの初期化を開始し、Wi-Fi接続処理中にもセンサを加熱するようにして、駆動時間が短くなるように配慮しました。 18 | 環境センサBME280についても、ドライバbme280.ino内のbme280_stop関数により省エネ待機させました。 19 | 20 | ## 制約事項 21 | 22 | 測定精度と起動後の測定継続時間は、トレードオフの関係になります。本来のセンサの測定精度を得ることは出来ません。 23 | 24 | ## 製作に必要なデバイス 25 | 26 | * Wi-Fiモジュール ESP-WROOM-02 27 | * CO2センサ AMS CCS811 28 | * 温湿度・気圧センサ BME280 29 | * その他、周辺部品など 30 | 31 | ## 回路の製作方法 32 | 33 | ESP-WROOM-02のIO4(10番ピン)を各センサのI2CのSDAへ、IO5(14番ピン)をI2CのSCLへ接続してください。また、省電力駆動のために使用するCCS811のWAK信号をESP-WROOM-02のIO2(7番ピン)へ、ハードウェアエラー時の復帰用のRST信号をIO0(8番ピン)へ接続します。本CCS811センサを間欠駆動したときに、エラーが発生する場合があったので、自動でリセットするようにしました。 34 | 35 | ## 動作方法 36 | 37 | ソースリスト中の#define部へ無線LANアクセスポイントのSSIDとパスワード(PASS)を設定して下さい。 38 | また、SLEEP_Pに測定間隔を約10分から60分の範囲内で設定します。初期値 59*60*1000000 は59分です。 39 | 40 | ## 製作例 41 | 42 | 43 | 44 | ## むすび 45 | 46 | CCS811の消費電流が4000μAほどありましたが、ディープスリープ時にCCS811をOFFすることで、平均の消費電流70μA程度(BME280、ESPモジュール、レギュレータ込・実測値)まで下げることが出来、乾電池による長時間の駆動が可能になりました。 47 | 起動後、データが得られるまでに要する時間を考慮すると、ディープスリープの間隔が約3.7分以上のときに省エネ効果があります。約4分以下の間隔で測定したい場合は、CCS811の電源を入れっぱなしにした方が良いでしょう。 48 | 49 | Copyright (c) 2017-2019 Wataru KUNINO 50 | 51 | -------------------------------------------------------------------------------- /2_example/example58_tftp/README.md: -------------------------------------------------------------------------------- 1 | Example 58(=32+26): 2 | # センサデバイス用 TFTPクライアント 設定 3 | 4 | TFTPサーバ上から設定ファイルをダウンロードし、モジュール内の設定を変更します。 5 | 本サンプルではESP32-WROOM-32のADCの入力ピンとディープスリープ時間を設定することが出来ます。 6 | 7 | ## TFTPとは 8 | 9 | TFTPはネットワーク機器などの設定ファイルやファームウェアを転送するときなどに使用されているデータ転送プロトコルです。 10 | 使い勝手が簡単で、プロトコルも簡単なので、機器のメンテナンスに向いています。 11 | 認証や暗号化は行わないので、転送時のみ有効にする、もしくは侵入・ファイル転送されても問題の無い用途で利用します。 12 | 13 | TFTPについて、より詳しいサンプルも公開しました(2021/01/16) 14 | 複数ブロック受信,SDカードへの保存に対応: 15 | https://github.com/bokunimowakaru/tftp 16 | 17 | ## 本サンプルの仕様 18 | 19 | 「ADC_PIN=ピン番号」をTFTPで受信すると、ESPモジュールのADC入力ピンを変更することが出来ます。また、「SLEEP_SEC=時間(秒)」を受信すると、ESPモジュールのスリープ間隔を変更することも出来ます。 20 | 21 | ## Raspberry PiへのTFTPサーバのインストール方法 22 | 23 | $ sudo apt-get install tftpd-hpa 24 | 25 | ## 設定ファイル(/etc/default/tftpd-hpa) の例 26 | 27 | # /etc/default/tftpd-hpa 28 | TFTP_USERNAME="tftp" 29 | TFTP_DIRECTORY="/srv/tftp" 30 | TFTP_ADDRESS="0.0.0.0:69" 31 | 32 | ## TFTPサーバの起動と停止 33 | 34 | $ chmod 755 /srv/tftp 35 | $ sudo /etc/init.d/tftpd-hpa start 36 | $ sudo /etc/init.d/tftpd-hpa stop 37 | 38 | ## 転送用のファイルを保存 39 | 40 | $ sudo echo "; Hello! This is from RasPi" | sudo tee /srv/tftp/tftpc_1.ini 41 | $ sudo echo "ADC_PIN=32" | sudo tee -a /srv/tftp/tftpc_1.ini 42 | $ sudo echo "SLEEP_SEC=50" | sudo tee -a /srv/tftp/tftpc_1.ini 43 | $ sudo chmod 644 /srv/tftp/tftpc_1.ini 44 | $ cat /srv/tftp/tftpc_1.ini 45 | ; Hello! This is from RasPi 46 | ADC_PIN=32 47 | SLEEP_SEC=50 48 | 49 | ## 注意事項 50 | 51 | * TFTPクライアント(ESP側)やTFTPサーバ(PCやRaspberry Pi側)起動すると、各機器がセキュリティの脅威にさらされた状態となります。 52 | * また、ウィルスやワームが侵入すると、同じネットワーク上の全ての機器へ感染する恐れが高まります。 53 | * インターネットに接続すると外部からの侵入される場合があります。 54 | * TFTPクライアントは少なくともローカルネット内のみで動作させるようにして下さい。 55 | * TFTPが不必要なときは、停止させてください。 56 | 57 | Copyright (c) 2016-2021 Wataru KUNINO 58 | 59 | -------------------------------------------------------------------------------- /5_learn32/esp32_18_voice/uspeech_README.md: -------------------------------------------------------------------------------- 1 | # uSpeech library # 2 | The uSpeech library provides an interface for voice recognition using the Arduino. It currently produces phonemes, often the library will produce junk phonemes. Please bare with it for the time being. A noise removal function is underway. 3 | ## Minimum Requirements ## 4 | The library is quite intensive on the processor. Each sample collection takes about 3.2 milliseconds so pay close attention to the time. The library has been tested on the Arduino Uno (ATMega32). Each signal object uses up 160bytes. No real time scheduler should be used with this. 5 | 6 | ## Features ## 7 | - Letter based recognition 8 | - Small memory footprint 9 | - Arduino Compatible 10 | - Up to 80% accuracy with words 11 | - Novel algorithm based on simple calculus 12 | - Plugs directly into an ``analogRead()`` port 13 | 14 | ## Documentation ## 15 | 16 | Head over to the [wiki](https://github.com/arjo129/uSpeech/wiki) and you will find most of the documentation required. 17 | 18 | ## Algorithm ## 19 | The library utilizes a special algorithm to enable speech detection. First the complexity of the signal is determined by taking 20 | the absolute derivative of the signal multiplying it by a fixed point saclar and then dividing it by the absolute integral of the signal. 21 | Consonants (other than R,L,N and M) have a value above 40 and vowels have a value below 40. Consonants, they can be divided into frictaves and plosives. Plosives are like p or b whereas frictaves are like 22 | s or z. Generally each band of the complexity coeficient (abs derivative over abs integral) can be matched to a small set of frictaves 23 | and plosives. The signal determines if it is a plosive or a frictave by watching the length of the utterance (plosives occur over short periods while frictaves over long). 24 | Finally the most appropriate character is chosen. 25 | 26 | - [Return to main page](http://arjo129.github.com) 27 | -------------------------------------------------------------------------------- /5_learn32/esp32_18_voice_ok/uspeech_README.md: -------------------------------------------------------------------------------- 1 | # uSpeech library # 2 | The uSpeech library provides an interface for voice recognition using the Arduino. It currently produces phonemes, often the library will produce junk phonemes. Please bare with it for the time being. A noise removal function is underway. 3 | ## Minimum Requirements ## 4 | The library is quite intensive on the processor. Each sample collection takes about 3.2 milliseconds so pay close attention to the time. The library has been tested on the Arduino Uno (ATMega32). Each signal object uses up 160bytes. No real time scheduler should be used with this. 5 | 6 | ## Features ## 7 | - Letter based recognition 8 | - Small memory footprint 9 | - Arduino Compatible 10 | - Up to 80% accuracy with words 11 | - Novel algorithm based on simple calculus 12 | - Plugs directly into an ``analogRead()`` port 13 | 14 | ## Documentation ## 15 | 16 | Head over to the [wiki](https://github.com/arjo129/uSpeech/wiki) and you will find most of the documentation required. 17 | 18 | ## Algorithm ## 19 | The library utilizes a special algorithm to enable speech detection. First the complexity of the signal is determined by taking 20 | the absolute derivative of the signal multiplying it by a fixed point saclar and then dividing it by the absolute integral of the signal. 21 | Consonants (other than R,L,N and M) have a value above 40 and vowels have a value below 40. Consonants, they can be divided into frictaves and plosives. Plosives are like p or b whereas frictaves are like 22 | s or z. Generally each band of the complexity coeficient (abs derivative over abs integral) can be matched to a small set of frictaves 23 | and plosives. The signal determines if it is a plosive or a frictave by watching the length of the utterance (plosives occur over short periods while frictaves over long). 24 | Finally the most appropriate character is chosen. 25 | 26 | - [Return to main page](http://arjo129.github.com) 27 | -------------------------------------------------------------------------------- /2_example/example09_hum_si7021/i2c_si7021.ino: -------------------------------------------------------------------------------- 1 | /********************************************************************* 2 | 本ソースリストおよびソフトウェアは、ライセンスフリーです。(詳細は別記) 3 | 利用、編集、再配布等が自由に行えますが、著作権表示の改変は禁止します。 4 | 5 | I2C接続の温湿度センサの値を読み取る 6 | SILICON LABS社 Si7021 7 | Copyright (c) 2017-2019 Wataru KUNINO 8 | https://bokunimo.net/bokunimowakaru/ 9 | *********************************************************************/ 10 | 11 | #include 12 | #define I2C_si7021 0x40 // Si7021 の I2C アドレス 13 | 14 | float _i2c_si7021_hum; 15 | 16 | float getTemp(){ 17 | int temp,hum; 18 | _i2c_si7021_hum=-999.; 19 | Wire.beginTransmission(I2C_si7021); 20 | Wire.write(0xF5); 21 | if(Wire.endTransmission()) return -999.; 22 | 23 | delay(30); // 15ms以上 24 | Wire.requestFrom(I2C_si7021,2); 25 | if(Wire.available()!=2) return -999.; 26 | hum = Wire.read(); 27 | hum <<= 8; 28 | hum += Wire.read(); 29 | 30 | delay(18); // 15ms以上 31 | Wire.beginTransmission(I2C_si7021); 32 | Wire.write(0xE0); 33 | if(Wire.endTransmission()) return -989.; 34 | 35 | delay(30); // 15ms以上 36 | Wire.requestFrom(I2C_si7021,2); 37 | if(Wire.available()!=2) return -999.; 38 | temp = Wire.read(); 39 | temp <<= 8; 40 | temp += Wire.read(); 41 | 42 | _i2c_si7021_hum = (float)hum / 65536. * 125. - 6.; 43 | return (float)temp / 65535. * 175.72 - 46.85; 44 | } 45 | 46 | float getHum(){ 47 | return _i2c_si7021_hum; 48 | } 49 | 50 | void si7021Setup(){ 51 | delay(2); // 1ms以上 52 | Wire.begin(); // I2Cインタフェースの使用を開始 53 | delay(18); // 15ms以上 54 | Wire.beginTransmission(I2C_si7021); 55 | Wire.write(0xE6); 56 | Wire.write(0x3A); 57 | Wire.endTransmission(); 58 | delay(18); // 15ms以上 59 | } 60 | --------------------------------------------------------------------------------