追蹤者

2019年3月9日 星期六

九十九元 NodeMcu Lua v2 好便宜

NodeMcu Lua v2  沒藍芽, 一個ADC。

ESP8266 九十九元好便宜拿來做基本實驗也好,
比ESP32窄, 放在麵包板上 拉線也方便!
NodeMcu Lua v2、WIFI 物聯網開發板 ESP8266






安裝
Nodemcu V2 芭蕉葉上聽雨聲 ---安裝 教導 下載 CP2102 驅動程式 使用 Arduino IDE  Lua 編輯器
...
「Boards Manager...」。
(出現「Boards Manager」對話窗)

Step6 捲動右側拉桿到下方,點擊「esp8266 by ESP8266 Community」那一欄,再點擊「Install」鈕。

...
Step2 點擊「工具」>「板子」,選擇「NodeMCU 1.0 (ESP-12E Module)」。

購買
露天99元 NodeMCU V2 CP2102 USB chip

實作
12. 待測 96x64 SPI color oled 
https://www.arduitronics.com/product/1403/rgb-oled-0-95-96x64-pixels-16-bit-color-oled-spi-interface
11. 待測 觸控螢幕.蓋格計 geiger-counter-esp8266-touchscreen/
10. 待測4 PINs touch-panel-module
9.待測 -wemos-tft-2.4"觸控螢幕
觸控螢幕TFT 8. ESP8266 + WIFI
https://github.com/AutoConnect/AutoConnect.ino  待測
https://github.com/esp8266/Arduino 到LIBRARY目錄看所需libraries


7.ESP8266 + BLUETOOTH
https://circuitdigest.com/microcontroller-projects/using-classic-bluetooth-in-esp32-and-toogle-an-led

csjhmaker bluetooth

https://blog.csdn.net/huibei_wuhan/article/details/83592075

6. IRreceiving   yehnan.blogspot.com/2013/05/IR

5. Wi-Fi smartconfig  with ROM
wyj-learning.blogspot.com/2018/03/nodemcu-15nodemcu-smartconfig

stonez56.blogspot/2019/01/voice-control-MQTT

4.
Dust sensor 

2019 /04/11 OK
實驗成功_laser_dust_sensor_SKU:SEN0177


/*接線 注意 PMS 7003 TX 接 esp8266 RX ,   PMS7003 RX(可不接) to esp8266 TX*/

//******************************
 //*Abstract: Read value of PM1,PM2.5 and PM10 of air quality
 //
 //*Version:V3.1
 //*Author:Zuyang @ HUST
 //*Modified by Cain for Arduino Hardware Serial port compatibility
 //*Date:March.25.2016
 //******************************
/*接線 注意 PMS 7003 TX 接 esp8266 RX ,   PMS7003 RX(可不接) to esp8266 TX*/
#include <Arduino.h>
#define LENG 31   //0x42 + 31 bytes equal to 32 bytes
unsigned char buf[LENG];

int PM01Value=0;          //define PM1.0 value of the air detector module
int PM2_5Value=0;         //define PM2.5 value of the air detector module
int PM10Value=0;         //define PM10 value of the air detector module


void setup()
{
  Serial.begin(9600);   //use serial0
  Serial.setTimeout(1500);    //set the Timeout to 1500ms, longer than the data transmission periodic time of the sensor

}

