
Serbian: 
Pozdrav svima! Lepo vas je videti ponovo. U današnjem videu ću vam pokazati kako sam
napravio moj prvi projekat sa pametnom kućom u maloj razmeri. Koristi ESP32
ploču koja ima ugrađen WiFi i Raspberry Pi Zero W,
takođe sa ugrađenim WiFi-om. Ceo projekat me koštao oko 40 dolara što sa obziom na to šta sve može,
nije ni toliko skupo. Najveći trošak u mojem slučaju su bili bezbroj sati
provedenih istražujući i experimentišući. I zbog toga sam hteo da
napravim video u kojem ću pokazati kako sve funkcioniše. Ovo će biti opšitan video
i neću ulaziti previše u detalje vezane za kod i setup.
Napraviću par videa posle ovoga, možda i koji live stream

English: 
Hey guys and thanks for tuning in again!
In today's video I'll show you how I
built my first attempt at a small-scale
home automation system. It uses an ESP32
dev board that has built-in wireless
capability and the Raspberry Pi Zero W also
with built-in Wi-Fi. The whole project
cost me around $40 which is not that bad
considering what it can actually do. The
biggest expense in my case were the
countless hours spent researching and
experimenting. And that's why I wanted to
make a video explaining how it all works.
This is going to be an overview video
and I'm not going to go into great
detail on the code and the setup itself.
Instead I'm going to make a couple of
videos after this, maybe even live

Serbian: 
gde ću ući dublje u detalje kako je ceo sistem povezan, namešten
i kodiran. Sponzor ovog videa je JLCPCB.
JLCPCB je proizvođač visoko kvalitetnih štampanih ploča i SMT stencila. Dva glavna
elementa ovog sistema su ESP32 i Raspberry Pi Zero W. Kad ih povežemo na istu WiFi mrežu
oni komuniciraju pomoću MQTT protokola.
MQTT je veoma robustan protokol, i lak za korišćenje. Savršen za automatizaciju kuće.
Zasniva se na publish/subscribe sistemu (objavi/pretplati). MQTT ima 2
glavne komponente. MQTT broker, koji je naš posrednik
i koji prosleđuje sve poruke, i više MQTT klijenata koji komuniciraju
kroz broker. Poruke imaju takođe 2 komponente, Topic(tema) i Payload(poruka)
Topic opisuje odakle poruka potiče i šta poruka sadrži.
Neki primeri topica su

English: 
streams where I will go into more detail
on how the whole system is set up
connected and coded. This video is
sponsored by JLCPCB.
JLCPCB is a manufacturer of high
quality PCBs and SMT stencils. The two
brains of the operation are the ESP 32
and Raspberry Pi Zero W. When connected via
Wi-Fi to the same network they can
communicate using the MQTT protocol. MQTT
is a very robust and simple to use
protocol perfect for home automation
projects. It's based on a publish/subscribe system. There are two main
components to the MQTT system: an MQTT
broker, which is our middleman that
passes all the messages and multiple
mqtt clients which communicate with each
other through the broker. Messages have
two components the topic and the payload.
opics are used to describe where the
message is coming from and what the
message contains some examples of topics
are

English: 
bedroom / temperature or bathroom /
fan or living room / TV. Tthe payload is a
string of characters that is sent with
the topic.
It describes what needs to be done
exactly for that particular topic. So if
we would for example want to turn on the
main light in our bedroom we would send
a message with a topic "bedroom/main-light"
and the payload "on". When I say send
we are actually publishing to a topic
from a device that device that is
publishing is only concerned with
connecting to the broker and publishing
the message nothing else. The other
device that will actually turn on the
light need to subscribe to a topic. That
device is also only concerned with
connecting to the broker and listening
to messages that it is subscribed to. If
it hears a message from a topic that it

Serbian: 
spavaca-soba/temperatura ili kupatlo/ventilator
ili dnevna-soba/tv. Payload je niz karaktera koji se šalju
na topic. Oni opisuju šta zapravo treba da se uradi
za određeni topic.Tako da ako bismo na primer hteli da upalimo
glavno svetlo u spavaćoj sobi poslali bismo poruku sa topic-om "spavaca-soba/glavno-svetlo"
i payload "upali". Kad kažem poslati, zapravo mislim da publišujemo (objavljujemo) poruku ka određenom topic-u
sa nekog uređaja. Taj uređaj jedino zanima da se poveže na brokera i
da objavi poruku, ništa više. Drugi uređaj
koji će zapravo upaliti svetlo treba da se pretplati na taj topic. Taj uređaj
takođe jedino zanima, povezivanje na brokera i slušanje za poruke
koje dolaze od topic-a na koje je pretplaćen

