I've been looking for an answer but can't find it. I have an emonpi setup and working great. Emonpi is sending data to emoncms.org
I have another arduino reading data from something else and reporting to emoncms.org and that is also working.
But what I really want is maybe the arduino to send data to the emonpi and the emonpi reports to emoncms.org. I want to do this to cut down on open internet connections.
How do I do this ? Do I create a node in emonhub ???
Re: Second arduino posting to emonhub ???
What you're proposing is the preferred method as emonHub can collate data from several sources and forward to several servers local and remote, it also offers some pre-send qualification/filtering so a bad packet can be stopped (or fixed) before being sent unnecessarily to multiple servers, plus there is the buffering of data if the remote servers down or network out.
However emonHub isn't (yet) set up to receive emonCMS formatted urls so you would need to rework the sketch in your 2nd arduino to either send via the existing hardware to a socket interfacer you can create in emonHub on the emonPi OR to send via RFM if you remove the Ethernet/WiFi and add a RFM69 board.
I only mention the second option as there will be more info readily available for editing the sketch for RFM than Sockets and the Interfacer is already there on the Pi.
If you search this site for socket interfacer you should get some info or i can help you further, but you will basically need your 2nd arduino to be able to send data formatted as 'nodeid val1 val2 val3' etc to the emon-pi via a lan ip or address with the port number opened for it eg 192.168.0.123:50011 or emonpi:50011 etc
Paul
Re: Second arduino posting to emonhub ???
I would like to know more info on data formatting, I need to send via IP. I am much more familiar with networking with the arduino just don't know how the emonpi accepts it and what formatting.
Thank you
Re: Second arduino posting to emonhub ???
Unfortunately I'm not that familiar with arduino networking so can only point you in the right direction.
I would suggest creating a socketinterfacer in emonhub as discussed in several threads and also use a simple test script, examples of which can be found in those threads to get a socket interfacer working (from the test script) with a format and address you are confident you can implement in the arduino sketch.
I theory you should have minimal down time as the route will be tried and tested and the new sketch written to suit before taking the 2nd arduino off line to upload the replacement sketch.
see How to simulate data sent from EmonTx to EmonHub in order to debug a reporter? to start with and if you need some specific help I'll assist you.
Set loglevel = DEBUG in emonhub.conf before you start and have a separate ssh window open and run "tail -f /var/log/emonhub/emonhub.log" to see verbose log entries in real time, you should se the socketinterfacer being created when you save emonhub.conf after adding the configuration, confirmation of settings and any data from your test script being processed. It is a huge help.
I expect you will also need an additional line in the socket interfacers [[[runtimesettings]]] pubchannels = ToEmonCMS as you are using the emon-pi variant of emonhub.
Paul
Re: Second arduino posting to emonhub ???
I have attached an Arduino sketch. Ignore the volts, amps, and power, data being past though. This is just a test sketch used without a sensor. I need help changing the formatting on the sendData() method. The changing the client IP and port number is easy enough. Does the emonhub accept the same formatting ??? what do I have to change ??? I have changed the emonhub
[interfacers]
[[solar]]
Type = EmonHubSocketInterfacer
[[[init_settings]]]
port_nb = 50011
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
[nodes]
[[1]]
nodename = solar
[[[rx]]]
names = volts, amps, power
datacodes = h, h, h
scales = 0.1,0.1,0.1
units = V,W,W
Re: Second arduino posting to emonhub ???
I hope someone can help you with the sketch as I'm not really able to.
The emonhub.conf settings look ok except the data will not be passed as byte pair ints so the datacodes won't suit. Previously in emonHub you had the option to omit the datacodes and the default for the SocketInterfacer was datacode 0 (defines no datacodes used) so real numbers could be passed.
You could try omitting the datacodes line, using datacode = 0 or datacodes = 0, 0, 0 to be more specific.
The string you need to send to http://192.168.10.31:50011 (ip:port) is node voltValue ampValue wattValue, Just four numbers seperated by a space, no labels, brackets or commas etc
and don't forget to allow 50011 in the UFW firewall.
Paul
Re: Second arduino posting to emonhub ???
Before trying to code this in arduino, is there a way you know of to throw a http post at emonhub as a test. I am not familiar with sending http posts. I know the json commands.
Can i send this in the address bar like the json requests ? I've tried researching POST requests and coding into arduino but still nothing shows up
When trying to connect to emonhub I get connection failed
if (client.connect(server, 50011)) {
some code
else {
// if you couldn't make a connection:
Serial.println("Connection failed");
Serial.println("Disconnecting...");
client.stop();
}
Maybe this is my first problem it skips past the code and fails. How does emonhub handle the connection ? I guess it doesn't like emoncms.org
I need to know how to test the POST before figuring out my connection woes.
Re: Second arduino posting to emonhub ???
I noticed this found at http://openenergymonitor.org/emon/modules/emonpi
To send a packet a HTTP POST request needs to be sent to the nodes API of the form:
Re: Second arduino posting to emonhub ???
I'm afraid I'm not familiar with the arduino side either, nor am I sure about the new emoncms api's you've found in the emonpi guide.
I can only really help you with "posting to emonhub" which isn't quite the same thing as posting to emoncms.
The correct method (IMO) is to send to emonhub and let emonhub post to both emoncms's, local and remote, but that is done via a websocket not via POST requests.
I have done this from python and bash, but not from an arduino,
Paul