Linux video editing, open source ERP systems, Windows apps, password managers, and more

Our biggest hit last week was Don Watkins’ article on why System76 will start making its Linux computers in the U.S. Here’s more of what readers were talking about the week of April 9-15:

  1. Linux computer maker to move manufacturing to the U.S., by Don Watkins
  2. Top 9 open source ERP systems to consider, by Opensource.com
  3. The current state of Linux video editing 2018, by Seth Kenlon
  4. 3 password managers for the Linux command line, by Scott Nesbitt
  5. 3 open source apps for Windows, by Jeff Macharyas
  6. Getting started with Jenkins Pipelines, by Miguel Suarez
  7. Replicate your custom Linux settings with DistroTweaks, by David Spring
  8. How to create LaTeX documents with Emacs, by Sachin Patil
  9. Git turns 13, Linux and SSH commands to know, Python programming, and more, by Rikki Endsley
  10. Build your first Redis Hello World application in Python, by Tague Griffith

Win a year of AdaBox

AdaBox is a US$ 60 per quarter service that delivers hand-picked Adafruit products, unique collectibles, and exclusive discounts to your door. Enter our giveaway by Sunday, April 29 at 11:59 p.m. Eastern Time for a chance to win.

Free 2017 Open Source Yearbook download

Our third annual open source community yearbook rounds up the top projects, technologies, and stories from 2017.

Call for articles

We want to see your JavaScript story ideas. Send article proposals, along with brief outlines, to rikki@opensource.com.

Stay up on what’s going on with Opensource.com by subscribing to our highlights newsletter.

Check out the editorial calendar for a preview of what’s ahead. Got a story idea? Send us a proposal!

LISA18 CFP now open

The CFP for LISA18 is open, and Brendan Gregg (Netflix) and I will co-chair this year’s event, which will be held Oct 29-31 in downtown Nashville. Do you have something to say about the present and future of Ops? If so, send in your talk proposal by May 24th. Follow LISA on Twitter to stay updated on deadlines and announcements. If you have questions or feedback, contact us at lisa18chairs@usenix.org.

Using less to view text files at the Linux command line

If there’s one thing you’re sure to find on a Linux system, it’s text files. A lot of them. Readme files, configuration files, documents, and more.

Most of the time, you probably open text files using a text editor. But there is a faster and, I think, better way of reading text files. That’s using a utility called less. Standard kit with all Linux distributions (at least the ones I’ve used), less is a command-line textfile viewer with some useful features.

Don’t let the fact that it’s a command-line tool scare you. less is very easy to use and has a very shallow learning curve.

Let’s take a look at some of the things that you can do with less.

Getting started

Crack open a terminal window and navigate to a directory containing one or more text files that you want to view. Then run the command less filename, where filename is the name of the file you want to view.

The file takes over your terminal window, and you’ll notice a colon (:) at the bottom of the window. The colon is where you can type any of the internal commands you use with less. More on these in a moment.

Moving around

Chances are that the text file you’re perusing is more than a couple of lines long; it’s probably a page or more. With less, you can move forward in the file in a few ways:

  • Move down a page by pressing the spacebar or the PgDn key
  • Move down one line at a time by pressing the Down arrow key

less also allows you to move backward in a file. To do that, press the PgUp key (to move up a page at a time) or the Up arrow key (to move up one line at a time).

Finding text

If you have a large text file or are trying to find a specific piece of text, you can do that easily in less. To find a word or phrase, press / on your keyboard and type what you want to find.

Note that the search function in less is case-sensitive. Typing “the silence” isn’t the same as typing “The Silence.”

less also highlights the words or phrases you search for. That’s a nice touch that makes it easier for you to scan the text.

You can press n on your keyboard to find the next instance of the word or phrase. Press p on your keyboard to find the previous instance.

Getting out of there

Once you get to the end of a text file and you’re done viewing it, how do you exit less? That’s easy. Just press q on your keyboard. (You can also press q at any time to leave the program.)

As I mentioned at the beginning of this post, less is easy to use. Once you use it, you’ll wonder how you ever did without it.

How to build a plotter with Arduino

Back in school, there was an HP plotter well hidden in a closet in the science department. I got to play with it for a while and always wanted to have one of my own. Fast forward many, many years. Stepper motors are easily available, I am back into doing stuff with electronics and micro-controllers, and I recently saw someone creating displays with engraved acrylic. This triggered me to finally build my own plotter.

As an old-school 5V guy, I really like the original Arduino Uno. Here’s a list of the other components I used (fyi, I am not affiliated with any of these companies):

  • FabScan shield: Physically hosts the stepper motor drivers.
  • SilentStepSticks: Motor drivers, as the Arduino on its own can’t handle the voltage and current that a stepper motor needs. I am using ones with a Trinamic TMC2130 chip, but in standalone mode for now. Those are replacements for the Pololu 4988, but allow for much quieter operation.
  • SilentStepStick protectors: Diodes that prevent the turning motor from frying your motor drivers (you want them, believe me).
  • Stepper motors: I selected NEMA 17 motors with 12V (e.g., models from Watterott and SparkFun).
  • Linear guide rails
  • Wooden base plate
  • Wood screws
  • GT2 belt  
  • GT2 timing pulley

This is a work in progress that I created as a personal project. If you are looking for a ready-made kit, then check out the MaXYposi from German Make magazine.

Hardware setup

As you can see here, I started out much too large. This plotter can’t comfortably sit on my desk, but it’s okay, as I did it for learning purposes (and, as I have to re-do some things, next time I’ll use smaller beams).

The belt is mounted on both sides of the rail and then slung around the motor with some helper wheels:

I’ve stacked several components on top of the Arduino. The Arduino is on the bottom, above that is the FabScan shield, next is a StepStick protector on motor slots 1+2, and the SilentStepStick is on top. Note that the SCK and SDI pins are not connected.

Be careful to correctly attach the wires to the motor. When in doubt, look at the data sheet or an ohmmeter to figure out which wires belong together.

Software setup

While software like grbl can interpret so-called G-codes for tool movement and other things, and I could have just flashed it to the Arduino, I am curious and wanted to better understand things. (My X-Y plotter software is available at GitHub and comes without any warranty.)

The basics