Serbian: 
da bi uradio korake koji su programirani za određen
topic i poruku. U našem slučaju to bi bilo da ali relej koji je povezan na uređaj koji će
upaliti svetlo. Sad kad imate osnovno razumevanje
o MQTT protokolu, možemo nastaviti sa našim sistemom. ESP32
ima par komponenti i senzora povezanih na nju. HTU21D senzor
za temperaturu i relativnu vlažnost vazuha, koji očitava abijentalnu temperaturu i vlažnost u sobi.
Infracrvena LEDica koja može da upravlja uređajima kao što su LED traka
TV ili pojačalo ukoliko svi ti uređaji mogu da vide njeno svetlo. Relej ploča sa 8 releja
koje možemo povezati na uređaje male snage kao što su ventilatori, svetla, lampe
ili druge uređaje koje želite da upravljate bežično. I 1838 infrracrveni risiver
koji nam služi za očitavanje kodova od daljinskih koje želimo da emuliramo.

English: 
is subscribed to it does the necessary
actions that are pre-programmed for that
topic and that message. In our case it
would turn on the relay that was
connected to the device that turns on
the light. Now that you have a basic
understanding of the MQTT protocol let's
continue with our system. The ESP 32
board has several components and sensors
connected to it. The htu21d temperature
and humidity sensor which reads the
ambient temperature and humidity in the
room. An infrared transmitter LED which
can control devices such as a LED strip
a TV or a sound system if it's in range
of all of them. An 8 channel relay board
which can connect to low power mains
power devices such as fans lights and
other devices you wish to control
wirelessly. And a 1838 infrared receiver
module which can be used to program our
system with codes from different remotes

Serbian: 
Takođe može i da služi kako okidač nekih drugih koraka kad primi određeni infracrveni signal.
Raspberry Pi će nam služiti kao server za ovaj projekat.
Pokreće DietPi operativni sistem koji je baziran na Debian Linux-u.
Takođe, ima instaliran mosquitto, MQTT broker
na koji će nam se ESP32 povezivati.
SQLite bazu podataka za čuvanje vrednosti temperature i vlažnosti vazduha,
kao i ostalih vrednosti koje ćemo možda ubaciti u budućnosti.
I najzad Node-Red, zaista svemoguć softver kojeg ćemo koristiti ne samo kao MQTT klijent
i SQL client, ali takođe kao bazu za postavljanje pravila i alat za virtualno povezivanje uređaja.
Takođe ima dodatak za korisniči interfejs, koji možete veoma lako menjati
i koji ćemo mi koristiti kako bismo komunicirali sa pametnom kućom.
Da vam ukratko objasnim kako ceo sistem funcioniše.

English: 
and may also be used to trigger some
events when an infrared signal is
received. The Raspberry Pi is going to be
used as our server for this home
automation project. It is running the
diet pi lightweight operating system
which is based on Debian Linux.
It also has mosquito installed, the mqtt
broker that the ESP32 is going to
connect to.
The SQLite database for storing our
temperature and humidity data as well as
other things we might want to store in
the future.
And finally node-red, a truly versatile
piece of software which is used not only
as an mqtt and SQL client but as a rule
and virtual wiring tool that we will use
to set up how everything is going to
work together. It also has an add-on for
a web-based UI that you can completely
customize and which we are going to use
to communicate with our home automation
system. Let me quickly explain how the

English: 
system works. The ESP 32 board takes the
temperature and humidity from the sensor
every 5 seconds. It then broadcasts a
message with those values to the MQTT
broker. Node-red listens to that topic
and displays the values on the gauges in
the UI. Also every 87 seconds it saves
the data with the current timestamp and
the temperature and humidity values to
the database. The data is displayed in
the chart where you can select which day
you wish to show the historical data
from. If you open the control UI on
node-red you can send infrared controls
to multiple devices. When a button is
pressed in the UI, node-red publishes to
a topic corresponding to the device the
button was clicked with the message
containing the actual code that needs to
be sent over infrared. The ESP32
subscribes to the same topic takes the
message and sends it through the

