Which Brain to Use?

With the widespread availability of devices today, you would be hard-pressed to find a microcontroller that didn’t meet the needs of simple hardware designs. A system such as this could easily be driven by an 8-bit core, like the ever popular Atmel AVR series devices, which are now driving millions of Arduinos worldwide.

As a side note, my embedded hardware design background began in the early 2000’s, using Motorola (now Freescale) 68HC11 devices. For anyone that doesn’t remember this series, it was extremely popular in the 80’s and early 90’s. The particular variant I was working with used EEPROM for the code space, and was UV-erasable. So, any changes you’d make in the firmware would require placing the devices under a UV lamp for a period of time to erase them before reprogramming. Often times they didn’t erase properly, and you’d end up with flipped bits in the code. The emulators for those chips were the size of a mini PC tower, with a complex array of parallel wiring and socket adapters. The firmware engineer at the time had also just transitioned to using a C compiler, instead of writing the code in Assembly Language. Why we were still doing all of this in 2001 was mind-boggling.

Motorola 68HC11

At that point I decided that for new designs it was time to transition to something more modern, with flash memory for starters. We ended up settling on the Atmel AVR series. It was a world of difference, being able to use C development IDEs, real-time debugging via JTAG, and the ability to erase and flash firmware in seconds. Over the course of my career there, I probably designed the ATMEGA128 into over 20 projects.



It wasn’t until a few years ago that I started venturing outside of the AVR realm. The demands of the projects I was working on were really too much for the Atmel chips. I started needing things like floating-point math, higher speed clocks, USB interfaces, Ethernet, etc. On several projects I went with a TI MSP430 device, which is quasi 16-bit. The ecosystem for the MSP430 series is very well established, and there are a plethora of development kits available. The TI CCS IDE is also pretty good if you don’t mind Eclipse. It can be slow and temperamental, but once you get a stable environment set up it tends to be rock solid.

I’ve also worked with Cypress PSoC3 devices, which have an 8051 core (8-bit) and a host of analog attachments on the chip. I was surprised with these at how easy the development environment was to use. Unfortunately my experience with these is in recovering someone else’s spaghetti code. I have messed around with the PSoC5 series (Cortex-M3) on their development kits, and my first impressions were generally good.

In the Wireless Sensor Module, I would be needing something with the following requirements:

  • Low-cost
  • Low-power
  • USB, SPI and I2C interfaces
  • RTC capability
  • Small package

I’ve been working a lot with the STM32 series devices, so I decided I would go with something in that line. This particular application doesn’t require much in the way of performance, and I’ve been wanting to work with the Cortex-M0 cores for a while now, so I settled on an STM32F042C6, a 32K Cortex-M0 in a TQFP-48 package. The intent is to have the mcu in sleep most of the time, waking up once per minute to sample the sensor and transmit a packet then going back to sleep. I was planning on running it with a small Li-Poly battery, ~800mAh. When the STM32F042 is in one of its low-power modes (with the RTC running), it should consume less than 10uA.

STM32 Schematic Block.

STM32 Schematic Block.

Since I’ve been doing a lot of development in the IAR EWARM IDE lately, I wanted to stick with that as the development environment. It’s not particularly aesthetic, but it’s fast and capable. For now, I’ve been using the Kickstart version, which is code-limited to 32K. I haven’t needed anything more, but I’ve gotten close. Unfortunately the full license is around $4,000.

Now that I’ve chosen the micro, it’s time to decide a few other things:

  • Battery + charger IC
  • Regulators
  • Peripherals
  • User interface hardware
  • Oscillators

I’ll address these in the next topic.

Choosing a Sensor

I’m back to discuss my choice of sensor for the Wireless RH/Temp Sensor Module. I wanted to capture a few simple requirements with the device.

  • Should be PCB mount, preferably SMT.
  • Should be capable of automated assembly, to avoid hand-placement in production.
  • Have an accuracy of ±3% RH or better.
  • Have an accuracy of ±0.5°C or better.
  • Have a resolution of 10-bits or better.
  • Have a response time of 10s. or better.
  • Needs to operate at the VCC rail of the device.

With regards to the system VCC I chose 2.5V to allow it to operate in the bottom-end of a Li-Poly battery charge life (around 2.8V), and to reduce current consumption. Keeping in mind that there would need to be LDO regulators to get down to 2.5V, and being conscious of their dropout voltage which might be ~0.1V. The radio works down to 2.0V, and most micros work down to 1.8V in some limited oscillator + power ranges. If for some reason a chosen device won’t work that low, I would have the flexibility to replace the 2.5V regulators with 3.0V or 3.3V ones, even if I didn’t get the same battery life.

One of the things I discovered when I went searching for a sensor device was that there is a great disparity in price with relation to accuracy, but it doesn’t scale linearly by any means.

I first searched to see what people might be using with Arduinos, and found this device at Sparkfun. Unfortunately, the minimum voltage is 3.3V, and it’s a little large.

I also found this board at Adafruit, using a Measurement Specialties device. It meets all of the requirements, so I looked the device up on Digikey. Although it has great specs, it’s also $12 per part in low volumes. So, I poked around on Digikey some more and found some Honeywell parts that met the specs as well. The problem here was the range of costs for similar parts. Most parts were ±4%, and ranged from $18-30 in SIP packages. The ±3% parts were even higher, some at nearly $80 a piece. I decided to take a look at Honeywell’s line guide on their site, and configured the part that I was looking for. The part I found was an HIH7130, which was difficult to buy on distributor sites and was costly ~$22 ea.

So I broadened my search on Digikey for different manufacturers, and eventually found a Silicon Labs part, SI7013-A10-GM1R. The only spec it didn’t meet was the response time (18s.) However, I realized humidity doesn’t change that quickly and I would only be sampling once a minute or less frequently. In addition, the per part cost was $5.13 ea. in low volumes at DK. At Mouser they are slightly less @$5.10 ea. In volume the costs are hard to predict because you can work with distributors and vendors to get the best pricing. But, it appeared that it would be around $4.50 / 1000 pcs.

The lesson here is that in product design, you may allow for one requirement (response time) to slip for another (cost.) In some client projects, there is little wiggle room and often something like response time may actually drive the rest of the requirements. For instance, if a sensor system is operating in a highly dynamic environment that requires continuous monitoring. RH isn’t a good example here, but if the sensor is monitoring the temperature of a mission-critical server node it definitely applies.

Datasheet of SI7013.

Silicon Labs SI7013 RH/Temp Sensor in T/R Strip.

Silicon Labs SI7013 RH/Temp Sensor in T/R Strip.

Intro to the Wireless RH/Temp Sensor Module

For a while now, I’ve wanted to have the capability to monitor isolated environments for changes in relative humidity and temperature over time. There are certain areas of our house that always seem hotter or more humid, especially in the summer. I’d like to have measurement nodes to confirm this by logging it over time, which will allow my to take some corrective action in the worst areas.

So the major requirements become:

  • Must be able to measure RH + Temp.
  • Must be wireless.
  • Must be battery powered.
  • Must allow remote data to be collected somewhere for future reference.

There are already available products on the market that do just this. One such product is the Wireless Sensor Tag System. These devices are small, relatively low-cost, battery powered, and wireless, with a backend for tracking and data. There are three things that I felt could use improvement, however: battery type/life, range, and the backend application.

Also, I like making things. So I decided to design my own. In addition to the above requirements, I had some additional ones:

  • Uses a Li-Poly or Li-Ion type battery.
  • Operates in the 900MHz ISM band.
  • Has some local intelligence.
  • Has a USB interface for battery charging, FW updates, and parameter changes.

I had the option of making the devices true IoT (Internet of Things) products by putting something like the TI SimpleLink WiFi devices on there, but I was concerned about battery life. Granted, the devices only need to wake up once a minute (or every five minutes, etc.,) transmit a data packet, and go back to sleep. Still, it takes time for a device to register on the network. By opting for just a low-bandwidth, low-power transmitter, the device can wake up and transmit a packet within several milliseconds, where WiFi can sometimes take 10’s of seconds to register on a network. According to the datasheet for the CC3100, TX mode can consume anywhere from 160-272mA.

The radio I decided to go with was the TI CC1175 transmitter. By comparison, the spec for transmit mode in the 900MHz band for a +10dBm output is 34mA. I chose this radio for several reasons: low-cost, low-power, flexibility of configuration, and ease of implementation. I’ve had experience with this series of radios before, so the interface feels familiar.

Full disclosure, I’m already pretty far along with this project, but I wanted to walk through the design process for everyone else. In the next post I’ll either detail the selection of sensor or micro.

The TX radio section of the wireless sensor module.

The TX radio section of the wireless sensor module.