To drive a stepper motor with the StepStick (or compatible) driver, you basically need to send a high and then a low signal to the respective pin. Or in Arduino terms:


digitalWrite(stepPin, HIGH);
delayMicroseconds(30);
digitalWrite(stepPin, LOW);

Where stepPin is the pin number for the stepper: 3 for motor 1 and 6 for motor 2.

Before the stepper does any work, it must be enabled.

digitalWrite(enPin, LOW);

Actually, the StepStick knows three states for the pin:

  • Low: Motor is enabled
  • High: Motor is disabled
  • Pin not connected: Motor is enabled but goes into an energy-saving mode after a while

When a motor is enabled, its coils are powered and it keeps its position. It is almost impossible to manually turn its axis. This is good for precision purposes, but it also means that both motors and driver chips are “flooded” with power and will warm up.

And last, but not least, we need a way to determine the plotter’s direction:

digitalWrite(dirPin, direction);

The following table lists the functions and the pins

Function Motor1 Motor2
Enable 2 5
Direction 4 7
Step 3 6

Before we can use the pins, we need to set them to OUTPUT mode in the setup() section of the code


pinMode(enPin1, OUTPUT);
pinMode(stepPin1, OUTPUT);
pinMode(dirPin1, OUTPUT);
digitalWrite(enPin1, LOW);

With this knowledge, we can easily get the stepper to move around:


    totalRounds = …
    for (int rounds =0 ; rounds < 2*totalRounds; rounds++) {
       if (dir==0){ // set direction
         digitalWrite(dirPin2, LOW);
       } else {
         digitalWrite(dirPin2, HIGH);
       }
       delay(1); // give motors some breathing time
       dir = 1-dir; // reverse direction
       for (int i=0; i < 6400; i++) {
         int t = abs(3200-i) / 200;
         digitalWrite(stepPin2, HIGH);
         delayMicroseconds(70 + t);
         digitalWrite(stepPin2, LOW);
         delayMicroseconds(70 + t);
       }
    }

This will make the slider move left and right. This code deals with one stepper, but for an X-Y plotter, we have two axes to consider.

Command interpreter

I started to implement a simple command interpreter to use path specifications, such as:

"X30|Y30|X-30 Y-30|X-20|Y-20|X20|Y20|X-40|Y-25|X40 Y25

to describe relative movements in millimeters (1mm equals 80 steps).

The plotter software implements a continuous mode, which allows a PC to feed large paths (in chunks) to the plotter. (This how I plotted the Hilbert curve in this video.)

Building a better pen holder

In the first image above, the pen was tied to the Y-axis with some metal string. This was not precise and also did not enable the software to raise and lower the hand (this explains the big black dots).

I have since created a better, more precise pen holder that uses a servo to raise and lower the pen. This new, improved holder can be seen in this picture and in the Hilbert curve video linked above.

The pen is attached with a little clamp (the one shown is a size 8 clamp typically used to attach cables to walls). The servo arm can raise the pen; when the arm goes down, gravity will lower the pen.

Driving the servo

Driving the servo is relatively straightforward: Just provide the position and the servo does all the work.


#include

// Servo pin
#define servoData PIN_A1

// Positions
#define PEN_UP 10
#define PEN_DOWN 50

Servo penServo;

void setup() {
  // Attach to servo and raise pen
  penServo.attach(servoData);
  penServo.write(PEN_UP);
}

I am using the servo headers on the Motor 4 place of the FabScan shield, so I’ve used analog pin 1.

Lowering the pen is as easy as:

 penServo.write(PEN_DOWN);

Next steps

One of my next steps will be to add some end detectors, but I may skip them and use the StallGuard mode of the TMC2130 instead. Those detectors can also be used to implement a home command.

And perhaps in the future I’ll add a real Z-axis that can hold an engraver to do wood milling, or PCB drilling, or acrylic engraving, or … (a laser comes to mind as well).

This was originally published on the Some Things to Remember blog and is reprinted with permission.

LG re-open sources WebOS, a look at the AI behind the Pixel 2's camera, and more news

In this edition of our open source news roundup, we take a look LG making WebOS open source (again), Google’s camera AI tools, a 3D printed stethoscope, and more.

Open source news roundup for March 18-31, 2018

LG makes WebOS open source… again

What was once open source is open source again. After Korean electronics giant LG bought WebOS from HP, it made the mobile operating system proprietary. The company has done an about-face and has released WebOS Open Source Edition. The goal: to convince developers to adopt WebOS for tablets, set-top boxes, and more.

WebOS, which was originally designed for Palm’s failed line of smartphones, has been powering LG’s televisions since 2013. Since then, “LG has refined the platform significantly, and hopes that the new release will help others exploit it.” To try to get developers on the WebOS bandwagon, the company has made a software development kit and build instructions available.

Google open sources its camera AI tools

Ever wonder how Google’s Pixel 2 smartphones take such impressive portrait-mode photos? Wonder no more. Google has open sourced the artificial intelligence technology behind it.

Called DeepLab 3+, the technology “uses a neural network to detect the outlines of objects in your camera’s field of view.” That enables a camera to gain a greater depth of field and to more accurately identify objects it sees. You can grab the code for DeepLab 3+ from GitHub and learn more about how the technology works.

Researchers create clinically-validated 3D printed stethoscope

Something as simple as a stethoscope can make a huge difference to medical professionals, especially ones in developing countries and in conflict zones. High-quality stethoscopes can be a difficult-to-obtain commodity in those situations, though. Thanks to the work of Dr. Tarek Loubani of the University of Western Ontario, anyone with access to a 3D printer and ABS plastic can 3D print a high-quality stethoscope for less than $3.

Loubani’s stethoscope design, called the Gila, “was made using free open source software to keep costs low and allow others to easily access the code.” Loubani said that the Gila “is the first open source medical device that has been clinically validated and is widely available,” and that “the acoustic quality was the same in our stethoscope as in a premium brand stethoscope.” You can learn more at the Gila Free Medical Hardware GitHub repository.

New open source file indexing software

The laboratory that gave the world the atomic bomb has made its search and retrieval software open source. Los Alamos National Laboratory boasts that its Grand Unified File Index (GUFI for short), released under a BSD license, can perform within seconds queries “that would previously have taken hours or days.”