void loop()
{
  PM01Value=0;
  PM2_5Value=0;  
  PM10Value=0; 
  if(Serial.find(0x42)){    //start to read when detect 0x42
    Serial.readBytes(buf,LENG);

    if(buf[0] == 0x4d){
      if(checkValue(buf,LENG)){
        PM01Value=transmitPM01(buf); //count PM1.0 value of the air detector module
        PM2_5Value=transmitPM2_5(buf);//count PM2.5 value of the air detector module
        PM10Value=transmitPM10(buf); //count PM10 value of the air detector module 
      }           
    } 
  }

  static unsigned long OledTimer=millis();  
    if (millis() - OledTimer >=1000) 
    {
      OledTimer=millis(); 
      
      Serial.print("PM1.0: ");  
      Serial.print(PM01Value);
      Serial.println("  ug/m3");            
    
      Serial.print("PM2.5: ");  
      Serial.print(PM2_5Value);
      Serial.println("  ug/m3");     
      
      Serial.print("PM1 0: ");  
      Serial.print(PM10Value);
      Serial.println("  ug/m3");   
      Serial.println();
    }
  
}
char checkValue(unsigned char *thebuf, char leng)
{  
  char receiveflag=0;
  int receiveSum=0;

  for(int i=0; i<(leng-2); i++){
  receiveSum=receiveSum+thebuf[i];
  }
  receiveSum=receiveSum + 0x42;

  if(receiveSum == ((thebuf[leng-2]<<8)+thebuf[leng-1]))  //check the serial data 
  {
    receiveSum = 0;
    receiveflag = 1;
  }
  return receiveflag;
}

int transmitPM01(unsigned char *thebuf)
{
  int PM01Val;
  PM01Val=((thebuf[3]<<8) + thebuf[4]); //count PM1.0 value of the air detector module
  return PM01Val;
}

//transmit PM Value to PC
int transmitPM2_5(unsigned char *thebuf)
{
  int PM2_5Val;
  PM2_5Val=((thebuf[5]<<8) + thebuf[6]);//count PM2.5 value of the air detector module
  return PM2_5Val;
  }

//transmit PM Value to PC
int transmitPM10(unsigned char *thebuf)
{
  int PM10Val;
  PM10Val=((thebuf[7]<<8) + thebuf[8]); //count PM10 value of the air detector module  
  return PM10Val;

}


阿玉的網站---我用PMS700320190411實驗成功
/*  2019 04 12 PM2.5 dht22  讀取資料 OLED 顯示成功*/
以前 使用的PM2.5感應器GP2Y1014,不太精準 有時還抓到負值。
於是到eBay 買了兩個PMS7003。
實驗了兩組網路抓的PM2.5讀取程式。
其中一組昨天可讀取及顯示到Oled,但整合溫濕度計,就罷工。
今天早餐後, 使用另一網站的PM2.5讀取程式, 再整合溫濕度程式。
成功了。

下一步 , 還要加入 PM2.5過高時, 要能啟動風扇 過濾空氣的功能。





dust_wifi

esp8266 ---pmsx003
pms-3003--- lcd --- 程式碼
co2 dht pm2.5 -air-sensor-by-yourself/
esp32-pm2-5-pm10-with-honeywell-hpma115


3. output high, Motor runs


2 . 
esp866--dht22-但是使用 dht bege e Tokyo library 跟我用在ESP32一樣的library
esp8266--dht22-web-server-tutorial
128*64oled-display-with-dht22-/ESP8266

1.esp8266dht. web-server-with-arduino-ide/
DHT22  讀取資料為 nan 之處理

網頁控制nodemcu-led  --- 含安裝  但不須用 Lua編輯器
2019.3.10飯後,在另一台PC 
安裝 arduino 1.8 , 開發板使用node mcu 1.0 esp12e 。
並Copy這個網頁 的程式 測試 網頁控制LED 亮跟滅 成功 。

但是 原始程式要修改一下 就是 手機連上網頁後,按led Off時候 LED要輸出LOW電位, 反之,按 led on的時候要輸出 HIGH電位。

B I2C OLED 128x32 , SCL---GPIO5, SDA---GPIO4, 3.3V, GND
http://arduino-er.blogspot.com/2016/04/nodemcu-esp8266-to-display-on-128x64.html
1. modify file  C:\Users\user\Documents\Ardkuino\libraries\Adafruit_SSD1306\ Adafruit_SSD1306.h

#define _Adafruit_SSD1306_H_
// ONE of the following three lines must be #defined:
#define SSD1306_128_64 ///< DEPRECTAED: old way to specify 128x64 screen
//#define SSD1306_128_32   ///< DEPRECATED: old way to specify 128x32 screen
2. 程式內
#define OLED_RESET  LED_BUILTIN   // default 4  Reset pin # (or -1 if sharing Arduino reset pin)

