STM32 Nucleo-L152RE SensorNodes Project

So for the past few months I have been working on planning a project that has been on the back burner for quite some time:  house hold wireless sensor network.  The principal is that I would have micro controllers running in low power mode spread across the house monitoring for special failure conditions, such as the toilet starting to leak.  Once a failure condition is detected, a wireless message would be sent and ultimately I would be notified via email or text message of the failure.

Choice of Platform for Project

The following platforms were considered:

  1. MiniWireless from Anarduino.
  2. ULPNode from Charles-Henri Hallard.
  3. JeeNode from JeeLabs (or their US distributor ModernDevice)
  4. Teensy 3.1 from pjrc
  5. Freedom-K64F from Freescale
  6. STM32 minimum development system on eBay
  7. STM32 Nucleo series from ST

The ATMega328 based platforms (MiniWireless, ULPNode, JeeNode) all have been exercised in low power modes and would serve well as simple wireless modules for checking simple conditions and sending a wireless message.  The downside of the platform is the limited number of interface options and the 8-bit processor itself. The lack of JTAG or SWD debugging increases debugging and validation time significantly.

Teensy 3.1’s are a great Freescale platform utilizing the MK20DX256 family of processors.  It has a 32-bit processor with a very dedicated designer who is very active in the support forums for the device.  One of my aspirations with this project is to be able to wirelessly reprogram all the sensors on the network, and the Teensy 3.1 won’t work in that regard.  The Teensy 3.1 supports a small microcontroller named HalfKay which runs closed source firmware which makes the Teensy 3.1 easy to program from the Arduino IDE (provided you have the Teensyduino library installed). The Teensy 3.1 is so stable that I have one at home and at work that I use to filter all of my keystrokes to create and replay macro’s. A rather nice side note is that the Teensy 3.1 platform now supports SWD debugging, which involves cutting two traces and soldering a few wires.

Freescale’s Freedom-K64F is a feature packed platform which has a variety of sensors already on the board, with bloggers dedicated to the configuration and usage of the platform. One of the key factors in the projects that I choose to work on is the accessibility of the components.  Ideally everything that I share with the open source community should be relatively inexpensive to purchase or download.  The FRDM-K64F however comes in at $35 plus shipping, which is a bit out of the inexpensive range compared to other offerings.  My plan is to have a dozen or more of these sensors around the house so the price for each development board would quickly add up.

The STM32 minimum development environment found on eBay is a bargain at under $6 for a fully reprogrammable module. However the support for the cloned hardware is lacking, and useful tools such as a JTAG programmer would have to be purchased separately.

STM32 Nucleo Family

STM32-Nucleo

In order to capture more marketshare of the Maker community, ST has partnered with mbed to produce the Nucleo line of development boards to showcase many of their processors. High performance Cortex M4’s are among the lineup as well as low power Cortex M0’s, all priced below $11. After carefully reviewing the available lineup, I selected the Nucleo-L152RE for its low power features and wide range of communication options. It’s the only board that not only has a large programming space of 512KB, but a 16KB EEPROM.  21 Channels for the ADC and two DAC outputs make it an ideal expandable platform.

I have already started to work through examples for it and learning the platform in general.  The great thing about the STM32 platform is the recent availability of the OpenSTM32 System Workbench. With the eclipse based IDE, it is fairly straight forward to create a new project, compile, reprogram and debug projects using the OpenOCD compatible ST-Link built into the Nucleo boards. AC6, the company that partnered with ST to deliver this great tool, have an update mechanism for not only the eclipse plugin but for all of the dependencies such as GCC and OpenOCD. Unlike other full featured open source development platforms, the only step needed is to install the System Workbench as it takes care of the rest.

After working with NXP’s LPC1788, LPC1347, Nordic Semiconductor’s nrf51422,  and Texas Instrument’s RM46L852, I find that the development workflow is best in OpenSTM32 System Workbench, followed closely by Nordic Semiconductor’s nrf51422 (after following all steps in Application Note 29 to get a working eclipse setup).

Nucleo-L152RE expansion board

L152RE Expansion Board Schematics

Today I sent out an Expansion board for the Nucleo L152RE which takes full advantage of the pins brought out to the Morpho headers ST provides. The design, developed in Kicad, is fully open source with a permissive Creative Commons – Share Alike license.  Even though I have a full Altium license available, I chose to use Kicad so that anyone can use the designs and all parts freely.  The design and design files are on github for download.  Do keep in mind that I haven’t tested it yet, so it should only be used as a reference.  Once boards come back I’ll populate them and begin testing.

Nucleo-L152RE Expansion Board

The expansion board has the following features:

  • Fully Open Source developed in open source Kicad with part numbers and the actual BOM (so anyone can take the design and change it)
  • RFM69HW pads for high power wireless
  • 128Mb external FLASH
  • MT3329 GPS footprint for 10Hz update rate
  • RGB LED pins along with 4 status LEDS and 1 status button
  • Circuit to perform zero power voltage measurements
  • RJ-45 connection for external power support along with some gpio pins and SPI bus
  • 2 RJ-45 connections that each support a SPI bus with a unique chip select, ADC pin, and a GPIO/DAC pin.
  • SWD breakout for ST-Link SWD debugger
  • 2 USART connectors
  • Micro USB AB connector that can potentially support host or device (with a programmable ID pin)
  • 4 I2C, 4 One Wire Bus connectors, 4 ADC water sensing pins, 4 motion sensing inputs, and 6 pins multiplexed into a single ADC channel meant for limit switches or on/off sensors

