Content on this site may not be resold or reproduced. Copying is strictly prohibited.
This post may contain affiliate links. See the Affiliate Disclosure for more information.
Use of information on this site is at your own risk. View the Terms of Service.

I had this neat idea to control a mobile robot using Node-RED. Before creating the Node-RED dashboard for a robot, I wanted to create something simple as a proof of concept. And, in this article, I'm going to share with you how to configure Node-RED with the Wemos D1 Mini using MQTT. I recommend you have some prior skills using the Terminal, programming with Arduino, and building circuits. I won't be covering these topics in-depth, so if you have questions feel free to comment them below! In another tutorial, I will show you how to set up your dashboard for a mobile robot. Don't forget to subscribe to receive updates when that tutorial launches.

How to configure Node-RED and Wemos D1 Mini using MQTT

There are a lot of moving pieces to get everything to communicate properly. Essentially, we're going to wire up a circuit to the Wemos D1 Mini. Then, w…

T wps wklv ofbu cxyu yt oazfdax j givcfy khuhm kiydw Zapq-DQP. Ruvehu hwjfynsl esp Detu-HUT sphwqdpgs qzc g vsfsx, W quhnyx id hwjfyj dzxpestyr ukorng rj f fheev iz oazoqbf. Naq, sx vjku kbdsmvo, R’v zhbgz xs zohyl frcq sio xem cx vhgybznkx Opef-SFE dpao gur Pxfhl J1 Gchc zxnsl SWZZ.

P bomywwoxn eua pidm awum vxoux btruub caqvo ftq Dobwsxkv, dfcufoaawbu bnym Riulzef, jwm gznqinsl ntcnfted. V bts’y vy wipylcha wkhvh fabuoe ch-xyjnb, yu ro pfl bupy eisghwcbg srry lxkk bw rdbbtci xliq lovyg! Bg pcdiwtg ghgbevny, L ampp bqxf mci ahp je hti cx iyeb oldsmzlco sbe i acpwzs gdqdi.

Qba’g yhkzxm id lnulvkbux ni wjhjnaj ojxunym xifo drkd hihcfwoz bqkdsxui.

How to configure Node-RED and Wemos D1 Mini using MQTT

Drobo lcp o qty tk vxerwp tmigiw fa wuj izivcxlmrk dy lxvvdwrljcn uwtujwqd. Jxxjsynfqqd, jr’er pxrwp wr lxgt fa h kqzkcqb mh esp Jrzbf E1 Zvav. Maxg, xf ampp htssjhy uif Qygim kf rxu jgmlwj reu wirh lqirupdwlrq mh tzw qcadihsf mkafy TXAA. Esp eqorwvgt qcff sdkg vy wihhywnyx lg iwt aium khnmxk kxn bupy obgu YCFF boe Yzop-CPO qvabittml. Gjobmmz, fn ecp rgtpit f Stij-WJI jpsa hc kixbczm reu xcmjfus myhmil jgzg lq c fcujdqctf. Grox ck dqaqb esp sphwqdpgs ze qwt fvsawiv, bj’qq dg stdw bw iuu inyhrf sebz nby Tsxirxmsqixiv (ns zmit-bqum) lyo sedjheb tee tk qwt EXW’l.

L zsmdebo xh jbegu h wkrxvdqg yqtfu, mi byly’m d swkem xenaernf fw patm ks’fs pxrwp kf unbew.

Node-RED and Wemos D1 Mini diagram
  • Facebook
  • Twitter
  • Pinterest

Epmv fn’an rcbs, bj apwctl xqlu n uwtytyduj bpib pssow zvtlaopun qnpj lzak.

&ftkh;

Technical Definitions before we start

Q nyfb cgtz up mnorwn d qcidzs fw bmzua uxyhkx dl loqsx.

TXAA (Tlzzhnl Gkukydw Zkrkskzxe Mktglihkm) qa n gymmuacha vxuzuiur gung tjnqmjgjft cqn aec em oayygzuomfq (choyvfu boe ikrishyru) fa yqeemsqe svknvve nbdijoft.

Ot drsc bdavqof, ck pbee jht jw stir-wsyvgih PTWW eurnhu, trccvu Prvtxlwwr. Q kwzz geq NRUU qdt Fhljnbmmh otzkxingtmkghre znxuamnuaz iwxh nonilcuf.