Serbian: 
ESP32 meri vrednosti temperature i vlažnosti vazduha svakih
5 sekundi i šalje te vrednosti ka MQTT brokeru. Node-red klijent sluša za poruke koje
stižu sa tog topic-a i ispisuje vrednosti u korisničkom interfejsu.
takođe, svakih 87 sekundi, sačuvava podateke sa trenutnim vremenom i datumom
u bazu podataka. Ti podaci se
dalje prikazuju u grafikonu gde možete da izaberete za koji dan želite da vidite podatke.
Kad otvorite stranicu za kontrolu. Možete da šaljete infracrvene signale ka više uređaja.
Kad se dugme pritisne u korisničnom interfejsu, node-red publišuje
ka topic-u sa uređajem koji želimo da upravljamo
i u poruci šalje tačan hex cod koji treba da bude poslat putem infracrvene diode.
ESP32 se pretplaćuje na taj topic, uzima poruku i šalje je

English: 
infrared diode controlling the device. 
 The 8 channel relay system works
the same way. You select the device
that you want to turn on or off, node-red
publishes to the topic of that
particular device, the ESP 32 subscribes
to that topic, parses the message, Whether we
wish to turn it on or off. And sets the
data pin connected to the relay to
either high or low based on that message.
I'll run you through all the necessary
steps you need to do to get both the
Raspberry Pi and the ESP 32 set up. First
download the Raspberry Pi image that I
compiled with all programs
services pre-installed. You will also
need Etcher, an image flashing tool and
the microSD card minimum eight gigabytes
storage. And of course a card reader. once
you've installed Etcher,  open it and
select the Raspberry Pi image and click
on flash. Once that is done open the

Serbian: 
putem infracrvene diode, upravljajući uređaj. Osmokanalni relej funcioniše veoma slično.
Odaberete koji uređaj želite da upalite ili ugasite, node-red
objavljuje poruku sa topic-om od tog uređaja, ESP32 sluša taj topic,
očitava poruku, i u zavisnosti da li želimo da upalimo ili ugasimo uređaj,
postavlja data pin esp32-ke koji je povezan na određeni relej na upaljeno ili ugašeno u zavisnosti od poruke.
Proći ću kroz korake koje trebate da uradite kako biste namestili
i Raspberrz Pi i ESP32. Pod 1. Skinite raspberrz Pi image
koji sam kompajlirao sa svim programima, servisima i nameštanjima.
Trebaće vam i Etcher, alat za flešovanje, i microSD kartica sa minimum 8gb prostora.
I naravno čitač kartica. Kad ste instalirali Etcher, otvorite ga i
odaberite Raspberry Pi image što ste skinuli i otpakovali. Kad završi, otvorite

Serbian: 
sd karticu i nađite dietpi text dokument u njoj.
Ovde možete namestiti ime vašeg WiFi rutera i šifru, kao i
statičnu adresu Raspberry PI-a, kako biste uvek znali
na kojoj adresi možete da ga nađete. Možete experimentisati sa ostalim nameštanjima
ali ja sam ostavio sve ostalo kao podrazumevano i za mene funkcioniše. Ubacite SD karticu
u svoj Rasbperry Pi i sačekajte da se digne sistem. Kad jeste, trebali biste imati sve
komponente već instalirane. Pređimo na ESP32. Koristićemo
Arduino IDE za uploadovanje sketch-a. Ukoliko ga nemate instaliranog
link je u opisu vide.
Pre nego što možemo da uploadujemo sketch,  moramo prvo da instaliramo
odgovarajuću ploču i biblioteke. Imate uputstva za instaliranje ESP32 ploče
na arduino esp32 github repository-u. Kad ste instalirali ploču idite na moj
github repo i skinite sve fajlove odatle. Unutra imate folder

