# How to MQTT image from Raspi using Base64 and Template node

**URL:** <https://discourse.nodered.org/t/how-to-mqtt-image-from-raspi-using-base64-and-template-node/42142>\
**Category:** Dashboard\
**Created:** [6 March 2021 10:46 UTC](https://discourse.nodered.org/t/how-to-mqtt-image-from-raspi-using-base64-and-template-node/42142 "2021-03-06T10:46:16Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 March 2021 19:51 UTC](https://discourse.nodered.org/t/how-to-mqtt-image-from-raspi-using-base64-and-template-node/42142/4 "2021-03-08T19:51:06Z")

</div>

> [@Reyner](#):
>
> I will use the correct format in my next post

Almost - you need the backticks above and below (on their own lines) (I'll edit it again)

  
  

> [@Reyner](#):
>
> Thankyou for your response but I'm not trying to send an email using MQTT

I never said you were. I said ...

> [@Steve-Mcl](#):
>
> so that flow looks like it sends an email not pass data over MQTT

And I said that because you posted the following flow...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b5d20fc5e2efc50e1be4fdd52c1d6d99fc811d26.png)

  
  

* * *
  

Anyhow, onto your issues...

  

> [@Reyner](#):
>
> I am trying to display the image in my NR dashboard installed in IBM Cloud. But right now it is not working. The image taken only displayed in the local NR dashboard and not in the NR dashboard installed in IBM Cloud.

there were a couple of things wrong. As I dont run an IBM Cloud instance, I have tweaked things around to get it working on a PI...

flow...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4fd04f0d43e1c74b3085ededab6a074adfc84f0b.jpeg)

dashboard...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/e/3e9ef108517731a0a04c901ccd337d6be959959b.jpeg)

demo flow...

```auto
[{"id":"ed24352e.c554d8","type":"image viewer","z":"c966426a.35dc8","name":"","width":"140","data":"payload","dataType":"msg","x":1042,"y":768,"wires":[["3eed774d.91df08"]]},{"id":"e56b6718.c5d278","type":"ui_button","z":"c966426a.35dc8","name":"","group":"2a53ae0e.c22ef2","order":2,"width":0,"height":0,"passthru":false,"label":"Take Photo","tooltip":"","color":"","bgcolor":"","icon":"fa-camera-retro","payload":"","payloadType":"str","topic":"","x":1030,"y":224,"wires":[["44d58bbc.3abd14"]]},{"id":"44d58bbc.3abd14","type":"mqtt out","z":"c966426a.35dc8","name":"","topic":"myapp/control/take_photo","qos":"","retain":"","broker":"933bb4dd.225038","x":1438,"y":224,"wires":[]},{"id":"bc86bdb1.303a","type":"mqtt in","z":"c966426a.35dc8","name":"","topic":"myapp/response/photo","qos":"2","datatype":"auto","broker":"933bb4dd.225038","x":1060,"y":288,"wires":[["15d91d02.fed173","1b1a0556.14207b","19380c57.bd1cc4"]]},{"id":"3f79f384.ec8dfc","type":"ui_button","z":"c966426a.35dc8","name":"","group":"f80260c9.08249","order":2,"width":0,"height":0,"passthru":false,"label":"Take Photo","tooltip":"","color":"","bgcolor":"","icon":"fa-camera-retro","payload":"","payloadType":"str","topic":"","x":1030,"y":656,"wires":[["4fbf613a.54b1e"]]},{"id":"c9d1b497.260c58","type":"file in","z":"c966426a.35dc8","name":"","filename":"/home/pi/Pictures/photo1.JPEG","format":"","chunk":false,"sendError":false,"encoding":"none","x":1282,"y":704,"wires":[["2dbac17c.9187ee"]]},{"id":"254d0583.26b7ca","type":"inject","z":"c966426a.35dc8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1020,"y":704,"wires":[["c9d1b497.260c58"]]},{"id":"de31de65.7c008","type":"mqtt in","z":"c966426a.35dc8","name":"","topic":"myapp/control/take_photo","qos":"2","datatype":"auto","broker":"933bb4dd.225038","x":1070,"y":608,"wires":[["4fbf613a.54b1e"]]},{"id":"5c725d4e.c183e4","type":"mqtt out","z":"c966426a.35dc8","name":"","topic":"myapp/response/photo","qos":"","retain":"","broker":"933bb4dd.225038","x":1764,"y":704,"wires":[]},{"id":"ebaed7.94117128","type":"comment","z":"c966426a.35dc8","name":"IBM Cloud end","info":"","x":1040,"y":184,"wires":[]},{"id":"70abc57e.d9041c","type":"comment","z":"c966426a.35dc8","name":"Local end","info":"","x":1020,"y":560,"wires":[]},{"id":"15d91d02.fed173","type":"debug","z":"c966426a.35dc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1126,"y":336,"wires":[]},{"id":"1b1a0556.14207b","type":"image viewer","z":"c966426a.35dc8","name":"","width":"140","data":"payload","dataType":"msg","x":1490,"y":336,"wires":[[]]},{"id":"4fbf613a.54b1e","type":"camerapi-takephoto","z":"c966426a.35dc8","filemode":"0","filename":"photo1.JPEG","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"1","rotation":"0","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"","x":1328,"y":656,"wires":[["2dbac17c.9187ee"]]},{"id":"2dbac17c.9187ee","type":"base64","z":"c966426a.35dc8","name":"","action":"str","property":"payload","x":1532,"y":704,"wires":[["5c725d4e.c183e4","ed24352e.c554d8","17502aa4.5e01f5"]]},{"id":"17502aa4.5e01f5","type":"debug","z":"c966426a.35dc8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1798,"y":752,"wires":[]},{"id":"19380c57.bd1cc4","type":"template","z":"c966426a.35dc8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img height=\"320px\" src=\"data:image/jpg;base64,{{{payload}}}\">","output":"str","x":1340,"y":288,"wires":[["81bd5139.448d1"]]},{"id":"81bd5139.448d1","type":"ui_template","z":"c966426a.35dc8","group":"2a53ae0e.c22ef2","name":"","order":0,"width":"6","height":"7","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":1484,"y":288,"wires":[[]]},{"id":"3eed774d.91df08","type":"template","z":"c966426a.35dc8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<img height=\"320px\" src=\"data:image/jpg;base64,{{{payload}}}\">","output":"str","x":1196,"y":768,"wires":[["ea3320aa.dc7fd"]]},{"id":"ea3320aa.dc7fd","type":"ui_template","z":"c966426a.35dc8","group":"f80260c9.08249","name":"","order":0,"width":"6","height":"7","format":"<div ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":1356,"y":768,"wires":[[]]},{"id":"2a53ae0e.c22ef2","type":"ui_group","name":"IBM Cloud","tab":"eb34fe8.0da08","order":2,"disp":true,"width":"6","collapse":false},{"id":"933bb4dd.225038","type":"mqtt-broker","name":"","broker":"test.mosquitto.org","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"f80260c9.08249","type":"ui_group","name":"Local","tab":"eb34fe8.0da08","order":1,"disp":true,"width":"6","collapse":false},{"id":"eb34fe8.0da08","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]

```

---

_[View the full topic](https://discourse.nodered.org/t/how-to-mqtt-image-from-raspi-using-base64-and-template-node/42142)._
