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

#28860
DonZalmrol
Participant

Looks like I was wrong the whole time with thinking the uploads needs to be in JSON…
Reworking the whole thing to work with the EXP protocol.

Current code:

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

  if(retry < 3)
  {
    if (client.connect("data.uradmonitor.com", 80))
    {
      if(client.connected())
      {
        Serial.println(F("Connection to uradmonitoring platform succeeded!"));

        // Authentication
        client.print(F("X-User-id:"));
        client.print(USER_ID) + "\r\n";
        client.print(F("X-User-hash:"));
        client.print(USER_KEY) + "\r\n";
        client.print(F("X-Device-id:"));
        client.print(DEVICE_ID) + "\r\n";

        // Concat data for POST
        String ptr = "POST http_:_//data.uradmonitor.com/api/v1/upload/exp";  // Do a post call to the API
        ptr += "/01/";                            // compulsory: local time in seconds
        ptr += timeClient.getEpochTime();         // 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

        // Print out pointer (ptr) to client
        client.print(ptr);
        client.println(F(""));
        
        // Test output
        Serial.println(ptr);

        Serial.println(F("\n"));

        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();
  }
}

Looks like I can now authenticate and received a device ID when querying with Postman. It states my device is online but my POSTs aren’t getting through…
Example of the output of one of my POSTs:

19:28:42.042 -> Connection to uradmonitoring platform succeeded!
19:28:42.042 -> POST http_:_//data.uradmonitor.com/api/v1/upload/exp/01/1621445321/02/23.00/04/46.00/0B/78/0C/406.39/10/0x6
19:28:42.091 ->
19:28:42.091 ->
19:28:42.549 -> Connection to uradmonitoring platform Disconnected.

If you POST the result using Postman the values are actually pushed to my dashboard into my device… But not from my ESP32.

One step forward, two steps back situation 😉

PS: added _:_ to prevent URLs