Skip to main content
edited tags
Link
user3201500
  • 225
  • 1
  • 6
  • 15
Source Link
user3201500
  • 225
  • 1
  • 6
  • 15

Convert byte* to int in Arduino

I am trying to convert byte* value to int here is how I have it.

void mqttCallback(char* topic, byte* payload, unsigned int length) {

  String topicStr = topic;
  int* payload_value;
  int updates_cal;
  
    payload_value = (int*)payload;
    //updates_cal = *payload_value;
    
    
    Serial.print((int)payload_value);
    

  delay(1);

  Serial.println();
  Serial.println("-----------------------");
 
}

I am getting MQTT payload as Integer value. Which I want to receive in my NodeMCU (ESP8266).

Is there any way to do this?

Thank you!