Home › Forum › Software › How to upload to uRadmonitor from (Arduino) ESP32? › Reply To: How to upload to uRadmonitor from (Arduino) ESP32?
May 20, 2021 at 8:01 pm
#28863
Participant
Getting a step further as the problem is currently situated in the X-headers.
21:52:28.951 -> Connection to radmon monitoring platform Disconnected.
21:52:28.951 -> Connection to uradmonitoring platform succeeded!
21:52:28.951 -> /01/1621540348/02/21.90/04/47.00/0B/60/0C/406.39/10/0x6
21:52:28.951 -> I am here now 01
21:52:31.422 -> X-User-Id:XXXX
21:52:31.422 ->
21:52:31.422 -> X-User-Hash:YYYY
21:52:31.422 ->
21:52:31.422 -> <strong>X-Device-id:0x13000212</strong>
21:52:31.422 ->
21:52:31.422 -> I am here now 02
21:52:34.401 -> I am here now 03
21:52:34.447 -> <strong>Status code: 200</strong>
21:52:34.447 -> <strong>Response: {"error":"Invalid Device ID"}</strong>
21:52:34.447 -> I am here now 04
21:52:34.918 -> I am here now 05
21:52:34.918 -> Connection to uradmonitoring platform Disconnected.
Looks like the connection get established (HTTP code = 200), my X-headers are validated, yet I receive “invalid device ID” for my device.
Tried “%08lX13000212″,”0x13000212” and “13000212”.
My current code:
// URadMonitoring credentials
const char *USER_ID = "XXXX\r\n";
const char *USER_KEY = "YYYY\r\n";
const char *DEVICE_ID = "13000212\r\n";
... minimized code ...
// Upload data to the uradmonitor.com server
void connecToURadMonLogger()
{
WiFiClient wifi;
HttpClient client = HttpClient(wifi, "data.uradmonitor.com", 80);
Serial.println(F("Connection to uradmonitoring platform succeeded!"));
// Get current time as UNIX time
time_t epoch = pftime::time(nullptr);
// Concat data for POST
String ptr = "/01/"; // compulsory: local time in seconds
ptr += epoch; // time epoch value
ptr += "/02/"; // 02 = optional: temperature in degrees celsius
ptr += dht.getTemperature(); // temperature value
ptr += "/04/"; // 04 = optional: humidity as relative humidity in percentage %
ptr += dht.getHumidity(); // humidity value
ptr += "/0B/"; // 0B = optional: radiation measured on geiger tube in cpm
ptr += totalCount_3; // a-cpm value
ptr += "/0C/"; // 0C = optional: high voltage geiger tube inverter voltage in volts
ptr += displayTubeVoltage(); // tube voltage value
ptr += "/10/0x6"; // 10 = Tube ID | 0x6 = GEIGER_TUBE_SI22G
// Test output
Serial.println(ptr);
Serial.println(F("I am here now 01"));
client.beginRequest();
client.post("/api/v1/upload/exp");
client.sendHeader("Content-Type", "application/x-www-form-urlencoded");
client.sendHeader("Content-Length", ptr.length());
client.sendHeader("X-User-Id:", String(USER_ID));
client.sendHeader("X-User-Hash:", String(USER_KEY));
client.sendHeader("X-Device-id:", String(DEVICE_ID));
client.beginBody();
client.print(ptr);
client.endRequest();
Serial.println("X-User-Id:" + String(USER_ID));
Serial.println("X-User-Hash:" + String(USER_KEY));
Serial.println("X-Device-id:" + String(DEVICE_ID));
Serial.println(F("I am here now 02"));
// read the status code and body of the response
int statusCode = client.responseStatusCode();
String response = client.responseBody();
Serial.println(F("I am here now 03"));
Serial.print("Status code: ");
Serial.println(statusCode);
Serial.print("Response: ");
Serial.println(response);
Serial.println(F("I am here now 04"));
uploadOk = true;
retry = 0;
// 5 blinks for 50 ms
blinkLedUpload(5, 50);
//client.flush(); // Flush connection
//client.stop(); // Stop client
//delay(5);// Give some time to stop
Serial.println(F("I am here now 05"));
Serial.println(F("Connection to uradmonitoring platform Disconnected."));
}
Wireshark is not yet possible as my device is in a secured vlan.