Current Ranger R3mk4 – new firmware & optimizations

The CurrentRanger continues to be improved especially on the firmware side, and in some hardware aspects as well. This blog is to summarize the most important changes and bug fixes with this new release:

  • UF2 bootloader – allows easy backing up of existing firmware and swapping with new firmware via a simple drag-drop action (like copying to/from a flash drive). More details and links to new firmware are given in the guide firmware page.
  • faster boot time!
  • faster ADC sampling (for auto-ranging and for USB/serial logging)
  • more linear and improved resolution ADC readings with secondary mid-range ADC reference (when this reference is active a ½ symbol is shown in the upper left corner. This reference is automatically switched for upper-range readings or when switching ranges
  • calibration information no longer printed on the product label, instead it is briefly displayed on the OLED after power-on and also output on the USB serial port. Unfortunately the EEPROM in the SAMD21 is not persistent between firmware updates, and hence you should always save this calibration information in case you plan to update the firmware.
  • Auto-off warning is now blinked on the OLED in addition to the buzzer sound. Also, the Auto-Off function timer is reset either by manual touching any pads, or by range switched when auto-ranging is enabled (previously reset only by manual touch of any pad)
  • There is now a set of commands available through the USB serial port. This allows to easily change parameters such as the calibration values, toggle logging via USB, toggle Auto-Off function. You could basically add more commands if you customize the firmware. Here are the defaults and examples of executed commands and their output:
  • Some limited number of CR3mk4 units have shipped with firmware that will always show 4.95Vbat. Use the latest firmware to correct that.
  • Better 3D printed enclosures – thanks to a brand new Prusa MK3S printer
  • Silkscreen changes: The previous “Load-” label at the input black terminal changed to “DUT+” to make it more obvious that this is not a “negative” terminal but is the positive side of the DUT. See header photo.

There are 2 essential calibration parameters: gain and LDO voltage. The LDO voltage can always be measured on any GND and 3V exposed headers. The gain has to be adjusted either with the recommended value or during measurement of a known accurate load (ex: apply the a fixed load and increase/decrease gain until the OLED reading reflects the given load). Note that the LDO voltage can slightly change based on factors such as temperature, load (ex: with/without OLED), whether charging is taking place, battery voltage. Each LDO is unique, has its own output voltage and will respond differently. If the LDO voltage swings a lot then you might need to adjust the values before a measurement to obtain the most accurate OLED/logged ADC readings.

A few continued challenges in manufacturing…

Some components like the thumb terminal (Phoenix Contact, made in Slovakia) and banana terminals (chinese) have long lead times. Right now the thumb terminal was on backorder for a month from Mouser and they just updated the lead time to an additional month. A simple component can disrupt the supply chain,  thanks to the chinese virus putting a pause to everything.

As you might have noted, PCBs and components have been hard and slow to source due to the world apocalypse we’re living through. It takes much longer to manufacture PCBs with all the pledges from the chinese makers that everything is back to “full production”.

One of the most painfully inconsistent features of chinese PCBs is the silkscreen, like most other things chinese it sucks. Look at OSHPark silkscreen, next to a chinese made PCB, any. There is no measure of comparison (and not just silkscreen). With the large graphic features on the front side of the PCB, any silkscreen quality glitches become obvious. Thankfully functionality is not affected by silkscreen, and unfortunately the magnitudes in cost difference forces PCB manufacturing to be done mostly in china. I doubt anyone else would pay $5 extra for perfect silkscreen, I certainly would only because I am quite OCD about things I use and look at on a regular basis.

The power button is hand soldered to each unit, and liquid flux is used in the process. Flux residue is removed with flux cleaner. Sometimes traces of dissolved flux may be  absorbed inside the button. At first, while this dissolved flux is still liquid, this is not a problem and the button works fine. When the flux solidifies, it can act as a film on the button internal dome, causing intermittent contact or in rare cases an apparent complete loss of contact. The most effective fix is to add a drop of flux cleaner or IPA to the button, press the button multiple times, in an effort to dissolve and loosen up any flux traces inside the button, and also absorb this solution back with a q-tip.

That’s it for now, any other minor changes will be documented in the CR guide.

Moteino SAMD 1.5.0 release

There is a major new release for the Moteino SAMD Boards Package 1.5.0. It will popup as an update reminder the next time you restart Arduino IDE, or you can go to the Boards Manager and update from there:

Here are the most significant changes in the SAMD package:

  • All MoteinoM0 and CurrentRanger boards will start shipping with the UF2 bootloader (it’s well worth a read if you’re not familiar with it). The TLDR; is: it supports sam-ba serial protocol uploads as before (via CDC serial, from bossac or via the Arduino IDE) and it also supports drag-drop updates of the firmware as well as the bootloader itself (via a MSC flash drive that appears when the M0 is running the bootloader). Extremely useful if you want to allow an end user to update the firmware and/or bootloader with a newFirmware.uf2 file drag-drop to the “flash-drive” simulated by the bootloader, without the need for the IDE. You could enter the UF2 with a RST double-tap as before, and you’d see a new “flash-drive” on your system (the CURRENT.UF2 is the actual firmware loaded in the MCU – useful to back up before an update):
  • To top off the UF2 awesomeness, MoteinoM0’s will continue to support updates of the firmware from the external FLASH-MEM chip, after an OTA upload via RFM69. The latest RFM69 library release 1.4 has been updated to support this.
  • SerialUSB is now completely removed from the MoteinoM0 and CurrentRanger variant definitions:
    • On MoteinoM0 Serial is now the USB serial, Serial0 is the UART on pins 30/31, and Serial1 is the UART on pins 0/1.
    • On CurrentRanger Serial is now the USB serial.
    • SERIAL_PORT_USBVIRTUAL is now Serial by default
  • You might notice in the MoteinoM0/CurrentRanger boards menu, there are now some options like choosing the USB stack (Arduino, TinyUSB) and more notably the Crystal selection. You can compile for the external crystal (default for MoteinoM0 R1) and “crystal-less” ie. the internal ultra low power 32.768kHz clock). When running without the external crystal, the internal clock is tuned using the USB bus clock which is very precise.

