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++CRust, Blazor, and Yew Framework are some of the popular tools that can integrate with WebAssemblyWebAssembly 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.

Overview

Host Raspberry Pi
Raspberry Pi 2

In my previous blog, I showed you how to host a wasm module in a Rust program using_ wasmi_. You can check that blog for reference. In this blog, I will be using_ wasmi _to make a rust program to act as a wasm host on Raspberry Pi. We will compile the rust program to armv7 as Raspberry Pi 2+ devices are arm v7 devices. Then we will host a WebAssembly module on the Raspberry Pi.

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.

#wasm #wasmi #webassembly

Host A Wasm Module on Raspberry Pi Easily Part 1
1.45 GEEK