Page 1 of 1

send values to dweet

Posted: Thursday 10 December 2015 21:51
by ralphw
Can anyone point me to a direction how to subscribe a sensor value to dweet. I would like to populate a freeboard with some values and since I do not want to open any inbound ports in my firewall I thought about using dweet since the values are not particulary secret. I tried to use httplink but am not succeeding to get a value out. Can anyone point me to some direction. For the record I'm not trying to set up MQTT or any other more elaborate system, just doing a put thru a wel defined API to dweet.io, that's it.

Ralph

Re: send values to dweet

Posted: Friday 11 December 2015 7:49
by Egregius
Easy with a small PHP script:

Code: Select all

#!/usr/bin/php
<?php
if(isset($_REQUEST['tag'])&&isset($_REQUEST['value'])) {
	$url = 'https://dweet.io/dweet/for/egregius';
	$data = array($_REQUEST['tag'] => $_REQUEST['value']);
}
else {
	echo "Nothing sent";
	exit;
}
$options = array(
	'http' => array(
		'method'  => 'POST',
		'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
		'content' => http_build_query($data),
	),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
Call the script by 'script://path/to/script/dweet.php?tag=Test&value=Hello' for a text message, or first pull the values you need with json and send those automatically.

Re: send values to dweet

Posted: Friday 01 April 2016 22:45
by oopee
Just got my Freeboard dashboard online. I used curl and jq to parse Domoticz sensors json, then curl again to push the data to Dweet. All this in a bash script. Scheduled in crontab to run every 10 mins. I'm not a developer so it's not pretty but working ok.