Some of you might have already heard about 21 Inc. (@21) and their vision for the next type of web — the Machine-Payable Web, built on Bitcoin. If you haven’t then that is surely a big omission on you part and you can do yourselves a favor and at least watch this video by 21 CEO Balaji Srinivasan.

The way I understand 21’s idea is the following: the ability to send ultra-small sums (microtransactions) enables the selling of small chunks of information, requested by people or programs, and provided automatically — bitcoin-paid API calls.

Being inspired by this vision and willing to improve my Linux OS skills I decided to challenge myself to follow the guides provided by 21 Inc. and start selling pings (Ping21) and weather sensor data (Sensor21).

My background is in Political Science and International Relations, but I have always been a “tech” guy with relatively good knowledge of computer software (Windows environments primarily, though) and hardware. Also, I have founded three bitcoin-related projects — bitcoini.com, CoinFixer.com and am currently primarily involved in BitHope.org — a “bitcoin crowdfunding for charity” website. On the part of using an UNIX terminal — I am a super noob and was advised by a 21 staff member in the 21.co Slack chat to go through the “Learn the Command line” course, freely provided by CodeCademy. This turned out to be an excellent advice, so I am forwarding it to you.

For the most part I was strictly following these guides:

· DIY 21 Bitcoin Computer — Raspberry Pi3 Edition,

· Ping21: Earn Bitcoin by Monitoring Uptime and Latency,

· Sensor21: Earn bitcoin by collecting environmental data.

Without any more unnecessary ado, let me share my experience of going from zero to being a member of the 21 Inc. Marketplace.

Getting the Raspberry Pi3 and the MPL3115A2 Barometer sensor

21 Inc. provide users with the opportunity to purchase a ready-to-use Bitcoin computer and skip some of the installations steps. However, with a price of 399.99 USD and posing a lesser challenge, this option is perhaps appropriate for more high-fed people than myself. When it was first introduced, the Bitcoin computer accumulated a fair share of criticism for being overpriced. Nonetheless, I do understand why it would be a sensible purchase for some. It provides better functionality and a fuller “Bitcoin-tech” experience by including a mining chip, a 128 GB SSD drive, the ability to be run as a micropayments server and a full Bitcoin node. In addition, as I found out later, some of the commands which are available in the actual 21 Bitcoin computer (21PC from here on) are not available in the software for the DIY one (not only to those which can be attributed to hardware differences).

Although the 21PC may not be such a horrible purchase, I preferred to go the Raspberry Pi3 way and use the DIY implementation (21DIY from now on). As mentioned before, I followed this guide which, not terribly surprisingly, instructed me to start by purchasing the relevant components.

I was able to acquire them all from Amazon.co.uk, including the barometer sensor and the required female to female jumper wires for the total price of GBP 66.51 (around 84.69 EUR/95.50 USD). For the Sensor21 installation, one needs a protective enclosure in which the sensor is placed. This can either be purchased from Shapeways (for 12 EUR/13.53 USD + shipping) or 3D printed from an STL file at GitHub. I found a local 3D printing service here in Sofia and they printed the file for 18 BGN, including VAT (around 9.21 EUR/10.39 USD).

You will also need a microSD card and, I recommend, an USB microSD card reader. The USB reader can come quite handy, since not all PCs have microSD card readers, but all have USBs. The SD card is used as a hard drive for the Raspberry Pi3, so it is super essential.

Here are all the components that I needed to purchase (without the 3D printed enclosure, which was being printed at that time) for the 21DIY.

The glorious hardware components

You will, of course need a mouse, keyboard and a screen for self-explanatory reasons. Since I have a desktop PC — I did not have to purchase those.

Installation Part 1 — Booting Ubuntu and downloading the Raspbian OS

What you will also need in addition to the components above is a PC (21 Inc. call it “host Ubuntu machine”). You will need that since you will have to flash the microSD card with the Raspbian OS on which the Bitcoin computer software will be installed. This has to be done under Ubuntu Linux, so you will need to create a bootable USB drive OR DVD with an Ubuntu installation. This sounds fairly easy and I have used Ubuntu many times to securely generate bitcoin paper wallets, so I was quite confident that there will be no stumbling blocks here. You can also download the Raspbian OS from the official website, but this is not mandatory (more on this in the next section).

Unfortunately, a few moments after the initiation of the experiment I found out that the PC I had prepared for booting the Ubuntu is unable to boot from an USB drive. It is an old PC with a DVD-ROM drive and I guess USBs were not that ubiquitous when its BIOS was created. I was lucky to find an empty DVD in a drawer at home, but if this did not happen — my adventure would have ended there, at least until I was able to purchase a DVD disk (it was late, so there were no shops open).

So, here is my first advice — make sure that the PC that you will be using for the Ubuntu-related operations (the host Ubuntu machine) can boot from USB OR can create a bootable DVD that it can boot from.

Creating a bootable USB under Windows

