跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • World
  • 使用者
  • 群組
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 預設 (Yeti)
  • 未使用主題設計
Collapse
品牌標誌
  1. 首頁
  2. ESP32教學與討論
  3. 溶氧感測器
  4. 溶氧感測器-序列埠監控視窗

溶氧感測器-序列埠監控視窗

已排程 已置頂 已鎖定 已移動 溶氧感測器
esp32溶氧感測器序列埠監控視窗
1 貼文 1 Posters 15 瀏覽
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • adminA 離線
    adminA 離線
    admin
    寫於 最後由 編輯
    #1

    2.溶氧感測器 序列埠監控視窗.pdf

    #define DO_PIN 36
    
    #define VREF 5000    //VREF (mv)
    #define ADC_RES 4096 //ADC Resolution
    
    //Single-point calibration Mode=0
    //Two-point calibration Mode=1
    #define TWO_POINT_CALIBRATION 0
    
    #define READ_TEMP (25) //Current water temperature ℃, Or temperature sensor function
    
    //Single point calibration needs to be filled CAL1_V and CAL1_T
    #define CAL1_V (1600) //mv
    #define CAL1_T (25)   //℃
    //Two-point calibration needs to be filled CAL2_V and CAL2_T
    //CAL1 High temperature point, CAL2 Low temperature point
    #define CAL2_V (1300) //mv
    #define CAL2_T (15)   //℃
    
    const uint16_t DO_Table[41] = {
        14460, 14220, 13820, 13440, 13090, 12740, 12420, 12110, 11810, 11530,
        11260, 11010, 10770, 10530, 10300, 10080, 9860, 9660, 9460, 9270,
        9080, 8900, 8730, 8570, 8410, 8250, 8110, 7960, 7820, 7690,
        7560, 7430, 7300, 7180, 7070, 6950, 6840, 6730, 6630, 6530, 6410};
    
    uint8_t Temperaturet;
    uint16_t ADC_Raw;
    uint16_t ADC_Voltage;
    uint16_t DO;
    
    int16_t readDO(uint32_t voltage_mv, uint8_t temperature_c)
    {
    #if TWO_POINT_CALIBRATION == 0
      uint16_t V_saturation = (uint32_t)CAL1_V + (uint32_t)35 * temperature_c - (uint32_t)CAL1_T * 35;
      return (voltage_mv * DO_Table[temperature_c] / V_saturation);
    #else
      uint16_t V_saturation = (int16_t)((int8_t)temperature_c - CAL2_T) * ((uint16_t)CAL1_V - CAL2_V) / ((uint8_t)CAL1_T - CAL2_T) + CAL2_V;
      return (voltage_mv * DO_Table[temperature_c] / V_saturation);
    #endif
    }
    double DOSensor;
    
    void setup()
    {
      Serial.begin(115200);
    }
    
    void loop()
    {
      Temperaturet = (uint8_t)READ_TEMP;
      ADC_Raw = analogRead(DO_PIN);
      ADC_Voltage = uint32_t(VREF) * ADC_Raw / ADC_RES;
      DOSensor = ((double)(readDO(ADC_Voltage, Temperaturet))/1000);
      Serial.print("Temperature:\t" + String(Temperaturet) + "\t");
      Serial.print("ADC RAW:\t" + String(ADC_Raw) + "\t");
      Serial.print("ADC Voltage:\t" + String(ADC_Voltage) + "\t");
      Serial.println("DO:\t" + String(readDO(ADC_Voltage, Temperaturet)) + "\t");
      Serial.print("目前溶氧:");
      Serial.println( String(DOSensor) + " mg/L");  
    
      delay(1000);
    }```

    平台使用上有任何問題歡迎寄信至[email protected]詢問

    1 條回覆 最後回覆
    0
    回覆
    • 在新貼文中回覆
    登入後回覆
    • 從舊到新
    • 從新到舊
    • 最多點贊


    風狂logo 藏碳logo 南台logo SDGS2 SDGS7 SDGS12
    • 登入

    • 沒有帳戶? 註冊

    Powered by NodeBB Contributors
    • 第一個貼文
      最後的貼文
    0
    • 版面
    • 最新
    • 標籤
    • 熱門
    • World
    • 使用者
    • 群組