Most of the pins on the STM32-L152RE can tolerate 5V, so for the pins that aren’t, I’ve added a special note on the pins on the schematic to serve as a clear reminder.

Part and PCB Price Comparison

Since the last board I sent out a number of comparison tools have entered the market that allow for the quick comparison between the different major part stores (digikey, mouser, newark, etc…) and different major PCB houses.  Using both of those I saved over $25 dollars on my small run of 10 boards + parts for 10 boards.  For SandSquid, it worked best if I used the manufacture part number rather than a particular store’s part number.  So for all of the parts in my schematic I have added field’s to the part that has the manufacture part number, and following the recommended way of Kicad, I modified the python script for BOM generation to throw that part number in a CSV with all of the other fields, so that I can copy and paste it into the example BOM on SandSquid.

In the past I have had a lot of success with OSHPark and I have found that their prices are reasonable, but after a quick look at PCB shopper I was able to find a PCB house that would print 10 of my boards for less than half the price to print 3 boards from OSHPark.  Since many of those cheap PCB houses are in China, the quality won’t be the same as the quality purple PCB’s from OSHPark, but I decided to take that chance.

Summary

So in summary I have started to branch out into developing on the STM32 family of MCU’s, with an ideal platform for collecting a variety of sensor measurements throughout my home and vehicles. This first revision of the board is meant as a stepping stone, with future open source boards integrating the STM32 processor into a one board solution. By choosing open platforms like Github and tools like Kicad, these designs and firmware can be a benefit to the community as a whole.

Needed features completed for Carduino, all that remains is nice to have features

For this project, I broke up the features into need to haves, and want to haves, with the intention that I could call the project complete once all of the need to haves are complete. I wanted a basic engine monitoring circuit that I can put into my cars, and I have that now.

I even added two shift registers with 8 LEDS and a BCD 8 segment display to compliment it. The purpose would be to display the sensor number, and if it is in a good range or not. I will mount this so that the driver can see it and monitor it. If a temperature or voltage exceeds the threshold in a dangerous way (over temp), It will not only sound an alarm, but light the small decimal point of the BCD so that I know something is up. I need to add sleep code, but that’s about it (and controlling the power rail of the BT serial, SD, GPS, and LEDs with a mosfet).

The remaining want to haves include: GPS and gyro. I don’t anticipate any problems with adding those, even though for both of those, I will be forced to use the SW versions of the protocols (serial, i2c) rather than using the on-board module.

I’m going to be doing some more testing of the alerting code (moving the temperature sensors near an open flame, monitoring temp on controller), but once I do that, I’ll start soldering boards up for it (with connectors for Gyro and GPS for future upgrades) and wiring up my car. I’ll be using the MotionPlus as a gyro, since it is so cheap.

The next two projects I’ll be working on is a Gardening bot, and a arduino for my Traxxas Slash RC car. Might be getting some video equipment so that I can see what the car sees, in real-time. Will also look into updating the OpenCurrent to add some goodies, and making a PCB of my controller, similar to the Ardustation.

I look back at the past 4 months, and I see how doing things, while not perfectly, can accomplish things. If I were too afraid to fail, I would do nothing, as history has shown. Some of the lessons I’ve learned: If it’s too hard, break it down. If your losing motivation, try switching your focus. Record everything in a notebook, writing ideas, no matter how silly. And above all, create rather than consume.

Next Project: Car monitor, here’s a GPS breakout board

This slideshow requires JavaScript.

My next project is going to be the Car monitoring circuit which logs to an SD card, as well as wirelessly broadcasts the information to my controller. The two big new things it will have are this MediaTek 3329 GPS module, and the Motion Plus Gyro.

The store that I purchased this from (for $30), wants to charge $9 for a breakout board for this, which I feel is kind of crazy (with that money, I could add an ATMEGA328 to parse the GPS), so I made a cheap $0.30 breakout board (well components push the board price to 0.50 or 1.00). It has the connections for USART and USB, and I plan to have an RJ45 connector to put this GPS circuit somewhere remote (RJ45 – ethernet connector). Thinking about disguising it in a gum box, but then again, it would be a gum box + ethernet cable coming out of it, so not much of a disguise.

I’ll update the Projects page, but here is the details of the car monitor (which will be similar to my UPC battery backup logging experiment):
– 6 Temp sensors (Engine x 2, Radiator, Transmission, outside, inside)
– GPS (location, speed, time)
– Piezo (maybe alert on high temp?)
– MotionPlus Gyro (sense direction)
– Bluetooth Serial module
– 3.3v system, powered via car battery

I will have the power for the GPS + MotionPlus + BT module controlled using a BSS123 nMOSFET, as explained here. When the car is off (can detect because Alternator pushes battery voltage to around 14.2), it will turn off the non-essential things and enter a sleep mode, where it wakes to determine if it should still sleep. Cars are noisy environments, so I will be using some techniques discussed here to protect the inputs of the ATMEGA328. This project shouldn’t take too long (ha) because most of the framework is there, I just need to add the code to sleep, to use the motionplus, filter the car battery voltage to power my circuit, and to parse the GPS data. Progress!