3. 結果 以上兩步驟 OLED都沒顯示,
修改第一步 //#define SSD1306_128_32 為#define SSD1306_128_32
再次證明買家給我的是 128x32

C. I2C OLED 顯示中文
電子老兵

D. ESP8266 dht22
彼得潘的-開發教室/-arduino-uno-esp8266-dht-22


其他
程式下載
silabs Download for Windows 10 Universal (v10.1.4)
arduino IDE 1.8.8   直接下載IDE 1.8.8

參考網頁
https://www.instructables.com/id/ESP8266-WiFi-touch-screen-thermostat/
Daijoubu
2 years ago
Use the BME280 sensor instead, has humidity, temperature and pressure, all in one :)
Also, the RTC may not be necessery, someone tested the time keeping of the ESP8266 and it was only 1 sec off per day, so running NTP sync every day(s)/week would be sufficient, also, the DS1302 is not even that precise, if one wants a good one, get the DS3231
nodemcu V2 芭蕉葉上聽雨聲 NodeMCU DEVKIT V1
https://www.youtube.com/網友Th27a介紹

 產生 BIN檔案                                                                                                                                                         Arduino>檔案>偏好設定>顯示詳細輸出: 編譯 , 上傳 打勾      , Arduino>草稿碼>匯出以編譯的二進位檔  ------>   2/27/2020 OK.                                                                                                                           但 Arduino>上傳, 卻出現"error: espcomm_open failed". <<< 不外接設備 重新上傳成功,                 如此不用每次都編譯再加上傳, 速度快很多了!

2019年3月8日 星期五

ESP32 晶片及 燒錄器, 還有其他ESP32產品

243元 買ESP32F 晶片 送PCB, 不過還要買燒錄器。 254元

ESP32U 晶片沒有附PCB
ESP32 U

OTA 空中更新軟體
https://makerpro.cc/2021/10/esp32-basic-over-the-air-programming/

youtube.com/ESP32燒錄教學

ESP32-WROVER燒錄夾具 含軟體安裝說明NT 759

甲蟲工作室 diy-esp燒錄 
CP2104 driver install   https://www.silabs.com/ << click to download CP210x

683元可燒ESP-WROOM-32   https://item.taobao.com/掏寶
ESP32-WROOM                              


       https://randomnerdtutorials.com/bin-binary-files-sketch-arduino 

arduino>Sketch>Export complied Binary,
arduino>Sketch>Show Sketch Folder,    then...You should have two files in your Sketch folder: the .ino and the .bin file. 

       再查了另一個教學YOUTUBE  https://www.youtube.com/watch                          arduino>File>Preferences> Settigs> Show verbose output during:  compilation and upload  selected   09:27秒開始講ESP8266                                                                                                

  1.    產生 BIN檔案                                                                                                                                                         Arduino>檔案>偏好設定>顯示詳細輸出: 編譯 , 上傳 打勾      , Arduino>草稿碼>匯出以編譯的二進位檔  ------>   2/27/2020 OK.                                                                                                                           但 Arduino>上傳, 卻出現"error: espcomm_open failed". <<< 不外接設備 重新上傳成功,                 如此不用每次都編譯再加上傳, 速度快很多了!
  2. ESP 系列燒錄韌體   https://www.espressif.com/zh-hans/support/download/下載   https://www.espressif.com/zh-hans/support/download/other-tools
  3. 解壓縮檔後執行flash_download_tools_v3.6.8\flash_download_tools_v3.6.8 APP

  4. ESP8266 燒錄教學 https://swf.com.tw/?p=1123






樂鑫官方AT固件


245元 ESP32 晶片附PCB
245元 ESP32-WROOM-32晶片附PCB https://m.ruten.com.tw/goods/show.php?g=21640885678533

327元 ESP32-WROOM-32晶片附PCB
ESP32-WROOM 晶片附PCB

ESP32-WROOM 17元轉接板



NT.224 Esp32-wroom-32
ESP-32F
ESP-32F開發板



