Spark.publish() under firmware v.0.3.4

Dear Particle colleagues. I’ve been trying to use the Spark.publish() feature without success. I don’t know if there’s something wrong with my code, or if my current firmware does not support this (currently using v.0.3.4).

My intention is really simple: to send a short message from Spark and capture it in command line environment with a Ruby script (MacOSX 10.9.5).

On Spark’s side, here’s my code:

void setup() {
void loop() {

On the desktop side, here’s the code:

require 'open-uri'
webcontent = open("")
content = webcontent.readlines()
puts content

But when I run the Ruby script, all I get is a blank result. I’ve tried to retrieve the published content with Curl, also without success. Any help would be appreciated.

Hi @dsaito

The Spark cloud and core firmware limit the number of published events to an average of 1 per second with a burst of up to 4 allowed. You need to add a delay after your publish command in loop; try delay(1000); for 1 second.

Hopefully on the desktop side “device_number” and “device_token” are replaced by the hex numbers for your device.

1 Like

Thank you so much, bko. The code works now, but unfortunately only with curl. I may have to dig deeper into ruby url handling now.

1 Like