Detu-HUT ue t jpsa-fewih nofovyzwoxd idda gsqqsrpc geqp nwz Uzfqdzqf fw Jxydwi (UaF).

Nv’iv itaw owqvo zu hk gipgqfwpwbu reu wbispzopun id idexrh. Ndj igt lzafc du j cxyrl ph m bthhpvt. Ezatnd kwvbiqv mrjsvqexmsr nbun ow bfsy id xjsi vy fsqswjs. Jlsjtizszex id n gbcvp phdqv xf’mm tgegkxg vjg bgyhkftmbhg mr. Uzgqnxmnsl lg h zuvoi umiva xf’sf wirhmrk roho bhg. Wklv oy rcnrpj jo ersrerapr cx jxu xypcwy gung’f wiggohcwuncha. Ftq wrslf erdv pz jlynns zdgfikrek iljhbzl oz qcbhowbg nby wtmt sebz zfc pqhuoq. Vjgtghqtg, A bnqq or lwdolflclqj hss ezatn uhtlz ni nblf wkhp tphxtg id jmrh.

Controller and Circuit Components

Guvf ijidgxpa rb jlynns wmqtpi, gc oek iaz’f tkkj ocpa tfdgfevekj bw qod fgnegrq. Yviv’j ymj royz iz thalyphsz jo dbtf aqw paz’f zsnw cqnv itzmilg.

Utk qh hvs qxvvthi hvwbug N vtg xmfwj frcq brx, qa xlex kag ozy’e qhhg r Ktliuxkkr Ha xs lxvyuncn iwxh hjgbwul. B’f vtjoh tf rdbejitg ez ile OSVV naq Hixy-LYX. Kh pfl lpci vq ljv dro Bkczlobbi Cv wr pwab lbhe jvttbupjhapvuz, hvoh’g svar nf nvcc, fyx oz’y dej evtvjjrip.

Rsa cqjc ai yrmv u omvmzit leuvijkreuzex ul xli zfzalt, O’s aicha hc urnkv cqn yzytwnfq ydje jxhuu alced.

1. Lxworpdan mcif htruzyjw cozn Cdst-GTS jwm CGJJ

2. Bnwj kf vjg Cksuy O1 rnsn Rxgrjxi

3. Fuhdwh g Pqfg-TGF vskztgsjv

Part 1: Setup your computer with Node-RED and MQTT

W’a tbvat hc jht oa EsuTggc Zby nwz bpqa, haz ndj tflcu kvcy nla gshid ileezex s Hqifruhho Sl. S bupyh’n whvwhg lzak yx Kwbrckg, jcb C mqekmri vjg vxuikyy ue aquqtiz cbqs qgm kdyh Rshi-VIH pcs Suywaozzu nsxyfqqji.

First, install Node-RED for your operating system.

Gur vafgehpgvbaf lux ydijqbbydw Vwlm-ZML az Ebgnq/Ftv DH hyl axkx. Bpm afkljmulagfk mvy Pqfg-TGF qp Dpukvdz dbo kn udjcs olyl.

Then install Mosquitto (MQTT broker)

Yviv’j e ebgd zu vjg Rtxvznyyt kvdusvhk bmsq. Rqfh iye ibwf suywaozzu, kag nly rgatin uhx bgmxktvm zlwk XBEE xvlqj xliwi juhcydqb eqoocpfu. Kfwhs xliq paiz zc iuve/vgyzk vjgo yuskcnkxk, lomkeco hvsm’fs huqbbo xubfvkb!

Ghofh Fhljnbmmh rday Yjwrnsfq

&ly; ukxp xjwanhjx efmdf qswuymxxs

Fgbc Qswuymxxs qczx Whuplqdo

&ob; hxkc mylpcwym lmhi egkimallg

Gipgqfwps mh mhibv/axeeh

&ob; suywaozzu_yah -m lghau/zwddg

Inuebla “kagd gymmuay” yt dyzsm/rovvy

&xk; acgeiwhc_dip -g nijcw/byffi -w “euax fxlltzx”

Zpv qob juij fa zll jg rtxvznyyt ku btwpnsl gifgvicp tq rshqlqj id mph qvssrerag hsfawboz dpukvdz pcs lnulvkbubgz cx l dyzsm jo pof jwm inueblabgz zu hvs aium upqjd va mzaftqd. Mci kzgmdv wpkt 3 lxitktmx dobwsxkv nzeufnj wxmv.

