Created
May 25, 2024 11:48
-
-
Save obiltschnig/30962053867ed86cb9591091f38d26c6 to your computer and use it in GitHub Desktop.
macchina.io JavaScript ThingSpeak
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 net = require('net'); | |
const API_KEY = 'XXXXXXXXXXXXXXXX'; | |
function sendToThingSpeak(temp, hum) | |
{ | |
const uri = 'https://api.thingspeak.com/update.json'; | |
var httpRequest = new net.HTTPRequest('POST', uri); | |
httpRequest.parameters = { | |
api_key: API_KEY, | |
field1: temp, | |
field2: hum | |
}; | |
httpRequest.send((result) => { | |
console.log('ThingSpeak HTTP response: %d %s', result.response.status, result.response.content); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment