Virtualizing the Raspberry Pi for local development

Starting new projects can be difficult, especially when the need arises to develop / debug. It is key to have a development environment that closely matches the same hardware / software production environment it will be run on in production.

When building a drink pouring robot ( raspberry pi powered alcoholic drink pouring robot ), the need arose to move faster than developing remotely on the raspberry pi. I found it helpful to create a sort of mock development environment to be able to toggle pins without have to be on an actual raspberry pi. This was the case when I was in an airplane, without internet and away from the raspberry pi. Having access to get feedback as the raspberry pi would react has made the development experience much more enjoyable. This virtualized raspberry pi allowed for me to create a product without having to actually having to need any hardware. The implementation is simple, create a sort interface for both virtualized pi and real pi to interact the same way by toggling a config. The code itself did not care if it was a real or virtualized pi.

The code

As a basic example I was allowed to control virtual raspberry pi pins like so:

var Pi = require('../pi'),
    pi = new Pi({
     mock: true
});

pi.toggle(1, 1); // set pin (1), to value ( high or on )
pi.high(2); // set pin 2 to high
pi.low(3); // set pin 3 to low

Jon

Innovative, entrepreneurial and positively unsatisfied mind that constantly pushes the tech boundaries to create new solutions and devices that change people’s lives. Throughout my career, I have had the opportunity of having a multi-disciplinary experience, which led me to wear the hats of: Architect, IoT Consultant (Internet of Things Consultant), Developer, Designer, Engineer, Server Admin, Consultant and Project Manager – to name a few. Based on this diversified background, I get projects done by following smart ideas and well-planned goals. In a world which is getting more unconventional by the day, I use unconventional ways, and a very healthy dose of integrity, to create devices and solutions that help companies go from a steady present to a dynamic future.

You may also like...