D0 GPIO16 T1 純水TDS (外波形3P黑)-(下公XH2.54 白) D1 GPIO5 , SCL M1 熱水流量計(公SM-4P 藍)-(母SM-4P 藍)-(上公XH2.54 白) D2 GPIO4 , SDA M2 冰水流量計(公SM-4P 黑)-(母SM-4P 黑)-(上公XH2.54 黃) D3 GPIO0 , 10k Pull-up S1 熱水開關 (公SM-4P 紅)-(母SM-4P 紅)-(上公XH2.54 橙) (因為用3.3V-GPIO電位不穩,必須用 pin0 GPIO(high)-ground) D4 GPIO2 , 10k Pull-up, BUILTIN_LED S2 冰水開關 (公SM-4P 綠)-(母SM-4P 綠)-(上公XH2.54 綠) (因為用3.3V-GPIO電位不穩,必須用 pin2 GPIO(high)-ground) D5 GPIO14, SCK T2 進水TDS (內波形3P黑)-(下公XH2.54 藍)-(下公XH2.54 黃) D6 GPIO12, MISO V1 進水電磁閥(內繼電3P紅)-(下公XH2.54 橙) D7 GPIO13, MOSI V2 冰水電磁閥(外繼電3P紅)-(下公XH2.54 綠) D8 GPIO15, 10k Pull-down, SS H1 電熱繼電器(母SM-2P 紅)-(公SM-2P 紅)(因為pulldown,必須用大負載否則wemos開不了機) X X X 5V GN D4 D3 D2 D1 RX TX 紫 藍 綠 橙 黃 白 紅 黑 WEMOS 3V D8 D7 D6 D5 D0 A0 RS 紫 藍 綠 橙 黃 白 紅 黑 X X Wemos D1 mini D1 (上公XH2.54 白)-(母SM-4P 藍) D2 (上公XH2.54 黃)-(母SM-4P 黑) D3 (上公XH2.54 橙)-(母SM-4P 紅) D4 (上公XH2.54 綠)-(母SM-4P 綠) GN (上公XH2.54 藍)-(母SM-2P 黑) -(公SM-2P 黑) D0 (下公XH2.54 白)-(外波形3P黑) D5 (下公XH2.54 黃)-(內波形3P黑) D6 (下公XH2.54 橙)-(內繼電3P紅) D7 (下公XH2.54 綠)-(外繼電3P紅) D8 (下公XH2.54 藍)-(公SM-2P 紅) 3V (下公XH2.54 紫)-(母SM-2P 紅) 外波形模塊 GN (外波形3P黃)-(上公XH2.54 藍) D0 (外波形3P黑)-(下公XH2.54 白) 3V (外波形3P紅)-(下公XH2.54 紫) 內波形模塊 GN (內波形3P黃)-(上公XH2.54 藍) D5 (內波形3P黑)-(下公XH2.54 黃) 3V (內波形3P紅)-(下公XH2.54 紫) 內繼電模塊 GN (內繼電3P黃)-(上公XH2.54 藍) 3V (內繼電3P黑)-(下公XH2.54 紫) D6 (內繼電3P紅)-(下公XH2.54 橙) 外繼電模塊 GN (外繼電3P黃)-(上公XH2.54 藍) 3V (外繼電3P黑)-(下公XH2.54 紫) D7 (外繼電3P紅)-(下公XH2.54 綠) 61.220.188.84 -> 119.29.228.213 mosquitto -d (背景啟動 MQTT server ) subscriber -> mosquitto_sub -h 119.29.228.213 -t Ko001 publisher -> mosquitto_pub -h 119.29.228.213 -t Ko001 -m 12 ps aux|grep -i 'bish-bosh' (查出執行 kill -9 第二排的id數字) /www/web/default/bish-bosh/bish-bosh --verbose 2 -- /www/web/default/bish-bosh/q01 & (背景執行後按 enter q01中不可以有output echo否則ssh斷線就退出停止) Ko Command: Ko Pub -> Gate topic Ko001 1.) 8x limit counter to stop: "C" + gate id xxxxxxxx + counter 0~7 xxxxxxxx (8x8) mosquitto_pub -h 119.29.228.213 -t Ko001 -m CGate00010000000011111111222222223333333344444444555555556666666677777777 2.) 8x limit minisec to stop: "T" + gate id xxxxxxxx + timer 0~7 xxxxxxxxxxxx (12x8) mosquitto_pub -h 119.29.228.213 -t Ko001 -m TGate0001000000000000111111111111222222222222333333333333444444444444555555555555666666666666777777777777 3.) pipe N limit counter to stop: "c" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx mosquitto_pub -h 119.29.228.213 -t Ko001 -m cGate0001712345678 4.) pipe N limit minisec to stop: "t" + gate id xxxxxxxx + pipe id x + timer xxxxxxxxxxxx mosquitto_pub -h 119.29.228.213 -t Ko001 -m tGate00017123456789012 Gate Report: Gate Pub -> Ko topic Dv001 2.) Gate Start Up: "i" + gate id xxxxxxxx + 9 digit 000000000 mosquitto_pub -h 119.29.228.213 -t Dv001 -m iGate0001000000000 2.) pipe N start flow counters: "b" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx mosquitto_pub -h 119.29.228.213 -t Dv001 -m bGate0001712345678 3.) pipe N stop flow counters: "e" + gate id begin + pipe id x + counter xxxxxxxx mosquitto_pub -h 119.29.228.213 -t Dv001 -m eGate0001712345678 4.) pipe N now flow counters: "c" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx mosquitto_pub -h 119.29.228.213 -t Dv001 -m cGate0001712345678 ======================= qq cloud MQTT ========================================= ps aux|grep -i 'bish-bosh' (查出執行 kill -9 第二排的id數字) /home/httpd/www/html/bish-bosh/bish-bosh --verbose 2 -- /home/httpd/www/html/bish-bosh/q01 & (背景執行後按 enter q01中不可以有output echo否則ssh斷線就退出停止) Ko Command: Ko Pub -> Gate topic Ko001 1.) 8x limit counter to stop: "C" + gate id xxxxxxxx + counter 0~7 xxxxxxxx (8x8) mosquitto_pub -h 61.220.188.84 -t Ko001 -m CGate00010000000011111111222222223333333344444444555555556666666677777777 2.) 8x limit minisec to stop: "T" + gate id xxxxxxxx + timer 0~7 xxxxxxxxxxxx (12x8) mosquitto_pub -h 61.220.188.84 -t Ko001 -m TGate0001000000000000111111111111222222222222333333333333444444444444555555555555666666666666777777777777 3.) pipe N limit counter to stop: "c" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx mosquitto_pub -h 61.220.188.84 -t Ko001 -m cGate0001712345678 4.) pipe N limit minisec to stop: "t" + gate id xxxxxxxx + pipe id x + timer xxxxxxxxxxxx mosquitto_pub -h 61.220.188.84 -t Ko001 -m tGate00017123456789012 5.) pipe N limit counter + minisec to stop: "p" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx + timer xxxxxxxxxxxx mosquitto_pub -h 61.220.188.84 -t Ko001 -m pGate0001712345678123456789012 Gate Report: Gate Pub -> Ko topic Dv001 2.) Gate Start Up: "i" + gate id xxxxxxxx + 9 digit 000000000 mosquitto_pub -h 61.220.188.84 -t Dv001 -m iGate0001000000000 2.) pipe N start flow counters: "b" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx mosquitto_pub -h 61.220.188.84 -t Dv001 -m bGate0001712345678 3.) pipe N stop flow counters: "e" + gate id begin + pipe id x + counter xxxxxxxx mosquitto_pub -h 61.220.188.84 -t Dv001 -m eGate0001712345678 4.) pipe N now flow counters: "c" + gate id xxxxxxxx + pipe id x + counter xxxxxxxx mosquitto_pub -h 61.220.188.84 -t Dv001 -m cGate0001712345678 振荡电路参考这个,其中R2就是探针之间的水电阻 1、求出探针之间的水电阻 2、根据探针的间距、横截面面积获得L/S 3、根据上面两个值获得探针之间的电导率 4、根据电导率获得TDS TDS= (0.55~0.7)电导率 两根针间距是5.2mm,针长度是5.5mm,针个直径是1mm /home/httpd/www/html/bish-bosh/bish-bosh --verbose 2 -- /home/httpd/www/html/bish-bosh/q01 & (背景執行 不可以有output echo否則ssh中斷就退出) ps aux|grep -i 'bish-bosh' (查出執行 kill -9 第二排的id數字) cd /home/httpd/www/html/bish-bosh ./bish-bosh --verbose 2 -- q01 mosquitto_pub -h 61.220.188.84 -t Dv001 -m Gate0001700000001 (gate id xxxxxxxx + pipe 0-7 + counter xxxxxxxx -> 00000001/begin 00000000/end else/counter) change valve publisher(84) -> mosquitto_pub -h 61.220.188.84 -t Ko001 -m Gate000100000010 (GateId + 8 valve on/off) 604,523,637 1,2,3 760 600,527,617 1,2,3 800 607,457,651 1,2,3 800,710,820 520,500,513 2,3,1 740 708,682,692 3,1,2 1050 1766 1544 1234 1,2,3 700 1514-870 1532-860 joe /usr/bin/dv01 chmod 777 /usr/bin/dv01 #!/bin/bash mxi=60*5 for (( i = 0; i < $mxi; i++ )); do dat=$(date "+%Y%m%d%H%M%S") echo $dat mosquitto_pub -h 61.220.188.84 -t Gate0001 -m $dat $(php '/home/httpd/www/html/mq.php') sleep 1 done exit 0 方 主板 rm /home/httpd/www/html/dv02 subscriber(84) -> mosquitto_sub -h 61.220.188.84 -t Gate0001 > /home/httpd/www/html/dv02 change valve publisher(84) -> mosquitto_pub -h 61.220.188.84 -t Master -m Gate00010000111 (GateId + 8 valve on/off) timer(84) -> /usr/bin/dv01 -> (mosquitto_pub -h 61.220.188.84 -t Gate0001 -m 20170720202311 + php '/home/httpd/www/html/mq.php') 電磁閥7 流量計7(電源旁) x-publisher(84) -> mosquitto_pub -h 61.220.188.84 -t Master -m 11118 (valve 3 ON 11117 OFF) systemctl restart mosquitto.service RSSI Wifi 訊號 0 - (-55)dbm 满格(4格)信号 (-55) - (-70)dbm 3格信号 (-70) - (-85)dbm 2格信号 (-85) - (-100)dbm 1格信号 =========== C language ===================== char *xxx = ""; -> 一定要先給值後才可以用array去改值 C++ string xxx.length() 字符串長度 char *xxx 沒有預留空間, char xxx[100] 才有 char[x+1] 至少要比字串多1,才不會影嚮下一個未串 ""->string ''->char ============================================ http://61.220.188.84/dv-m/mq-1.php -->從KO送DATA去wemos http://61.220.188.84/dv-m/mq-2.php -->查KO的SQL最後10筆 wemos傳給KO的DATA david@NB3 MINGW64 /f/WX-Water/Arduino/hardware $ cd esp8266com david@NB3 MINGW64 /f/WX-Water/Arduino/hardware/esp8266com $ git clone https://github.com/wemos/Arduino_D1.git esp8266 Cloning into 'esp8266'... remote: Counting objects: 13742, done. Receiving objects: 18% (2606/13742), 1.71 MiB | 8.00 KiB/s s david@NB3 MINGW64 /f/WX-Water/Arduino/hardware/esp8266com $ cd esp8266/tools david@NB3 MINGW64 /f/WX-Water/Arduino/hardware/esp8266com/esp8266/tools (master) $ python get.py Platform: i686-mingw32 Downloading esptool-0.4.9-win32.zip Done Extracting dist/esptool-0.4.9-win32.zip Renaming esptool-0.4.9-win32/ to esptool Downloading win32-xtensa-lx106-elf-gb404fb9-2.tar.gz Done Extracting dist/win32-xtensa-lx106-elf-gb404fb9-2.tar.gz Downloading mkspiffs-0.1.2-windows.zip Done Extracting dist/mkspiffs-0.1.2-windows.zip Renaming mkspiffs-0.1.2-windows/ to mkspiffs david@NB3 MINGW64 /f/WX-Water/Arduino/hardware/esp8266com/esp8266/tools (master) $ wemos MQTT broker(84) -> mosquitto -v subscriber(103-esp) -> 固定send outTopic + 收到callback inTopic publisher(84) -> mosquitto_pub -h 61.220.188.84 -t inTopic -m 111111111111 upload speed 115200 COM5 wemos D1 & mini AVRISP mkII D1接GND + RST接GND Wemos Installing Hardware package cd /f/WX-Water/Arduino/hardware/esp8266com git clone https://github.com/wemos/Arduino_D1.git esp8266 cd esp8266/tools python get.py MQTT broker(84) -> mosquitto -v subscriber(104-pi) -> mosquitto_sub -h 61.220.188.84 -t dv01 publisher(84) -> mosquitto_pub -h 61.220.188.84 -t dv01 -m 12 --------------------- raspberry pi ------------------------------------------- 控制gpio18亮燈 (104-pi) -> sudo python simple.py (84) -> mosquitto_pub -h 61.220.188.84 -t dv01 -m "{\"pin\":18,\"value\":1}" apache-php 加權限才可執行shell sudo visudo 加一行 www-data ALL=(ALL:ALL) NOPASSWD:ALL php 必須用 sudo 去執行shell bash 安裝 PHP + APACHE apt-get install apache2 php5 libapache2-mod-php5 安裝 vsftpd apt-get install vsftpd ftp 修改匿名設定才能上傳檔案 joe /etc/vsftpd.conf write_enable=YES anonymous_enable=YES anon_upload_enable=YES anon_mkdir_write_enable=YES ftp 修改上傳檔案欋限自動變為666 (777?) local_umask=000 讀取 TDS 模塊 minicom -H -S /usr/local/bin/dv02 -C /usr/local/bin/dv03 dv02----------------- #!/bin/sh print "\n" send \0374\0374\0374 dv03----------------- fd 5e 00 fd fd fe 24 01 fe fe raspberry pi 接 USB-串口 接 TDS 產生Hex的 FD FD FD 檔案 > dv01 echo -e "\0375\0375\0375" > dv01 進入minicom -H 顯示十六進位 ctrl-A -> S -> ascii -> /usr/local/bin/dv01 上傳檔案 dv01 當作發送 FD FD FD TDS 雙路 9600 8N1 停止位 1 TX-RX,RX-TX 交換接 TDS 二直突條正面4P孔向上,左->右,接wemos GRN-RX-TX-5V 发送FC FC FC 返回 FD TDSL1 TDSH1 FD FD FE TDSL2 TDSH2 FE FE IC盒探針線向上 右1左2 TDS 單路 9600 8N1 停止位 1 TX-TX,RX-RX 對接 發送 FD FD FD 返回 FD 低位 高位 FD FD ssh -NfR 8080:192.168.100.104:22 root@61.220.188.84 先 apt-get update 再 apt-get install minicom 工作文件區 /usr/local/bin/ ...... gpio18 設定方式 echo 18 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio18/direction echo 1 > /sys/class/gpio/gpio18/value 取消設定 echo 18 > /sys/class/gpio/unexport apt-get install joe apt-get remove xxx pi + raspberry (已改) -> frevres0907 -> su + frevres0907 ====================================== 20170531 New WX Water ===================================================== https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx7fe291f76cf93354&secret=d8fd277920bba0cfddc1fd8f5eacf937 {"access_token":"y-RkXsDVDdxRaMTBybYL8hj5YREkUJmG6hLkGM4E_JkcNmq1pClejE5gF9mTJrmI5qc4Jf2elQf2aD7OBmgx22sWoaZrtArDxAa3A6RWQa8","expires_in":7200} 微信公眾平台 lee@dacomputing.com aa2233zz AppID(应用ID) wx7fe291f76cf93354 AppSecret(应用密钥) d8fd277920bba0cfddc1fd8f5eacf937 weixin.qq.com 101.227.131.102, 101.226.76.175 BIOS 中的南橋USB->8 ports, USB2.0->disable 才不會常常抓不到USB0 BIOS設少8小時->如果linux多8小時 為了確定 wifi AP 是否存在用 ping wifi AP 192.168.188.253 開機增加/etc/sysconfig/network-scripts/ifcfg-eth0:4 --> 192.168.188.100 date -s 2015-01-15 date -s 09:41:30 hwclock -w 把date 寫入 BIOS 點煙器的黃線在中間藍靠主板咖啡靠面板 如果timer_3g卡死,flag-3g-busy將一直存在 ps -ef 列出defunct 僵屍 kill -9 xxxx 進程號 /usr/bin/autossh -M 5678 -NfR 8080:192.168.100.99:22 root@61.220.188.84 ipad-saferi