writing code faster
managing iot devices remotely
all things we would like of course
when a few viewers wrote that they
discovered a new kit in the block that
promises a new view on these topics
i had to try it
what did i discover
let's have a closer look
great youtubers here is the guy with the
swiss accent with a new episode and
fresh ideas around sensors and
microcontrollers
remember if you subscribe you will
always sit in the first row
frequent viewers know that i like the
simplicity of docker on raspberries and
the connectivity of the esp chips
this is why we created iot appstory.com
for the arduino ide and the esp chips
and iot stack for the raspberries both
with the goal to create simple and
manageable environments
and they remember my video about micro
python three years ago where i thought
micro python and circuit python would
have a bigger footprint in the future
because of their simplicity
and ease of use
adafruit invested a lot of effort and
was successful with beginners but
commercial projects still mainly use c
plus
and iot app story is used in some niches
where remote management is essential
and as far as i know containers are
currently not used in iot devices
a small sparta tries to combine these
three concepts into one
the company and the product is called
toit
and its founders come from google and
uber
so in this video we will test toit to
see if it is really the coolest kit in
the block
check out the status of the project
particularly the availability of
examples and libraries
compare it with the other two frameworks
the arduino ide with c plus plus and
micro or circuit python
and finally you will get my verdict
twit is the name of a new language and a
cloud service to manage connected esp32s
because the cloud is not everybody's
darling i will focus on a subset called
jaguar
it works like platform io standalone
inside visual studio code
the toy language by the way is open
source
the installation is hassle free and fast
just download a package and start the
setup in a command prompt of windows
after a few seconds you can go to vsc
and install the tight extension of
course you have to install vsc if you do
not already use platform i o
now we can start with a hello world
program it's not very long only two
lines
we already see a difference to the
arduino ide
there is no setup and loop only main
we must add a while statement to emulate
setup and loop
like python the toid language uses
indentions instead of curly braces not
everybody's darling
next question how can we upload the code
to our esp32 to check if our jaguar
installation was successful we type jack
the abbreviation of jaguar and version
yes everything is okay
now we have to flash the infrastructure
code via serial to our esp32
but why do we need an infrastructure
arduino only needs the code no
infrastructure
because the toit crew wanted to make
sure that the device does not completely
crash also not if our code crashes
so they created an operating system
which always run on the esp very similar
to micro python
the programs we write sit in containers
and are managed by this os
if the code in a container goes mad the
madness stays insulated in this
container and the rest of the esp still
runs
you can remotely change your wrong
program via wi-fi
no more unexpected reboots should occur
the containers are entirely separated
and even do not share the memory or the
libraries
our esp32 is now ready to run
applications
i saved the hello world example in a
file
because we will upload via wi-fi we
first have to connect our esp32
this is done by jack scan
if we hit enter we are connected
now we can type jack run hello world dot
toit
but unfortunately nothing happens
no hello world
fortunately we can add a second terminal
window to vsc
if we type jack monitor in this second
terminal we should get the printed
output
but we only get a wi-fi timeout
if i use party connected to the esp32
via serial we see the hello world
message
now we can go on
by the way sometimes the console also
worked in vsc obviously a bug
let's hope it will be corrected in the
next version
and now i show you a cool feature i have
never seen before
instead of run i use jack watch
helloworld.toit
a nice touch by the way commands are
auto-completed if you press the tab key
i now add a loop a delay and print a
variable to show you what happens
if i change the text in the program it
automatically compiles and if no errors
are detected uploads to the esp32
in a fraction of a second
mind boggling fast
and if i make a mistake during
programming the compiler immediately
shows it how cool is that
but how is this possible
we all know that compiling and uploading
takes ages in the arduino ide
this is possible because the toit
language is optimized for
microprocessors with limited resources
and the compiler is optimized for that
purpose too
no unnecessary things that is why it's
so fast
the upload by the way is not via serial
it's via wi-fi only debugging is via
serial so you can update your program
remotely over the air exactly what we do
with iot app story
toy like python uses so-called bytecode
which is interpreted by the
infrastructure this seems to be a
standard way of doing things but we know
from micropython that the interpreters
are slow compared to compiled c plus
plus i think this should and could be
changed in the future because the
advantage of byte code its portability
is much smaller on iot devices we will
later see how slow or fast toy is
compared to micro python on the same
hardware
so far we could wirelessly deploy our
first program to an esp32 and it run
not bad but as usual on this channel we
want more
so let's try a sensor in this respect
the arduino definitely has an advantage
and to a certain extent also circuit
python
both have a ton of tested libraries toit
for the moment only has a small
selection
i use the bme 280 which uses an i square
c interface as a first step we want to
check if i square c works
here is the code for an i square c
scanner
it is straightforward and not very long
and really it finds the sensor at
address 76 hex
and here we see language elements we do
not see in c plus plus
the first is that we do not need to
define the type of a variable the only
thing we have to do is to add a column
when we first use it
like here where the variable found is
declared
it gets its type automatically later we
can use it in the loop
extremely simple if we compare it to c
plus plus
and similar to python
toyt can also format the print
statements by the way
another small time saver when iterating
over a set each member is automatically
available through the it variable
and as with python we have to import
libraries before we can start
next question how can we read the sensor
here is the program we initialize i
square c the sensor and in the loop read
and print the sensor values that's all
the usual programming structures like if
then else exist in addition toyt offers
a cool command i never saw before
100 dot repeat in c plus this would be
written like that
what is next if we can read sensors of
course we have to transfer them via mqtt
and wi-fi to our server this program is
very similar to an arduino sketch and
also here it works
frequent viewers know that i like ble
but was not happy with the
implementation on the esp32
toy also has some ble examples so let's
check them out
i use my iphone and nrf connect to check
if the esp32 is visible
the first example creates a ble device
with the name toit device and every 50
milliseconds transmits packets without
content no problem the second example
exposes a battery service unfortunately
it does not contain any information
not very useful if you ask me
the third example shows manufacturer
data but there is not a lot of value
here too
it seems that ble is supported and works
but we need better examples like the
transmission of a temperature or
humidity of the bme
an esp32 can hold and run different toy
containers in parallel and even can
communicate between them similar to an
rtos
this will only work in one of the
subsequent releases but for sure it will
be extremely useful
without excellent and well documented
examples starting with a new environment
like toit is tough
so i hope the team starts an effort and
creates many meaningful examples and a
few more libraries or it rewards
developers to do so
what did i forget yes of course the
benchmarks
toed published three benchmarks and
casper the founder ran them for me
because i did not have the time
these are the results
toit on average is 10 times faster than
micro python on the same esp32
also here we see that they built an
infrastructure dedicated to
microcontrollers
maybe we will also get benchmarks that
compare toy with c plus plus
then we would know exactly how much
speed we lose if we change from arduino
to toit
the last test is essential
what happens if i reset or even on or
re-plug the esp-32
nothing other than expected the last
program starts to run as with the
arduino ide
a little slower than expected because
the esp-32 has to connect to wi-fi first
so it's time to make the comparison
these are my criteria
turn around time from a code change till
it runs on the board
ease of programming
need of resources
speed of execution on a particular
hardware
stability of code
availability of libraries
community including tutorials
availability for different mcus
and here is the result arduino still is
the leading platform and the new toy is
last i also included a subtotal where we
only see the technical aspects and here
toit is first because of the unique
features we saw before
so for me
it is clear where the development team
around casper has to put a lot of effort
write tutorials and libraries and
sponsor projects like adafruit did with
circuit python
the result also changes if you mainly do
prototyping and small series then your
priority is engineering hours and not
hardware cost
one thing was not covered today but
might also be a deciding factor remote
management the arduino ide has iot app
story and toy it has its cloud solution
so far i do not know of a remote
management solution for the micro python
world maybe you know
this was all for today as always you
find all the relevant links in the
description
i hope this video was useful or at least
interesting for you if true please
consider supporting the channel to
secure its future existence
thank you bye