Connect sensor with azure iot hub


hi all,

I am trying to connect rpi ds18b20 with azure iot hub, but the iot hub is disconnected all the time even I entered the host name. here, I am trying with real sensor , it is not simulated. could you help me to know where is the problem, please?
I installed node-red in raspberry pi 3 modle b+ , with raspbian
node-red version V0.19.3
node.js version v8.11.1




Have you looked at the log file to see if any errors are listed?



Sorry, do you mean node-red console? or there is another log.



Well you could check the console or look at the historical log data using the command node-red-log



ok. sorry I am new with node-red. I found this in console

Connection string :HostName=HostName=c......;DeviceId=undefined;SharedAccessKey=undefined

12 Oct 06:26:09 - [error] [azureiothub:Azure IoT Hub] Could not connect: connect ENOENT /=[c,,,,,,,,](

I didn't define this in node red as I do not know where can I enter this information? I just put the host name in azure iot hub node?



If you haven’t read it the page dedicated to the raspberry pi in the docs is worth a read.

I’ve never used that node (if you are using a specific node it’s worth stating that in your initial post in future). But there is a initial flow in the nodes readme, so I would suggest trying to get their example to work and if you can’t come back here.



It looks like you haven't completed the setup of the Azure hub. I've not used it myself but I'm guessing that it uses an OAuth authentication that requires setup firstly in the hub itself. That should give you an access key and possibly the other settings you are missing above (DeviceId for example). It may also require you to define the URL that the authentication service will hand control back to. Likely to be the URL for Node-RED.



thanks guys

it is working now, the problem was " "
I should write the connection string between " "

but after that I have encountered new problem ...
sometimes the device send data to cloud, other times it shows error message...

"Error while trying to send message : not connected error: connect ECONNREFUSED "node-red ip: port"



Are you on an enterprise network? If so, I'd say that their security services and routing is slowing down your connection. It may be that the latency is sometimes a little too high.

1 Like


I am using the university network and connect to azure iot hub from my university account ... I think the problem as you said