Quick Look: Makerfocus NodeMCU Board with 18650 Battery On-Board

Disclaimer: This post has affiliate (and direct) links to the reviewed product on Amazon.

As fun as adding a voltage booster (for 5V projects) and/or voltage regulation and a charge circuit is to our designs, sometimes it’s nice to just have everything done for us. We’re big fans of the ESPxxxx/NodeMCU ecosystem: they’re cheap, they’re WiFi-enabled out-of-the-box, they’re small, and they’re usable in the Arduino ecosystem if that’s how you roll.

We found this little guy on Amazon:

It’s a NodeMCU-compatible board with a built-on 18650 battery holder and charge control circuit: it may end up being one of our go-to designs when we need a battery-operated, low-IO WiFi-enabled part (a disturbingly-frequent ask), barely larger than the battery itself. Slick. Let’s take a look, and do a sanity programming check.

Major plus: MOUNTING HOLES. Boards without mounting holes are a real pain. Minor drag: the 18650 battery holder is on the back, so you’re not going to pop this bad boy in a breadboard any time soon, unless you put some longer headers on the top of the board, and don’t mind not being able to hit the switches or see the lights.

The Guts

The brain is an ESP-WROOM-02 (see links in Resources) with a Silicon Labs CP2102 handling USB comms. An Advanced Monolithic Systems AMS1117 chip regulates the volts, charging is controlled with a Nanjing Extension Microelectronics TP5400 (whose datasheet I could only find in Chinese 🙁

The LED near the charge controller will be red when charging, green when charged or under USB-only power. You can charge and run the board at the same time. We see solar in this board’s future.

The Setup

There are a number of steps to make this work in the Arduino environment; you may want to go a different route–but we needed to keep in the Arduino ecosystem to keep our classes as uniform as possible.

  • Install USB Driver
  • Add Board Manager URL
  • Pick a board, any board
  • Set the RESET method

Install USB Driver

You may need to install a driver for the Silicon Labs CP2102. Drivers are available on the Silicon Labs CP2102 Driver Downloads page for major environments.

For OS X (the only one we’ve tested so far) you’ll get a ZIP file with a disk image (DMG). Unzip, open the image, and run the package file Silicon Labs VCP Driver.pkg, and do the normal package install thing.

Add Board Manager URL

If you haven’t already been using ESP-ish boards you’ll need to add a board manager URL to the board manager. In the Arduino IDE open the preferences via Cmd-, or the menu. The list of board manager URLs is a comma-separated list.

Board manager dialog box with board manager URL text box highlighted
Board Manager Dialog

To it add:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Pick a Board, Any Board

For this mini-review we stuck with a generic 8266 board. Under Tools ⇨ Board choose “Generic ESP8266 Module.”

Board selection drop-down menu
Board Selection

Set the RESET Method

To upload our sketches to the board we need to set the RESET method under Tools ⇨ Reset.

Shows board drop-down method with board reset method
Reset Method

We didn’t need to make any other changes to get the basics working.

The Glory

The “documentation” on the Amazon product page states that the on-board LED is on GPIO16, so our go-to example, Blink, will use pin 16 for the LED:

#define LED 16

void setup() {
  pinMode(LED, OUTPUT);
}

void loop() {
  digitalWrite(LED, 0);
  delay(250);

  digitalWrite(LED, 1);
  delay(250);
}

If you’ve followed all the steps above (and do let us know if we’ve left anything out) you should see an attractively-blue blinking LED.

We’ll be revisiting this board both here and in our upcoming Maker’s End Inspiration Series book, ESP Inspiration, so stay tuned–this little guy is going to get some projects!

Resources

Products

Build: Arduino Tachometer (Reflective Style)

Disclosure: This post contains affiliate (and direct) links to some parts off Amazon for making a (relatively) hand-held device as well as the commercial product we replaced.

In the first book of the Maker’s End Inspiration Series, Arduino Inspiration, we’re controlling some computer fans to make a pleasant desk fan. To get some data on various fans, we needed a tachometer. So we wrote a different book. Because reasons.

Thus the first Maker’s End MEMO (Maker’s End Mini-Overview) publication, MEMO#001: Arduino, Interrupted, in which we provide a quick (but thorough) introduction to using interrupts on Arduinos of various flavors. As preparation for releasing a kit of the tachometer we started prototyping case designs in case we wanted to print the case instead of building a carrier plate for a commercially-available case (jury’s still out).

In this post we’ll take a quick look at the prototype case and code, discuss miniaturizing designs (spoiler: don’t!), and see where we go from here. There’s actually a video showing some of the design and wiring process, but it turned out to be really boring, so we didn’t post it :p

We whipped up a quick-and-dirty tach using a reflective sensor (read: when light bounces off of something back into the sensor it’s a “pulse” and we count it as a revolution) using the STEMTera for prototyping, then moved it as-is onto an Arduino Nano clone with USB power bank. (The kit will use a simple battery pack or LiPo.)

We 3D-printed a small mounting plate so we had something we could use and to start exploring the design space of such a small tool that still uses off-the-shelf parts without a custom PCB so we had a tool we could use around the shop. It’s roughly equivalent to a cheap “laser”-based reflective tachometer we also got off of Amazon as a simple way to test performance. Not quite as pretty, but customizable, accurate-enough, and a cute little project.

Any of these parts can be substituted. We built one with a different IR sensor and a white monochrome OLED, with essentially no code changes. We also have one that uses a 18650 or LiPo batter with a built-in charger and voltage converter–or just use a board with a built-in LiPo charger like an Adafruit Feather: we’ll post a followup article that uses a Feather that’ll send the data to your phone or to a computer for data storage as well.

Build the Circuit

There are two circuit “chunks”, both quite simple. First is hooking up the reflective sensor, second is hooking up the OLED. The Adafruit part comes with the resistors necessary for operation–we went ahead and made a slightly more “self-contained” sensor unit by soldering the resistors onto the sensor and running breadboard-ready wires for the initial prototype.

The OLED hookup, since it’s an I2C OLED, is as easy as hooking up Vcc and Gnd to the appropriate pins, and SCL/SDA to (in our case) the Uno (or Nano) A4/A5, the default I2C pins.

While we prototyped on an Uno, the “final” version uses a Nano (clone), so we’ll show that circuit–it’s the same on the Uno, though, in case you want a giant tachometer (or also go the smart route and prototype on something large).

Write the Code

The code is (roughly) as simple as you’d expect. There’s not a whole lot to talk about, but we’ll break it down anyway. The code for the kit version will be available on Github; the code here is just the prototyping to make sure it was accurate-enough.

Administrivia

It’s just a bunch of library headers (we don’t need all of them for our initial example, but the kit code uses them).

#include <Wire.h>

#include <gfxfont.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>

#include <Adafruit_SSD1306.h>

// Useful constants
#define IR_LED  12    // Turns on IR emitter
#define IR_IN    2    // Input from IR sensor
#define DELAY  500    // Milliseconds between display updates

// Initialize OLED
// OLED_RESET is connected to SDA on OLED.
// NOTE: It's *analog* Pin 4 on the Arduino.
#define OLED_RESET 4  // Pin for OLED SDA connection
Adafruit_SSD1306 display(OLED_RESET);

// Revolution tick/pulse counter.
// NOTE: Volatile!
volatile unsigned int rev;

// For calculations/results.
unsigned long int rpm;      // Current RPM
unsigned long int maxRpm;   // Maximum calculated RPM
unsigned long int time;     // ... time.
unsigned long int prevTime; // The time before!

Interrupt Service Routine (ISR)

The ISR is the “meat” of the code even though it’s a single line long. ISRs can be confusing to new programmers, which is why MEMO#001: Arduino, Interrupted will exist–to demystify them. The only thing we do in the ISR is increment a value–the count of how many times we received a signal (pulse) from the IR sensor, which in turn pulses on each revolution of what we’re measuring.

void rpmCount() {
  rev++;
}

We’ll put up a few more posts on interrupts in general. Suffice to say that in Setup (below) we’ll tell the Arduino to run rpmCount every time we get a pulse, which just tells the code to add one (increment) the number of revolutions. We’ll see the rev value later, because we’ll clear it out when we display the current revolutions per minute (RPM).

Setup

Most of the setup method is self-explanatory: we do a bunch of stuff to the OLED so we can display the current RPM. We set a bunch of values to known startup values (zero in this case), set our IO pin directions, and turn on the IR emitter.

void setup() {
  Wire.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3c);

  display.clearDisplay(); // clearing the display
  display.setTextColor(WHITE); //setting the color
  display.setTextSize(1); //set the font size
  display.setCursor(0, 0); //set the cursor coordinates
  display.print("Tachyons are Go!");
  display.display();
  delay(500);

  // Start clean!
  rev    = 0;
  rpm    = 0;
  time   = 0;
  maxRpm = 0;

  // Set up IO
  pinMode(IR_IN, INPUT);
  pinMode(IR_LED, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);

  // Set up interrupt handler
  attachInterrupt(digitalPinToInterrupt(2), rpmCount, FALLING);
  
  digitalWrite(IR_LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
}

The only thing of note is this:

attachInterrupt(digitalPinToInterrupt(2), rpmCount, FALLING);

attachInterrupt “hooks up” an Arduino (really the processor interrupt) to a given pin, runs the provided code (rpmCount), every time the signal rises, falls, or changes: here we care when the pin changes from high (5V) to low (0V) because that’s what the sensor is wired to do.

The digitalPinToInterrupt function allows us to provide the Arduino pin number instead of knowing what CPU-level interrupt is used for a given pin. This can be different across Arduino boards (and non-Arduino boards programmed in the Arduino environment), so it’s a safer bet to use this convenience method.

Loop

The “meat” lives in loop as with many an Arduino sketch. And yes, we’re using delay here–sorry! You’ll undoubtedly will read (or have read already) that using delay is generally a bad practice, and for the kit code with a UX, it’ll go away (and it has to!). But for prototyping a simple tach with no UX it’s fine. We’ll be discussing this, and how to avoid delay, in MEMO#001: Arduino, Interrupted and in subsequent posts.

void loop() {
  delay(DELAY);

  detachInterrupt(digitalPinToInterrupt(2));

  long currTime = millis();
  long idleTime = currTime - prevTime;

  rpm = 30 * 1000 / (millis() - time) * rev * 2;

  if (rpm > maxRpm) {
    maxRpm = rpm;
  }

  time = millis();
  rev = 0;

  display.clearDisplay(); // clearing the display
  display.setTextColor(WHITE); //setting the color
  display.setTextSize(1); //set the font size
  display.setCursor(0, 0); //set the cursor coordinates
  display.print(rpm);
  display.display();

  prevTime = currTime;

  attachInterrupt(digitalPinToInterrupt(2), rpmCount, FALLING);
}

Most everything is related to talking to the OLED, but note we detach the interrupt via detachInterrupt before performing the RPM calculation and write to the OLED: this results in missed pulses for the duration of that code, but we don’t want to interrupt writing to the OLED or update the rev count during the calculation.

Usage

Because it’s a reflective tach whatever you’re measuring will need something shiny. We stuck on some reflective tape that came with the cheap reflective tach we purchased on Amazon.

Fan showing how to place shiny tape
Fan with Shiny Tap

Some things won’t need additional shiny, like a disc with holes in it, or may need to work the opposite way, e.g., you’ll need to stick black tape on in order to break the beam. Some measurements would require handling multiple pulses-per-rev. The code handles none of this, nor is there a way to switch modes–when the kit is released we’ll have UX to handle at least some of these concerns.

How Accurate Is It?

We tested against a cheap reflective tach (link in Products section) and were consistently within 1-5%, so it’s “accurate enough” for what we needed. With minor code tweaking it should be pretty much dead-on, but for quick checks of computer fans, an electric drill, and a Dremel tool, we were pleasantly surprised with how close it was to a cheap (albeit trashy) commercial model. Plus we can customize it to our heart’s content, which is never a bad thing.

Is It Worth Building?

Debatable, but ultimately, we think so. Our cheap commercial tachometer was $20 and the only thing our hacked version doesn’t have (but is trivial to add) is storing the max, min, and last measurement (although we’d need to add some non-volatile storage, or keep the device on in a power-sip mode).

Our build was roughly $10 (we over-spent on the OLED, but it was what we had laying around when we needed it) and could probably be even cheaper. If you bump up the cost to $20, we could add more functionality:

  • More storage (via an SD card)
  • Wireless connectivity (via WiFi, BLE, or other radio)
  • Swappable inputs (via a jack for various sensors, like break-beam)
  • Software continuously hackable
  • Multiple power options

We might switch to a different board for some of this, which would increase the price, but something like an Adafruit Feather or a random ESP board with on-board WiFi is still really cheap, and opens up a world of remote monitoring possibilities.

BUILD FTW!!1!

Resources

Products

Review and Build: Pimoroni Keybow, a blinky auxiliary keyboard

We love our keyboards, from mechanical to split to Apple Magic. We also love our shortcuts, and even with a zillion macro programs, we still sometimes “need” dedicated keys for our most-used apps and application shortcuts (here’s looking at you, every CAD program ever).

We’re purchased a multitude of commercial keyboard “extensions” over the years, from industrial-strength over-priced 16-key strips to products designed for video editing. We’ve put together several cobbled systems using touch screens and Arduinos and Raspberry Pis. They’ve all worked, to some extent (we’ll detail some touchscreen builds in an upcoming post since they’re quite similar to this product, and provide extra blinkage).

We were attracted to this product because it’s a mechanical solution, and its underlying platform has extra capabilities and versatility: this is a 12-key matrix with an RGB matrix under each key, powered by a Raspberry Pi Zero WH. This opens up a world of keyboard possibilities and hacks.

It’s (marginally) pricey at £49.98 (about $65USD plus post) so it won’t be saving you much money over commercial solutions, but the open platform and trivial hackability are attractive. That said, if you already have a keyboard that suits your needs, you might be better off hacking in the RPi yourself. But we love Pimoroni and throw money at them often, so yep.

What’s in the Box

PARTSES. There’s the Pi0, a PCB for the keys, the keys, the keycaps, two acrylic plates, rubber feet, and connection hardware.

You’ll need a micro-SD card, so be prepared. We were not, and had to wait.

But it can be a small one, they claim a 1G card is sufficient. We used 8G because we had them.

The problem with micro-SD cards? They’re micro, and we’re old.

The board includes an I2C breakout for adding peripherals (we’ll use this in an upcoming build) and runs a mini-Raspbian OS called Keybow OS to get things done. Interface customization is handled by Lua, an embeddable scripting language with great functionality.

The Build

This is not a tricky build: there’s no soldering, just press-fitting and screwing a few tiny screws and bolts that our fat fingers occasionally dropped: it wouldn’t hurt to have a few extra M2.5 parts on-hand just in case (we buy them by the mixed-case every now and then; we’ll throw up a post about keeping the shop stocked some day).

The assembly docs on the Pimoroni site do a great job of piecing it together; we’ll add a few details, but generally just follow their docs.

Prepare Baseplate

  • Remove protective sheets from acrylic parts (we hate this part; be careful on the thinner spacer piece).
  • Stick on little rubber feet. (Unless you’re going to mount it some other way, like in a 3D-printed stand–see below!)
  • The “Keybow” text should be on the lower-left, facing you, not backwards. This is the bottom of the device.

Attach Raspberry Pi Zero WH to Baseplate

  • Use two M2.5 screws and nuts on the front of Pi0 (the long edge with the USB ports) to attach to the thicker baseplate.
  • Attach it to the side without the rubber feet, e.g., the “inside”.
  • Don’t over-tighten the screws; acrylic loves to crack.

Attach Keybow PCB

  • Remove standoffs’ protective film on pCB ferrules
  • Mount standoffs on the PCB
  • Line up the Pi0’s GPIO pins with the header on the PCB.
  • Press to fit; support whichever side you’re pushing against.

Mount Switches

  • Push each switch through the “gold leaf” PCB, from the gold leaf side down. Make sure each key is seated evenly.
  • The “gap” on the underside of the keys (where the pins are, and where the plus-shaped plunger/switch is not) should be oriented to the top of the gold leaf PCB.

Mount Keycaps

  • Press each keycap onto the switch. They’re all the same, and symmetrical, so orientation doesn’t matter.
  • Support the bottom of the switch when you press: it’s a tight fit.

Mount the keys to the PCB

After the pins are all aligned just push it into the PCB, firmly and evenly.

The Software

The Keybow runs a tiny version of Linux based on Raspbian. To install it onto the SD card download the latest ZIP or TAR file from the Keybow OS GitHub Releases page. Un-archive it and copy the files from the sdcard directory to the root level of your SD card.

To restate: everything under the sdcard directory (highlighted in the image at right) should be at the top level of the SD card’s root directory.

The Default Layout

It’s a numeric keypad like on a PC keyboard, e.g., 7-8-9 are on the top row, and 0-.-[ENTER] are on the bottom row, when the USB cable is sticking out the right-hand side of the Keybow.

It also comes with some sample macros; we’ll discuss updating them, various ways to poke the RGB LEDs, and some more fun stuff. We’ll be using it horizontally, and will detail macros, customizations, and using the Pi0 in our next (and final?) Keybow post.

Smoke Test

  • Put the MicroSD card into the Raspberry Pi
  • Plug in a USB cable
  • You should see some blinky lights

Any Problems?

If we have any complaints it’d be around the USB cable location and cutout. We would have preferred the RPi be firing towards the back so the USB cable would have a straight shot out the rear. Barring that, a larger cutout for the USB plug itself to support right-angle connectors so the cable could run out the side might have been a better choice.

Additionally, we had to hunt around to find a Micro USB cable that would seat properly in the keyboard due to the small size of the cutout. The problem was at least partially solved when we broke the thinnest piece of the spacer acrylic by accident: you may want to break it on purpose.

Going Further

3d printed keybow stand
3D Printed Keybow Stand

Naturally we built a small box for it; the design is available on Thingiverse. The initial version for sizing is a bit tight, and keeps the entire build visible. We might do a version with taller walls with a slot for the USB cable. The rubber feet were stuck on the bottom of it so it wouldn’t slide. (It’s not hollow; hollow might be better to allow adding some weight.)

Instead of mounting it on its rubber feet you might prefer to drill out some holes, countersink the board-side’s holes, and screw it onto a platform (like at an angle). Or omit the rubber feet and 3d print a small angled platform with some spaces for the screw heads. Like we did.

Resources

Quick Look: DFRobot Beetle BLE

Beetle BLE Front

Disclosure: This post contains affiliate and direct product links.

We have several projects that have low pin counts and require some form of connectivity. We found the DFRobot Beetle BLE to be a great fit for those projects (some of the builds will be documented; we’ll update this post as the build posts are updated).

A (tiny!) Arduino Uno-alike with on-board BLE, perfect for low pin count projects that require BLE connectivity.

Basic Features

It’s basically an Uno with a reduced pin count, so you get the expected functionality, just less of it:

  • ATmega328@16MHz
  • Digital: 4
  • Analog: 4
  • PWM: 2
  • UART: 1
  • I2C: 1
  • Micro USB: 1
  • ~ 29mm x 33mm

There are also dual ICSP interfaces (unpopulated), one for the 328P, and one for the CC2540 BLE chip.

The docs state it’ll take up to 8V (although we’ve only ever used USB or a reasonable 5V supply).

The I2C (SCL/SCA) and UART (TX/RX) pins are also broken out on the bottom of the board as pads: you’ll need to tweak your normal dev process if you plan on utilizing that functionality.

The Play Bluno app (iOS, Android) app allows interaction with the board, but any reasonable Arduino/BLE app should work.

Using The Beetle BLE

It shows up as an Uno–doesn’t get much easier than that! Under OS X the port shows up as a USB modem as you’d expect, with the additional “Arduino/Genuino Uno” tag. Since it’s an Uno, all default Uno sketches (that respect the Beetle BLE’s limited IO) should work right out of the box.

What is it not for?

  • IO-heavy projects
  • WiFi
  • Forget standard headers and breadboarding 🙁
  • Trivially mounting: it’s an odd shape (wearables, anyone?)
  • TODO 3D Printed Simple Mount

What’s Next?

We’re writing up a complete review with some tips for getting started and simple starter apps. We’re also using the board to power a tracked smart car chassis–both the chassis and build project will have their own posts.

Competition

There are a lot of similar boards these days, our favorites are products from the Adafruit Feather line:

Those are larger boards with a full complement of IO, and a wide variety of add-ons (“Feather Wings” in Adafruit-speak). For demanding projects they’re probably a better choice. (Quick and full reviews coming, naturally.) They’re also more expensive (by about $10-15), so if you don’t need the additional power for a specific project, the Beetle BLE is a great little board.

Reference Links

Product Links