Introduction to Rust

Rust is a relatively new programming language that promises to be as fast as C, but less complex and error prone.

Rust compiles directly to machine code, so it doesn’t require a virtual machine. This makes it faster than languages like Java or Python. It also doesn’t use a garbage collector, which makes it faster and more predictive than other compiled languages like Golang.

On top of speed and predictability, Rust also promises a programming model that ensures memory and thread safety, which makes it great for complex applications.

Installation

The recommended way to install rust in Linux and Mac is using this command:

1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

We will be greeted by this prompt asking to choose an option:

1
2
3
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
Read More

Sending HTTP requests with Arduino

To make HTTP and HTTPS requests from an Arduino board, we need to first install the ArduinoHttpClient library:

1
arduino-cli lib install ArduinoHttpClient

Once we have the library, we can use it to make requests:

Read More

Using Arduino Language Server With Neovim

In this post we’re going to configure neovim to work with Arduino Language Server.

Nvim Lsp Config

Neovim comes with an LSP client included, nvim-lspconfig is a plugin that helps us configure the client so it can talk to LSP servers.

This configuration should be enough to get started with Arduino:

1
2
3
4
5
6
return {
  "neovim/nvim-lspconfig",
  config = function()
    require('lspconfig').arduino_language_server.setup {}
  end
}
Read More

Using Arduino Serial Monitor From Linux

Arduino Serial Monitor is a tool that can be used for debugging or interacting with our Arduino board. More specifically, it allows us to read and write data to a serial port.

For our sketch to be able to use the serial monitor, we need to use Serial.begin and specify a baud rate. For example:

1
Serial.begin(9600);

The valid baud rates vary depending on the board we are using. 9600 is a safe value that works on most boards.

Reading

The first thing we want to do is print to the serial port. For example:

1
Serial.println("Hello");
Read More

Introduction to Arduino CLI

In my previous post, Getting Started With Arduino UNO R4, I showed how we can upload a sketch into an Arduino board. In this article, we are going to do the same, but this time using the Arduino CLI.

Why Arduino CLI?

I personally, use neovim for coding, which makes it a necessity for me to be able to compile and upload my code from my terminal.

If you prefer the IDE, this article might not be for you, but, understanding the CLI could be useful in the future to automate repetitive tasks or run things in a CI environment.

Installation

We can install the Arduino CLI on our system with these command:

1
2
3
4
5
6
7
8
# Create a folder to install the CLI
mkdir ~/bin/arduino-cli

# Move to the folder we created
cd ~/bin/arduino-cli

# Install
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
Read More

Getting Started With Arduino UNO R4

In this article, I’m going to show how to write a simple program for Arduino UNO R4. I expect most of the steps I follow here can be used for other models of Arduino, but I’m going to be using the LED Matrix that come in the board and will only test on this model.

Installing the IDE

In order to compile and install our programs into our Arduino, we need to download the Arduino IDE. We can get it from the Arduino Software Page.

The installation instructions might vary depending on your OS. I use Ubuntu, so I downloaded the AppImage file.

In order to run AppImage files we need FUSE:

1
2
sudo add-apt-repository universe
sudo apt install libfuse2

Then we can just run the AppImage file:

1
2
chmod +x arduino-ide_2.2.1_Linux_64bit.AppImage
./arduino-ide_2.2.1_Linux_64bit.AppImage
Read More

Introduction to KiCad for Circuit Design

In a previous article I introduced Ngspice as a popular open source circuit simulation tool. After some more time playing with circuits, I stumbled into KiCad, a popular open source tool for designing circuits.

KiCad focuses on design of schematics (diagrams that show components and how they are connected) and PCBs. On top of this, KiCad can integrate with Ngspice to run simulations on the schematics we design, making it an all-in-one tool for circuit design.

Installation

We can get the latest version of KiCad from their downloads page. Installing it in Ubuntu, is as easy as running these commands:

1
2
3
sudo add-apt-repository ppa:kicad/kicad-7.0-releases
sudo apt update
sudo apt install kicad
Read More

Resistors

I started learning electronics a few days ago and I’m seeing resistors in every diagram I find and using them in pretty much all my experiments. So far, I’ve been using them blindly, but in this article I’m going to try to get a better understanding of what they actually do.

Electrical Resistance

A resistor is a component that implements electrical resistance. Electrical resistance is usually explained using a water and pipes analogy.

Let’s start by imagining two containers; One full of water and the other one completely empty:

Two containers representing the potential energy

This will be analogous to the two poles of a battery. One of them contains more electrons (water) than the other. While the two containers are not connected, water doesn’t flow.

Let’s now connect the two containers, but we’ll do it with an obstructed hose, so water can’t go through:

Two containers connected by obstructed hose

Read More

Introduction to Ngspice for Circuit Simulation

I’ve decided to try to learn electronics, and for this, I will of course need to interact with hardware (cables, resistors, diodes, etc…), but I’m lucky I was born in a time when a great deal of circuit design can be done from a computer using specialized software.

Being very new to this world and a stubborn Linux user, I did a quick search to try to find what’s my best option. I stumbled into this Electronics Circuit Simulator Software comparison page in Wikipedia.

I mainly looked at 3 things:

  • Compatible with Linux
  • Latest release date
  • Open source

With these simple requirements, I found two contenders:

Qucs-S has a nice graphical user interface, but depends on a SPICE back-end (e.g. Ngspice) to run. Due to this dependency, I’m going to be required to learn Ngspice anyway, so I decided to start with this one.

Read More

Getting Started With Neovim

I’ve known about neovim for a long time, but I’ve never tried it out. My goal for this article is to try to replicate my current vim configuration:

  • File explorer
  • Grep
  • Fuzzy file finder
  • Syntax highlight
  • .vimrc configuration

If Neovim is as good as people say, I should be able to do that, and it should run faster.

Installation

Neovim is already packaged for most OS. Sadly, the version included in Ubuntu is too old for most plugins out there. For this reason, we’ll have to build from source.

Install prerequisites:

1
sudo apt-get install ninja-build gettext cmake unzip curl
Read More