Photointerruptor for fermenter not tallying and publishing

Hi @andyr6184

Sorry! I should have read your code first. Yes, Particle.publish takes two Strings or char arrays and sends a “message” out on to the cloud. Publish is a “push” technology. A String is an object (check the Arduino doc for details) that has various nice methods that can help you handle character type data. A char array is the older C-style string that is just an array of bytes in memory that get interpreted as text strings. Both work.

But your original code was just trying to use an integer where publish expected a String or char array, so the code did not know how to interpret that integer into human readable text. When you call String(bubbletally) you are creating a new String object whose character contents are the value of the integer. So if bubbletally has the integer value 1234, String() of that becomes an object that contains “1234” stored as ASCII characters in memory.

You may want to use sprint() or even better snprintf() to print your variables into a char array. Here is a tutorial on a web-friendly way to do that:

You could also use the “pull” which would be Particle.variable. Here you would declare bubbletally as a cloud variable in setup and then something on the internet could “pull” the value whenever it needed it.