Home Forum Software How to upload to uRadmonitor from (Arduino) ESP32? Reply To: How to upload to uRadmonitor from (Arduino) ESP32?

#28855
DonZalmrol
Participant

Getting a step closer.

I now have a correctly formed json to upload the following data:

10:10:12.021 -> {
10:10:12.021 ->   "id": "0",
10:10:12.021 ->   "latitude": "50.989699",
10:10:12.021 ->   "longitude": "3.503907",
10:10:12.021 ->   "altitude": "12",
10:10:12.021 ->   "city": "Deinze",
10:10:12.021 ->   "country": "BE",
10:10:12.021 ->   "detector": "SI22G",
10:10:12.021 ->   "factor": "0.001714",
10:10:12.068 ->   "timefirst": 1621411811,
10:10:12.068 ->   "cpm": 86,
10:10:12.068 ->   "temperature": 22,
10:10:12.068 ->   "humidity": 49,
10:10:12.068 ->   "voltage": 406.395
10:10:12.068 -> }

However I still see nothing in my dashboard. Believe the issue is still in my authentication.

Current partial code for uradmon connection:

// Upload json to the uradmonitor.com server
void connecToURadMonLogger()
{
  WiFiClient client;

  if(retry < 3)
  {
    if (client.connect("data.uradmonitor.com", 443))
    {
      if(client.connected())
      {
        Serial.println(F("Connection to urad monitoring platform succeeded!"));
        
        uploadJson["timefirst"] = timeClient.getEpochTime();
        uploadJson["cpm"] = totalCount_3;
        uploadJson["temperature"] = dht.getTemperature();
        uploadJson["humidity"] = dht.getHumidity();
        uploadJson["voltage"] = displayTubeVoltage();

        // Below does not work
        String ptr = "GET /data.uradmonitor.com/api/v1/upload/exp/01/";
        ptr += "X-User-id:%s\r\nX-User-hash:%s\r\nX-Device-id:%08lX\r\n";
        ptr += USER_ID;
        ptr += USER_KEY;
        ptr += "0";

        serializeJsonPretty(uploadJson, ptr);
        serializeJsonPretty(uploadJson, Serial);

        // Print out pointer (ptr)
        client.print(ptr);

        Serial.println(F("\n"));
        Serial.println("Uploaded cpm  = " + String(totalCount_3));
        
        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("Connection to urad monitoring platform Disconnected."));
      }

      else
      {
        // you didn't get a connection to the Radmon server:
        Serial.println(F("Connection to urad monitoring platform failed!"));

        client.flush(); // Flush connection
        client.stop(); // Stop client
        delay(1);// Give some time to stop
        
        uploadOk = false;
        retry++;
      }
    }
    else
    {
      // you didn't get a connection to the Radmon server:
      Serial.println(F("Connection to urad monitoring platform failed!"));

      client.flush(); // Flush connection
      client.stop(); // Stop client
      delay(1);// Give some time to stop
      
      uploadOk = false;
      retry++;
    }
  }
  else
  {
    Serial.println("Rebooting due uradmonitoring failed connection");
    ESP.restart();
  }
}

The used user-id and key I get from my dashboard. For my device ID how can I generate (or request) the correct ID I could use?
First time using json queries, so its pretty new to me 😉