Hi, i have a problem with the create input in the emoncms. The emoncms is installed in localhost(windows with wampserver).
I have a arduino that send data for emoncms through java application. I use the notebook for connection.
The problem is that i can’t create of the inputs.
The return is a json: {“success”:false,“message”:“Username or password empty”}
The utilized code is:
public static void enviar(String mensagem) {
try {
URI uri = new URIBuilder()
.setScheme("http")
.setHost("localhost")
.setPath("/emoncms/input/post.json")
.addParameter("node=","1")
.addParameter("json=",mensagem)
.addParameter("apikey=",apikey)
.build();
DefaultHttpClient client = new DefaultHttpClient();
HttpPost httpget = new HttpPost( uri );
HttpResponse response = client.execute(httpget);
InputStreamReader inputReader = new InputStreamReader(response.getEntity().getContent());
BufferedReader bufferedReader = new BufferedReader( inputReader );
String linha = "";
while ( (linha = bufferedReader.readLine()) != null){
System.out.println(linha);
}
} catch (Exception e) {
System.err.println("Erro ao enviar mensagem para o emoncms. " + e.getMessage());
e.printStackTrace();
}
}
I have used the following ‘not really java’ code in the Processing Language to send data to emoncms.org and a local host. The string etherPacket is assembled with the data.
String hostname = "emoncms.org";
chttp = new Client(this, "emoncms.org", 80); // Connect to server on port 80
String etherPacket = "[[0,20,"+Integer.toString(icekwmeter)+
","+Integer.toString(icekwavg)+
","+Integer.toString(psMeter)+
","+Integer.toString(powerAvail)+
","+Integer.toString(rawsstap)+
","+Integer.toString(emmDemand)+
","+Integer.toString(demandNow)+
","+Integer.toString(demandValle)+
","+Integer.toString(demandPeak)+
","+Integer.toString(demandNoche)+
","+Integer.toString(icewattmeter)+"]]";
chttp.write("GET /input/bulk.json?data="+etherPacket+"&apikey=myapikey HTTP/1.1 \r\n");
chttp.write("Host: " + hostname + "\r\n");
chttp.write("Accept: */*\r\n");
chttp.write("User-Agent: Java\r\n");
chttp.write("\r\n");
System.out.println("sent to emoncms");
The code I posted above has worked fine for 3+ years. It stopped working 3 days ago. Problem 1 was insufficient funds in the account. Took care of that problem. Data is not getting to the feed page. I can send data using a browser but not with the ‘java’ program. Any ideas where to look for the problem?