Blynk API REST question

Hi

I’m building a soil moisture based on REST but I have some problem to upload data.
Code seems ok

The first shoot upload all OK

http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V5?value=27.00
Float request respond : 200
Lux Level : 27
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V0?value=45.24
Float request respond : 200
Humidity : 45.24%
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V1?value=24.88
Float request respond : 200
Temparature: 24.88°C
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V2?value=20.00
Float request respond : 200

‘’’

Problems starts at second upload:
‘’‘http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V5?value=28.00
[sendFloatToBlynk] http connection failed
Float request respond : -1
Lux Level : 28
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V0?value=45.28
[sendFloatToBlynk] http connection failed
Float request respond : -1
Humidity : 45.28%
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cxxxx/update/V1?value=24.89
‘’’

and so on…

there is some flooding protection? or limits?

For sure, it’s basically a free service and it wouldn’t be able to handle trillions of transactions would it.
If you need high data throughput Blynk have dedicated servers for you with their subscription service.
How frequently are you trying to upload?

@Costas actually, there is no limits for HTTP API right now :wink:.

@joepesce in text you paste I see

Doesn’t that mean that request was successfully processed?

1 Like

Yes but presumably the -1 on the second run means fail?

hi thank you for all your answers

sensors is on ESP32
turn on from deepsleep, read 4-5 values, uploads and turn off

http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V5?value=35.00
[sendFloatToBlynk] http connection failed
Float request respond : -1
Lux Level : 35
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V0?value=46.47
[sendFloatToBlynk] http connection failed
Float request respond : -1
Humidity : 46.47%
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V1?value=23.77
[sendFloatToBlynk] http connection failed
Float request respond : -1
Temparature: 23.77°C
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V2?value=0.00
[sendFloatToBlynk] http connection failed
Float request respond : -1
Moisure lvl: 0
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V3?value=48
[sendFloatToBlynk] http connection failed
int request respond : -1
WiFi RSSI: 48%
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V4?value=0
[sendFloatToBlynk] http connection failed
int request respond : -1
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/update/V4?color=%23D3435C
[sendFloatToBlynk] http connection failed
property request respond : -1
[sendFloatToBlynk] http POST failed
notification request respond : -1

start:
http://blynk-cloud.com:8080/b6e8ebe68b6d483cb0506e545b8cXXXX/notify
*****************
{
“to”:"xxxxxxxxxxxx@gmail.com",
“title”:“Plant”,
“subj”:“Battery drained…”
}
81
*****************
[sendFloatToBlynk] http POST failed
Battery Lvl: 0%

[get_OTAStatus] http connection failed

it works only at first connection after 10-15 minutes… but if I want to wake up every 3min or 5min (for example) it give me the error that I post

Seems like issue with your code. Please paste it.



int sendEmailToBlynk(String email, String subject, String message){
  HTTPClient http;
  int returnValue = -1;

  /* prepare the json messsage */
  String jsonPayload = String("{\n\"to\":\"") + email + String("\",\n") +
                       String("\"title\":\"") + subject + String("\",\n") +
                       String("\"subj\":\"") + message + String("\"\n}");

  /* prepare the REST request */
  String POST_STING = "http://" + String(blynk_server)+ ":" + String(blynk_port) + "/" + String(auth) + String("/notify");
  
  #ifdef DEBUG
  #ifdef NETWORK_DEBUG
  Serial.println("\nstart:");
  Serial.print("\t");
  Serial.println(POST_STING);
  Serial.println("\t*****************");
  Serial.print("\t");
  Serial.println(jsonPayload.c_str());
  Serial.print("\t");
  Serial.println(jsonPayload.length());
  Serial.println("\t*****************");
  #endif
  #endif

  /* start blynk http connection */
  http.begin(POST_STING);
  http.addHeader("Content-Type", "application/json");
  int httpCode = http.POST((uint8_t*) jsonPayload.c_str(), jsonPayload.length());      // send post request

  if( httpCode > 0){
    returnValue = 0;
    #ifdef DEBUG
    #ifdef NETWORK_DEBUG
    Serial.print("email request respond : ");
    Serial.println(httpCode);
    Serial.print("server reply : ");
    Serial.println(http.writeToStream(&Serial));  
    #endif
    #endif
  }else{
    returnValue = -2;
    #ifdef DEBUG
    Serial.println("[sendFloatToBlynk] http POST failed");
    #endif
  }
  
  http.end();             //close the http 
  return returnValue; 
}`

I edited your code formating… use backticks not commas, thanks.

Blynk - FTFC

thank you!

no one have an idea?

@joepesce seems strange, please confirm I have this correct. You send approx 5 updates via API to Blynk, deepSleep for 15 minutes and when you repeat all is fine. But if you reduce deepSleep to 3 or 4 minutes the first upload is OK but no subsequent uploads?

Doesn’t really make any sense, is there anything you are omitting to tell us or is that the full procedure?

if I don’t send any data (or try to send) in 10-15 min. Just turn on or off esp32 it goes OK

if I try to send data it’s ok only first time and after it is like server block me and I have to stop to try send data for a period

I notice you are using the email widget in the API. @Dmitriy I know you said their were “no limits” with the API but surely you are not allowing a trillion emails a day from @joepesce to go through the server?

@joepesce disable email part and retest.

is only in the code, the app don’t have widget. I don’t know if it’s the same

In your code above you have:

int sendEmailToBlynk(String email, String subject, String message){}

Try with this function disabled and let us know the results. Either you are blocked for spamming or blocked for using a widget that is not in the your app. Note: Gmail allow 100 emails per day so you will be locked out by somebody if you try every few minutes.

it seems works now :slight_smile:

thank you so much