Last active
July 23, 2018 07:56
-
-
Save TakehikoShimojima/0229d2a671c1166104be12b0b635fb18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Obniz = require("obniz"); | |
| const ambient = require('ambient-lib'); | |
| const obniz = new Obniz("obniz_ID"); | |
| const channelId = 100; | |
| const writeKey = 'writeKey'; | |
| const get_data_send = async (bme280) => { | |
| const val = await bme280.getAllWait(); | |
| console.log(val); | |
| ambient.send({d1: val.temperature, d2: val.humidity, d3: val.pressure}, (err, res, body) => { | |
| if (err) { | |
| console.log(err); | |
| } | |
| console.log(res.statusCode); | |
| }); | |
| } | |
| obniz.onconnect = async () => { | |
| const bme280 = obniz.wired("BME280", {vio:6, vcore:5, gnd:4, csb:3, sdi: 2, sck: 1, sdo:0 }); | |
| await bme280.applyCalibration(); | |
| ambient.connect(channelId, writeKey); | |
| get_data_send(bme280); | |
| setInterval(() => { | |
| get_data_send(bme280); | |
| }, 300 * 1000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment