PT100/PT1000 工业级温度传感器

来自Jack's Lab
(版本间的差异)
跳转到: 导航, 搜索
(MCP3421)
(MCP3421)
第37行: 第37行:
  
 
<source lang=cpp>
 
<source lang=cpp>
 +
#include <Wire.h>
 +
#define MCP3421_ADDRESS 0X68
  
 +
void setup()
 +
{
 +
  Serial.begin(115200); 
 +
  Wire.begin();
 +
}
 +
 +
void loop()
 +
{
 +
  Wire.requestFrom(MCP3421_ADDRESS, 4);
 +
  if (Wire.available() != 4) {
 +
    Serial.println("Wire.available failed");
 +
    while(1);
 +
  }
 +
  int16_t v = (Wire.read() << 8);
 +
  v |= Wire.read();
 +
  // read but ignore status
 +
  uint8_t s = Wire.read();
 +
  //print voltage from channel one in millivolts
 +
  Serial.print(v);Serial.println(" mv");
 +
  delay(1500);
 +
}
 
</source>
 
</source>
  

2016年3月1日 (二) 08:26的版本

目录

1 概述



2 ESP8266 ADC

硬件连接:

 VCC33 ---> PT1000 <-- (A0) --> 300R 1% ---> GND


void setup()
{
  Serial.begin(115200);
}

void loop() {
  int vd = analogRead(A0);
  Serial.print("vd = ");
  Serial.println(vd);

  uint32_t rtd = (1024 - vd) * 300 / vd;
  Serial.print("rtd = ");
  Serial.println(rtd);

  delay(1000);
}



3 MCP3421

Mcp3421-app.png


#include <Wire.h>
#define MCP3421_ADDRESS 0X68

void setup()
{
  Serial.begin(115200);  
  Wire.begin();
}

void loop()
{
  Wire.requestFrom(MCP3421_ADDRESS, 4);
  if (Wire.available() != 4) {
    Serial.println("Wire.available failed");
    while(1);
  }
  int16_t v = (Wire.read() << 8);
  v |= Wire.read();
  // read but ignore status
  uint8_t s = Wire.read();
  //print voltage from channel one in millivolts
  Serial.print(v);Serial.println(" mv");
  delay(1500);
}



4 资源






















个人工具
名字空间

变换
操作
导航
工具箱