Introduction: Office Room Temperature Logging With PcDuino and Yeelink Server

Picture of Office Room Temperature Logging With PcDuino and Yeelink Server

pcDuino can connect to Internet by Ethernet, WiFi, GPRS and 3G. In this project, we will see a TMP36 temperature sensor to sense the office temperature and push to yeelink server, and check the temperature anytime anywhere through the Internet.

Step 1: Part List

1  x  pcDuino V2
1  x  TMP36 sensor
1  x  Breadboard
1  x  3.3k ohm resistor
Several jumper wires

Step 2: Connect the TMP36 to PcDuino

Picture of Connect the TMP36 to PcDuino

The first figure is the bottom view of  TMP36. The corresponding pins from the left to right are VCC, VOUT and GND.

We connect TMP36 to pcDuino in the following way:

VCC of TMP36 -> 3.3V of pcDuino
VOUT of TMP36 -> A5 of pcDuino
GND of TMP36 -> GND of pcDuino
Add a shunt resistor between VCC and GND of TMP36 to prevent damage of components.
Final Setup:

Step 3: Sample Code

#define aref_voltage 3

const int tmpPin = A2;
char buffer[50];
int tmpReading;

void setup(){
void loop(){
    tmpReading = analogRead(tmpPin);
    printf ("tmpReading = %d\n",tmpReading);
    float voltage = tmpReading * aref_voltage;
    voltage /= 4096;
    float tmpC = (voltage - 0.5) * 100;
    sprintf (buffer, "{\"value\":%4.2f}\n", tmpC);
    FILE* fp = fopen ("/home/ubuntu/datafile.txt","w+");
    fwrite (buffer, sizeof(char), strlen(buffer), fp);
    fclose (fp);
    exit (0);

Step 4: Compile the Code

Refer to book to check how to run Arduino style code in command line.

Create a file named tmp_yeelink.c. You can download the code from tmp36_yeelink.

Put the tmp_yeelink.c file to the sample directory under the c_environment which you just obtained from githun .

$ cp ***/tmp36_yeelink.c ***/c_environment/sample

***is the file you save the c_enviroment and the path of tmp_yeelink.c

Then modify the Makefile:

$ vi Makefile
Add the tmp36_yeelink after OBJS+= ***


Save and quit, input make and start to compile.

$ make

Then we will translate the analog value from the sensor to actual value of temperature, and save into a file named ‘data_file.txt’ in JSON format.

Step 5: Send Data to Yeelink

Curl is an open source communication tool which uses the URL approach in command line.

Create a script file named the, then write the following code to the file. (Modify the corresponding APIKEY and URL according to your own condition, and as well as the path to  the file named tmp36_yeelink)
$sudo /home/ubuntu/c_enviroment/output/test/tmp36_yeelink
$curl --request POST --data-binary @"/home/ubuntu/datafile.txt" --header
Add the execution right for the script after you save and exit the file.
$ chmod +x
–request <command> specify use command
–data-binary in binary POST data
@”…” cooperatively use with last command, to POST the content behind the @ to the server.
–header The custom header information is passed to the server

Step 6: Periodically Push Data to Yeelink Server

We will use a task called crontab to periodically push data to yeelink server.

Launch crontab editor by using:

$crontab -e
Add the script name as shown below:

Note: You should use instead.

Step 7: Result

Picture of Result

First measure the temperature of the office using a thermometer:
Then view the monitor state in the yeelink website:
The corresponding curve is our monitor temperature in the office.

If you want to learn more about the pcDuino jump to :


About This Instructable



More by Yanny Guo:Use pcDuino as Photo Booth ControllerUse Si4703 FM Breakout Board on Arduino UnoUse SIM900 GPRS/GSM Shield on pcDuino
Add instructable to: