Particle Photon + Azure IoT Hub + Stream Analytics

I am having a very annoying problem, which i cannot see to find out why it occurs. I use Particle Photon to publish data to Azure IoT Hub. I then use Stream Analytics to get the inputStream and output it to a database. I use the database to expose data to my webapi so i can create a nice webview with angularJS.

Its working for some messages, but after 8 messages i get this message:

Encountered error trying to write 1 event(s): Cannot convert from property ‘temperature’ of type ‘System.String’ to column ‘temperature’ of type ‘System.Double’

My question is… why is the first messeges going through and suddenly after a while my temperature gets converted to a string?

Here are the latest 10 readings: (this is outputed from stream analytics to DB)

How quickly are you sending data to the IOT Hub? I know there is a limit per min or something like that.

@dave May be able to help out.

Also have you checked out Microsoft Power BI for visualizing the data you have in the database now? It’s pretty sweet.

1 Like

I was first sending every 3 seconds, but that made it crash. Now i send it every 2 minutes, but still after 7-8 readings it gets output error. I believe this has more something to do with stream analytics and how i manipulate my data.

Hmm, my guess is that it’s not the string->double conversion, but that something is putting a non-numeric string in your temperature field. Any chance you can log out the raw value when that exception gets thrown?

1 Like

Hmmm no… but seems like its working again now… magically o.o

But i noticed that when the warning occured my data was outputting nothing. Comparing with particle console and stream analytics in my particle console, the data gets published, but my stream analytics somehow are having troubles with outputting the inputstream from IoT Hub.

1 Like

interesting! So the data is getting to iot hub fine, but stream analytics is having an issue? We can ping the Microsoft folks and see if they have an issue on their end. If you had some specific dates / times, and specific stream jobs / iot hub IDs and other info, that would probably help their team see what’s going on.


1 Like

I am sorry! I see now that the input is getting no content. This is from Particle console.

But it looks like it stopped sending content for about an hour ago. So its back to the same problem again :frowning:

Hi @hoaben13,

It looks like your data string doesn’t quite parse as json, you’re missing quotes around the room for the “loc” property, it should be:

#currently is
\"loc\": room_23

#should be
\"loc\": \"room_23\"

I suspect that’ll help! :slight_smile:



I notice that the data field contains escaped double quotes. These slashes should not be here in the message, the JSON format does not expect that the quotes of the string themselves are escaped. Only characters within strings can be escaped.

See also this thread: How to pass unescaped JSON to Azure IoTHub?

Hi @svelde,

The JSON object encoded as a string is evaluated on its way through the webhook. So in this case the escaped quotes are necessary

"{ \"property\": 123 }"

becomes ->

{ "property": 123 }

etc, etc.


Hello @Dave,

Thanks for your response.

As seen in this thread I finally managed to get it working, thanks to the enhanced JSON. There is still a question left in that thread, the enhanced JSON does not accept values without quotes. So all values are strings in the end. Please check it out, thanks again!