daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Nov 20th, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dht DHT;
  2.  
  3. #define DHT11_PIN 7
  4. float tem [4];
  5.  
  6. void setup() {
  7.   Serial.begin(9600);
  8.   pinMode(12, OUTPUT);
  9. }
  10.  
  11. void loop() {
  12.   int chk = DHT.read11(DHT11_PIN);
  13.   int val = (int)(DHT.temperature);
  14.   Serial.println(val);
  15.   delay(600000);
  16. }
  17.    
  18. var fs = require('fs')
  19. var logger = fs.createWriteStream('/data/Temperature/temperature.csv', {
  20.   flags: 'a' // 'a' means appending (old data will be preserved)
  21. })
  22.  
  23. var SerialPort = require("serialport")
  24. var serialPort = new SerialPort("/dev/ttyACM0", {
  25.   baudRate: 9600,
  26. });
  27.  
  28. serialPort.on("open", function () {
  29.   serialPort.on('data', function(data) {
  30.     var moment = require('moment');
  31.     var dayTime = moment().format('YYYY-MM-DD,hh:mm');
  32.     var val1 = data.toString();
  33.     var val = val1.trim();
  34.     if (val == '') {
  35.       console.log('no data');
  36.     else {
  37.       console.log(val);
  38.       logger.write(dayTime + ',' + val + 'n');
  39.     }
  40.   });
  41. });
RAW Paste Data
Top