Gary Grider, who heads the High Performance Computing division at Los Alamos, said that GUFI “will have a big impact on the ability for many levels of users to search data and get a fast response.” That includes making “calculations that support national security, as well as basic scientific research in fields such as engineered materials, biological processes, and earth systems modeling.”

In other news

Thanks, as always, to Opensource.com staff members and moderators for their help this week. Make sure to check out our event calendar to see what’s happening next week in open source.

Meet the Raspberry Pi 3 Model B+

Raspberry Pi just celebrated its sixth birthday—that’s six years since the launch of the original Raspberry Pi. Since then, it has released various new models, including the Pi 2, Pi 3, and Pi Zero. So far, 9 million Raspberry Pi 3s have been sold—and over 18 million Pis in total—and those numbers are likely to grow following today’s announcement of the Raspberry Pi 3 Model B+. This new Pi features:

  • 1.4GHz 64-bit quad-core ARM Cortex-A53 CPU
  • Gigabit Ethernet (over USB)
  • Dual-band WiFi and Bluetooth
  • Power-over-Ethernet (PoE) pins
  • Improved PXE and USB booting
  • Improved thermal management

This is a big update to the existing Pi 3, including a re-spin of the BCM2837 CPU (running faster at 1.4GHz), new dual-band wireless connectivity (so you can connect to both 2.4- and 5-GHz WiFi networks), better thermal control, and more. As always, you’ll need an up-to-date Raspbian SD card, but the new model is backwards-compatible with all previous models and runs the same operating systems and programs. The Raspberry Pi 3 Model B+ is available now at the usual price of $35.

raspberry-pi-3bplus-1_1.jpg

Gigabit Ethernet and PoE

The Raspberry Pi has always suffered an Ethernet bottleneck, throttling network speeds over USB 2.0. The new 3B+ replaces the LAN9514 USB hub with a with a LAN7515 adding Gigabit Ethernet. It’s still limited by USB 2.0 but gives a 3x LAN throughput increase, which will please a lot of Pi users with network-hungry applications in the home and in industrial applications.

raspberry-pi-3bplus-5_1.jpg

The addition of four new pins offset from the main GPIO header provides support for Power-over-Ethernet. An official HAT (add-on board) has been designed to provide this feature natively, and it will be released soon.

The original Raspberry Pi 3 was the first Pi board to support multiple boot modes (an alternative to regular booting from the SD card)—including PXE network booting and booting from USB mass storage devices. This means you can boot Raspbian from a USB hard drive, which has faster disk I/O than an SD card.

The PiServer tool, launched in December, provides simple Raspberry Pi network management. This means you can manage a cluster of Raspberry Pi 3s on a wired network, and the Pis don’t need SD cards inserted as they boot remotely into a managed operating system image. This is ideal for classrooms, handy in the home, and can even be used to manage factory automation processes in industrial applications.

The 3+ also supports netbooting, and some minor bugs in the bootrom, found in the Pi 3 after rollout, have been fixed.

Thermals and power management

Over the years, as the Raspberry Pi became more powerful and increased its CPU speed, it became more power-hungry and tended run hotter. The 3+ improves power regulation, allowing the Pi to run happily at 1.4GHz when the CPU is under 70°C, and it decreases the core voltage and drops to 1.2GHz above 70°C before throttling at 80°C, but the improved power management should prevent it from reaching this point.

With Raspberry Pi 1 you could get away with using low-power mobile phone chargers. Although some of them can manage to boot the Pi 3 and 3+ ok, they likely won’t stand up to intensive applications that draw lots of power, so a quality 2.5A power supply is recommended.

What can you do with it?

There are many applications for Raspberry Pi: it’s used heavily in education (in schools and in coding clubs), in the home (see 5 projects for Raspberry Pi at home), and in industry. Many people use Pis for media centers and home automation projects or just for learning about code and building hardware projects. You can do physical computing and camera projects. Check out the getting started guide, read up on which Raspberry Pi to choose for your project, and take a look at this selection of Raspberry Pi add-on boards. Learn how to set up Postgres on the Pi and write a Twitter bot with Python!

Get involved with the Raspberry Pi Foundation

The Raspberry Pi Foundation is not just a hardware company. It’s primarily an educational charity with the aim of putting the power of digital making into the hands of people all over the world. Making affordable, programmable computers is just one of the things the Foundation does to help with this goal.

Last weekend, the Raspberry Jam Big Birthday Weekend took place, and over 120 Jam events took place around the world. Check out the round-up of these events, and see how to run a Raspberry Pi meetup in your community.

Raspberry Jam Big Birthday Weekend

You can also give young people an opportunity to learn about coding and digital making by starting a Code Club or CoderDojo near you.

How to measure particulate matter with a Raspberry Pi

We regularly measure particulate matter in the air at our school in Southeast Asia. The values here are very high, particularly between February and May, when weather conditions are very dry and hot, and many fields burn. These factors negatively affect the quality of the air. In this article, I will show you how to measure particulate matter using a Raspberry Pi.

What is particulate matter?

Particulate matter is fine dust or very small particles in the air. A distinction is made between PM10 and PM2.5: PM10 refers to particles that are smaller than 10µm; PM2.5 refers to particles that are smaller than 2.5µm. The smaller the particles—i.e., anything smaller than 2.5µm—the more dangerous they are to one’s health, as they can penetrate into the alveoli and impact the respiratory system.

The World Health Organization recommends limiting particulate matter to the following values:

  • Annual average PM10 20 µg/m³
  • Annual average PM2,5 10 µg/m³ per year
  • Daily average PM10 50 µg/m³ without permitted days on which exceeding is possible.
  • Daily average PM2,5 25 µg/m³ without permitted days on which exceeding is possible.

These values are below the limits set in most countries. In the European Union, an annual average of 40 µg/m³ for PM10 is allowed.

What is the Air Quality Index (AQI)?

The Air Quality Index indicates how “good” or “bad” air is based on its particulate measurement. Unfortunately, there is no uniform standard for AQI because not all countries calculate it the same way. The Wikipedia article on the Air Quality Index offers a helpful overview. At our school, we are guided by the classification established by the United States’ Environmental Protection Agency.