Note that the Moteino AVR boards package is now at v1.6.1. You are encouraged to update both of these packages. Older boards running the sam-ba bootloader may be flashed with the new bootloader included in the 1.5.0 package via SWD programmer. I may even offer to do this for free if you’re willing to return the board and pay for shipping back to you. Please report any bugs or issues in the MoteinoM0 or CurrentRanger forums.

Current Ranger R3 released!

CurrentRanger is now at revision R3!

I received great feedback and several threads in the forum outlined some patterns of user behavior which led me to make some improvements and hopefully eliminate some of the issues I’ve seen people run into. Here is the change log:

Reverse polarity protection

Perhaps some folks were too excited to turn the CurrentRanger on and missed double checking their battery polarity and pufff .. the charger chip released the smoke. I offered free fix/repair to a few who’ve asked, and to put this behind – R3 now ships with reverse polarity protection. If you get it wrong, nothing happens, including the obvious – won’t turn on!

Redesigned 3D enclosure

The previous pillar style enclosure takes about 1h05m to print. And because of the way the mounting pillars are placed in R1-R2 the case called for PETG (stronger less brittle material) but often produced diagonal drag lines in the inside-bottom of the case, and PET tends to print stringy which requires additional cleanup. Mounting screws are now moved closer to corners, this yields more PCB area and allows the case to have top corner posts which are a lot more practical, free the bottom of the case for a larger battery and shave a whopping 18 minutes off the print time. This also yields more room for enclosing a bluetooth module inside the case while keeping the case low profile. And the case print just looks that much better in PLA (no posts that can easily snap either). I’m really happy about this improvement.

Gold terminals be gone!

I am done with Gold terminals, they are the fake news of banana terminals. There is nothing truly gold about them. I tried to like them but frankly, I found them to be more trouble than their gold appearance is worth. Being exposed makes them a short hazard, and twist-locking wiring actually rips the wires. Besides, I almost never use the input terminals since I added the green thumb terminal which makes it a snap to insert battery and project wires. Those gold terminals looked rich and fancy (until the “gold” wears off revealing the dull communist metal) and that’s where the “goods” stop. And yes – I did try many different vendors, I could not find a vendor with consistent quality and repeatability. They may be good for your speaker where you never touch and see them again, but I think not suitable for an electronic instrument.

You want Gold(less) terminals on your CurrentRanger? Be my guest, get them from wherever you can, but I won’t ship these anymore. I cant put fake on awesome. Instead the kit is now standard with low profile banana terminals – simple, compact, functional, consistent, just as or more conductive, that’s real “gold” in my e-tool box.

Moved components & features

A few folks in the forum reported damaging/snapping some of the capacitors near the input terminals, causing the unit to behave erratically – these are now moved away from the terminals to help reduce the chance of this happening. Just to give you an idea, here’s what that looked like, and what to avoid doing when mounting mechanicals around small SMD components on any board:

