Success! and a question

Gentlemen, I hope it is alright to express positive excitement in this forum. A number of you have provided amazing support for this old newbie. Thank you!

The company I work for has a professional programmer who does all our programming for the Particle Electrons, web sites, microprocessors, mobile apps etc. that we use. I do the hardware, he does the software. This is personally my first entry into the particle programming world. I did not know what publish or subscribe was, and barely how to do anything in this modern programming world. However, with your support I now have two xenons communicating with one another through the subscribe and publish examples provided in the IDE. It is truly amazing! Again, thank you. I am so excited that I am going to go upstairs and give my wife a big hug and kiss. After 47 years of being married to her, she is going to wonder what I am up to… I hope you can get a chuckle out of this. After all, you guys are helping real people meet their goals! I am grateful.

I had to change the “analogWrite(power,4095);” command to “analogWrite(power,255);”. I am learning that the programming examples provided in the IDE sometimes have to be modified to work on particular devices, and I have to check the reference documentation. After doing this, and building a voltage divider for the photo-resistor sensor in the example, my “Publish and Subscribe with Photoresistors” example worked great!

Moving ahead with the next question: I tried to change the particle.publish and particle.subscribe commands to mesh.publish and mesh.subscribe. I assumed the code would run the same, but without sending the data to the cloud. I got an error that said “mesh” is not declared in this scope.

Is this because the mesh.publish and mesh.subscribe are not yet supported in the online IDE? Can you explain the situation for me please?


Mesh should be capitalized like Particle is.


Thank you nrobinson2000!
That fixed it! Capitalization wasn’t important in code years ago. I’m trying to remember to be mindful of it now.


There might be a misunderstanding, the docs do tell it right (most the time :wink: )
The Gen2 devices (Photon, Electron, ...) have two kinds of analogWrite()

  • one for PWM output which has a default duty cycle range from 0..255
  • one for DAC wich has a analog voltage range of 0..4095 steps @3.3V

It may be that you just looked at the DAC sample for analogWrite() but the Mesh devices only support PWM analogWrite()

However, you can set the PWM resolution via analogWriteResolution() which would then allow PWM analogWrite() to take other ranges to set the duty cycle.

Actually it's not how long ago, but what language. C (and many others) has always been case-sensitive while others (e.g. BASIC, PASCAL, ...) weren't and still aren't.

1 Like