Everyone Running the NYC Marathon Has a Story to Tell

Everyone running the NYC Marathon has a story to tell, and unique burdens they carry. Look around you at your next race and be inspired by each runner’s public declaration of courage and humility.

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Host a wasm module on Raspberry Pi easily Part 1

In this series of WebAssembly, I tell you about wasm and some useful CLI to have fun with wasm. WebAssembly is an open standard that defines a portable binary code format for executable programs, and a corresponding textual representation for interactions between such programs and their hosts. More than 20 companies reportedly use WebAssembly in their tech stacks, including Backend, Foretag, and Cubbit. C++, C, Rust, Blazor, and Yew Framework are some of the popular tools that can integrate with WebAssembly. WebAssembly is a widely used compile target for Rust. Rust also helps us to host wasm modules easily. This enables us to use an IoT device like Raspberry Pi as a host.

In this blog of the series, I will tell you how to host a wasm module generated by a Rust program in your IoT devices like Raspberry Pi. So let’s see how can we do this.

Host Raspberry Pi
Raspberry Pi 2

First of all, we will be writing the program in Rust that is to be hosted and then compile it to wasm. We’re going to build a battery indicator. Its operation is quite simple. One of the sensor inputs represents the amount of
battery remaining as a percentage. In response to that percentage, we’re going to control the colour of a group of eight LEDs. Let’s begin.

The LEDs can light up colours as a combination of RGB components ranging in between 0 to 255. The actual hardware that is used is Blinkt! Pimoroni. You can buy this online if you want to implement this.

Blinkt!
Blinkt! Pimoroni

For example — if the battery percentage is 80 then the number of LEDs lighting up will be 7 as 80 / 12.5 = 6.4, so we take the ceiling value.

So let’s see the code and then discuss it further.

Now we are all set to host this program on our Raspberry Pi but before that, we need to create a host program that will run on our Raspberry Pi and continuously watch for the wasm module. We will see how to build a host on Raspberry pi in our next blog. So stay tuned.

Before that make sure you compile this program to wasm so that we can use this and run the battery indicator on Raspberry pi.

Knoldus-blog-footer-image

Add a comment

Related posts:

The Importance of the Date of Separation

Many couples who are going through divorce are usually most concerned with the date their divorce is finalized. However, the date of separation is oftentimes much more important. Many courts use this…

How to build a Discord Bot

This is a quick and easy template for building your own Discord bot, this project relies on Discord.js, if you want to extend this bot, I suggest you look at the official Discord API documentation…

Managing the conflict between Economic Growth and Environmental Impact

The conflict between economic growth and the environment is not new and has existed ever since the Industrial Revolution, but events in recent years have brought it more sharply into focus as…