NT.99 NodeMcu V2 CP2102 雖然便宜 但可看出 功能少一些


2019年3月7日 星期四

2019年2月13日 星期三

NodeMcu DOIT ESP32 DEVKIT V1


pin out ] 
https://randomnerdtutorials.com/ esp32腳位使用
D34, D35, D36(VP), D39(UN) all are input only!

我買的是30GPIOs ESP32 DEVKIT DOIT board 沒 GPIO0...


179 元我最便宜 ESP32 Arduino相容 含藍芽WIFI , 

型號:DEVKIT (NODEMCU 32S )

https://goods.ruten.com.tw/item/show?21848118800764
180元 esp32s


[安裝]  https://www.silabs.com/developers/usb-cp102-drivers
https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/

STEP 3  Tool > Board Manager > Arduino / Genuino Uno
不要漏掉呦! 我就是少掉,直接跳STEP4 , 一直裝不好

File > Preferences > additiomal boards Manager URL 加入下列
https://dl.espressif.com/dl/package_esp32_index.json,http://arduino.esp8266.com/stable/package_esp8266com_index.json
Tools > Board menu > DOIT ESP32 DEVKIT V1
選一個測試程式
6) Press the Upload button in the Arduino IDE. Wait a few seconds while the code compiles and uploads to your board.
8) Open the Arduino IDE Serial Monitor at a baud rate of 115200:
9) Press the ESP32 on-board Enable button and you should see the networks available near your ESP32:
--------------------------------------------------------------------------------------------

[錯誤排除]
Failed to connect to ESP32: Timed out… Connecting…
當你看到 “Connecting….” 時, 按下BOOT” 鍵! 直到顯示Connecting。

[ESP-WROOM-32 DEVKIT V1 實作]
待測


4 PINs touch-panel-module
I2s DAC
esp32-i2s-to-play-wav-music-from-sdcard

www.twblogs.net/ 藍芽

esp32-m5stack-server-and-client 藍芽

以下是測試過的
A. 16x2 I2C OLED (PT0066) 測試成功

I2C LCD + OLED 16x2  
Getting the LCD Address測試成功, Display Static Text on the LCD失敗

上傳程式後 顯示RESET RTX...不用管它

Arduino>Tool> Serial Monitor >跳出一個新視窗 > 右下方  baud rate >選 115200.
 Press the ESP32 EN button. The I2C address should be displayed in the Serial Monitor.
以上可測出LCD 的位址 

露天賣家 附的LIBRARY及DEMO程式 測試成功

OLED 16x2 ASCII TABLE     ascii 223:  o at upper position, ascii 48: 0,  ascii 80: P

B. 黃藍I2C OLED 測試成功 2019Feb.21

(賣家標示128x64 OLED 且附贈範列 但實驗失敗,  改用賣家附檔128x32 Library 內程式測試成功)



PS 使用USB伸縮轉接線(方便PLUG IN, OUT) 很方便 !  

C.  2.13"三色電子紙 接線及程式測試成功2019.Feb.22
方法:
一 Arduino >Tool > Manage library> install GEPD2 library
二 使用 c:/users/user/arduino/library/GEPD2/GEPD2.examples 修改內容後 測試成功
(使用賣家範列實驗失敗) 賣家附的範例 compiling會有錯誤
"avr/pgmspace.h: No such file or directory"

D.  Encoder Switch 接線及程式  測試成功 2019.Feb.25


Enoder switch 程式 需要Arduino library? 需要用到中斷資源? 
記得以前在PIC單晶片用state machine的觀念 很快就完成了!

前兩天 測試Arduino, 不用Library ,不用Interrupt使用下列網路現成程式失敗。   henrys-bench/rotary-encoder 040-rotary-encoder switch   , 符合預感 

所以我今天下午, 把2005推出CS3310音量控制套件 使用PIC16F84A組合語言寫成的程式,  改成Arduino C 測試成功了!

後記
Google arduino rotary encoder switch,
看起來這程式也像state machine 觀念。
http://www.hobbytronics.co.uk/  試用很順。

