-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathLM35.ino
More file actions
44 lines (38 loc) · 1.17 KB
/
LM35.ino
File metadata and controls
44 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <Ethernet.h>
#include <WiFi.h>
#include <SPI.h>
#include <yl_data_point.h>
#include <yl_device.h>
#include <yl_w5100_client.h>
#include <yl_wifi_client.h>
#include <yl_messenger.h>
#include <yl_sensor.h>
#include <yl_value_data_point.h>
#include <yl_sensor.h>
//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(4136); //此处替换为你的设备编号
yl_sensor therm(5895, &ardu);//此处替换为你的传感器编号
//replace first param value with ur u-apikey
yl_w5100_client client;
yl_messenger messenger(&client, "dc7d1c98898fa2e45xxxxxxx", "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);
}