What do we need to measure particulate matter?

Measuring particulate matter requires only two things:

  • A Raspberry Pi (every model works; a model with WiFi is best)
  • A particulates sensor SDS011

If you are using a Raspberry Pi Zero W, you will also need an adapter cable to a standard USB port because the Zero has only a Micro USB. These are available for about $20. The sensor comes with a USB adapter for the serial interface.

Installation

For our Raspberry Pi we download the corresponding Raspbian Lite Image and write it on the Micro SD card. (I will not go into the details of setting up the WLAN connection; many tutorials are available online).

If you want to have SSH enabled after booting, you need to create an empty file named ssh in the boot partition. The IP of the Raspberry Pi can best be obtained via your own router/DHCP server. You can then log in via SSH (the default password is raspberry):

$ ssh pi@192.168.1.5

First we need to install some packages on the Pi:

$ sudo apt install git-core python-serial python-enum lighttpd

Before we can start, we need to know which serial port the USB adapter is connected to. dmesg helps us:


$ dmesg
[ 5.559802] usbcore: registered new interface driver usbserial
[ 5.559930] usbcore: registered new interface driver usbserial_generic
[ 5.560049] usbserial: USB Serial support registered for generic
[ 5.569938] usbcore: registered new interface driver ch341
[ 5.570079] usbserial: USB Serial support registered for ch341-uart
[ 5.570217] ch341 1–1.4:1.0: ch341-uart converter detected
[ 5.575686] usb 1–1.4: ch341-uart converter now attached to ttyUSB0

In the last line, you can see our interface: ttyUSB0. We now need a small Python script that reads the data and saves it in a JSON file, and then we will create a small HTML page that reads and displays the data.

Reading data on the Raspberry Pi

We first create an instance of the sensor and then read the sensor every 5 minutes, for 30 seconds. These values can, of course, be adjusted. Between the measuring intervals, we put the sensor into a sleep mode to increase its lifespan (according to the manufacturer, the lifespan totals approximately 8000 hours).

We can download the script with this command:

$ wget -O /home/pi/aqi.py https://raw.githubusercontent.com/zefanja/aqi/master/python/aqi.py

For the script to run without errors, two small things are still needed:


$ sudo chown pi:pi /var/wwww/html/
$ echo[] > /var/wwww/html/aqi.json

Now you can start the script:


$ chmod +x aqi.py
$ ./aqi.py
PM2.5:55.3, PM10:47.5
PM2.5:55.5, PM10:47.7
PM2.5:55.7, PM10:47.8
PM2.5:53.9, PM10:47.6
PM2.5:53.6, PM10:47.4
PM2.5:54.2, PM10:47.3

Run the script automatically

So that we don’t have to start the script manually every time, we can let it start with a cronjob, e.g., with every restart of the Raspberry Pi. To do this, open the crontab file:

$ crontab -e

and add the following line at the end:

@reboot cd /home/pi/ && ./aqi.py

Now our script starts automatically with every restart.

HTML page for displaying measured values and AQI

We have already installed a lightweight webserver, lighttpd. So we need to save our HTML, JavaScript, and CSS files in the directory /var/www/html/ so that we can access the data from another computer or smartphone. With the next three commands, we simply download the corresponding files:


$ wget -O /var/wwww/html/index.html https://raw.githubusercontent.com/zefanja/aqi/master/html/index.html
$ wget -O /var/wwww/html/aqi.js https://raw.githubusercontent.com/zefanja/aqi/master/html/aqi.js
$ wget -O /var/wwww/html/style.css https://raw.githubusercontent.com/zefanja/aqi/master/html/style.css

The main work is done in the JavaScript file, which opens our JSON file, takes the last value, and calculates the AQI based on this value. Then the background colors are adjusted according to the scale of the EPA.

Now you simply open the address of the Raspberry Pi in your browser and look at the current particulates values, e.g., http://192.168.1.5:

The page is very simple and can be extended, for example, with a chart showing the history of the last hours, etc. Pull requests are welcome.

The complete source code is available on Github.

[Enter our Raspberry Pi week giveaway for a chance at this arcade gaming kit.]

Wrapping up

For relatively little money, we can measure particulate matter with a Raspberry Pi. There are many possible applications, from a permanent outdoor installation to a mobile measuring device. At our school, we use both: There is a sensor that measures outdoor values day and night, and a mobile sensor that checks the effectiveness of the air conditioning filters in our classrooms.

Luftdaten.info offers guidance to build a similar sensor. The software is delivered ready to use, and the measuring device is even more compact because it does not use a Raspberry Pi. Great project!

Creating a particulates sensor is an excellent project to do with students in computer science classes or a workshop.

What do you use a Raspberry Pi for?

Top 5: Perl hashes and arrays, landing a Linux day job, and more

In this week’s top 5, we take a look at Perl, wikis, what the Grateful Dead has to do with Creative Commons, and more.

5. Perl hashes and arrays: the basics

Community moderator Ruth Holloway gets us back to basics with an introduction to two important parts of Perl. If you’re interested in getting started with Perl, you need to read this article.

4. How Linux became my job

Phil Estes tells the tale of how he took his hobby and went pro with it. May we all be so lucky.

3. Create a wiki on your Linux desktop with Zim

Need a private wiki on your desktop? Community moderator Scott Nesbitt shows you how it’s done with Zim.

2. SUNY math professor makes the case for free and open educational resources

Disruption in school will usually get you sent to the principal’s office. But community moderator Don Watkins tells us how open educational resources are making a good disruption.

1. How the Grateful Dead were a precursor to Creative Commons licensing

The Grateful Dead didn’t just make music, they made it so people could share music. Matthew Helmke connects the dots from the Dead to Creative Commons.

Get started with IoT: How to build a DIY Blynk Board

This tutorial is for those with some DIY hardware experience, though advanced beginners may find it a fun challenge. Also, experienced users might find it fun to set this up for beginners to learn from. To make this board without the SparkFun IoT Starter Kit with Blynk Board, you’ll need sensors and other components to complete the built-in projects. For instance, the SparkFun Blynk Board comes with onboard WS2812 RGB LED, so you’ll need a similar module to make projects using the device. You can purchase the components individually from Sparkfun

