Publish data with ThingSpeak

Hi

I tried to publish some values on one ThingSpeak channel
It works from a winform via Api request or using MQTT.fx but not sure how to set the parameter for the Publish in TinyClr

to update field1 value, I tried
topic = “channels//publish/fields/field1/”;
client.Publish(topic, Encoding.UTF8.GetBytes(“23.3”), QoSLevel.MostOnce, false, (ushort) packetId);

1 Like

seems to work now …

1 Like

Great. We want to hear more and even add a page to docs about it. You are also welcome to add to docs if you like.

1 Like

I have defined my first real project. nothing original as it is a meteo station (temp - humidity _ pressure- light - uv - wind and noise, solar powered and connected to thingspeak with a new FEZ of course)
but i need to do more testing as I never used mqtt till today.
it works but

  • sometimes data is not published
  • used the non secure channel 1883 as i could not connect yet with port 8883 (tls)
  • I don’t know how to publish data for several fields. if I try to update all fields sequentially, not all are updated
  • I was expecting ClientOnPublishReceivedChanged and ClientOnPublishedChanged event to be called after publishing but they are not.
    so lack of MQTT experience for sure and it need more testing. it will be for this evening after work

check my examples when

i published two different data (as test) and subscribed to the two another topics

publish mean what you want to sent

  • temp topic - tinyclr/tmep
  • humidity topic - tinyclr/hum

and used two different topic for receiving data from outer world by

subscribe (this meaning what you want to receive)

  • for one i put values 0/1 for on/off - tinyclr/light
  • for second ones i put values 10/11 for on/off - tinyclr/switch

so in this way i did received from outer world to my app values from subscribe

also i can not connect from 8883 with data included as string and converted to byte[] of certificate…

Thanks. currently I didn’t subscribe to any topics, just try to publish
Your example seems a little bit different.
I don’t find any topic like the one in your example in ThingSpeak
Instead I have a channel Called Meteo Station with a Channel ID assigned to it.
4 of the 8 fields are defined as a test

---- found — how to publish several fields

var data = “field1=84.3&field2=67.3&field3=31.8&field4=26.7&status=MQTTPUBLISH”;
client.Publish(topic, Encoding.UTF8.GetBytes(data), QoSLevel.MostOnce, false, (ushort) packetId);

with topic = channels//publish/