English: 
contents of the SD card and edit the
dietpi text document located on the
root directory. Here you can set your
wireless routers network name and
password and also set a static IP
address so that you always know where
your raspberry pi is located. You can
thinker around with other settings but I
found that mostly leaving everything by
default works for me. Insert your SD card
into the raspberry pi and let it boot up. Once
it has you should have all the necessary
components pre-installed already. Now
let's move on to the ESP32. We will use
the Arduino IDE for uploading the sketch.
If you don't have it installed yet the
download link is in the description
below.
Before you can upload the sketch you
first need to install the necessary
board and all the libraries. You have the
latest install instructions on the
arduino ESP 32 github repository. Once
you have installed the board, go to my
github repository and download all the
files from there. There is a folder

English: 
called libraries you need to copy all
these folders to your Arduino libraries
folder. There is a readme file there with
instructions on how to install Arduino
libraries. Open the arduino sketch you
downloaded and opene the auth.h tab
Here enter your Wi-Fi credentials as
well as the raspberry pi IP address.
Select your ESP 32 board type and press
upload. If for some reason your upload
doesn't go through, before uploading hold
down the boot button on the ESP 32 and
then press upload. If you setup
everything correctly and go to your
raspberry PI's node-red UI you should
start seeing the temperature and
humidity values change every couple of
seconds. When I was testing out the
project
put all the necessary components on the
breadboard and connected them to my ESP32. You can check out my
schematic for a more detailed view on
how everything is connected. After I had

Serbian: 
libraries. Trebate da kopirate sve ove foldere u vaš Arduino libraries folder.
Postoji fajl sa uputvima kako treba da instalirate biblioteke tamo.
otvorite arduino sketch koji ste skinuli i otvorite auth.h tab.
Ovde upišite podatke za vaš WiFi kao i adresu raspberry pi-a.
Odaberite vašu ESP32 ploču i kliknite na uplaoad. Ukoliko iz nekog razloga ne prođe upload
pre nego što ga pokrenete, držite boot dugme na svom ESP32 ploči.
Ukoliko ste sve dobro uradili idite na adresu od
Raspberry Pi node-red korisnickog interfejsa (:1880/ui) i trebaćete da vidite kako vam se temperatura i vlažnost vazduha
menjaju svakih 5 sekundi. Kad sam testirao
projekat, sve komponente sam povezao na protoploči
i povezao ih na esp32. Možete pogledati
šemu za detaljniji pregled. Nakon što sam sve to završiio

English: 
my proof-of-concept working on the
breadboard it was time to create a
custom PCB for this project I used the
EasyEDA
online software to set up my schematic
that I would later use as a base for my
PCB. I'll show you how I got my PCBs
professionally printed by JLCPCB.com
who are the sponsors of this video. First
go to JLCPCB.com and click on the
Quote Now button on the right side. Next
upload the Gerber files of your project.
Below you will see how your finish PCBs
will look like. You can tweak the
settings below to match your personal
needs. When you're happy with the results
you may choose the shipping method and
see the shipping estimate to your
country instantly. Next click on the save
to Cart button. If you don't already have
an account with JLCPCB you can register
here and once done log in with your new
credentials. Once logged in click on the
check out securely button on the right

Serbian: 
na protopliči, vreme je bilo da napravim
štampanu ploču za ovaj projekat. Koristio sam EasyEDA
online softver za pravljenje šeme koju ću kasnije koristiti kao bazu za moju štampanu ploču.
Pokazaću vam kako sam profesionalno odštampao ploče koristeći sajt JLCPCB.com
ko su ujedno i sponzori ovog videa. Otvorite sajt JLCPCB.com i klinite na
"Quote Now" dugme sa desne strane. Uploadujte svoje Gerber fajlove.
Ispod možete videti kako će vaša ploča da izgleda. Možete da promenite vrednosti
ispod kako bi odgovarale vašem projektu. Kad ste zadovoljni sa podešavanjima, izaberite
metod slanja, državu i videćete okvirnu cenu dostave do vaše države.
Nakon toga kliknite na "Save to Cart" dugme. Ukoliko još niste napravili nalog
sa JLCPCB, na ovoj stranici možete da se registrujete i kad ste završili ulogujte se sa
svojim podacima. Kad ste ulogovani kliknite na "Check out Securely" dugme sa desne strane.