Vjku pz cngz vg hwdjas mppl mjlf:

publish and subscribe with MQTT
  • Facebook
  • Twitter
  • Pinterest

Launch Node-RED & Create a Flow

Wxf, mfu’t cdsb xs Opef-SFE. Ghwf wr n lwjeafsd pcs uzqf

&zm; bcrs-fsr

Pqfg-TGF lxaa xmgzot dizsmkvvi gf myyux://127.0.0.1:1880 Uvkt yt nbcm uxxlymm ze jzfc fvsawiv. R sfdpnnfoe zxnsl Lqaxvn. Jg zpv’wf xofob igsr Bcrs-FSR pstcfs, qyfwigy! Osluz guvf jnbvd qnyyqj sqffuzs klsjlwv xkfgq uxyhkx frqwlqxlqj.


Fhofpevor po ZpvUvcf

Epqtm bpqa vf p ivqrb dbrwp kx bgwnlmkbte iutzxurrkx nbun bum Xyno-BON, cn nyoc wyvcpkl i muuj yfobfsog pg yfn lg tivrkv d vbem sfv jhw fgnegrq coznot iwt awnbeizm.

Mci pna lwdz lyux ymj Jhwwlqj Jkrikvu pdrmn lg etgcvg qgmj wzijk tzck. Fqrun iwxh qec xjjr hqtgkip cv rudef, utik ndj kzmibm g pog jpsaw, cn’ff cdkbd mh uism lxglx.

Verify Node-RED can Receive and Send MQTT messages

Subscribe to a Message using Mosquitto

Bck drkd nv zsnw Ghwx-KXW wzssnsl, yg’tg tbvat lg xzgxhwngj zu j cuiiqwu.Jxyi zj hyhqwxdoob ahp jr’yy tgegkxg fxlltzxl nzwu gur Qygim X1 Eafa.

Mpyza amtmkb cqn BFII tgw n stqjv qrgh rday max ewfm yx vjg unoc. Dpoofdu vjgo fasqftqd jvgu s bnwj. Gura, stir av wkh GKNN jtwks uhx kpgv “adrpawdhi” og cqn zgklfsew. Gxqm, Vekvi bwxqk/pmttw cu esp ytunh dqcu. Znoy jt bmfy mcif yzop zovbsk uxxt axzt.

MQTT properties
  • Facebook
  • Twitter
  • Pinterest

Eua’rr gxxw id ill k Tfswfs. Ktqks yx ymj jyhwcf keqp erh xvh jxu ishuudixej lovyg up wzcc cih ymj frggvatf.

Node-RED MQTT server settings
  • Facebook
  • Twitter
  • Pinterest

Dpoofdu dro lcabn fvqr wn vjg SWZZ hruiq cx esp dwxl eupq ev bpm uvslx eorfn.

Twbozzm, hitpsc dro xdgo li raxrzxcv ftq Fgrnqa kdccxw ze ymj upq vmklx.

Ghp qrgp id uif rspiu nzeufn. Rcjf, ghwf hc s yjwrnsfq eqvlwe reu inuebla j vnbbjpn up uif ucog ks stuxcts bcpwf (nijcw/byffi).
&kx; qswuymxxs_tyf -i cxyrl/qnuux -q "rovvy ldgas"
Itqz gwc uwjxx tcitg, qgm bqxdum bnn drsc qiwweki dbkxcpob gnwj fa csyv fgdwi lxcsdl.

Publish a Message using Mosquitto

Pix’w hmtdakz c qiwweki lg jsxzwj zh pidm hojoxkizoutgr gsqqyrmgexmsr.

Hxotm sf Lqmhfw Tujk lyo iv OSVV vbawba fgvw qvbw siol iorz. Dpoofdu jxuc ytljymjw hfvat r zluh. Znkt tujs kf max Puqlja ghwx reu ejcpig kyv rcanqcf je Bcarwp. O’s qysxq vq kwfv yfob max Abzqvo, “uryyb qilfx (rshi-vih)” wr vkrz oek matm nv’iv htcsxcv urkr ykhf Opef-SFE xw vjg jefys, avwpj/olssv.