Misc other changes & additions:

  • the power button is moved slightly left to allow easier access when OLED is mounted
  • the charge LED is now moved next to the USB and is see-through just like all other board LEDs
  • the Bias LED is moved symmetrical to the LPF LED
  • a GND pin added to the SPI header next to the lower right mounting hole
  • minor layout changes & silkscreen additions

Silkscreen nightmares!

Since the top of the PCB serves as the user interface, the silkscreen needs to look fairly good and crisp. I went the extra mile to try and design some nice graphics and make a PCB with a bunch of traces look more attractive and professional.
Unfortunately since inception I’ve had numerous silkscreen issues because of these graphic elements (some my fault, some the fab’s fault, and some “in between”) causing several batches of panels to go straight into the trash. I painstakingly retraced all these graphic elements on the board in a vectorized form and these issues are now resolved (as far as silkscreen design goes). The fab can still screw up but hopefully that won’t happen again.

The official guide is updated, as always please read it carefully before using your unit. Here’s the SMD side:

CurrentRanger is made with great love and pride in Michigan USA, and I welcome feedback, suggestions and contributions.

Gateway V9 Released

The Pi Gateway software is now at v9.0.0, this release is a major new feature and bug fix release. This blog entry serves as a change log and feature review. Below are the main highlights.

New Node button & sample metric generators (ex: Internet Speed polling event)

Clicking New Node you may add a numeric ID node. This could be a future RF or LAN node, or a dummy node to hold data such as your internet speed over time (add the Internet Speed event and enable it).

For RF nodes, any node that starts sending data through the serial port attached RF gateway, will automatically generate a new node. For RF nodes, node IDs up to 1023 are now possible thanks to 10bit addressing. Below you can also see a node with ID 999 that reports temperature.

MultiGraphs

A new Multigraph button on the node page allows generating a graph containing multiple metrics right on the node page. This enables you to easily compare the various metrics of a node chronologically. Clicking the far right remove button under the graph allows you to generate another graph with a different combination of metrics. There is a practical limit to how many metrics you can show since each metric can contain a lot of data and generates a separate vertical legend, so be reasonable and avoid pushing limits. Here’s such a graph showing the various metrics of an RF node:

Desktop graph scroll-zoom & double-click zoom

You may now scroll-zoom with your mouse wheel over a graph (works in all graphs) and it will zoom in and out. You can also double-click and it will zoom in. On mobile devices double tapping will zoom-in.

Edit and Delete metric data

Graphs now show lines between data points instead of bars by default. Still, sometimes it can be confusing looking at lines or bars, where the actual data points are. So you can now turn on data points. Additionally, you can edit and remove any single data point (click on specific data point to edit/remove) or range of data points (select range of data points to remove or change to a new value) if you wish by enabling the edit/delete mode using two buttons below the metric graph. Data points are automatically enabled when editing data.

Easy node image change

You can now change a node’s icon very easily to any existing icon (under the /www/images folder), or upload a new image of your choice (uploaded to /www/images/uploads). Icons should be 120x120px, if larger they are resized. Clicking the node icon:

This brings up the node icon change dialog (pick existing or upload new):

Other icon changes:

  • some default icons have changed (ex. CT-50 thermostat)
  • for consistency, all default icon nodes are now prefixed with icon_
  • rssi icons renamed to rssi_n with n=[1, 7]

New HTTPEndpoint for posting data from LAN

You may now submit data to the Gateway from any LAN device, thus enabling the use of WiFi (ESP anyone?) and network connected nodes, and also essentially removing the need of using only RF nodes. For instance:

https://raspberrypi/httpendpoint/?id=1234&MOTION&F=77.77

will generate a new node (if non existent) with ID=1234, and generate two new metrics (MOTION, and temperature). If an ID is not provided, then the IP of that node becomes the ID. The generated node will always have a new _ip property which contains the IP of the sender. Other examples:

  • /httpendpoint/?MOTION&F=12 ->  ID=(valid IP)
  • /httpendpoint/ -> no update, just lastupdated timestamp

The response will be JSON of this form:
response: {"status":"success","message":"SUCCESS!","matchedMetrics":2}

Run in internet isolated LAN

All script files are now loaded locally and there is no longer a dependence on an internet connected RaspberryPi to fetch these scripts. So there is no concern running this completely disconnected or behind firewalls etc.

Title setting & Menu changes

You can set your own custom title from the settings page, don’t forget to click Save to apply changes. The menu now shows the Gateway app version, when the database was last compacted (done once daily automatically), and an option to compact the database on demand.

You can now quickly restart the app via Ctrl+Atl+Shift+R, or from the Menu as before.

Run it as a Mobile app

