USB

Review: USB-PD 65W Fast Charging Module (XPM52C)

This USB-PD (Power Delivery) Charging module is based on the XPM52C 65W USB-PD Multi-protocol Buck Converter. It allows USB devices (mobile phones, tablets, laptop computers, cameras etc) to be efficiently charged from a low voltage DC power source (8 to 30V DC) such as 12V/24V battery or power station. While my interest was in the USB-C power delivery capability, the device supports a range of legacy fast-charging protocols: This module is available from your usual cheap electronics sources such as AliExpress, Amazon, and Banggood. As the vendors normally don’t list the main part in their descriptions, search for “PD 65W

Electronics Hardware

Review: Low Voltage 12 – 85V DC/AC E27 Light Bulb

In off-grid systems, it can make sense to use a low voltage DC light bulb, instead of having the overheads of a DC to AC inverter – in terms of capital cost, quiescent (idle) current, conversion efficiency and risk of electrocution. For example, in a shed or other de-attached structure you could have a small 12V or 24V PV Solar system and run your lighting directly from that source. LED bulbs exist in standard E27 (Edison screw, 27mm) and B22 (Bayonet cap, 22mm) that can be powered from lower voltages – typically 12V, 24V or 48V. We review one such

USB

Review: USB-C Power Delivery Trigger Board (CH224)

Depending upon their capability, USB-C PD adapters and chargers can source a variety of different voltages and currents. This is typically 5V, 9V, 12V, 15V and 20V up to 100W (for PD version 3.0). The adapter will initially provide either 5V (to support legacy protocols) or no voltage at all (if USB-C PD only). To obtain 5V or a higher voltage, the sink device needs to request this. For USB Power Delivery, the mechanism is that the source (adapter) will advertise its capabilities through a series of PDO or power delivery objects and the sink will request the desired voltage

Zephyr

Using STM32 HAL with Zephyr: Setting the Brown Out Reset Threshold

The Zephyr RTOS has good support for the STM32 family, but every now and again you need to access something that is not supported. In my most recent experience, I needed to set the Brown-Out Reset (BOR) thresholds on a STM32WLE5CC. Adding vendor or device specific functions can break Zephyr’s code portability between devices and should only be done as a last resort. Where possible, use Zephyr’s supported API. Documentation The STM32 HAL (Hardware Abstraction Layer) and STM32 LL (Low-Level Drivers) comes bundled as a module with Zephyr. The source can be found on Github at https://github.com/zephyrproject-rtos/hal_stm32 with some basic

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

Zephyr

DeviceTree Overlays on Zephyr RTOS: Adding I2C or SPI

After 18 months developing with the Zephyr RTOS, I’m starting to become a strong proponent. In my opinion, one of the key advantages of the Zephyr RTOS is the hardware abstraction. It allows applications to be written for Zephyr that are platform independent and can be moved between different boards including different manufacturers of microcontrollers. In a world still suffering from chip shortages, it has been a breath of fresh air. The Zephyr application (project) contains the application source code while the board files detail the hardware and GPIO assignment, or essentially, how the printed circuit board is wired. This

Electric Vehicles

Prototype IEC61851 / J1772 EVSE Interface

This is a prototype IEC61851 / J1772 EVSE (Electric Vehicle Supply Equipment) Interface intended to connect to a 3.3V micro-controller of your choice. It was originally designed to piggyback on the Electric Vehicle Charge Controller PCB (shown above) and utilise the on-board Microchip dsPIC33 MCU. Firmware for the dsPIC33 is currently working. Code is now being developed for the ESP32. The ESP32 has WiFi capability and this will enable the EVSE to retrieve electricity market pricing or instantaneous PV solar generation data. Below are selection of open source designs for EVSE. Some have been through multiple revisions and make a

Electric Vehicles

IEC61851 / J1772 Electric Vehicle Charge Controller

This device acts as the vehicle when connected to an EVSE (Electric Vehicle Supply Equipment) and negotiates the supply of power. It can be used in EV (Electric Vehicle) conversions, or in applications where you want to obtain power from public charging infrastructure – i.e., battery trailers to replace dirty and noisy generators, electric watercraft etc. Both hardware and firmware is provided as open source. The provided firmware will allow the EVCC to successfully request power and obtain the maximum obtainable current. Boiler plate code is available for the CAN interface and some firmware development would be expected to interface

Electronics Hardware

INA226 DC Voltage/Current/Power Monitor

A breakout board for a DC Voltage/Current/Power Meter based on the popular INA226 36-V, Bi-Directional, Ultra-High Accuracy, I2C Current/Power Monitor with Alert.  While many INA226 breakout boards are available from eBay/Banggood/AliExpress (e.g. CJMCU-226) they do not allow for easy connection of the bus voltage. In addition, we list different shunt resistor values you can use to customise the current range to best suit your application. Specifications Design Notes The device is powered via a separate 2.7 to 5.5V power supply connected to J3. Typical power consumption is just 330uA @ 3.3V.  The signed 16-bit bus voltage register has a least significant bit/resolution

Software

What is MQTT?

MQTT stands for Message Queuing Telemetry Transport. It is a lightweight protocol designed for efficiently transporting messages between M2M or IoT devices. It uses a publish-subscribe model where devices publish information to a broker, and any number of clients can subscribe to them. For example, a temperature sensor device in the home could publish the temperature to a topic, for example /home/indoor/temperature. The air conditioning system could then subscribe to this temperature and switch on and off when the value exceeds programmed thresholds. It might also be desirable to have an indoor temperature display. This device could also subscribe to

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

