Hello everyone!
I'm writing a java program and I want to get received data.
As I understand you have a special emonhub service to deal with it, but how can I do it by my own?
Are you saving data first to mysql database? Or you're just sending it to emoncms straight?
Could you help me please?
Re: emonhub service in java code?
emonHub does not currently use any SQL it can buffer data in RAM if needed but it does not store it.
I do not code in java so cannot give you any pointers how to write it but if you elaborate on where you want to receive data from and what that data is eg format and range of values etc and what is expected or required by your java program then we may be able to give you some pointers.
Paul
Re: emonhub service in java code?
I have emonTx v3 conneced to RPI by rfm12 pi.
I tried to debug RFM12pi by minicom, I'm receiving something like
10 0 0 0 0 0 0 0 0 0 0, where 10 - is a node nuber and zeros are because I don't have any sensors plugged in emonTx.
I want to get the same packet 10 0 0 0 0 0 0 0 0 0 0 from RXTX interface but not in minicom but in my java program.
I'm pretty sure that what you're doing in emonHub is just the same thing. You getting bytes from rx pin and then parse it.
Could you give me a hand what is the packed format, how many bytes are sending from emonTx to RPI?
Or maybe I can escape from creating my own protocol parser and use something already written?
Thank you!
Re: emonhub service in java code?
The data you see coming in via the serial port is defined in the sketch you have loaded, i suspect it is node 10 and 10 bytevalues(0..255) as explained to you by Robert in your minicom utility problems with understanding thread.
Yes you will need to repeatedly read the serial port, parse the values and process as your java program requires. I cannot even suggest how this is done in java I'm afraid.
You could indeed use something already written it's called emonHub! this was suggested in your Where does the RPI save received data from rfm12pi module? thread.
What is it you are trying to achieve?
You have mentioned receiving from rfm2pi, sending via Ethernet and saving to SQL, this is what emonhub and emoncms do. But you want to use java for some reason, which is fine if that's your preference but neither emonhub or emoncms are written in java and there is very little java development (if any) in the OEM project.
Paul
Re: emonhub service in java code?
Ok, again you mentioned that I can use emonHub. But how? I can use it from command line? I can write python script and use emonHub methods from there?
Re: emonhub service in java code?
"But how?"
To do what???
Re: emonhub service in java code?
"You could indeed use something already written it's called emonHub! this was suggested in your Where does the RPI save received data from rfm12pi module? thread."
How to use emonHub?
Re: emonhub service in java code?
Once installed you may have to configure it to your preferences, set urls, frequency group id etc etc but it's defaults are for a 433MHz RFM2Pi, group 210, baseid 15 and it just needs to know your emoncms.org apikey.
It is included on the OEM SDcard images or there is an installer if you prefer to add it to an existing set up, It autostarts at boot time and It runs in the background, receiving, parsing, processing, buffering and forwarding the data received.
You can start and stop it via the command line but it is a service not a command line tool.
There are many threads on how to configure emonHub and there is nothing else to do unless you want to do something specific, if that is the case we need to know what that is if you want help.
Trystan has written several guides on how to use emonhub when an SDcard image is used and I have written many posts on how to do specific things with emonHub. If I had more context maybe I could point you to the right place.
Emonhub installation/update
https://github.com/emoncms/emoncms/blob/low-write/docs/setup.md#3-posting-to-emoncmsorg
Connect an EmonTx v3 to RaspberryPI via serial
Paul
Also here are a couple of threads about using a emontx v3's directly linked to the pi's serial port
Emon v3 Direct Serial
Serial link RPI<->EMonTX using Emonhub (emonSD-13-08-14.img)