但後續加上16x2 I2C OLED 初步發現問題
重開機後, oled程式不動
 慢慢檢查指令, 發現...
LCD.cursor(); 不能刪
刪除此指令 , no work  after reboot, 非常詭異。

E. OLED16x2 I2C 整合旋鈕 加 按鍵  
2019.Mar.1  test ok 調整 運作平順

重開機也可正常工作

F. DHT22 溫濕度 OLED顯示 Mar.03.2019 test ok
注意 setup() 
dht.setup(DHTpin, DHTesp::DHT22); //DHTesp::DHT11for DHT11 Connect DHT sensor to GPIO 17
DHTesp::DHT11 要改成 DHT22

dht22-humidity-temperature可參考程式 OK
取用設定Setup(), temperature, humidity 另外自行更改float轉換int後顯示 成功




G. Esp32 pm2.5
我使用GPIO13 input for ADC, GPIO4 output . +5V供電給GP2y1014AU
下列兩個連結網頁的程式 都測試成功可以跑我選用第一個
1.
阿玉maker研究區
https://sites.google.com/site/wenyumaker/03-pm2-5hui-chen-chuan-gan-qi
很好的範例 SERIAL MONITOR 可顯示: 電壓... ug/m3
2.
SHARP 原裝夏普 GP2Y1014AU 接線及程式碼 
賣家程式 我在家實驗 顯示2000以上,
不過 他加註0~1050 300-1050 = 一般
SHARP GP2Y1014AU

PS
1. ESP32  esp8266 v2  跳動不太穩
拉夫多多思考 推薦買更新型的PM2.5感應器
2. 其他PM感應器我沒買, 沒實驗
PMS5003T for PM1.0 ,2.5, 10 及溫濕度
PMS7003   PMS3003 for PM1.0、PM2.5、PM10
Dsm501 pm10, pm2.5
PPD42N

3. 小米空氣清淨機 感應器 升級
Joeyhc.blogspot.com/2018/03/ PMS7003

後來 我在ESP8266也使用PMS7003成功, 偵測顯示非常穩定。
為什麼又改用低階一點ESP8266呢?因它便宜只要一百元。
所以又試玩看看

H. Bluetooth on ESP32

http://youyouyou.pixnet.net/blog/category/0