I organize workshops in my local community to introduce people to open source hardware platforms such as Arduino and Raspberry Pi. With all the buzz around the Internet of Things these days, everyone wants to start tinkering and prototyping. The enthusiasts are usually designers, web developers, or students, and most want to get going with little coding.

ESP8266-based Blynk Boards come with preloaded projects and are ideal for introducing Internet of Things and basic electronics concepts.

About the hardware

The ESP8266 is a great chip with built-in WiFi. It was originally used with Arduino boards to WiFi-enable hardware projects but soon became a cheap standalone Arduino-compatible development board. It comes in many shapes and forms and is most famous in development boards such as NodeMcu, Adafruit HUZZAH, or the SparkFun ESP8266 Thing.

David Egts wrote this terrific article about the ESP8266.

While the ESP8266 is great open source hardware for getting started with the Internet of Things, Blynk is an ideal platform to control Arduino, Raspberry Pi, and the like over the Internet. Essentially, Blynk includes three components: a Blynk app for the smartphone, the Blynk server, and Blynk library (firmware), which is compatible with a variety of makers’ hardware.

Both the Blynk server and Blynk library are open source, while the Blynk app is available free for iOS and Android. The Blynk app allows you to build a graphic interface for your IoT project by simply dragging and dropping widgets. Blynk includes widgets such as LCD display, Joystick, and Buttons so you can start hacking away with just an IoT development board.

Blynk partnered with SparkFun to create the SparkFun Blynk Board based on the ESP8266. It comes fully programmed and includes more than ten pre-loaded Blynk projects. The SparkFun IoT Starter Kit with Blynk Board is a solid introduction to the world of Internet of Things (IoT) technology with no difficult programming.

If you’re like me and have several ESP8266-based development boards lying around, you can use the firmware and turn them into DIY Blynk Boards. This would be ideal for running boot camps or workshops using existing boards. You’ll still need sensors and other components to be able to complete the built-in projects. For instance, the SparkFun Blynk Board comes with onboard WS2812 RGB LED, so you’ll need a similar module to make projects using the device.

Making a DIY Blynk Board

Gather the gear

  • An ESP8266-based development board such as NodeMCU, Wemos D1, Sparkfun ESP8266 Thing, etc.
  • Computer with Arduino IDE and proper drivers for development board
    You should already be able to flash an Arduino sketch onto the development board.
  • USB cable to connect board to a computer
  • WiFi network
  • Smartphone
  • An LED for testing
  • Blynk app: iOS and Android
    Before going any further, download the app to your smart device.

Install the required libraries

  1. Open the Arduino IDE
  2. Go to Sketch –> Include Library –> Manage Libraries
  3. Search for “blynk”, then install:
  4. Install the following additional libraries, using the latest version available:

    SparkFun HTU21D:

    Adafruit NeoPixel:

    SparkFun TSL2561:

Flashing the ESP8266 board with Blynk Board firmware

  1. Download the Blynk Board firmware.

    Extract the content of the zip file:

  2. Open any of the .ino files, which will open the Arduino IDE with several tabs:
  3. Scroll down on the BlynkBoard_Core_Firmware tab and uncomment the line:

    //#define DEBUG_ENABLED

    Comment the line:

    #define SELF_TEST_ENABLED

  4. Select the appropriate board (I’m using NodeMCU):
  5. Verify the sketch. The build should be successful.
  6. Connect your board to the computer via USB cable and upload the sketch.

The board is now flashed with BlynkBoard firmware.

Provisioning your DIY Blynk Board

In the provisioning process, we’ll use a smartphone, laptop, or computer to connect directly (over WiFi) to the Blynk Board. Once connected, your smart device will send the necessary data and tell the Blynk Board to connect to your Internet-connected wireless network and Blynk.

The Blynk Board is initially configured to operate as a WiFi access point (abbreviated “AP,” kind of like a router). A smartphone or WiFi-enabled computer can briefly connect to the Blynk Board, and using either the Blynk app or a browser, send all of the necessary information over to it. After the Blynk Board receives that info, it’ll transition from AP to WiFi device and connect to your WiFi network. The AP has SSID in the format BlynkMe-XXXX:

Note: The SparkFun Blynk Board has a built-in RGB LED. When powered on, it blinks with a unique sequence (randomly allocated) of four colors, including either red, green, blue, purple, or yellow, with a long stop in between. If you have a WS2812 RGB LED, you can connect it to Pin 4. In my case, the LED would blink red, red, yellow, and then red.

Follow one of the alternative provisioning methods in Sparkfun’s Getting Started with the SparkFun Blynk Board tutorial.

Testing the board

(Source: SparkFun tutorials)

Blynk setup

1. Make sure your project is not running – the upper-right icon should be a triangular play button.

2. Touch anywhere in the blank gray project space. A toolbox should open up on the right side with all of your widgets to choose from.

3. Select the Button widget by tapping it. You’ll find it at the top of the “Controllers” list.

4. Tap and hold the button widget to drag it anywhere within the project space. You’ve got a lot of room to work with right now.

 

5. Touch the Button Widget to bring up the settings page, and modify these values:
a. Name: “LED” – While the widget is a button, we’ll be using it to control an LED.
b. Output: 5 – in the “Digital” list.
c. Color: Click the red circle to change the color of the button. Try blue, since we’re toggling a blue LED.
d. Mode: Use “Switch” mode.

 

6. Confirm the settings:
If you’re using an Android, hit the back arrow in the upper-left corner
If you’re using an iOS device, hit the OK button.

Adding an offboard LED

Wire the LED as shown in the diagram below. The LED’s positive pin (the longer leg) should be connected to GPIO Pin number 5. Accordingly, on the NodeMCU GPIO 5 is Pin D1. Identify the correct pin for your board by referring to its pinout reference. The other LED pin should be connected to a ground pin (“GND”).

Blynk run

Now that the button is all configured in the Blynk app and the LED is properly wired to the board, run the project by tapping the Play button in the upper-right corner of the screen in Blynk app.

Once the project is running, tap the Button widget. When the widget is set to ON, the LED should also turn on.

Congrats! You have successfully made a DIY Blynk Board. You can now follow the above steps for any other ESP8266-based boards you have, and gear up for introducing IoT to enthusiasts in your community.