Review: Huawei R4850G2 Power Supply 53.5VDC, 3kW with CAN

The Huawei R4850G2 is a very capable 48V Telecommunications grade power supply available brand-new at cheap surplus prices (normally under $100 USD). Rated at 3000W, it can deliver a considerable 56.1A when powered from a suitable 200-240V rated AC source. The CAN2.0B interface allows for online monitoring and/or adjustment of the output voltage and current. Given the power supply is a Telecoms spare part (most likely for a Huawei mobile phone Base Terminal Station), a surprisable amount of official documentation exists on the hardware from the manufacturer: But when it comes to the CAN communications protocol and operation, the best

Electric Vehicles

ESP32 DIN Rail Module

I’ve been wanting to automate my EV (Electric Vehicle) charging. It’s a long story for another day. I had started out with a high level RS485 interface into my EVSE (Electric Vehicle Supply Equipment) and hit some ‘bugs’. A month later, it turned out much easier to fall back to KISS principals (Keep it Simple, Stupid) and directly turn on and off the power when I needed too. While my EVSE is currently set to charge at a paltry 10 amps, I wanted something a little more robust than a cheap ESP8266 based Smart Plug adapter. Designed to a price

ESP32

ESP32-WROOM-32 Breakout Board

Featured here is a breakout board for the Espressif Systems ESP32-WROOM modules incorporating a MCU with WiFi and Bluetooth connectivity. The board is designed to be minimalist and targeted towards battery operated devices. As such, no voltage regulator is included. For those not already familiar with the ESP32, this SoC offers the following features: Xtensa dual-core 32-bit LX6 microprocessor running up to 240MHz. 448KB rom for bootloader and core functions. 520KB SRAM (plus 16KB SRAM contained in RTC). 802.11b/g/n WiFi up to 150 Mbps. Bluetooth V4.2 BR/EDR and Bluetooth LE. 3.0 to 3.6V operation. A datasheet for the latest ESP32-WROOM-32E

ESP32

Espressif esp-idf & Eclipse IDE: Debugging with JTAG and OpenOCD

Developing ESP32 code by iteratively downloading code to your target via esptool can become laborious for anything but the smallest of projects. In addition to the UART Bootloader, the ESP32 can also be programmed and debugged via the JTAG interface. Debugging allows single stepping through your code, adding breakpoints and examining the contents of registers. Besides the rich debugging, programming over JTAG can also speed up development as the JTAG interface can be as fast as 20MHz as opposed to the serial download at a typical 460,800 bps. Setup This tutorial assumes you have Eclipse and the esp-idf set-up on

ESP32

Getting Started with the Espressif esp-idf & Eclipse IDE

The Espressif IoT Development Framework (esp-idf) is the official development platform for the ESP32 and ESP32-S series of SoCs from Fabless Semiconductor designer Espressif Systems. Espresif have developed the IDF eclipse plugin to make the setup and integration of the esp-idf with the eclipse IDE simple and relatively painless. Installation consists of four main steps: Install the Eclipse IDE Install the Espressif IDF Plugin for Eclipse Download and configure the esp-idf Install the esp-idf build tools Once installed, we run through the basics: Importing an IDF project Building Flashing SDK Config This tutorial will work you through setting up Eclipse

Electronics Hardware

Primer: The USB-C Connector

Anyone who has used a USB Type-A plug will know the fact that it takes three attempts to successfully insert. The USB Type-C connector sets out to solve this life’s little annoyance. But it doesn’t just stop there, it also offers many other advantages: Reversible plug. No upstream/downstream facing connector. The cable now has the same connector on both ends. Smaller connector allowing for thinner devices such as phones and tablets. Higher bandwidth from Super Speed differential pairs. Configuration Channel (CC). Increased power delivery (up to 100W). Non-USB signalling such as Display Port (Alternate mode) and Analog Audio (Accessory mode).

Embedded Linux

ANSI C Basic Lightweight NMEA Parser for GPS

For a recent OBD2 (vehicle/fleet data-logging) project running on a Raspberry PI Zero, I needed access to GPS data – both position/speed and time. The Raspberry PI doesn’t include a Real Time Clock (RTC). Upon boot, it doesn’t know what the actual time it is, unless it has access to a network and can retrieve the time via Network Time Protocol (NTP). With the logger fitted to a vehicle, a network connection wasn’t always available for NTP. Robust, feature rich software packages currently exist such as gpsd – a GPS service daemon. gpsd can also be used used in conjunction

CAN - Controller Area Network

SWCAN Single Wire CAN Transceiver Breakout Board

Single Wire CAN (SAE J2411) is commonly used in cost-sensitive Automotive applications where speed and cable length is not as onerous. It is also useful in applications were a traditional CAN differential pair is physically not possible. For example, on Type 2 Mennekes connectors used for Electric Vehicle (EV) charging, the communication between the supply equipment and the vehicle is performed via a PWM signal on a single Control Pilot (CP) pin in respect to earth. Tesla has used SWCAN to digitally communicate over this single pin. Various SWCAN drivers are available and generally share the same compatible pinout (SO8 and

CAN - Controller Area Network

Adding CAN to the BeagleBone (Black)

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 Sitara AM335x MCU found on the BeagleBone includes two CAN 2.0 controllers (DCAN) using IP modules from Bosch. The BeagleBone Black PCB, however, doesn’t include any CAN bus transceivers and these must be added externally. CAN Transceiver Wiring The BeagleBone Black has two DCAN ports: DCAN0