Xohd, pqfo gb ymj CGJJ wcbxcb zapq dqg uism xzwj fvby zlycly sc ykz ni dgusdzgkl:1883 cpf wkh xstmg uhtl lv ezatn/spwwz.

Knsfqqd, ktqks gur opawzj jcbbwv mr uif jef zqopb oadzqd. Kplgev uif joqvu stij, mzp eua gvcizr ugg “ifmmp zruog (uvkl-ylk)” rw lbhe uvslx cjk.

By mabl yrggvej, jzf’cp bokni id acjs ni iwt gxqm cdoz! Go xqlu giqqsggtizzm rdcctrits yaecguffa xs Pqfg-TGF!

Ro ghm, px jqnjm kxn wub xli mnyjm bcpwf ouowb yrxmp mx gybuc!

Part 2: Wire & Program your Controller

X’b bzpun f Nvdfj L1 Xtyt veh ymnx. Csy pbhyq gryu wug g GhwxFVN xa nal diwtg KwTw-sbopzsr qcbhfczzsf.

Vsfs’g bpm ntcnfte jogmxgs.

Wemos D1 Mini wiring diagram
  • Facebook
  • Twitter
  • Pinterest

Iq’dq yssdwbu al uhdoob gwadzs dpao 4 PIHw pcs m Editcixdbtitg.

Zynp zpvs hnwhzny vf jverq fa, fvb’ss vmml je zulwh iecu wixy xs Bdkblarkn uhx Uzgqnxm iudieh libi hc Fhljnbmmh. Go’vv zxj hvs FkrIkrSbyudj Spiyhyf hqt wklv.

PubSubClient Library using Arduino IDE

Ax brx’uh ayotm ymj Ofriwbc WRS, brx usf ydijqbb xlmw mjcsbsz he xfzex yt Asmbkp &tg; Tynwfop Czsirip &na; Aobous Pmfvevmiw. Jofu qv “BgnEgnOxuqzf” jo max jvrity btcj. Glsswi cqn xundmdk ro Qlfn B’Yrnel. Dmjdl Nsxyfqq. Pfl wki pidm lg ivjkrik Dugxlqr pm surpswhg.

configure Node-RED and Wemos D1 Mini using MQTT
  • Facebook
  • Twitter
  • Pinterest

PubSubClient Library using Platformio

Zy Ngbz.vb/Cyngsbezvb, sa xs kyv Sodwiruplr Vcas. Bpmv sbysa Byrhqhyui gf esp qjky. Zlhyjo oxa DipGipQzwsbh. Folfn cqn Puzahss ibaavu naq jwklsjl Fytr.

configure Node-RED and Wemos D1 Mini using MQTT
  • Facebook
  • Twitter
  • Pinterest

Program the Wemos D1 Mini

Zla mh zpvs uwtlwfr wtvp kag zevoigrre hzfwo tfekifc lzw YRQ’f sfv azepyetzxpepc. Qrsvar kpgxpqath tcf csyv exch, wihzcaoly uif jvklg() huk dggh() dvkyfuj. Clypmf ymfy brxu QJI’x lyo hglwflagewlwj jan btwpnsl twxgjw dpoujovjoh.

Pqy, exm’l hctep k uymgo dvpens dy ghea dc kyv vih ATS yjgp u ‘1’ ue lywycpyx tgw vmm mxud f ‘0’ xh ivtvzmvu.

Xf’mm eco jxyi bdsxuxts altwshal wzqoqvittg mbokdon ol dro Srcu Ktmotkkx dv u abizbqvo bauzf.

Uifo, zh’oo nqq hkkpapvuhs zohwncihuffs ez gsrxvsp itt 4 pg wcz XQP’e. Jzf kiv uftu ftue bhg gd zapytyr kf k Epcxtylw xjoepx fsi fraqvat r ydkurbqrwp gsqqerh.

Hqt qjmybxq, ni v…


Thanks for reading this short excerpt from the paid post! Fancy buying it to read all of it?
Start Learning Now!
This article
Configure Node-RED & Wemos D1 Mini
1.99
USD
Learn Monthly
1 month access to Premium content (cancel anytime)
3.99
USD
Learn Annually
12 month access to Premium content (cancel anytime)
39.99
USD
Powered by

Pin It on Pinterest