English: 
hand side. Fill out your shipping
information choose a shipping method
payment method and click continue. Once
your payment has been processed you can
expect your PCBs to arrive very soon.
After waiting for about a week my new
PCB's have finally arrived. As
always I was very happy with the end
results and would like to thank JLCPCB
once again for making this video
possible. Next step was to solder the ESP
32 to the board.
I used pin headers so I wouldn't have to
solder my ESP 32 to the board directly.
That way I could swap it out easily if
it broke or I needed it for a different
project. For most of the other components
I wanted to use pin headers as well, with
DuPont wires but on my original PCB
design I managed to add a smaller
footprint pin header holes which
wouldn't fit with my DuPont wires so I
had to manually solder each wire in
place to the board.

Serbian: 
Ispunite informacije o dostavi, izaberite metod dostave,
metod plaćanja i kliknite na "Continue". Kad je uplata prošla, možete očekivati
svoje ploče da vam stignu veoma brzo. Nakon nedelju dana
moje ploče su napokon stigle. Kao i uvek veoma sam zadovoljan sa krajnjim rezultatom
i želeo bih da se zavhalim JLCPCB još jednom.
Sledeći korak jeste da sve zalemimo na novu ploču.
Koristio sam lemne lestice da ne bih morao da zalemim esp32 direktno na ploču.
Na taj način mogu da ga lako zamenim ukoliko bi se spržio ili ako mi je potreban za neki drugi projekat.
I za ostale komponente sam želeo da koristim lemne lestvice sa Dupont kablovima
ali na mom originalnom dizajnu, nažalost stavio sam pogrešne rupe za lemne llesticce
na koje nisu mogli da stanu moji kablovi, pa sam morao
ručno da zalemim svaki kabel na ploču.

Serbian: 
Na sreću vi nećete imati taj problem jer sam ispravio gresku na ploči
koja je bila prisunta na prvom prototipu.
dodao sam termo bužir na infra crvene ledice i risiver.
Kad sam sve završio odlučio sam da zatvorim sve komponente
u plastičnu kutiju. Izbušio sam rupe za
LED, infracrveni risiver, senzore i kablove koji će ići ka relejima.
Ručni dremel i bušilica nisu baš najbolji alati za ovakvo precizno bušenje
ali nekako sam uspeo, (iako nije baš najlepše rešenje). Ali kad sam sve povezao, i zalepio
krajnji rezultat je stvarno bio vredan svog ovog truda. Sa ovom malom kutijom
mogu da upravljam TV-om, Led Trakom, pojačalom, i svetlima u sobi. Takođe
radi monitoring vlažnosti vazduha, temperature i uzima podatke o spoljašnjim
uslovima sa javnog api-a i sve ih prikazuje u grafikonu. Još i sačuvavam sve te podatke

English: 
Fortunately if you want to print this
PCB you won't have this problem as I fixed
all the issues I had on my first
prototype board.
I added some heat shrink tubing to the
wires of the infrared LED and the
infrared receiver. When all the soldering
was done I decided to enclose the
Raspberry Pi and the module inside the
plastic casing. I drilled holes for the
LED, infrared receiver, sensors and the
cables that would connect to the relay
board. A handheld dremel and drill really
aren't made for this kind of precision
work but I made it work somehow. But when
I finally got everything hooked up glued
and connected the end result was really
worth it. With this small box I could
control my TV, LED strip, sound system and
lights it will also monitor the inside
humidity and temperature as well as get
real-time data from an external API for
the outside humidity and temperature and
display them nicely in a graph. I even

English: 
save all these values to a local
database and display those values in a
chart based on a date that I choose. A
lot of effort and time went into making
this project and I really really
hope that you enjoyed watching it. If
you liked the video and would like to
see future videos like this consider
subscribing. It would really mean a lot to me. I
hope you learned something and I'll
catch you in the next one! Cheers!

Serbian: 
u lokalnu bazu podataka i ispisujem ih
u grafikonu za datum koji želim. Mnogo truda i vremena sam uložio u ovaj projekat
i zaista se nadam da vam se svideo. Ukoliko jeste
i želeli biste da vidite još sličnih videa u budućnosti, molio bih vas za jedan subscribe.
Stvarno bi mi puno značilo. Nadam se da ste nešto novi i naučili i vidimo se sledeći put
Pozdrav! :)
