JavaScript For IoT

Diary of a JavaScript developer on the magical world of IoT and electronics. Join me as we share knowledge.
Let's learn together!

Welcome!

You may have read some of my blogs on Salesforce development and architecture, but this year I decided to embark on a new hobby: Robotics! So this blog will be a bit different than the ones you regularly read from me.

To start learning about this fantastic new world, I decided to purchase a few things on Christmas 2020 from Amazon. If you want to join me in this journey, you may want to read the getting started article.

Once I had acquired these items, I was ready to start my journey and, let me tell you; it has been an incredible ride!

The Freenove kit that I acquired has a great set of components, and the projects are simple and work quite well. The concepts are incremental, starting with a simple LED and evolving to add switches and more advanced components.

I decided that if I wanted to learn, I would have to challenge myself, so I came up with a great idea: I will build the circuits they have in the book, but I will write the code using JavaScript (Node.js). The kit comes with code samples in C++ and Python, and I can use those samples as guides.

This idea was great because I have to fully understand the sample code they provide to rewrite it using JavaScript. The book has some essential explanations of how things work, but it does not go into depth. Sometimes they do oversimplify things, but having to translate the code to another language requires me to go much deeper into the information provided and learn not only how it’s done but why it’s done. So the book, together with Google, has been a great educational experience!

But it was easier said than done, especially at the beginning of my journey. After a lot of research (trial and error and plenty of googling), I found a couple of good npm libraries named RPIO and PIGPIO that work pretty well with Raspberry Pi and Javascript. So far, they have everything I need.

If I had to choose just one of those libraries, I would use PIGPIO because it has a few more features. For example, I have noticed that RPIO does hardware-based PWM, but PIGPIO does DMA-based PWM. Why is this important? It allows me to use more pins on the Raspberry Pi.

UPDATE [2021-06-20] The more I work with these projects, the happier I feel about PIGPIO. It’s a much better npm library than RPIO. I think I am going to stick with that.

There are other npm libraries. For example, Johny-Five allows you to write simpler Node.js code because it has one more abstraction layer. But this is precisely the reason I have stayed away from that library: it does too much hand-holding. I feel this would not help me learn as much, but it could help me later in some projects.

I want to start a series of blogs, sharing my knowledge while working on some projects. So stay tuned, and join me in the discovery of this new fascinating world.


Please help me keep this blog alive and free of ads
Support me with a small contribution by Paypal or, if you prefer, buy me a coffee.

Please leave a comment

Comments are powered by Utterances. A GitHub account is required to comment. Comments are moderated. Be respectful. No swearing or inflammatory language. No spam.

I reserve the right to delete any inappropriate comments. All comments for all pages can be viewed and searched online here.

Opinions expressed in this blog are solely my own and do not express the views or opinions of my employer, wife, son, friends, boss, or anybody else! 😀

To edit or delete your comment:

  1. Click the "Comments" link
  2. Find your comment on this GitHub page and click the 3 dots in the top-right
  3. Click "Edit" or "Delete". Editing or adding a comment from the GitHub page also gives you a nicer editor.