2019年12月21日土曜日

ソースコードの挿入実験

どうやったら良いのか分からなかったのでググったらQiitaにGoogle-code-prettifyというのがあったので、早速実験!
無事実行成功! ただ、これだけでは足りなかったので、以下のCSS(元のページ)を追加して、max-heightを加えて縦横スクロールを追加。
これでやっとやりたいことが出来るようになった、、、。
  1. /*
  2. Google code-prettify
  3. */
  4. pre.prettyprint
  5. {
  6. border: 1px solid #cccccc !important;
  7. line-height: 1.5em;
  8. overflow: auto;
  9. width: auto;
  10. max-height: 600px;
  11. padding: 2em !important;
  12. }
  13. pre.prettyprint > ol.linenums
  14. {
  15. padding-left: 2em;
  16. }
  17. pre.prettyprint > ol.linenums > li
  18. {
  19. border-left: 1px solid #cccccc;
  20. margin-bottom: 0;
  21. }
  22. pre.prettyprint > ol.linenums > li.L0,
  23. pre.prettyprint > ol.linenums > li.L1,
  24. pre.prettyprint > ol.linenums > li.L2,
  25. pre.prettyprint > ol.linenums > li.L3,
  26. pre.prettyprint > ol.linenums > li.L4,
  27. pre.prettyprint > ol.linenums > li.L5,
  28. pre.prettyprint > ol.linenums > li.L6,
  29. pre.prettyprint > ol.linenums > li.L7,
  30. pre.prettyprint > ol.linenums > li.L8,
  31. pre.prettyprint > ol.linenums > li.L9
  32. {
  33. list-style-type: decimal;
  34. }
  35. pre.prettyprint > ol.linenums > li.L1,
  36. pre.prettyprint > ol.linenums > li.L3,
  37. pre.prettyprint > ol.linenums > li.L5,
  38. pre.prettyprint > ol.linenums > li.L7,
  39. pre.prettyprint > ol.linenums > li.L9
  40. {
  41. background-color: transparent;
  42. }
  43. pre.prettyprint > ol.linenums > li span:first-child
  44. {
  45. padding-left: 1em;
  46. }
  47. pre.prettyprint > ol.linenums > li span:last-child
  48. {
  49. padding-right: 1em;
  50. }
  51. /* plain text */
  52. pre.prettyprint .pln { color: #cccccc; }
  53. /* string content */
  54. pre.prettyprint .str { color: #cccc33; }
  55. /* a keyword */
  56. pre.prettyprint .kwd { color: #00cc00; }
  57. /* a comment */
  58. pre.prettyprint .com { color: #cc3366; }
  59. /* a type name */
  60. pre.prettyprint .typ { color: #00cc00; }
  61. /* a literal value */
  62. pre.prettyprint .lit { color: #3399cc; }
  63. /* punctuation, lisp open bracket, lisp close bracket */
  64. pre.prettyprint .pun,
  65. pre.prettyprint .opn,
  66. pre.prettyprint .clo
  67. { color: #cccccc; }
  68. /* a markup tag name */
  69. pre.prettyprint .tag { color: #3399cc; }
  70. /* a markup attribute name */
  71. pre.prettyprint .atn { color: #00cc00; }
  72. /* a markup attribute value */
  73. pre.prettyprint .atv { color: #cccc33; }
  74. /* a declaration; a variable name */
  75. pre.prettyprint .dec,
  76. pre.prettyprint .var
  77. { color: #00cc00; }
  78. /* a function name */
  79. pre.prettyprint .fun { color: #cc66cc; }
  80.  
  1. /*
  2. Deep Sleep with External Wake Up
  3. =====================================
  4. This code displays how to use deep sleep with
  5. an external trigger as a wake up source and how
  6. to store data in RTC memory to use it over reboots
  7. This code is under Public Domain License.
  8. Hardware Connections
  9. ======================
  10. Push Button to GPIO 33 pulled down with a 10K Ohm
  11. resistor
  12. NOTE:
  13. ======
  14. Only RTC IO can be used as a source for external wake
  15. source. They are pins: 0,2,4,12-15,25-27,32-39.
  16. Author:
  17. Pranav Cherukupalli
  18. */
  19. #include "esp_deep_sleep.h"
  20. #define BUTTON_PIN_BITMASK 0x8004 // GPIOs 2 and 15
  21. //#define BUTTON_PIN_BITMASK BIT64(GPIO_NUM_34)|BIT64(GPIO_NUM_36)// GPIOs 34 and 36
  22. unsigned long time0;
  23. unsigned long time1;
  24. RTC_DATA_ATTR int bootCount = 0;
  25. /*
  26. Method to print the reason by which ESP32
  27. has been awaken from sleep
  28. */
  29. void print_wakeup_reason(){
  30. time0 = micros();
  31. esp_sleep_wakeup_cause_t wakeup_reason;
  32. wakeup_reason = esp_sleep_get_wakeup_cause();
  33. switch(wakeup_reason)
  34. {
  35. case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
  36. case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
  37. case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
  38. case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
  39. case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
  40. default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
  41. }
  42. time1 = micros();
  43. Serial.print("==>print_wakeup_reason() : ");
  44. Serial.println( time1 -time0 );
  45. }
  46. /*
  47. Method to print the GPIO that triggered the wakeup
  48. */
  49. void print_GPIO_wake_up(){
  50. time0 = micros();
  51. int GPIO_reason = esp_sleep_get_ext1_wakeup_status();
  52. time1 = micros();
  53. Serial.print("GPIO that triggered the wake up: GPIO ");
  54. Serial.print( GPIO_reason );
  55. Serial.print( " : " );
  56. Serial.println((log(GPIO_reason))/log(2), 0);
  57. Serial.print("==> print_GPIO_wake_up() : ");
  58. Serial.println( time1 - time0 );
  59. }
  60. void setup(){
  61. Serial.begin(115200);
  62. delay(1000); //Take some time to open up the Serial Monitor
  63. //Increment boot number and print it every reboot
  64. ++bootCount;
  65. Serial.println("Boot number: " + String(bootCount));
  66. // Following 4 lines from http://wakwak-koba.hatenadiary.jp/entry/20170219/p1
  67. // to make deep sleep to 4 micro amp consumption, otherwise 27 micro amp?
  68. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  69. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  70. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  71. esp_deep_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  72. //Print the wakeup reason for ESP32
  73. print_wakeup_reason();
  74. //Print the GPIO used to wake up
  75. print_GPIO_wake_up();
  76. /*
  77. First we configure the wake up source
  78. We set our ESP32 to wake up for an external trigger.
  79. There are two types for ESP32, ext0 and ext1 .
  80. ext0 uses RTC_IO to wakeup thus requires RTC peripherals
  81. to be on while ext1 uses RTC Controller so doesnt need
  82. peripherals to be powered on.
  83. Note that using internal pullups/pulldowns also requires
  84. RTC peripherals to be turned on.
  85. */
  86. //esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_15,1); //1 = High, 0 = Low
  87. //If you were to use ext1, you would use it like
  88. esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);
  89. //Go to sleep now
  90. Serial.println("Going to sleep now");
  91. delay(1000);
  92. esp_deep_sleep_start();
  93. Serial.println("This will never be printed");
  94. }
  95. void loop(){
  96. //This is not going to be called
  97. }

温湿度モニターデータ検証

取り敢えず何日か走ったので、データをグラフ化して筐体や周辺環境の影響を考えてみました。
 ブルーは参照に室内の温度のデータで、東向きなので太陽光が入ると温度が上昇します。
 日当たりの良い、東側の道路に面したところ(オレンジのグラフ)では、やはり温度が20度を超えるようなところまで上昇し、これが筐体の温度上昇によるのか、周辺の反射熱も測りこんでいるのかは定かでありません。 一番下のグラフは庭の中央部で、日当たりは余り良くありませんので、太陽光が太陽電池に当たるよう少し高いところに置いていますが、此方は適切な範囲を推移しているように思われます。
高い精度を要求しているわけでもないので、当面はこのままにして、「さー、このデータを何に使うのか?」 
ま、朝起きた時に「今日は寒いのかな?」って外気温の参考にはなりますが、、、。

庭の草花の開花時期と積算温度の関係とか? でも、何時からの積算温度? と、結構利用価値が無いのかも、、、。

2019年12月14日土曜日

室外温湿度モニター筐体実験

太陽電池とLiPoで動いているので、太陽電池面には太陽が当たって欲しいのですが、暖められた筐体の温度を測っても意味が無いので、結局は筐体に工夫が必要で、これが結構難題。 
取り敢えず、100均で買ってきたPPの籠の底に断熱テープを張り付けて、屋外で1週間ほど測定してみましたが、結果は右の様に、太陽が出ると急激に温度が上がってしまっています。
 筐体の表面温度はもっと高いので、多分雰囲気温度には近いのでしょうが、ちょっと気がかりなので、筐体内側にゴミ箱にあった1cm厚程の防音用のガラスウールのシートを敷き、その上にアルミ板を固定して、その上に温湿度センサーを乗っけて、設置してみました。 これで、また1週間ほど調べてみるつもりですが、これでも温度が上がり過ぎることになると、手詰まりです。 


自動車に室外温度が表示される機能がついている物がありますが、これってどこで温度測定しているのですかね? エンジンルームや、路面の近く、トランクルームというのはうまくないと思うのですけど、、、。

簡単なようで、結構難しいですねー。 子供の頃から毎日観察して記録をつけるのが苦手(嫌い?)だったので、「それって何とか電子技術に押し付けて、結果だけを後でゆっくり見れたらナ~」 という、昔からのトラウマの解決実験なのですが、何ともうまくゆかない!

筐体がPPなので何年かするとボロボロになるでしょうから、その対策も考えておかないと、、、。紫外線吸収剤入り塗料(PPにくっ付く)!なんてあるのかな?









2019年12月10日火曜日

nanoVNA-Fが到着

シンガポールのデポを26日に出て、成田には翌日について、一週間ほど川崎の税関の軒先で待たされて、昨日ようやく手元に到着。 全体が大きく重たくがっちりしていますが、特に使い勝手は変わらない。 TFTが大きくなったので、画面上での操作が苦労なく出来るのはありがたいですが、全体の作りとしてnanoVNAの方が小型軽量で、個人的にはカッコ良いと思っています。 故障しなければ最高。
で、nanoVNA-FはBH5HNUがTTRFTECHのNanoVNAをFreeRTOS versionに書き換えた物で、firmwareの書き換えなどの方法が違っていて、選択スイッチを押し込みながら電源スイッチをオンすると、USB接続されたPC上に、USBディスクとして認識されているので、そこにダウンロードしたfirmware.binをコピーする、という事の様です。
BH5HNUはアクティブでgitHubでメンテされており、mailing listもアクティブで本人も良く書き込みをしているので、結構安心感がありますが、firmwareのupdate情報とbinaryの在処がまだ見つかりません。
最新のnanoVNAに有ったconfigのメニューが無いのですが、バッテリの電圧表示はありますので、本家にはかなりの所で追いついてはいるのでしょうが、、、。
今回は簡単には壊れないことを期待しています。

> MLで「S21のキャリブレーションが酷いよ!」って書き込みがあったので、実際にキャリブレーションした後にS11とS21をキャリブレーション用の20cm程のケーブルで直結してみたら+6.?dBと表示されていました。 うーん、ちょっと酷いね! 
BH5HNUが次のバージョンアップで修正する、と言っていますが、ソフト開発者の層の厚さからは通常のnanoVNAの方が信頼できるかも、、、。



RM Noise

最近Galaxyの携帯のCMで風のノイズ除去をしているシーンが気になっていて、「AIで処理すれば、ノイズ除去性能は上がるのでは?」なんて思いながら、 AIのopen source?の Hagging face をブラブラしていましたら、何故かFacebookで RM noize ...