bluemix

Home Forums Conduit: AEP Model bluemix

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #9178
    Sean O Connell
    Participant

    Hi,

    I have a problem setting up Bluemix connection in Node red. I use sample flow provided on device HQ – temperature monitoring one. I am using conduit with one AT type node plus I have registered account on bluemix. I followed MT recipe on IBM site but it is not clear how to setup the fields on node red for connection (MQTT out box).
    Anyone have experience of this previously ?

    Thanks, Sean.

    #9183
    Brandon Bayer
    Blocked

    Sean,

    To connect to Bluemix using the MQTT node in Node-RED, you’ll need to (1) have a Bluemix account, (2) create a Bluemix app, (3) add the “Internet of Things” service to the app, (4) Launch the IoT service and add a device, (5) save the device credentials, (6) use documentation here: https://docs.internetofthings.ibmcloud.com/messaging/devices.html to configure the MQTT node in Node-RED.

    Here are some screenshots:

    Add device

    device credentials

    configure mqtt

    Does that help?

    -Brandon

    #9233
    Sean O Connell
    Participant

    Hi Brandon,

    Thanks for this reply – it seems to explain it clearly. I will try it out and let you know how I get on.
    Just one other question ; Do I need to update the nodes with any new app code for this temperature demo ? Presently, I use just one end node with std AT command firmware as in Mdot dev kit.

    Rgds, Sean.

    #9234
    Brandon Bayer
    Blocked

    Sean,

    If you are expecting to receive temperature readings, then yes, you’ll need to hook up a temperature sensor and write some code to read the temperature and transmit it.

    I’m unsure of what Node-RED flow you are using. Can you export it to the clipboard from the Node-RED menu and paste it here?

    -Brandon

    #9311
    Sean O Connell
    Participant

    Hi Brandon,
    Below is node red code used which is basically your device hq automation demo code.

    Rgds, Sean.

    [{“id”:”c429edbe.3bd61″,”type”:”mqtt-broker”,”broker”:”kv9upa.messaging.internetofthings.ibmcloud.com”,”port”:”1883″,”clientid”:”d:kv9upa:MultiTech-Conduit:MT-18325913″},{“id”:”80fb7440.7f0488″,”type”:”inject”,”name”:”Run Once At Start”,”topic”:””,”payload”:””,”payloadType”:”date”,”repeat”:””,”crontab”:””,”once”:true,”x”:157,”y”:62,”z”:”91303ddf.6ecfc”,”wires”:[[“1865eb31.e79a15”]]},{“id”:”1865eb31.e79a15″,”type”:”http request”,”name”:”Get Device ID”,”method”:”GET”,”ret”:”obj”,”url”:”http://127.0.0.1/api/system/deviceId”,”x”:342,”y”:62,”z”:”91303ddf.6ecfc”,”wires”:[[“3ce248ac.c31db8”]]},{“id”:”3ce248ac.c31db8″,”type”:”function”,”name”:”Set Global”,”func”:”context.global.deviceId = msg.payload.result;\nreturn context;”,”outputs”:1,”x”:529,”y”:62,”z”:”91303ddf.6ecfc”,”wires”:[[]]},{“id”:”5a3fd69a.a5c028″,”type”:”debug”,”name”:”RECEIVING”,”active”:false,”console”:”false”,”complete”:”payload”,”x”:585,”y”:133,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”3d612472.c29edc”,”type”:”lora out”,”name”:”lora”,”eui”:”00:80:00:00:00:00:9c:dd”,”payload”:””,”x”:570,”y”:208,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”5268f659.ad9708″,”type”:”debug”,”name”:”SENDING”,”active”:false,”console”:”false”,”complete”:”outputMessage”,”x”:577,”y”:254,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”f321fa26.0cde08″,”type”:”twitter out”,”twitter”:””,”name”:”Tweet”,”x”:563,”y”:326,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”26546c09.d9ab94″,”type”:”debug”,”name”:”Down Button Pressed”,”active”:false,”console”:”false”,”complete”:”payload”,”x”:609,”y”:364,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”fbd21338.042df”,”type”:”debug”,”name”:”Sending to the Cloud”,”active”:true,”console”:”false”,”complete”:”true”,”x”:606,”y”:493,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”b0fb8af7.4f0478″,”type”:”mqtt out”,”name”:”IBM Blue Mix”,”topic”:”iot-2/evt/status/fmt/json”,”qos”:””,”retain”:””,”broker”:”c429edbe.3bd61″,”x”:580,”y”:537,”z”:”91303ddf.6ecfc”,”wires”:[]},{“id”:”4286e993.bd7918″,”type”:”function”,”name”:”Updata data & send data”,”func”:”//Initialize the message variables.\nreceivedMessage = null;\ntransmittedMessage = null;\ndownButtonPushedMessage = null;\ncloudMessage = null;\n\n//Init variables if needed\ncontext.currentTemperature = context.currentTemperature || 0;\ncontext.setPoint = context.setPoint || 0\ncontext.isAlarm = context.isAlarm || 0;\ncontext.downButtonPresses = context.downButtonPresses || 0;\ncontext.cloudUploadTime = context.cloudUploadTime || new Date();\n\n//Receiving temp data\nif (msg.payload.length > 1) {\n\t\n\tvar rawMessage = msg.payload.split(‘,’);\n\tvar oldSetPoint = context.setPoint;\n\tvar oldTemperature = context.currentTemperature;\n\tvar oldAlarm = context.isAlarm;\n\tvar currentTime = new Date();\n\t\n\t//Get the current temperature and set point from the incoming message.\n\tcontext.currentTemperature = parseInt(rawMessage[0].split(‘ ‘)[1]);\n\tcontext.setPoint = parseInt(rawMessage[1].split(‘ ‘)[1]);\n\n\t// Was the down button pushed?\t\n\tif (oldSetPoint > context.setPoint) {\n\t\tcontext.downButtonPresses++;\n\t\tdownButtonPushedMessage = {};\n\t\tdownButtonPushedMessage.payload = \”Down Button Has Been Pushed \” + context.downButtonPresses + \” Times. New Set Point = \” + context.setPoint;\n\t}\n\t\n\t// Check to see if the alarm should be set\n\tif (context.currentTemperature > context.setPoint) {\n\t context.isAlarm = 1;\n\t}\n\telse {\n\t context.isAlarm = 0;\n\t}\n\t\n\t//See if this should be uploaded to the cloud\n\t\n\t// Always upload if the alarm condition has changed.\n\tif (oldAlarm != context.isAlarm) {\n\t\n\t\t// Set the upload time\n\t\tcontext.cloudUploadTime = new Date();\n\t\t\n\t\t//Copy the pertinent details to the output message. \n\t cloudMessage = {};\n\t cloudMessage.deviceId = context.global.deviceId;\n\t cloudMessage.temperature = context.currentTemperature;\n\t cloudMessage.alarm = context.isAlarm;\n\t cloudMessage.setPoint = context.setPoint;\t\n\t cloudMessage.reason = \”Alarm Changed\”;\n\t cloudMessage.payload = \”{\\\”deviceID\\\”: \” + context.global.deviceId + \”, \\\”temperature\\\”: \” + context.currentTemperature + \”, \\\”setPoint\\\”: \” + context.setPoint + \”, \\\”alarm\\\”: \” + context.isAlarm + \”}\”;\n\t}\n\t\t\n\t// Upload if it has been at least 2 minute since the last upload\n\tif ((currentTime – context.cloudUploadTime) > (1000 * 60 * 2)){\n\n\t\t// Set the upload time\n\t\tcontext.cloudUploadTime = new Date();\n\t\t\n\t\t//Copy the pertinent details to the output message. \n\t cloudMessage = {};\n\t cloudMessage.deviceId = context.global.deviceId;\n\t cloudMessage.temperature = context.currentTemperature;\n\t cloudMessage.alarm = context.isAlarm;\n\t cloudMessage.setPoint = context.setPoint;\n\t cloudMessage.reason = \”Periodic Upload:\”;\n\t cloudMessage.payload = \”{\\\”deviceID\\\”: \” + context.global.deviceId + \”, \\\”temperature\\\”: \” + context.currentTemperature + \”, \\\”setPoint\\\”: \” + context.setPoint + \”, \\\”alarm\\\”: \” + context.isAlarm + \”}\”;\n\t}\n\t// Create a nice message to send to the debug node\n\tmsg.payload = \”TX: Temp: \” + context.currentTemperature + \”, Set: \” + context.setPoint + \”, Alarm: \” + context.isAlarm;\n\t\n\t// Set the received message so it can be sent to the correct output node.\n\treceivedMessage = msg;\n}\n\n//Receiving empty packet from receiving mdot -> send data\nelse {\n\n\t// Set the Eui\n\tmsg.mdotDeviceEui = msg.eui;\n\t\n\t// Create a message to be sent to the receiving unit. Each number is separated by a space\n\tmsg.payload = context.currentTemperature + \” \” + context.setPoint + \” \” + context.isAlarm;\n\t\n\t// Create a nice message to display in the debug node.\n\tmsg.outputMessage = \”RX: Temp: \” + context.currentTemperature + \”, Set: \” + context.setPoint + \”, Alarm: \” + context.isAlarm;\n\n\t// Set the transmittedMessage to the messsage so it can be sent to the correct output node.\n\ttransmittedMessage = msg;\n}\n\n\n// Return an array of the messages. The array matches with the output nodes.\n// The first element of the array is sent out of the top output node. The\n// last element of the array is sent to the bottom output node.\nreturn [receivedMessage, transmittedMessage, downButtonPushedMessage, cloudMessage];\n”,”outputs”:”4″,”x”:316,”y”:260,”z”:”91303ddf.6ecfc”,”wires”:[[“5a3fd69a.a5c028”],[“3d612472.c29edc”,”5268f659.ad9708″],[“26546c09.d9ab94″,”f321fa26.0cde08”],[“b0fb8af7.4f0478″,”fbd21338.042df”]]},{“id”:”eafd9e43.15026″,”type”:”lora in”,”name”:”lora”,”datatype”:”utf8″,”x”:105,”y”:260,”z”:”91303ddf.6ecfc”,”wires”:[[“4286e993.bd7918”]]}]

    #9313
    Brandon Bayer
    Blocked

    Sean,

    I can’t import that flow into Node-RED because I get a syntax error. Could you try exporting again?

    (Try to import it yourself to make sure the import works)

    -Brandon

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.