Arduino OSC sends weird values after a while [solved]

I know this is the Of forum, but since a lot of people use Of with the Arduino and this community seems more lifely, I’ll take my chances:

I try to read an analog value from my Arduino and send it to Of over OSC, using a ethernet shield. I have a potmeter connected to analog pin 0, 5V and ground.

At first it seems to work fine. When I check the values in the Arduino serial monitor, I keep seeing the right numbers: ‘0’ (the pin number) and ‘1023’ (the value).

When I send them to Of osing OSC it starts fine, but after a few seconds I start getting weird numbers and it stops.

edit:
I see Of throws the following error:

  
ofxOscMessage::getArgType: index 1 out of bounds  
ofxOscMessage::getArgType: index 1 out of bounds  
ofxOscMessage:getArgAsInt32: error: argument 1 is not a number  

So somehow, it starts sending a different type of message, which would explain the weird numbers. But I don’t have a clue why it changes, since it’s just keeps executing the same script and I’m not touching anything.

Here is my code (now I’m just reading pin 0, but it’s in a variable because I want to extend it later).
Also; I’m now using the OSC addres “/adr/” and send the pin number and value inside the message. How can I add the pin number to the address so it becomes “/adr/0/”?

  
#include <Ethernet.h>  
#include <ArdOSC.h>  
  
OSCClient client;  
OSCMessage message;  
  
byte myMac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  
byte myIp[]  = {169, 254, 3, 10 };  
byte destIp[] =  {169, 254, 3, 17 };  
int  destPort = 12345;  
  
char oscAdr[] = "/ard/";  
  
long int inputNumber = 0;  
long int inputValue = 0;  
  
void setup(){  
  Ethernet.begin(myMac ,myIp);    
  message.setAddress(destIp,destPort);  
}  
  
void loop(){  
  inputNumber = 0;  
  inputValue = analogRead(inputNumber);  
  message.setOSCMessage(oscAdr ,"ii" , &inputNumber, &inputValue);  
  client.send(&message);  
  delay(100);  
}  

I’m on a deadline, that’s why I posted here for help, but I seem to have found the answer myseld. So I guess I’ll reply on my own question.

I’m not sure why, but as said, the message gets corrupted after a while.
In the code given above, I created the osc message in the setup and set it’s content in loop();

I found out I can prevent the problem by creating the message inside the loop, so it gets created again every cycle.
I’m not sure why, but it works.
So in case someone encounters the same problem, here is the working Arduino script

  
#include <Ethernet.h>  
#include <ArdOSC.h>  
  
OSCClient client;  
  
byte myMac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  
byte myIp[]  = {169, 254, 3, 10 };  
byte destIp[] =  {169, 254, 3, 17 };  
int  destPort = 12345;  
  
char oscAdr[] = "/ard/";  
  
long int inputNumber = 0;  
long int inputValue = 0;  
  
void setup(){  
  Ethernet.begin(myMac ,myIp);    
}  
  
void loop(){  
  OSCMessage message;  
  message.setAddress(destIp,destPort);  
  inputNumber = 0;  
  inputValue = analogRead(inputNumber);  
  message.setOSCMessage(oscAdr ,"ii" , &inputNumber, &inputValue);  
  client.send(&message);  
}