2019年12月21日土曜日

ソースコードの挿入実験

どうやったら良いのか分からなかったのでググったらQiitaにGoogle-code-prettifyというのがあったので、早速実験!
無事実行成功! ただ、これだけでは足りなかったので、以下のCSS(元のページ)を追加して、max-heightを加えて縦横スクロールを追加。
これでやっとやりたいことが出来るようになった、、、。

/*
Google code-prettify
*/
pre.prettyprint
{
    border: 1px solid #cccccc !important;
    line-height: 1.5em;
    overflow: auto;
    width: auto;
    max-height: 600px;
    padding: 2em !important;
}
pre.prettyprint > ol.linenums
{
    padding-left: 2em;
}
pre.prettyprint > ol.linenums > li
{
    border-left: 1px solid #cccccc;
    margin-bottom: 0;
}
pre.prettyprint > ol.linenums > li.L0,
pre.prettyprint > ol.linenums > li.L1,
pre.prettyprint > ol.linenums > li.L2,
pre.prettyprint > ol.linenums > li.L3,
pre.prettyprint > ol.linenums > li.L4,
pre.prettyprint > ol.linenums > li.L5,
pre.prettyprint > ol.linenums > li.L6,
pre.prettyprint > ol.linenums > li.L7,
pre.prettyprint > ol.linenums > li.L8,
pre.prettyprint > ol.linenums > li.L9 
{
    list-style-type: decimal;
}
pre.prettyprint > ol.linenums > li.L1,
pre.prettyprint > ol.linenums > li.L3,
pre.prettyprint > ol.linenums > li.L5,
pre.prettyprint > ol.linenums > li.L7,
pre.prettyprint > ol.linenums > li.L9 
{
    background-color: transparent;
}
pre.prettyprint > ol.linenums > li span:first-child
{
    padding-left: 1em;
}
pre.prettyprint > ol.linenums > li span:last-child
{
    padding-right: 1em;
}
/* plain text */
pre.prettyprint .pln { color: #cccccc; }
/* string content */
pre.prettyprint .str { color: #cccc33; }
/* a keyword */
pre.prettyprint .kwd { color: #00cc00; }
/* a comment */
pre.prettyprint .com { color: #cc3366; }
/* a type name */
pre.prettyprint .typ { color: #00cc00; }
/* a literal value */
pre.prettyprint .lit { color: #3399cc; }
/* punctuation, lisp open bracket, lisp close bracket */
pre.prettyprint .pun,
pre.prettyprint .opn,
pre.prettyprint .clo
{ color: #cccccc; }
/* a markup tag name */
pre.prettyprint .tag { color: #3399cc; }
/* a markup attribute name */
pre.prettyprint .atn { color: #00cc00; }
/* a markup attribute value */
pre.prettyprint .atv { color: #cccc33; }
/* a declaration; a variable name */
pre.prettyprint .dec,
pre.prettyprint .var
{ color: #00cc00; }
/* a function name */
pre.prettyprint .fun { color: #cc66cc; }

/*
Deep Sleep with External Wake Up
=====================================
This code displays how to use deep sleep with
an external trigger as a wake up source and how
to store data in RTC memory to use it over reboots

This code is under Public Domain License.

Hardware Connections
======================
Push Button to GPIO 33 pulled down with a 10K Ohm
resistor

NOTE:
======
Only RTC IO can be used as a source for external wake
source. They are pins: 0,2,4,12-15,25-27,32-39.

Author:
Pranav Cherukupalli 
*/
#include "esp_deep_sleep.h"

#define BUTTON_PIN_BITMASK 0x8004 // GPIOs 2 and 15
//#define BUTTON_PIN_BITMASK BIT64(GPIO_NUM_34)|BIT64(GPIO_NUM_36)// GPIOs 34 and 36
unsigned long time0;
unsigned long time1;

RTC_DATA_ATTR int bootCount = 0;

/*
Method to print the reason by which ESP32
has been awaken from sleep
*/
void print_wakeup_reason(){
  time0 = micros();
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();

  switch(wakeup_reason)
  {
    case ESP_SLEEP_WAKEUP_EXT0 : Serial.println("Wakeup caused by external signal using RTC_IO"); break;
    case ESP_SLEEP_WAKEUP_EXT1 : Serial.println("Wakeup caused by external signal using RTC_CNTL"); break;
    case ESP_SLEEP_WAKEUP_TIMER : Serial.println("Wakeup caused by timer"); break;
    case ESP_SLEEP_WAKEUP_TOUCHPAD : Serial.println("Wakeup caused by touchpad"); break;
    case ESP_SLEEP_WAKEUP_ULP : Serial.println("Wakeup caused by ULP program"); break;
    default : Serial.printf("Wakeup was not caused by deep sleep: %d\n",wakeup_reason); break;
  }
  time1 = micros();
  Serial.print("==>print_wakeup_reason() : ");
  Serial.println( time1 -time0 );
}

/*
Method to print the GPIO that triggered the wakeup
*/
void print_GPIO_wake_up(){
  time0 = micros();
  int GPIO_reason = esp_sleep_get_ext1_wakeup_status();
  time1 = micros();
  Serial.print("GPIO that triggered the wake up: GPIO ");
  Serial.print( GPIO_reason );
  Serial.print( " : " );
  Serial.println((log(GPIO_reason))/log(2), 0);
  Serial.print("==> print_GPIO_wake_up() : ");
  Serial.println( time1 - time0 );
}
  
void setup(){
  Serial.begin(115200);
  delay(1000); //Take some time to open up the Serial Monitor

  //Increment boot number and print it every reboot
  ++bootCount;
  Serial.println("Boot number: " + String(bootCount));
  // Following 4 lines from http://wakwak-koba.hatenadiary.jp/entry/20170219/p1
  // to make deep sleep to 4 micro amp consumption, otherwise 27 micro amp?
  esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF);
  esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_deep_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  esp_deep_sleep_pd_config(ESP_PD_DOMAIN_MAX, ESP_PD_OPTION_OFF);
  //Print the wakeup reason for ESP32
  print_wakeup_reason();

  //Print the GPIO used to wake up
  print_GPIO_wake_up();

  /*
  First we configure the wake up source
  We set our ESP32 to wake up for an external trigger.
  There are two types for ESP32, ext0 and ext1 .
  ext0 uses RTC_IO to wakeup thus requires RTC peripherals
  to be on while ext1 uses RTC Controller so doesnt need
  peripherals to be powered on.
  Note that using internal pullups/pulldowns also requires
  RTC peripherals to be turned on.
  */
  //esp_deep_sleep_enable_ext0_wakeup(GPIO_NUM_15,1); //1 = High, 0 = Low

  //If you were to use ext1, you would use it like
  esp_sleep_enable_ext1_wakeup(BUTTON_PIN_BITMASK,ESP_EXT1_WAKEUP_ANY_HIGH);

  //Go to sleep now
  Serial.println("Going to sleep now");
  delay(1000);
  esp_deep_sleep_start();
  Serial.println("This will never be printed");
}

void loop(){
  //This is not going to be called
}

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

取り敢えず何日か走ったので、データをグラフ化して筐体や周辺環境の影響を考えてみました。
 ブルーは参照に室内の温度のデータで、東向きなので太陽光が入ると温度が上昇します。
 日当たりの良い、東側の道路に面したところ(オレンジのグラフ)では、やはり温度が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の方が信頼できるかも、、、。



php のインストールの確認

phpって最初のfacebook書くときに使われたみたいで、それなりに歴史のある言語で、私も2006年位から使っていますが、CLIで使う事はあまり無いので、apacheとの連携のトラブル(mod_phpのバージョンの齟齬)などは気になりますが、拡張モジュールのインストールの問題に...