In this article, we’ll have a look at Toit’s PubSub API and show how we can use it to control a small DC motor remotely. An N20 geared motor will be hooked up with an L9110s motor driver to control its speed as well as direction. A potential application of such a setup could be a remotely controlled water pump in agriculture as IoT is playing a major role in the agricultural sector.
For those who are not familiar with Toit, it is a modern IoT platform that enables a low-cost ESP32 MCU to work as a full computer. Toit provides you with everything you need to develop software: cloud, out-of-the-box connectivity, a web-based console to monitor everything, and even a new programming language. This new high-level language makes development faster and we’ll see more about it in the further sections.