How to start writing macros in LibreOffice Basic

I have long promised to write about the scripting language Basic and creating macros in LibreOffice. This article is devoted to the types of data used in LibreOffice Basic, and to a greater extent, descriptions of variables and the rules for using them. I will try to provide enough information for advanced as well as novice users.

(And, I would like to thank everyone who commented on and offered recommendations on the Russian article, especially those who helped answer difficult questions.)

Variable naming conventions

Variable names cannot contain more than 255 characters. They should start with either upper- or lower-case letters of the Latin alphabet, and they can include underscores (“_”) and numerals. Other punctuation or characters from non-Latin alphabets can cause a syntax error or a BASIC runtime error if names are not put within square brackets.

Here are some examples of correct variable names:


MyNumber=5

MyNumber5=15

MyNumber_5=20

_MyNumber=96

[My Number]=20.5

[5MyNumber]=12

[Number,Mine]=12

[DéjàVu]=“It seems that I have seen it!”

[??? ??????????]=“The first has went!”

[??? % ?? ??????]=0.0001

Note: In examples that contain square brackets, if you remove the brackets, macros will show a window with an error. As you can see, you can use localized variable names. Whether it makes sense to do so is up to you.

Declaring variables

Strictly speaking, it is not necessary to declare variables in LibreOffice Basic (except for arrays). If you write a macro from a pair of lines to work with small documents, you don’t need to declare variables, as the variable will automatically be declared as the variant type. For longer macros or those that will work in large documents, it is strongly recommended that you declare variables. First, it increases the readability of the text. Second, it allows you to control variables that can greatly facilitate the search for errors. Third, the variant type is very resource-intensive, and considerable time is needed for the hidden conversion. In addition, the variant type does not choose the optimal variable type for data, which increases the workload of computer resources.

Basic can automatically assign a variable type by its prefix (the first letter in the name) to simplify the work if you prefer to use the Hungarian notation. For this, the statement DefXXX is used; XXX is the letter type designation. A statement with a letter will work in the module, and it must be specified before subprograms and functions appear. There are 11 types:


DefBool – for boolean variables;
DefInt – for integer variables of type Integer;
DefLng – for integer variables of type Long Integer;
DefSng – for variables with a single-precision floating point;
DefDbl – for variables with double-precision floating-point type Double;
DefCur – for variables with a fixed point of type Currency;
DefStr – for string variables;
DefDate – for date and time variables;
DefVar – for variables of Variant type;
DefObj – for object variables;
DefErr – for object variables containing error information.

If you already have an idea of the types of variables in LibreOffice Basic, you probably noticed that there is no Byte type in this list, but there is a strange beast with the Error type. Unfortunately, you just need to remember this; I have not yet discovered why this is true. This method is convenient because the type is assigned to the variables automatically. But it does not allow you to find errors related to typos in variable names. In addition, it will not be possible to specify non-Latin letters; that is, all names of variables in square brackets that need to be declared must be declared explicitly.

To avoid typos when using declared variables explicitly, you can use the statement OPTION EXPLICIT. This statement should be the first line of code in the module. All other commands, except comments, should be placed after it. This statement tells the interpreter that all variables must be declared explicitly; otherwise, it produces an error. Naturally, this statement makes it meaningless to use the Def statement in the code.

A variable is declared using the statement Dim. You can declare several variables simultaneously, even different types, if you separate their names with commas. To determine the type of a variable with an explicit declaration, you can use either a corresponding keyword or a type-declaration sign after the name. If a type-declaration sign or a keyword is not used after the variable, then the Variant type is automatically assigned to it. For example:


Dim iMyVar                      ‘variable of Variant type
Dim iMyVar1 As Integer, iMyVar2 As Integer ‘
in both cases Integer type
Dim iMyVar3, iMyVar4 As Integer ‘in this case the first variable
                                ‘
is Variant, and the second is Integer

Variable types

LibreOffice Basic supports seven classes of variables:

  • Logical variables containing one of the values: TRUE or FALSE
  • Numeric variables containing numeric values. They can be integer, integer-positive, floating-point, and fixed-point
  • String variables containing character strings
  • Date variables can contain a date and/or time in the internal format
  • Object variables can contain objects of different types and structures
  • Arrays
  • Abstract type Variant

Logical variables – Boolean

Variables of the Boolean type can contain only one of two values: TRUE or FALSE. In the numerical equivalent, the value FALSE corresponds to the number 0, and the value TRUE corresponds to -1 (minus one). Any value other than zero passed to a variable of the Boolean type will be converted to TRUE; that is, converted to a minus one. You can explicitly declare a variable in the following way:

Dim MyBoolVar As Boolean

I did not find a special symbol for it. For an implicit declaration, you can use the DefBool statement. For example:

DefBool b 'variables beginning with b by default are the type Boolean

The initial value of the variable is set to FALSE. A Boolean variable requires one byte of memory.

Integer variables

There are three types of integer variables: Byte, Integer, and Long Integer. These variables can only contain integers. When you transfer numbers with a fraction into such variables, they are rounded according to the rules of classical arithmetic (not to the larger side, as it stated in the help section). The initial value for these variables is 0 (zero).

Byte

Variables of the Byte type can contain only integer-positive values in the range from 0 to 255. Do not confuse this type with the physical size of information in bytes. Although we can write down a hexadecimal number to a variable, the word “Byte” indicates only the dimensionality of the number. You can declare a variable of this type as follows:

Dim MyByteVar As Byte

There is no a type-declaration sign for this type. There is no the statement Def of this type. Because of its small dimension, this type will be most convenient for a loop index, the values of which do not go beyond the range. A Byte variable requires one byte of memory.

Integer

Variables of the Integer type can contain integer values from -32768 to 32767. They are convenient for fast calculations in integers and are suitable for a loop index. % is a type-declaration sign. You can declare a variable of this type in the following ways:


Dim MyIntegerVar%
Dim MyIntegerVar As Integer

For an implicit declaration, you can use the DefInt statement. For example:

DefInt i 'variables starting with i by default have type Integer

An Integer variable requires two bytes of memory.

Long integer

Variables of the Long Integer type can contain integer values from -2147483648 to 2147483647. Long Integer variables are convenient in integer calculations when the range of type Integer is insufficient for the implementation of the algorithm. & is a type-declaration sign. You can declare a variable of this type in the following ways:


