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
#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 资源
- http://openenergymonitor.org/emon/buildingblocks/rtd-temperature-sensing
- http://forum.arduino.cc/index.php?topic=16731.0
- http://stackoverflow.com/questions/21644642/how-to-connect-pt-1000
- http://41j.com/blog/2015/01/esp8266-analogue-input/
