Embedded Linux

Measuring DC Voltage, Current, Power, Energy & Charge with a Raspberry Pi

Do you have a requirement to measure the voltage, current and power drawn from a battery or by a device using a Raspberry Pi? Perhaps you are also seeking to measure energy consumed (watt/hours) or charge (amp/hours) to determine state of charge (SoC) like a coulomb counter? If the answer is yes, then one of the easiest ways of achieving this is via a dedicated I2C sensor wired into the Raspberry Pi. Hardware One of the more popular sensors for measuring voltage and current is the digital power monitors from Texas Instruments. At the time of writing, the portfolio included

LoRaWAN

LoRaWAN: Installing Basic Station and connecting to The Things Network V3 Stack

With the migration of The Things Network to the version 3 stack, I thought it was an opportune time to upgrade my Raspberry PI based gateway from the legacy Semtech packet forwarder to Basic Station. Basic Station LoRaWAN gateway maintainers should be using secured and encrypted connections to the LoRaWAN Network Server (LNS) rather than the old legacy packet forwarder using UDP packets. Semtech provide opensource software called LoRa Basics™ Station for this purpose: Basic Station exchanges data as JSON encoded objects over secure WebSockets.  The gateway identifies itself with a secret API key, ensuring it’s authorised. In addition to

CAN - Controller Area Network

Adding CAN to the Raspberry PI

The CAN bus (Controller Area Network) was originally designed by Bosch for the automotive market to connect ECUs (Engine/Electronic Control Units) together. Today, this robust communications bus is commonly found, not only in vehicles, but also on the factory floor in automation (e.g. CANOpen) and other applications such as PV solar inverter/battery Energy Storage Systems (ESS). The Raspberry PI doesn’t natively support CAN. The Broadcom SoCs (System on a Chip) used by the Raspberry PI doesn’t include a CAN controller. The Linux kernel supports CAN and includes SocketCAN drivers for the Microchip MCP2515 Stand-alone CAN Controller with SPI Interface. Various

Electronics Hardware

LTC4040 5V, 2.5A Uninterruptible Power Supply (UPS) with USB-C

Motivation I have had the requirement to back-up small 5V low-powered devices such as a Foscam C1 security camera and a Raspberry PI based LoRaWAN concentrator. Many commonly available 5V Uninterruptible Power Supplies feature a two chip design with a Li-Ion battery charger to charge the back-up battery, and boost converter to step up the battery voltage back up to 5V. Like most of my personal designs, cost was not a primary driver. I was on the search for a elegant, preferably single chip device that was fit for purpose. Lithium Ion batteries can be stressed when left at full

Embedded Linux

An Introduction to chardev GPIO and Libgpiod on the Raspberry PI

Linux 4.8 introduced a new GPIO user space subsystem for accessing GPIO. This tutorial provides an introduction to the new Character Device GPIO and explores how to control GPIO from the command line. sysfs GPIO User-mode GPIO (General Purpose Input/Output) has historically been performed via the legacy “integer-based”sysfs pseudo file system.  For example, to set GPIO25, one would: # echo out > /sys/class/gpio/gpio25/direction # echo 1 > /sys/class/gpio/gpio25/value GPIO access via this legacy sysfs interface has been deprecated since version 4.8 of the Linux kernel. chardev GPIO The new way of doing GPIO is via the “descriptor-based” character device ABI (Application Binary

Embedded Linux

Compiling U-Boot with Device Tree Support for the Raspberry Pi

U-Boot U-Boot (The Universal Bootloader) is a popular, feature rich, open source bootloader for embedded systems. It is licenced under the GNU General Public Licence version 2. While its primary purpose is to boot an operating system, such as Linux, it also provides many useful tools for developing and debugging embedded systems. This includes support for many common file-systems including FAT, ext3, ext4, NFS etc and interfaces such as USB, Ethernet (IP), MMC and even Asynchronous Serial (Kermit/xmodem/ymodem). This allows the developer to load new images and file-systems from a variety of sources for testing and/or reflashing. It also includes

LoRaWAN

RAK833/RAK2247 LoRaWAN Concentrator

This board is a Raspberry PI Hat for the RAK833/RAK2247 LoRa Concentrator Gateway Modules. The RAK2247 is improved version of the RAK833 with better heatsinking, a boost in the maximum transmission power and improved interference immunity. Both are a smaller version of the popular RAK831. The RAK831 is larger, about the same footprint than a Raspberry PI and requires a breakout board to convert the RAK831’s 24 pin connector to the Raspberry PI’s 40 pin connector. The RAK833 is a more elegant industry standard PCI Express Mini Card form factor (Type F2). The RAK833 module consists of a Semtech SX1301 Digital Baseband chip