Hello everybody! I'm having difficulty figuring out why and how to post my data onto the emoncms.
I have a Raspberry Pi computer connected to the emonTX v3.4 via a serial connection.
It took me a lot of googling and two days to finally see the data coming from the emonTX via minicom.
I then started to post things on Twitter and got a recommendation from @Openenergymonitor to use emonhub to post my data onto emoncms.
I configured (almost) the emonhub, and went onto emoncms.
emoncms gave me 2 two api keys, one read only and one read and write. Which one to use in /etc/emonhub/emonhub.conf in this section?
# This reporter sends data to emonCMS
[[emonCMS_remote]]
Type = EmonHubEmoncmsReporter
[[[init_settings]]]
[[[runtimesettings]]]
url = http://emoncms.org
apikey = ????????read or write api????????
Fine, it seems emonhub is sending something to emoncms, but what is it?
Do I have to mess with the "node" data structure?
#[[99]]
[[10]]
datacode = h
datacodes = 1, h, h, h
Mistery...
And then... When I go to the emoncms page and try to go to inputs it shows me nothing but a link to a bunch of JSON and (other bs) URLs. What To Do with these?
Clicking around randomly I got some "node" data onto the Inputs page with wierd values. OK, something is alive.
I like English people, they are honest and always considerate. But having been raised in the Colonies and being a Perl guy I have difficulty understanding the (darn) Python lingo along with the porn(scratch that) git hub documentation ending with the .md extentions. (joke)
Long story short. Please give some instructions on how to make this bastard do something useful.
How do I make my "inputs" show up in emoncms "Inputs" section?
How do I fight the "Feeds" or should I?
My head is spinning from all the wiki stories, all asking me to do something else...
SOS
Re: Getting started with emoncms
Hello pashanoid,
Yes its the write apikey
You should not need the node decoders in this application so I would delete the entry. Are you using the "EmonHubSerialInterfacer" as I detailed on the documentation page?
You should now see data appear on the inputs page of emoncms at which point you can go on to create feeds etc via the user interface rather than the API.
Trystan
Re: Getting started with emoncms
Here's a very short Perl script to read data from the emonTx:
#!/usr/bin/perl
use warnings;
use strict;
use Device::SerialPort;
my $PortObj=Device::SerialPort->new("/dev/ttyAMA0");
$PortObj->user_msg("ON");
$PortObj->databits(8);
$PortObj->baudrate(9600);
$PortObj->parity("none");
$PortObj->stopbits(1);
$PortObj->handshake("rts");
$PortObj->read_char_time(0); # don't wait for each character
$PortObj->read_const_time(1000); # 1 second per unfulfilled "read" call
my $chars=0;
my $buffer="";
while (1) {
my ($count,$saw)=$PortObj->read(1); # will read _up to_ 255 chars
if ($count > 0) {
$chars+=$count;
$buffer.=$saw;
print $saw;
}
exit;
Re: Getting started with emoncms
I gave up on python and wrote a Perl script that writes data from the emonTX to mysql
#!/usr/bin/perl
use warnings;
use strict;
use Device::SerialPort;
use DBI;
use DBI;
my $host = 'IP ADDR or HOSTNAME';
my $db_name = "YOUR MYSQL DATABASE NAME";
my $db_user = "YOUR MYSQL DATABASE USER NAME";
my $db_pass = "YOUR MYSQL DATABASE USER PASSWORD";
my $dbh = DBI->connect("dbi:mysql:$db_name;host=$host","$db_user","$db_pass")
or die "I cannot connect to dbi:mysql:$db_name as $db_user - $DBI::errstr\n";
my $PortObj=Device::SerialPort->new("/dev/ttyAMA0");
$PortObj->user_msg("ON");
$PortObj->databits(8);
$PortObj->baudrate(9600);
$PortObj->parity("none");
$PortObj->stopbits(1);
$PortObj->handshake("rts");
$PortObj->read_char_time(0); # don't wait for each character
$PortObj->read_const_time(1000); # 1 second per unfulfilled "read" call
my $chars=0;
my $buffer="";
my ($wt1, $wt2, $wt3, $wt4, $ac1);
my $temp="";
my ($count, $saw);
$wt3=0;
$wt4=0;
while (1) {
($count,$saw)=$PortObj->read(1); # will read _up to_ 255 chars
if ($count > 0) {
$chars+=$count;
$buffer.=$saw;
#print $saw;
$temp = $buffer;
}
if ($saw =~ /\n/g){
chop $temp if ($temp =~ /\n$/);
chop $temp if ($temp =~ /\r$/);
($wt1, $wt2, $ac1) = split /\s/, $temp;
$ac1 =~ s/\D//g;
last if (!$ac1);
$ac1 = $ac1/100;
#print "temp=$temp\t";
#print "wt1=$wt1, wt2=$wt2, ac1=$ac1";
#print "\n";
#print "$wt1\t$wt2\t$ac1\n";
my $dbh = DBI->connect("dbi:mysql:dbname=$db_name","","");
$dbh->do("INSERT INTO powerlog ( kw1, kw2, kw3, kw4, voltage) VALUES (?,?,?,?,?)", undef, $wt1, $wt2, $wt3, $wt4, $ac1);
$saw = "";
$buffer ="";
$temp = "";
($wt1, $wt2, $ac1) = ("","","");
$dbh->disconnect;
}
}
exit;
Did you not see "NEW USERS, PLEASE READ - Posts held for moderation"? Your duplicate post has been deleted. RW
Re: Getting started with emoncms
hii
this is what the amonhub.log show me as error
2015-05-05 10:25:01,266 INFO Opening hub...
2015-05-05 10:25:08,420 WARNING 1 Discarded RX frame 'non-numerical content' : $
2015-05-05 10:25:08,866 WARNING 2 Discarded RX frame 'non-numerical content' : $
some help plz
thanks
Re: Getting started with emoncms
Hi. i hope you got things figured out. I have had a similar problem but I have the Emonpi with all sensor inputs built in which probably simplifies things.
Anyway, I have after much head scratching and posts on various forum threads here managed to get my data appearing in the inputs on emoncms.org and wondered if after my experiences I could assist you?
I had not done any programming since BBC BASIC at school 25 years ago so this has been quite challenging...