Adding Emoncms upload code to Arduino script

I am looking for a little help and I am a little embarressed I haven’t been able to do this myself.

I built this temperature, humidity and pressure system. The stock code works fine, but I wanted to post the data to the Emoncms server. No problem I thought I have managed to do this with a bit of hacking of php code in the past. However I am very new to Arduino and after many attempts and failures I am looking for some help.

I have looked at many similar bits of Ardunio code in this forum and I can’t get them to even compile without errors. I was going to post my attempts, but I think it may just complicate the matter further. I think it would be better if someone would be kind enough to provide some suggested code to use.

here is my code, I hope it helps

EthernetClient client;
String apikey = "2342"

sendData(realPower1, realPower2, tPower, realPower3, realPower4, Water, Range, second_board);


void sendData(float realPower1, float realPower2, float tPower, float realPower3, float realPower4, int Water, int Range, String sec_board) {
  
  
  if (client.connect(server, 80)) {
    
    client.print("GET /api/post?apikey="); 
    client.print(apikey);
     
    client.print("&json={");
    client.print("t_power:");
    client.print(tPower);               // Total power
   
    client.print(",P_A:");
    client.print(realPower1);           // Phase A    
    client.print(",P_B:");
    client.print(realPower2);           // Phase B
    
    client.print(",move:");
    client.print(realPower3);           // Refrigerator    
    client.print(",Wheater:");
    client.print(Water);                // Water heater    
    client.print(",Range:");
    client.print(Range);                // Range    
    client.print(",CompRoom:");
    client.print(realPower4);           // Computer Room power    
    client.print(sec_board);
    client.print(",solar:0");           // Solar
    client.println("} HTTP/1.1");
    client.println("Host:emoncms.org");
    client.println("User-Agent: Arduino-ethernet");
    client.println("Connection: close");
    client.println();
    
  } 
  else {
  
   
    client.stop();
  }

Thanks for this.

I have a few questions:

  1. You haven’t defined a nodeid. How is this handled?
  2. In the “sendData” you have a different order to “Get” post. “realPower1, realPower2, tPower,” compared to “tPower, realPower1, realPower2” Does this cause a problem, or was it done for a specific reason?

I am not too sure what nodeid is, but almost certain that you don’t need it

it is just a variable being sent and received by the function. As long as the same order is in the

sendData(realPower1, ...
and in 
void sendData(float realPower1, ....

the rest does not matter, you can compose your GET request the way that works for you.

LMK if you have more questions