首先準備器材
1.ESP32:NodeMCU-ESP32s(露天搜尋: https://goods.ruten.com.tw/item/show?21848118800764 )
2. 2個繼電器
3. 一個USB風扇
4. 一個LED檯燈
5. Android手機,並安裝這個APP: Arduino Bluetooth Control(Google Play: https://goo.gl/jEAmbu) ,其他APP不是不行,而是這個APP有支援語音命令,真的很好玩。


bluetooth-in-esp32-and-toogle-an-led

2018/05/esp32-m5stack-server-and-client
ESP32-BLE-Android-App-Arduino-IDE-AWESOME/

esp32-arduino-serial- 看來很簡單-over-bluetoth-hello-world/amp/

I.  0.95" oled color 96x64 ssd1331

2020/Jan/07 實驗成功

GOOD
但很詭異 接腳不是影片說的 RES接D2, DC D4...
而是使用他的SSD_13XX library , 接線: 同下列第四點
可能是使用其他網頁的接線但程式失敗 改用SSD_13XX的EXAPLE成功
這種情形 印象中常常發生
實驗會成功 常常"突然"發生的
其實很辛苦


二 解壓縮 SSD_13XX-1.0 目錄後, 再將該目錄改名成 SSD_13XX ,
放進 C:\Users\user\Documents\Arduino\libraries\
三 arduino> Files>examples> SSD_13XX> Clock_example, 不用修改直接 upload to ESP32
四 接線:
ESP32 DEVKIT V1
GPIO 23 to oled SDA GPIO 18 to oled SCL, GPIO 5 to oled RST GPIO 16(RX2) to oled DC GPIO 17(TX2) to oled CS

[C 語法] 

Arduino C goto

 void changePinState(int pin)
// if pin reads LOW, set it HIGH
// if pin reads HIGH, set it LOW
 {  
int state=digitalRead(pin);
 if (state == HIGH) goto skip_1; 
 if (state == LOW) goto skip_2;
 goto error;  

skip_1:   state = LOW;    goto done;  
skip_2:    state = HIGH;    goto done;   
error:   Serial.println("Internal Function Error");   
done:    digitalWrite(pin, state);
 } 
--------------------------------------------------------------
switch (s0) {
    case 0:    // your hand is on the sensor
      goto P1;
      break;
    case 1:    // your hand is close to the sensor
      goto P2;
      break;
    case 2:    // your hand is a few inches from the sensor
     goto P3;
      break;
 
  }
--------------------------follow case 0...59: compile error  ----------------------------------
char grade;
int score; 
switch (score) {
  case 0...59 :
     grade='F';
     break;
  case 60...69 :
     grade='D';
     break; 
  case 70...79 :
     grade='C';
     break;
  case 80...89 :
     grade='B';
     break; 
  case 90...99 :
     grade='A';
     break; 
  default :
     break;
  }
Example
int i;
float f;

f = 3.6; 
i = (int) f; // now i is 3
---
--------------------------------------------------------------------------
小狐狸事務所Arduino 基本語法筆記
小狐狸事務所 有很多相關範例

/pmwiki./Bitshift   Arduino   Bit shift

Example:

    int a = 5;        // binary: 0000000000000101
    int b = a << 3;   // binary: 0000000000101000, or 40 in decimal
    int c = b >> 3;   // binary: 0000000000000101,
The following example can be used to print out the value of a received byte to the serial monitor, using the Leftshift operator to move along the byte from bottom(LSB) to top (MSB), and print out its Binary value:
  // Prints out Binary value (1 or 0) of byte
  void printOut1(int c) {
    for (int bits = 7; bits > -1; bits--) {
     // Compare bits 7-0 in byte
     if (c & (1 << bits)) {
       Serial.print ("1");
      }
      else {
        Serial.print ("0");
      }
    }
  }
--------------------------------------------------------------------------

[其它網路資料]

/2019/01/25/esp32-dht11-22-humidity-temperature

iot-based-home-automation-project Home server

Waveshare e-paper  with DEVKIT V1 成功範例

a  電子老兵賣家 附程式碼
B. arduino 紅外線遙控
1. 1106 oled esp32

2. 不錯的ESP32範例esp32-and-oled-display-internet-clock-dht22-3. b142e4 OLD 待測
待測esp32-over-the-air-ota-programming/

4. OLED+溫溼度感應
5. 影像
6. 安裝 python
7. epaper 此網路資料 實驗沒成功
8.Arduino>範例>ESP32>ESPNow>Basic>Master
9. SH1106 oled I2C/how-to-use-arduino-esp32-to-display-oled.html
10.esp32-pinout-reference-gpios/
11. ESP 32觸控手指觸控式led開關
Botton 開關 :一端接3.3V電源,另一端同時連接220Ω電阻接地與GPIO21腳。

[本網頁 顯示器使用的接腳]

I2C

When using the ESP32 with the Arduino IDE, you should use the ESP32 I2C default pins (supported by the Wire library):
  • GPIO 21 (SDA)
  • GPIO 22 (SCL)

Epaper SPI

epaper SPI code & PIN assignment below
"My pinout

IO23 : MOSI
IO18 : CLK
IO17 : DC
IO16 : RST
IO5 : SS
IO4 : BUS"
我的電子紙測試,按照這接法, 成功。
其實GEPD2 Library範例程式內 有寫腳位如何接。

SPI E-PAPER? espwroom-32-SPI/issues/4    esp-wroom-32 spi

[下載]
silabs Download for Windows 10 Universal (v10.1.4)
arduino IDE 1.8.8   直接下載IDE 1.8.8
安裝Python


PS
舊版?esp-wroom-32 日本範例
硬體
Hd44780 I2C LCD

看一下 阿旺師
OLED+溫溼度感應 下載程式碼