Problem With "Particle.publish"

Hi there,
I am trying to “publish” this data onto the particle IoT and I am having some trouble. This is my first project so I don’t know the language that well, the error it comes up with is " Expected Primary Expression Before Const, Event and Data" (the ones in Bold)
Any Help is Much appreciated :slight_smile:

int D = A4;
int val = 0;
const char *eventName = "Pressure";
int  data = val;
void setup() {


void loop() {
 val = analogRead(D)/25-20;
Particle.publish(**const** char *eventName const char data);
Particle.publish(**String** eventName, String **data**);


That first line is the method signature, and should be deleted. Particle.publish can accept either char* or Strings as the arguments. When you call a function in C, you don’t put in the types, just the values. eventName is already a const char*, so you can pass that directly. For data, you need to convert that to a char* or a String object.

Particle.publish(eventName, String(data));
1 Like

@Ric Thankyou very Much