LM35

LM35的详细介绍

创作者:qq1741806414 | 更新日期:2017-10-08 | 在线时长:0秒
qq1741806414的第一个设备,来自贝壳物联


#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

//this example reads data from a lm35dz sensor, convert value to degree Celsius
//and then post it to yeelink.net

//replace 2633 3539 with ur device id and sensor id
yl_device ardu(360847);  //此处替换为你的设备编号
yl_sensor therm(411832, &ardu);//此处替换为你的传感器编号
//replace first param value with ur u-apikey
yl_w5100_client client;
yl_messenger messenger(&client, "a02aa5452fe546dc5b866531873b5d0f", "api.yeelink.net");   //此处替换为你自己的API KEY

const int THERM_PIN  = A0;

float lm35_convertor(int analog_num)
{
  return analog_num * (5.0 / 1024.0 * 100);
}

void setup()
{
    Serial.begin(9600); //for output information
  byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xAA};
  Ethernet.begin(mac);
}

void loop()
{
  int v = analogRead(THERM_PIN);
        Serial.println(lm35_convertor(v));
    yl_value_data_point dp(lm35_convertor(v));
    therm.single_post(messenger, dp);
    delay(1000);
}