Send POST data with orange pi

0

I am trying to send a series of data to my database that I have on a server, and I thought about using an orange pi one, which is the one I have at home, and on the server I have set up a web service on java spring , the idea would be that the data collected by the orange pi is sent to my server, first in the local obviously, but I would also like it to be online.

I had planned to use an arch-linux distribution, since I found by Google that I can install it like this:

link

Although the truth would give me the same as distribution use, I want the lightest terminal I can find, since I only need to use the GPIOs and ethernet.

Any advice? What do you think? Would you use another distribution? If you could also tell me a bit how to do what ethernet is what I eat the most would be grateful.

Thank you very much for reading and advising me (if you post something: P)

Greetings.

    
asked by Peisou 19.06.2018 в 11:18
source

1 answer

0

If you feel comfortable with Java, do not be afraid and go ahead, do it in Java, it will allow you to focus on the idea and not worry about the language, because you already know and master it.

What you will have to develop will be a library (.jar) that will be invoked by command line, and where you will pass the parameters or arguments that you want to send to the server through POST:

java -jar MyClient.jar param1 param2

If you want to send for example the measurements of the humidity and oxygen sensors, it would be something like:

java -jar MyClient.jar "oxigeno:27" "humedad:49"

In this way, your main class would look like this:

public class MyClient {
  public static void main(String args[]) {
    for(String s: args) {
      System.out.println("Lectura sensor recibida: " + s);
    }
  }
}

After that, you should take each argument and make a split (":"), which will return an array, in order to know which sensor you are operating (position 0) and what value you have measured / received from that sensor (position 1).

Once that is done, you can now dump your data where you need it, such as a database.

I hope I could clarify the doubt

    
answered by 21.06.2018 в 14:50