You can now run the application as a mobile app. A manifest.json definition that loads automatically with the web page allows you to create a shortcut via the Add To Home Screen option in your mobile device’s browser. Then clicking that icon on your home screen opens the web page like a mobile application without the extra browser bars.

New default metrics

  • It’s sometimes desirable to compare the RSSI of an RF node with the transmit level of an RF node. The new X:n metric with n=[0, 31] allows this to work nicely with the RFM69_ATC library extension and you can see the transmit level drop or rise based on the RSSI change.
  • A new TYPE:nodeType which matches the exports.motes definition of a mote in metrics.js allows to automatically pick that mote’s icon and other features like buttons. Example: when a SwitchMote is powered up, it can send a 1 time TYPE:SwitchMote token to indicate it’s a SwitchMote. You can always later override and pick the node type from the node type dropdown

Other misc changes

  • node name/title added on the metric page – this helps determine which node’s temperature metric you may be looking at (vs. just “Temperature”)
  • ordered Node/Event type dropDowns (A-Z)
  • reworded and simplified licensing terms

Installation and upgrade path

This being such a major change with many new/renamed/deleted files, it’s a good idea to reinstall the application from scratch on a new raspbian image rather than try to do an in-place manual upgrade. This also ensures you will be running the latest and best raspbian, nginx, PHP7, nodeJs & packages, etc.

To transition your data to V9, backup the content of the /home/pi/gateway/data/dbfolder, then make a complete image backup of your currently functional previous version and store that until you are sure V9 runs smoothly on your Pi and all your old data is picked up.

Then follow the Gateway software setup steps in the official guide to install V9 to the latest raspbian image.

Once the V9 is running, to load your old data, you will need to sudo systemctl stop gateway, copy/overwrite the saved data into the new /home/pi/gateway/data/db folder, and then sudo systemctl restart gateway, and you should see all your old nodes and their data.

For any issues and bugs, please use this forum or you may submit a PR to the Github repository. Note that this change log may be edited as any loose ends are tied and before an official release is created.

SwitchMote available with PSU R3

The full SwitchMote kit is available again. I had to redesign the PSU cover and some 3D printed spacers which fit the new PSU R3. Everything is pretty much the same as before, except that there’s significantly less soldering to do. The PSU R3 is also available separately. All the small passives are now SMD soldered. There are now 4 screws that balance the cover a little better than before., and the FTDI programming header is offset from the edge.

You do the programming the same via an FTDI-Adapter and a double length male header which is provided in the kit.

SwitchMote PSU R3 release

The SwitchMote PSU is now at revision 3, here are the changes:

  • DC side is now SMD assembled, no more through hole components
  • 2OZ copper PCB
  • with the RECOM RAC02-05SGA there is no need for a fuse, only a MOV at 230V
  • although the DC side TVS footprint is left there, the specs of the AC-DC do not warrant a TVS on the DC side
  • same relay options as before – two 10A/250V relays or one 16A/250V relay
  • same control via AVR Moteino
  • optional footprint for ACS711 hall effect current sensor, this is experimental – it offers an analog output proportional to the AC current flowing through the SwitchMote relays. Adding this sensor requires cutting the main HOT trace where indicated and soldering solder jumpers on the bottom from the transducer’s DC side (isolated) to the Moteino side.
  • 4 symmetric mounting holes for a better enclosure – planning to make a 3D printed PETG enclosure and make the SwitchMote available with it

The kit will include the SMD assembled PCB along with the RECOM PSU, relays, MOV, screw terminal and headers. Optionally it can be ordered assembled at an additional cost.

New Moteino packages released for Arduino IDE

There is a new Moteino Arduino core package release (v1.4.0). If you’ve used the Moteino package so far with the Arduino IDE, you should get a little notice next time you start it up. By the way the link to the LowPowerLab package definition JSON is the same and should be pasted in your Preferences dialog under Boards Manager URLs:

Then you can either install or upgrade to the latest AVR package. Notice there is a brand new Moteino SAMD package with a new MoteinoM0 board as well, more on that in a separate post. Install/upgrade these in your Boards Manager:

These two packages includes a refined selection of taget boards:

  • [ Moteino / Moteino-USB ] – use this to send your sketch to a Moteino or MoteinoUSB
  • [ Moteino (8Mhz) ] – for 8Mhz Moteinos
  • [ MightyHat ] – technically identical definition to Moteino but use this to target a MightyHat
  • [ MoteinoMEGA / MoteinoMEGA-USB ] – use this to program MoteinoMEGA or MoteinoMEGA-USB
  • [ MoteinoM0 ] – a new Moteino based on SAMD21 Cortex M0+!

