Skip to content

Instantly share code, notes, and snippets.

@obiltschnig
Created May 25, 2024 11:48
Show Gist options
  • Save obiltschnig/30962053867ed86cb9591091f38d26c6 to your computer and use it in GitHub Desktop.
Save obiltschnig/30962053867ed86cb9591091f38d26c6 to your computer and use it in GitHub Desktop.
macchina.io JavaScript ThingSpeak
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