Dim MyLongVar&
Dim MyLongVar As Long

For an implicit declaration, you can use the DefLng statement. For example:

DefLng l 'variables starting with l have Long by default

A Long Integer variable requires four bytes of memory.

Numbers with a fraction

All variables of these types can take positive or negative values of numbers with a fraction. The initial value for them is 0 (zero). As mentioned above, if a number with a fraction is assigned to a variable capable of containing only integers, LibreOffice Basic rounds the number according to the rules of classical arithmetic.

Single

Single variables can take positive or negative values in the range from 3.402823x10E+38 to 1.401293x10E-38. Values of variables of this type are in single-precision floating-point format. In this format, only eight numeric characters are stored, and the rest is stored as a power of ten (the number order). In the Basic IDE debugger, you can see only 6 decimal places, but this is a blatant lie. Computations with variables of the Single type take longer than Integer variables, but they are faster than computations with variables of the Double type. A type-declaration sign is !. You can declare a variable of this type in the following ways:


Dim MySingleVar!
Dim MySingleVar As Single

For an implicit declaration, you can use the DefSng statement. For example:

DefSng f 'variables starting with f have the Single type by default

A single variable requires four bytes of memory.

Double

Variables of the Double type can take positive or negative values in the range from 1.79769313486231598x10E308 to 1.0x10E-307. Why such a strange range? Most likely in the interpreter, there are additional checks that lead to this situation. Values of variables of the Double type are in double-precision floating-point format and can have 15 decimal places. In the Basic IDE debugger, you can see only 14 decimal places, but this is also a blatant lie. Variables of the Double type are suitable for precise calculations. Calculations require more time than the Single type. A type-declaration sign is #. You can declare a variable of this type in the following ways:


Dim MyDoubleVar#
Dim MyDoubleVar As Double

For an implicit declaration, you can use the DefDbl statement. For example:

DefDbl d 'variables beginning with d have the type Double by default

A variable of the Double type requires 8 bytes of memory.

Currency

Variables of the Currency type are displayed as numbers with a fixed point and have 15 signs in the integral part of a number and 4 signs in fractional. The range of values includes numbers from -922337203685477.6874 to +92337203685477.6874. Variables of the Currency type are intended for exact calculations of monetary values. A type-declaration sign is @. You can declare a variable of this type in the following ways:


Dim MyCurrencyVar@
Dim MyCurrencyVar As Currency

For an implicit declaration, you can use the DefCur statement. For example:

DefCur c 'variables beginning with c have the type Currency by default

A Currency variable requires 8 bytes of memory.

String

Variables of the String type can contain strings in which each character is stored as the corresponding Unicode value. They are used to work with textual information, and in addition to printed characters (symbols), they can also contain non-printable characters. I do not know the maximum size of the line. Mike Kaganski experimentally set the value to 2147483638 characters, after which LibreOffice falls. This corresponds to almost 4 gigabytes of characters. A type-declaration sign is $. You can declare a variable of this type in the following ways:


Dim MyStringVar$
Dim MyStringVar As String

For an implicit declaration, you can use the DefStr statement. For example:

DefStr s 'variables starting with s have the String type by default

The initial value of these variables is an empty string (“”). The memory required to store string variables depends on the number of characters in the variable.

Date

Variables of the Date type can contain only date and time values stored in the internal format. In fact, this internal format is the double-precision floating-point format (Double), where the integer part is the number of days, and the fractional is part of the day (that is, 0.00001157407 is one second). The value 0 is equal to 30.12.1899. The Basic interpreter automatically converts it to a readable version when outputting, but not when loading. You can use the Dateserial, Datevalue, Timeserial, or Timevalue functions to quickly convert to the internal format of the Date type. To extract a certain part from a variable in the Date format, you can use the Day, Month, Year, Hour, Minute, or Second functions. The internal format allows us to compare the date and time values by calculating the difference between two numbers. There is no a type-declaration sing for the Date type, so if you explicitly define it, you need to use the Date keyword.

Dim MyDateVar As Date

For an implicit declaration, you can use the DefDate statement. For example:

DefDate y 'variables starting with y have the Date type by default

A Date variable requires 8 bytes of memory.

Types of object variables

We can take two variables types of LibreOffice Basic to Objects.

Objects

Variables of the Object type are variables that store objects. In general, the object is any isolated part of the program that has the structure, properties, and methods of access and data processing. For example, a document, a cell, a paragraph, and dialog boxes are objects. They have a name, size, properties, and methods. In turn, these objects also consist of objects, which in turn can also consist of objects. Such a “pyramid” of objects is often called an object model, and it allows us, when developing small objects, to combine them into larger ones. Through a larger object, we have access to smaller ones. This allows us to operate with our documents, to create and process them while abstracting from a specific document. There is no a type-declaration sing for the Object type, so for an explicit definition, you need to use the Object keyword.

Dim MyObjectVar As Object

For an implicit declaration, you can use the DefObj statement. For example:

DefObj o 'variables beginning with o have the type Object by default

The variable of type Object does not store in itself an object but is only a reference to it. The initial value for this type of variables is Null.

Structures

The structure is essentially an object. If you look in the Basic IDE debugger, most (but not all) are the Object type. Some are not; for example, the structure of the Error has the type Error. But roughly speaking, the structures in LibreOffice Basic are simply grouped into one object variable, without special access methods. Another significant difference is that when declaring a variable of the Structure type, we must specify its name, rather than the Object. For example, if MyNewStructure is the name of a structure, the declaration of its variable will look like this:

Dim MyStructureVar As MyNewStructure

There are a lot of built-in structures, but the user can create personal ones. Structures can be convenient when we need to operate with sets of heterogeneous information that should be treated as a single whole. For example, to create a tPerson structure:


Type tPerson
  Name As String
  Age As Integer
  Weight As Double
End Type

The definition of the structure should go before subroutines and functions that use it.

To fill a structure, you can use, for example, the built-in structure com.sun.star.beans.PropertyValue:


Dim oProp As New com.sun.star.beans.PropertyValue
OProp.Name = “Age” ‘Set the Name
OProp.Value = “Amy Boyer” ‘
Set the Property