Once the packages are installed or upgraded you should see these new boards in your Tools>Boards menu:

And if you’re using my custom IDE board/port shortcut bar add-on, you can quickly add and access them directly from a click of a button, no more searching in the mile long Boards submenu of doom:

Some notable changes in these new packages:

  • added standard LED_BUILTIN pin macro definitions for all boards, you can simply use this macro to address the onboard LED of any Moteino, no more need for specific checks of what board it is you’re targeting, the LED_BUILTIN will just work. This macro references D9 on 328P Moteinos and MightyHat, D15 on MoteinoMEGAs, and D13 on MoteinoM0, simply use this macro directly in your sketch:
  • added board macro definitions for all Moteino boards:
  • added SS_FLASHMEM macro pin definitions for all Moteinos, again this is to ease the use of the SPI CS/SS selection pin across all Moteino boards:

I hope you find these changes useful. There’s lot of work to be done to upgrade all the sketches in the RFM69 and SPIFlash libraries to make use of these new macros. Please report any issues and stay tuned for the coming updates on MoteinoM0!

RFM69 and SPIFlash libraries released via Arduino LibraryManager

The LowPowerLab RFM69 and SPIFlash libraries are now published to the Arduino Library directory, and available to install in the IDE’s Library Manager (under Tools>Manage Libraries). Note that if you already have these library installed manually, you may need to remove it and re-install using the manager:

As new versions are released, you can update to the latest or switch back to an older version if you have a need to do so. If you’re new to using the Library Manager, it’s worth to read the official Arduino Library guide, and also check the Library Manager FAQ, to understand how Arduino libraries work, and how manage them (adding, switching, updating, manual library installation, deleting local libraries, etc).

As usual, please report any issues or bugs in the forum or open a Github issue where appropriate.

Gateway app Updated to v8.10

The Pi Gateway software is now at v8.10, this release is mainly a new feature release and also it fixes some issues. You can view a list of all the changes in the official release notes. Here are some quick highlights:

Node/overridable Settings

If you’d like a particular global setting (from settings.json5) to be overridable in a node (for instance minimum voltage for battery powered nodes) you can now do so in metrics.js by using the new settings section under exports.motes, note that the included settings must match the name in settings.json5 or they will be ignored. Example from exports.motes.MotionMote:

imageThen on nodes of that type, the setting can now be set a custom value:
image

Wifi RadioThermostat CT50 IP setting support

Specific code for the CT50 was updated to support a new IP setting in the UI. This allows the user to override and set the IP of a thermostat on the node page, thus enabling having multiple thermostats with different IPs in the app:
image

New Setting Types

This enables more user friendly settings. Supported types are jQuery mobile HTML5 defaults, and examples of how to use these are found in the settings.json5 file:

  • checkbox – for true/false settings
  • number
  • email
  • password – obsoletes setting.password:true/false
  • range – min, max
  • default (no type) is text

A few examples using new types:
image

Email attachments

The sendEmail function in gateway.js has a new parameter where you can pass the URL of an attachment to include in sent emails: global.sendEmail = function(SUBJECT, BODY, **ATTACHMENTS**). Example email with attachment:
image

Scheduled events time remaining & datetime

Scheduled events now show time remaining until they will run, and the datetime when that happens:
image

Sunset/sunrise API for events

Based on suncalc, this node API allows creating events that run at various times during the day based on calculation of the sun position. A few examples are:

  • sunrise
  • sunset
  • solarNoon
  • goldenHour
  • dusk
  • dawn

To calculate these events, the latitude/longitude coordinates can be provided on the general settings page:

image

New All-Events page which shows all scheduled and disabled events:

image

Modified main menu:

  • removed the Exit item (redundant)
  • added app version:
    image

RSSI is now a metric and logged/graphed by default:

imageimage

Low Battery Voltage

Warning icon now blinks in/out over the node icon:
image

As always, when you update:

SwitchMote with single 16A relay

SwitchMote and SwitchMote PSU are now available with a single 16A relay, instead of dual 10A relays. I realize this is most often the case that a second relay is not really necessary, except when replacing dual gang switches with a single gang SwitchMote, so I found this higher rating relay which can be soldered as shown in the guide. I also added the option to get it with a single 10A relay since most light applications now use either CFLs or LEDs and 16 amps are not really necessary for such small loads.

This new 16A relay requires removing two of the leads to make it fit the SwitchMote PCB, this is also added to the guide:

Worth noting here that the dual relay SwitchMote (a.k.a. 2x10A) is now the official kit that deprecates the older single 5A relay SwitchMote – that one has been discontinued and will only be available by special order.