Receive image from mqtt

963 views
Skip to first unread message

Giovanni Guliano

unread,
Jan 23, 2018, 7:52:55 AM1/23/18
to Node-RED
guys, currently im working on sending image from arduino to server (node-red) via MQTT protocol.

from aduino (using vc0706 camera) i can send multiple part of image data to mqtt broker.

my question is how can i save image from multipart data in node-red?
i tried using save file node but can't get the picture.

erwin....@gmail.com

unread,
Jan 24, 2018, 4:57:23 AM1/24/18
to Node-RED
Hi,

if I understand your problem correctly, you are sending an image via the MQTT protocol to your node-red server. This image (one single image) is split into different parts. Each part is sent via a separate message on a certain topic via MQTT.

In node-red, you have already figured out how to receive messages on a certain topic via MQTT. You still have to combine the individual messages (parts of the image) to one single image to form a complete image.
You can combine multiple parts with the join-node, you have different criteria for joining. So you have to figure out what are the best criteria in your case. Also be aware of what you would want to happen is one part of the image does not arrive. That can make it very complex.

Maybe you can share your flow and the debug output? Have you wired a debug node (to display the whole message) to the output of the node that feeds the save file node? So you can see what you are actually sending to that node?

Is it not possible to send the whole image in one message? This would make it a lot easier...

Op dinsdag 23 januari 2018 13:52:55 UTC+1 schreef Giovanni Guliano:

Giovanni Guliano

unread,
Jan 24, 2018, 6:06:11 AM1/24/18
to Node-RED
i think it's not possible to send the whole image in one message because arduino's memory limit.
i tried using python script (bytearray) and i can save the image perfectly in node-red maybe because it send the image in one message.


this is my flow:

[{"id":"c7b1fa7.7166508","type":"debug","z":"d6daadd.b7d105","name":"tes2","active":true,"console":"false","complete":"payload","x":462,"y":143,"wires":[]},{"id":"adc0a2df.8b814","type":"mqtt in","z":"d6daadd.b7d105","name":"","topic":"fc/ta/single/image","qos":"0","broker":"ed749e7a.9705","x":148.42859649658203,"y":230.14285278320312,"wires":[["e4ef6a24.d168f8","79de1a49.72fc44","67c8c0bc.579b9","e8ceecd1.09698","a3a51a51.7a5db8","9e328a2f.5f91a8"]]},{"id":"a7237c2b.252b2","type":"file","z":"d6daadd.b7d105","name":"","filename":"C:\\Users\\Opanepan\\Desktop\\TA\\image_processing\\pic.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":597.7142944335938,"y":183.8570556640625,"wires":[]},{"id":"5c1f67c2.b3b878","type":"comment","z":"d6daadd.b7d105","name":"save file (image) to storage","info":"","x":124.4285888671875,"y":202.142822265625,"wires":[]},{"id":"e4ef6a24.d168f8","type":"debug","z":"d6daadd.b7d105","name":"tes1","active":true,"console":"false","complete":"payload","x":158.4285888671875,"y":113.99993896484375,"wires":[]},{"id":"b6f0e21a.0973d","type":"inject","z":"d6daadd.b7d105","name":"","topic":"data","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"x":120.4285888671875,"y":155.99993896484375,"wires":[[]]},{"id":"79de1a49.72fc44","type":"merge","z":"d6daadd.b7d105","name":"","timeout":"10","x":312.4285888671875,"y":182.99993896484375,"wires":[["c7b1fa7.7166508","a7237c2b.252b2"]]},{"id":"67c8c0bc.579b9","type":"join","z":"d6daadd.b7d105","name":"join merge","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"10","count":"","x":327.4285888671875,"y":232.99993896484375,"wires":[["a49c94f2.6b7068","b1e4291a.f0dbe8"]]},{"id":"a49c94f2.6b7068","type":"file","z":"d6daadd.b7d105","name":"","filename":"C:\\Users\\Opanepan\\Desktop\\TA\\image_processing\\pic1.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":651.4285888671875,"y":242.99993896484375,"wires":[]},{"id":"b1e4291a.f0dbe8","type":"debug","z":"d6daadd.b7d105","name":"tes3","active":true,"console":"false","complete":"payload","x":597.4285888671875,"y":220.99993896484375,"wires":[]},{"id":"e8ceecd1.09698","type":"join","z":"d6daadd.b7d105","name":"join buffer","mode":"custom","build":"buffer","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"bin","accumulate":false,"timeout":"10","count":"","x":323.4285888671875,"y":268.99993896484375,"wires":[["33f98f02.cd6ad"]]},{"id":"a3a51a51.7a5db8","type":"join","z":"d6daadd.b7d105","name":"join string","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"10","count":"","x":321,"y":307,"wires":[["736ecfbd.8ed79"]]},{"id":"33f98f02.cd6ad","type":"file","z":"d6daadd.b7d105","name":"","filename":"C:\\Users\\Opanepan\\Desktop\\TA\\image_processing\\pic2.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":646,"y":283,"wires":[]},{"id":"736ecfbd.8ed79","type":"file","z":"d6daadd.b7d105","name":"","filename":"C:\\Users\\Opanepan\\Desktop\\TA\\image_processing\\pic3.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":649,"y":324,"wires":[]},{"id":"9e328a2f.5f91a8","type":"join","z":"d6daadd.b7d105","name":"join auto","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"10","count":"","x":315,"y":348,"wires":[["bca5f6d7.0125a8"]]},{"id":"bca5f6d7.0125a8","type":"file","z":"d6daadd.b7d105","name":"","filename":"C:\\Users\\Opanepan\\Desktop\\TA\\image_processing\\pic4.jpg","appendNewline":false,"createDir":false,"overwriteFile":"true","x":642,"y":370,"wires":[]},{"id":"ed749e7a.9705","type":"mqtt-broker","z":"","broker":"m13.cloudmqtt.com","port":"12110","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Reply all
Reply to author
Forward
0 new messages