The creation of a bootable USB is super easy and requires an Ubuntu image file that should be downloaded from the official Ubuntu page and a small program called Rufus that you do not even have to install on your Windows machine (it is just a single .exe file). Once you have an image file and the Rufus program — just follow these steps.

Creating a bootable DVD under Windows

If you decide that the DVD option is better suited for you then you need the Ubuntu image file and this, again small and free, Free ISO Burner program. You can, of course, use any other program that you have. Nero is quite a popular one, but also — paid. In the case of the Free ISO Burner — it might be a good idea to choose the lowest speed available and put a tick on the “Finalize disk” option. These setting improve the chances that the DVD will be readable after the burn process is complete. I forgot to put the thick on, but my disk was nonetheless readable.

Final note on this part — in order for your PC to boot from USB or from the DVD ROM, its BIOS settings must be set accordingly. If you insert the USB/DVD, start/restart the PC and Windows is launched (so the inserted device was not detected as bootable) this means that you will have to set a proper device boot order in the BIOS. Usually, when you start the PC, one of the first screens that appear before Windows launch will tell you which “F” key to hit to either enter the BIOS or open the Boot menu. In my case that was F12 (BIOS Menu). I hit the F12 key several times in small intervals immediately after pressing the physical “Turn on” button on the PC. This will let you inside the BIOS menu and from there you should change the boot options, making the USB/DVD drive be checked for bootable mediums BEFORE the hard drive on which the Windows system is installed.

Installation Part 2 — Flashing the SD card with the Raspbian OS under Ubuntu

This is where things got a bit too interesting and I lost quite a bit of time. The 21 Inc. guide advises you to download the Raspbian installation with a “curl” command in the Ubuntu terminal. (Note: to get the Ubuntu terminal simply press Ctrl — Alt + T). Since I had downloaded the Raspbian OS beforehand, I thought I can skip the download part and use the file I had. I renamed it in order to match the name in the guide — namely “raspbian.zip”.

Not following the instructions provided by 21 Inc. on the background of my extremely limited knowledge of the command line (terminal), lost me quite a lot of time. However, the primary issue was related to the fact that I had to write an .img file larger than 4 GB to the microSD. That caused a few unexpected problems.

First, for some reason the microSD card had a large portion of disk space in unallocated state. This resulted in the “sudo dd” command (which copies the Raspberry .img file to the microSD) to not work due to insufficient disk space.

At that time I was unaware how to make a screenshot in Ubuntu.

Finding out why my brand new 32GB microSD card is being treated as “low on space” translated into a lot of frustration. I searched the internet for a way to look at the USB drive from the graphical user interface of Ubuntu. I found out about the “Disks program”. How to find it? This is done with the “SUPER + A” keyboard shortcut, where SUPER is the Windows key. A search bar appeared, where you have to type “Disks”. There you can see the USB drive. There is another problem that can appear in this part as well — the USB can be visible in the Disks program, but might not actually be mounted. In this case you have to click on the little icon with the two gears and choose “Edit Mount Options” and then make sure that “Automatic Mount Options” is set to “ON”. You should eject and re-insert the USB in order for it to be mounted.

So, from the Disks program I found out that my 32 GB microSD had only 2 GB of allocated disk space. No idea why. This had to be fixed. The easiest way to do it is through the DISKPART command under Windows. Watch this YouTube video to learn how it is done.

Once I formatted the microSD card with the DISKPART tool, the microSD revealed its full capacity of 32GB. However, the same error appeared in Ubuntu as before — not enough disk space.

I was really ready to manifest my physical superiority over the computer at this point, but my troubles were hardly over.

I had to investigate the reason causing a 32 GB SD card with fully allocated disk space to be considered as low on space, again. After a bit of research, I found out that the DISKPART command allocated the space in FAT32 format, while the Raspbian .img file I was trying to copy was over 4 GB. The FAT32 system DOES NOT support single files larger than 2 GB (I knew that)! So, what I did is again eject the SD card reader (with the microSD card in it) from the Ubuntu PC and used a Windows PC (the same PC, actually) to format the SD card into NTFS, which has no realistic file-size or partition size limits. I did this with a right click on the USB drive in Windows Explorer, selecting format, choosing NTFS and doing a quick format. After that — re-insertion in Ubuntu.

But the error was still there!

After another extensive internet research session, I found out that since I was running Ubuntu directly from the bootable DVD drive (without installing it on the hard drive) some write functions may not be available (I did not have the administrative rights to execute them). That meant that I had to install Ubuntu before running the “sudo dd” command which flashed the Raspbian on the microSD.

Again, image quality, I know.

After successful installation of Ubuntu in parallel to my Windows 7 system, I was FINALLY able to successfully execute the “sudo dd” command and flash the Raspbian on the Raspberry Pi3 “hard drive” (microSD). The process of copying took a while (~10 minutes) during which time the system was not showing any signs of doing something, so be patient. After it is done, you should see something like that:

This screen appeared after some time of…nothing. Great success!

Installation Part 3 — Starting the Raspberry Pi3 for the first time

