mqtt input only works with single character

i try to control a lamp with mqtt
When i send a 1 or 2 the script below works
But when i send a more complex command like lamp/on it’s not working
I think it has to do with a string?? But no clue to solve that :frowning:

 Basic MQTT example with Authentication

  - connects to an MQTT server, providing username
    and password
  - publishes "hello world" to the topic "outTopic"
  - subscribes to the topic "inTopic"

#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>

int wait = 50;
int location = "test";

int i = 0;

// set pin numbers:

int ledPin = 15; 

// Update these with values suitable for your network.
byte mac[]    = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 50);
IPAddress server(192, 168, 1, 49);

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print("] ");
 for (int i=0;i<length;i++) {
  char receivedChar = (char)payload[i];
  if (receivedChar == '101'){

  digitalWrite(ledPin, HIGH);

  } else if (receivedChar == '102'){
   digitalWrite(ledPin, LOW);

EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);

void setup()
  // initialize serial communication:
pinMode(ledPin, OUTPUT);

  // Note - the default maximum packet size is 128 bytes. If the
  // combined length of clientId, username and password exceed this,
  // you will need to increase the value of MQTT_MAX_PACKET_SIZE in
  // PubSubClient.h
  //print out the IP address

Serial.print("IP = ");

  if (client.connect("arduinoClient", "USERNAME", "PASSWORD")) {



void loop()
if (receivedChar == '101'){

This will never be true. receivedChar is one character, so you cannot compare it to multiple characters. BTW a string is wrapped by double quotes ("), single quotes are reserved for single characters.

To compare C-strings (character arrays) you can use the function strncmp().

int location = "test";

What is this nonsense?