For a simpler filling of the structure, you can use the With operator.


Dim oProp As New com.sun.star.beans.PropertyValue
With oProp
  .Name = “Age” ‘Set the Name
  .Value = “Amy Boyer” ‘
Set the Property
End With

The initial value is only for each variable in the structure and corresponds to the type of the variable.

Variant

This is a virtual type of variables. The Variant type is automatically selected for the data to be operated on. The only problem is that the interpreter does not need to save our resources, and it does not offer the most optimal variants of variable types. For example, it does not know that 1 can be written in Byte, and 100000 in Long Integer, although it reproduces a type if the value is passed from another variable with the declared type. Also, the transformation itself is quite resource-intensive. Therefore, this type of variable is the slowest of all. If you need to declare this kind of variable, you can use the Variant keyword. But you can omit the type description altogether; the Variant type will be assigned automatically. There is no a type-declaration sign for this type.


Dim MyVariantVar
Dim MyVariantVar As Variant

For an implicit declaration, you can use the DefVar statement. For example:

DefVar v 'variables starting with v have the Variant type by default

This variables type is assigned by default to all undeclared variables.

Arrays

Arrays are a special type of variable in the form of a data set, reminiscent of a mathematical matrix, except that the data can be of different types and allow one to access its elements by index (element number). Of course, a one-dimensional array will be similar to a column or row, and a two-dimensional array will be like a table. There is one feature of arrays in LibreOffice Basic that distinguishes it from other programming languages. Since we have an abstract type of variant, then the elements of the array do not need to be homogeneous. That is, if there is an array MyArray and it has three elements numbered from 0 to 2, and we write the name in the first element of MyArray(0), the age in the second MyArray(1), and the weight in the third MyArray(2), we can have, respectively, the following type values: String for MyArray(0), Integer for MyArray(1), and Double for MyArray(2). In this case, the array will resemble a structure with the ability to access the element by its index. Array elements can also be homogeneous: Other arrays, objects, structures, strings, or any other data type can be used in LibreOffice Basic.

Arrays must be declared before they are used. Although the index space can be in the range of type Integer—from -32768 to 32767—by default, the initial index is selected as 0. You can declare an array in several ways:

Dim MyArrayVar(5) as string String array with 6 elements from 0 to 5
Dim MyArrayVar$(5) Same as the previous
Dim MyArrayVar(1 To 5) as string String array with 5 elements from 1 to 5
Dim MyArrayVar(5,5) as string Two-dimensional array of rows with 36 elements with indexes in each level
from 0 to 5
Dim MyArrayVar$(-4 To 5, -4 To 5) Two-dimensional strings array with 100 elements with indexes in each level
from -4 to 5
Dim MyArrayVar() Empty array of the Variant type

You can change the lower bound of an array (the index of the first element of the array) by default using the Option Base statement; that must be specified before using subprograms, functions, and defining user structures. Option Base can take only two values, 0 or 1, which must follow immediately after the keywords. The action applies only to the current module.

Learn more

If you are just starting out in programming, Wikipedia provides general information about the array, structure, and many other topics.

For a more in-depth study of LibreOffice Basic, Andrew Pitonyak’s website is a top resource, as is the Basic Programmer’s guide. You can also use the LibreOffice online help. Completed popular macros can be found in the Macros section of The Document Foundation’s wiki, where you can also find additional links on the topic.

For more tips, or to ask questions, visit Ask LibreOffice and OpenOffice forum.

3 steps to reduce a project's failure rate

It’s no secret that clear, concise, and measurable requirements lead to more successful projects. A study about large scale projects by McKinsey & Company in conjunction with the University of Oxford revealed that “on average, large IT projects run 45 percent over budget and 7 percent over time, while delivering 56 percent less value than predicted.” The research also showed that some of the causes for this failure were “fuzzy business objectives, out-of-sync stakeholders, and excessive rework.”

Business analysts often find themselves constructing these requirements through ongoing conversations. To do this, they must engage multiple stakeholders and ensure that engaged participants provide clear business objectives. This leads to less rework and more projects with a higher rate of success.

And they can do it in an open and inclusive way.

A framework for success

One tool for increasing project success rate is the Open Decision Framework. The Open Decision Framework is an resource that can help users make more effective decisions in organizations that embrace open principles. The framework stresses three primary principles: being transparent, being inclusive, and being customer-centric.

Transparent. Many times, developers and product designers assume they know how stakeholders use a particular tool or piece of software. But these assumptions are often incorrect and lead to misconceptions about what stakeholders actually need. Practicing transparency when having discussions with developers and business owners is imperative. Development teams need to see not only the “sunny day” scenario but also the challenges that stakeholders face with certain tools or processes. Ask questions such as: “What steps must be done manually?” and “Is this tool performing as you expect?” This provides a shared understanding of the problem and a common baseline for discussion.

Business analysts often find themselves constructing these requirements through ongoing conversations. To do this, they must engage multiple stakeholders and ensure that engaged participants provide clear business objectives.

Inclusive. It is vitally important for business analysts to look at body language and visual cues when gathering requirements. If someone is sitting with arms crossed or rolling their eyes, then it’s a clear indication that they do not feel heard. A BA must encourage open communication by reaching out to those that don’t feel heard and giving them the opportunity to be heard. Prior to starting the session, lay down ground rules that make the place safe for all to speak their opinions and to share their thoughts. Listen to the feedback provided and respond politely when feedback is offered. Diverse opinions and collaborative problem solving will bring exciting ideas to the session.

Customer-centric. The first step to being customer-centric is to recognize the customer. Who is benefiting from this change, update, or development? Early in the project, conduct a stakeholder mapping to help determine the key stakeholders, their roles in the project, and the ways they fit into the big picture. Involving the right customers and assuring that their needs are met will lead to more successful requirements being identified, more realistic (real-life) tests being conducted, and, ultimately, a successful delivery.

When your requirement sessions are transparent, inclusive, and customer-centric, you’ll gather better requirements. And when you use the Open Decision Framework for running those sessions, participants feel more involved and empowered, and they deliver more accurate and complete requirements. In other words:

Transparent + Inclusive + Customer-Centric = Better Requirements = Successful Projects