基于Blinker物联网+Esp8266的燃气灶温度与燃气残留浓度监控装置的设计与实现之三

   三、关键代码

(一)知识储备:要编写基于Blinker+esp8266的代码,应掌握arduino平台搭建、基于arduino平台下esp8266代码编写、Blinker平台相关函数的使用等知识。以上平台相关知识,在CSDN有很多优秀博文由浅入深详细介绍,本人学习太极创客、IT老翟等博客相关文章,受益匪浅,在此致谢,并建议有需求的读者阅读参考。
(二)关键代码。在arduino平台上的相关例程,实际上是各种应用开发的框架蓝本,开发者在此基础上,结合自己业务流程进行修改,本案也不例外,如下是与本例相关的在arduino平台上的开源代码。
// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple
 
#include "max6675.h" //加载max6675库
 
int thermoDO = 4;     //S0
int thermoCS = 5;     //CS
int thermoCLK = 6;    //SCK
 
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);  //建立MAX6675 对象实例
int vccPin = 3;     //VCC
int gndPin = 2;     //GND
  
void setup() {
  Serial.begin(9600);    //串口波特率9600
  // use Arduino pins 
  pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);//vccPin设置为输出
  pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);//gndPin设置为输出
  
  Serial.println("MAX6675 test");   //串口输出
  // wait for MAX chip to stabilize
  delay(500);
}
 
void loop() {
  // basic readout test, just print the current temp
  
   Serial.print("C = "); 
   Serial.println(thermocouple.readCelsius());   //串口输出摄氏度
   Serial.print("F = ");
   Serial.println(thermocouple.readFahrenheit());//串口输出华氏温度
 
   delay(1000);
}

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值