Once I put the microSD card in the slot on the Raspberry Pi and plugged the keyboard, mouse and screen — the Raspbian started loading, terminal-style and I found out that the Raspbian also has a GUI, which was a pleasant surprise.

You will have to go through some initial setup steps like setting a password, configuring you keyboard layout, connecting to the internet via Wi-Fi and making sure that the Raspian system used the full amount of space, available in the SD card (this card again!). After that you will have to update your OS version to the latest one, which is very easy if you have internet connection.

Setting up Ping21

Installing the 21 software is extremely easy. The “curl https://21.co | sh” command does that. You will have to register an account with 21, which is done by going here.

Once you have the 21 software installed on your Raspbian and you are logged in, you are ready to start selling services on the 21 Marketplace. The easiest way to begin is by installing ping21. You can look at the 21 guide for the required actions on your part, but it all boils down to:

1. Install git — “sudo apt-get install -y git”;

2. Clone the Ping21 server code — “git clone https://github.com/21dotco/ping21.git”;

3. Enter the ping21 directory — “cd ping21”;

4. Pull in and install ping21’s dependencies — “sudo easy_install3 pip” and after that — “sudo pip3 install -r requirements.txt”;

5. Publish your ping21 server — “21 publish submit manifest.yaml -p ‘name=”YOUR NAME” email=”YOUR E-MAIL” price=”PRICE PER CALL (usually between 5 and 3000)” host=”AUTO” port=”6002" ‘ “;

6. Run the server — “python3 ping21-server.py -d” (you will have to enter this each time you restart your Pi3 in order to re-initiate the ping21 server).

After all this, it is good to check if your server is running. In their guide, 21 Inc. have suggested a way to do that. However, to me it seems a bit too burdensome, especially having in mind that I found an easier way to do it with the “21 publish list” command that will display all your running services.

And that is it for Ping21 — you are now selling pings for bitcoins.

Setting up Sensor21

This was more interesting and a bit harder. In order to start selling environmental data, you will have to first generate it. This is done with a little piece of hardware called “MPL3115A2 — I2C Barometric Pressure/Altitude/Temperature Sensor”, female-to-female jumper wires and an enclosure, keeping the sensor protected. As mentioned before, the former two are available on Amazon.co.uk, while the enclosure you can either 3D print locally or purchase from Shapeways. My recommendation is to get a white enclosure as opposed to a black one — the simple logic here being that sun rays are more unforgiving to black objects.

The sensor chip is really small and once inside the enclosure, it must be secured with a single tiny screw. You will need two more screws for the lid of the enclosure. I can ensure you that the screws are as important as any other component so make sure you do have them.

I didn’t.

So I spent one hour searching for the right screws from other devices at home. I was lucky to find the perfect size screws in my Asus Eee PC. Without them I wouldn’t have been able to secure the sensor and prepare it for the rough weather conditions outside my room window.

The sensor comes with a little connection pin that must go through the sensor holes and is used for connecting the sensor to the jumper wires. During my first installation of the chip inside the enclosure (with a single screw) I was hoping that the connection will be good enough without the need for soldering. Unfortunately, once the I connected the sensor to the Pi3 — it did not start. After removing the sensor — it did. At that point I decided to contact someone from 21 Inc. in order to find out what is the problem. I used their Slack group and find it to be really useful. There is always someone there who is willing to answer your question, although not immediately. I was told that in order for the sensor to work properly, the connection pins must be soldered to it. So that is what I did:

That was my friend Radoslav, actually. I am not proficient at soldering.

And here is the final result:

Perfect.

The “ready-for-use” sensor looks like this:

It is really small and light, but generates accurate measurements.

Once the chip was inside the enclosure, I connected it to the Pi3.

I was feeling like a scientist at this point.

You may notice that I used two pairs of two jumper wires. The obvious reason for this is to get more distance between the Pi3 and the sensor, so that the sensor can be placed outside a closed window.

Here is the closed Pi3 with the connected sensor:

The 21DIY and sensor — ready for satoshis generation.

Once the sensor was connected all I had to do is follow the steps in the 21 Inc. guide.

If you face any difficulties, just post your question in the 21 Slack group. There is always someone who can help you there.

Extra hint

In order to be able to access your 21PC without having to be plugged into it, it is a good idea to setup SSH. This is pretty easy and since SSH was already installed on my Pi3 (I believe as part of the 21 installation), all I had to do is forward the internal network IP for the Pi3 through my router settings. In order to do this you need to know the Pi3 IP address. Just type “sudo ip addr show” and the system will display all the device’s IPs. Since I have connected the Pi3 through WiFi, the device identifier was “wlan0”. After that go to your router settings, enter the “Forwarding” or “Port Forwarding” menu and create a new setting. You must enter the IP that you want to forward and a port. The IP you know already, and as for the port — use 22. After this is saved you will be able to access your Pi3 from anywhere by using PuTTY, where you have to enter your ISP-assigned IP (hopefully static, otherwise this will not work) and port — 22. You will also need the user and pass for your Pi3. That’s it!

If I was able to do it, you will be able to do it too!