Thursday, March 31, 2016

LoRa Products Coming from Adafruit!

Over the past couple of months I've been working on bringing LoRa support to the Adafruit Feather line of microcontroller boards. I designed a small Development Breakout FeatherWing for the HopeRF RFM95/96(W) module, as well as the LoRa FeatherWing IOX that uses an I/O expander to drive the numerous pins of the RFM module over I2C.

My boards are of course non-official FeatherWings that can be added as daughterboards to Feathers (similar to shields for Arduinos). Well, it looks like Adafruit has also been working on LoRa products! On a recent episode of their weekly Ask An Engineer web show, Ladyada gave a sneak peak of some boards she has in the works. One looks to be a Feather board with an RFM95W module directly on it. Another board is a breakout for the RFM module.

Prototype of a new "Top Secret" LoRa Feather.

Breakout board for the RFM modules (yellow PCB) along with a tester and a live demo.

This is great news for the LoRa community. As official products, they will be sold in the store and no doubt come with excellent code support and tutorials. Additionally, it will help to integrate LoRa Feathers with other FeatherWings and eliminate the need for a daughterboard just for the module itself.

There was no ETA given on the LoRa products, but with functional prototypes and testers already completed, we shouldn't have to wait long.

Thanks for reading!

- Dan W.

Sunday, March 20, 2016

Atmel SAM D09 Development Board

In this post I will document a development board that I designed for the Atmel SAM D09 microcontroller.

A fun little development board for the Atmel SAM D09.

Introduction


The Atmel SAM D series of 32-bit microcontrollers includes several devices, each with a long list of features at great prices. Perhaps the best known of the series in the maker community is the SAM D21 due to its use on the Arduino Zero. However, there are several other devices in the product line that are worth taking a look at. The smallest of the bunch is the SAM D09 that comes in a 14-pin SOIC package. The 14SOIC package is one of my favorites. It is easy to solder, easy to break out on a PCB, and takes up little board space. I decided to order some SAM D09C chips and design a small development board in order to learn more about the capabilities of the device.

Atmel SAM D09C


The SAM D09C in the 14-pin SOIC package is capable of running at 48 MHz, includes 8K of FLASH and 4K of SRAM, and has 12 GPIO pins with numerous peripherals. Despite the significant upgrades compared to similarly-sized 8-bit AVR microcontrollers, it is actually cheaper! For example, when purchased in single quantities the SAM D09C costs $1.15 USD, versus an ATtiny841 which is $1.67 USD. (Prices from Digikey, 3/20/2016). The ATtiny841 is one of my favorite AVR devices, and quickly replaced the use of the venerable ATtiny84A in my projects when it came out. However, this SAM D09C has me considering yet another update for my projects that need a 14-pin microcontroller. Once you are familiar with programming ARM Cortex-M devices, upgrading to feature-packed 32-bit microcontrollers makes sense for numerous reasons.

Let's take a look at the pinout and a table of features for the SAM D09.

Pinout for the Atmel SAM D09C (14SOIC).


Features of the SAM D09 devices in SOIC and QFN packages.


Development Board


The development board that I designed for the SAM D09C makes it very easy to work with the device. The pins of the microcontroller are broken out to standard 0.1" headers. I included a high-quality 32.768 kHz external crystal, which can be used with the on-board DFLL or DPLL to generate system clock frequencies up to 48 MHz. You can also use it with the Real-Time Counter (RTC) in the SAM D09 for accurate timekeeping. Additionally, I included a reset button, power LED, and a user LED connected to pin A25. The chip is programmed via a 10-pin Cortex Debug header.

Connect an Atmel ICE to the Cortex Debug header for programming and debugging.

For powering the board, I added a spot for a CR2032 coin cell battery holder on the bottom. This is a nice solution for testing low-power configurations and/or using the board without power supply wires attached. The supply voltage range of the SAM D09 is 2.4V to 3.6V, and this matches nicely with the output voltage of a CR2032 over its discharge cycle. You can also power the development board with an external power supply by connecting to the VDD and Ground pins on the headers. Make sure to remove the CR2032 battery before connecting an external power supply!

CR2032 battery holder on the bottom of the development board.

Programing the device is quite easy in Atmel Studio. The Atmel ICE integrates nicely with the IDE, and the Atmel Software Framework (ASF) helps you to develop programs rapidly. Programming 32-bit microcontrollers is much more complex than programming 8-bit devices, and a good set of libraries is important when you are getting started. The development board does need to be powered externally for programming. I found that throwing in a coin cell battery to power the SAM D09 and upload my program was quite handy.

Atmel ICE programmer/debugger connected to the development board.

Assemble Your Own


Here is the information you need if you'd like to make your own development boards for the Atmel SAM D09C.

Atmel SAM D09C Development Board: Order PCBs on OSHPark!

Parts List:
  • Microcontroller: Atmel SAM D09C 14SOIC
  • CrystalCitizen CM200C32768
  • Reset ButtonC&K PTS525SM15SMTR2 LFS
  • C1: 10uF 1206 Tantalum SMD capacitor, 10V rated minimum
  • C2, C3: 100nF 0603 Ceramic SMD capacitor
  • C4, C5: 22pF 0603 Ceramic SMD capacitors
  • LEDs: 0805, colors of your choice
  • R1: 10k ohm 0603
  • R2, R3, R4: 560 ohm 0603 (adjust values of R3 and R4 to change brightness of LEDs)
  • Battery Holder: MPD BK-912 CR2032 Holder
  • Debug Header: Amphenol FCI 20021111-00010T4LF
  • Headers: 2x 7 pin standard 0.1" headers (your choice of male or female)
  • Screws and Standoffs: Sized for M3 screws, standoff length is your choice.

Notes: If you want to do away with the power LED for low-power testing, you can also omit R3. The value of R2 is not critical, use whatever value you pick for the LEDs. There are various stability and load capacitance options for the CM200C 32kHz crystal. I picked the +/- 5ppm version with 12.5pF load capacitance.

Assembly Note: Before soldering on the CR2032 holder, tin the square ground pad in the middle of the footprint. It should have a little mound of solder on it to ensure good contact with the battery.


Atmel SAM D09C development board schematic.

Atmel SAM D09C development board layout.

Here's a straight-on shot of the board to help with assembly.

Wrap Up


Let me know if you order PCBs and make your own development boards! This is a fun little board, and I'm looking forward to doing some projects based around this very capable microcontroller.

Please post any questions and comments below.

Thanks for reading!

- Dan W.

Saturday, March 19, 2016

DIY LED Light Bulb Kits

Recently I saw a video by bigclivedotcom on YouTube about LED light bulb (lamp) kits from eBay. I decided to pick up a few of these kits and check them out. I was not disappointed!

LED light bulbs I assembled myself. Lots of fun!
The LED colors shown are cool white diffused, multicolor and warm white clear.


Cheap LED Lamp Kits from eBay


These kits can be found for less than $2 USD on eBay. One example listing to start your search if you want to purchase your own is #171505070176. That price does not include LEDs, but the real beauty of these is that you can assemble them with any LEDs you want. You can purchase white LEDs in many different color temperatures, such as cool or warm white. Colored or multi-color LEDs are also an option, as Big Clive did in his video. He also did a video assembling one of these kits with neon lamps!

The kit comes with the plastic housing, a clear plastic dome, two small circuit boards, and the parts you need to assemble the power supply circuit. The ones that I ordered house 38 LEDs, but there seem to be a variety of kits on eBay in different configurations. Grab some of these and a huge bag of cheap LEDs and you are ready to make some light bulbs!

Contents of the DIY LED lamp kits.

Assembly


The kits do not include any instructions, but assembling them is pretty easy. All of the component values on the small green power supply PCB are labeled in the silk screen. Just place the parts as shown and solder it up. Do be careful with the polarities of the electrolytic capacitor and diodes, though. The circular LED board clearly shows the correct polarities for the LEDs, so that is also easy to stuff.

The LED and power supply boards assembled and ready for installation.

Strangely, the attachment points for the power supply on the LED board are just pads without drills. Hmm.... The board in one of the kits I got had misaligned solder mask that exposed a trace between two LEDs next to the DC input pads. Yikes! These issues may or may not be present on the boards you get.

Attachment points on the power supply and LED boards.
Can you spot a safety hazard here when they are crammed into the housing?

As I started to install the boards into the housing, I saw that it would be very easy for shorts to happen between the exposed electrical connections on the undersides of the boards. I decided to put electrical tape across the bottom of the power supply board to insulate it from the LEDs.

Almost done!

Before snapping on the clear plastic dome, test the bulb to make sure it works. Murphy will ensure that at least one LED doesn't work if you don't test it first. It goes without saying, but please be careful when doing this. The power supply board has completely exposed mains AC voltage on it.

Super cool custom LED light bulbs.
The bulb with blue, yellow, and orange LEDs makes a nice violet color.

Wrap Up


These are fun little kits. I wouldn't recommend them for making light bulbs to install throughout your home. The obvious safety hazards of these kits and inconsistent hand assembly make them a bit dangerous. However, I think they are useful for fun projects and making novelty LED light bulbs that will be used in a controlled setting.

Thanks for reading!

- Dan W.

Friday, March 18, 2016

Checking Out the New Atmel ATtiny102/104

In this post I will discuss my experiences with the Atmel ATtiny104 Xplained Nano kit, and compare this new microcontroller from Atmel with other ATtiny devices.

The Atmel ATtiny104 Xplained Nano evaluation board.

Introduction


I love microcontrollers, and I do my best to keep up with new devices being released from the major manufacturers. Recently, I saw that Atmel had released new ATtiny devices, the ATtiny102 and ATtiny104. I decided to order one of their Xplained Nano kits for the ATtiny104 and check it out. The board costs $4.50 USD and is available from Digikey right now. Other distributors have it on order.

Update (4/5/16): Mouser now has the kit in stock as well.

Let's be honest, the cool box is worth the price of admission. 


ATtiny102/104


First step in researching any microcontroller: look at the datasheet. Let's get a few of the basics out of the way first. The ATtiny102 is an 8-pin device that comes in SOIC and UDFN packages, and the ATtiny104 is a 14-pin version of the device that comes in SOIC only. The larger device has extra GPIO, and extra channels on some of the peripherals such as the Analog-to-Digital Converter (ADC), but otherwise they are identical.

 Pinouts of the ATtiny102 and ATtiny104 in SOIC packages.


As I read through the key features of the new microcontroller, I immediately saw some parallels to the ATtiny4/5/9/10. I played around with the ATtiny10 quite a bit when it first came out, and recently developed a super tiny breakout board for it. However, I saw some very interesting additions to this new device, such as a hardware USART. I decided to make a table comparing the key features of the ATtiny102 and ATtiny10 (8- and 6-pin devices respectively). I also included the classic ATtiny85 in the comparison that has served me well in numerous projects. The ATtiny85 is well-known and loved by many embedded developers and electronics enthusiasts alike, and it even has coveted Arduino support to help make the device accessible to all.

Comparing the key features of the ATtiny102, ATtiny10, and ATtiny85.
(Unit costs shown are from Digikey, 3/18/2016)

We see many similarities between the ATtiny102 and the ATtiny10, especially in the amount of FLASH, SRAM, instructions, and general purpose working registers. However, the new device has some key upgrades. The most important of these is probably the hardware USART, which can also work in an SPI Master mode. While the ATtiny10 is very capable at collecting data from sensors and the like, it has almost no way to pass that data on to another device for processing. It is meant to handle simple, embedded tasks on its own. Given the tiny board space occupied by the SOT-23-6 chip and the low cost, it does very well in that regard.

The hardware USART on the ATtiny102 opens the device up to many more projects and potential uses. You can pass data on to another microcontroller, or even transmit it using a wireless module that accepts data over serial and handles the wireless transceiver functions on its own. Additionally, the ATtiny102 has some upgrades on the ADC front. Importantly, it has 10-bit resolution, where as the ATtiny10 has an 8-bit ADC. Besides an extra ADC channel, you also have three internal voltage references in the new device which can improve the accuracy of your measurements, especially when powered from varying supply voltages.


Comparison with the ATtiny85


In many regards, the ATtiny85 is a more robust device. The extra FLASH, SRAM, working registers, and instructions are crucial when developing more complicated solutions. Tasks we take for granted on many AVR devices such as floating point arithmetic and string manipulation are very difficult to implement on the ATtiny10 and ATtiny102/104. The ATtiny85 also comes in a DIP package, which is important to many electronics hobbyists.

However, the lack of a hardware USART on the ATtiny85 has always been a limitation. You can do software serial, but a hardware peripheral is very welcomed when available. Also, the ATtiny85 only has 8-bit counters, where as the smaller ATtiny devices have single 16-bit counters.

Finally, the ATtiny85 costs more, even when purchased in volume. The price difference doesn't seem large on the table above, but component cost adds up when using many of the devices in a solution, or designing something that will be produced in quantity.


ATtiny104 Xplained Nano


Atmel did a great job on their evaluation board for the ATtiny104. The board has a programmer and debugger built in! Simply plug it into your computer with a USB cable and it connects directly to Atmel Studio 7 for programming. I encountered no issues working with the board in Atmel Studio, though I did have to update the program before using the board.

My favorite feature of the Xplained Nano board is that you can connect to the USART on the ATtiny104 over USB and talk to it with a serial terminal. This is HUGE for prototyping and development when you need to read out your data for debugging and verification. The serial link is available as a simple COM port, and I found that I could keep it connected to my terminal program even when re-programming the chip.

The ATtiny104 Xplained Nano has a user button and LED on board, and breaks out all pins of the microcontroller. Additionally, you have some options for taking current measurements and running the ATtiny104 at supply voltages other than 5V USB.

Check out the official documentation on the evaluation board for more info:

ATtiny104 Xplained Nano User Guide
ATtiny102/104 Getting Started Guide

Wrap Up


I enjoyed working with the ATtiny104 evaluation kit, and I plan to order some bare chips when they are available from distributors. This new microcontroller from Atmel does have limitations as I discussed above, and other AVRs may be better options for your project. But if you have worked with the ATtiny10 before and just wished it had a USART, or if you need a low-cost chip for simple embedded tasks in a project, I think this is a good device to consider.

Thanks for reading!

- Dan W.

Wednesday, March 16, 2016

LoRa FeatherWing IOX for Adafruit Feather

In this post I will document another custom FeatherWing that I have designed for the Adafruit Feather line of microcontroller boards, the LoRa FeatherWing IOX.

LoRa FeatherWing IOX on a Feather HUZZAH ESP8266.

Introduction


Last month I posted about a LoRa FeatherWing Development Breakout that I made for Feather. Please check out that post to learn more about LoRa, the HopeRF RFM95/96(W) modules and potential uses of the breakout.

The LoRa FeatherWing IOX (I/O eXpander) is a follow-up to that design. The RFM95/96(W) side of the board is exactly the same as on the earlier FeatherWing. The big difference on the IOX is that I have replaced the breakout header for the Digital IO, chip select, and reset lines from the RFM module with an MCP23008 8-bit I/O expander. This chip allows the Adafruit Feather to control all of those pins on the RFM module over I2C. It is a huge step forward in this project, because it eliminates the manual wiring required for the breakout. This FeatherWing does not tie up any of your digital I/O pins on the Feather, and it makes the board compatible with any Feather variant. This is particularly important for the Feather HUZZAH ESP8266 which has a limited number of GPIO available.

Current LoRa and LoRaWAN libraries can be modified to incorporate the simple MCP23008 I2C library to drive the RFM module. I have also developed example programs to turn a Feather HUZZAH ESP8266 into a LoRa gateway to Adafruit IO using Wi-Fi.


A node with LoRa FeatherWing IOX, Feather M0, MCP9701 temperature sensor and a Li-Po.
The node transmits data bursts to a Feather HUZZAH acting as a gateway,
which then pushes the data to Adafruit IO over Wi-Fi.


Incorporating the I/O Expander


To incorporate the MCP23008 into my earlier example programs, I used the Adafruit library for the chip. I felt this was a good approach, because if you are using Feathers you are likely already familiar with downloading Adafruit libraries. The library is quite simple. You use the same digitalRead and digitalWrite commands you are familiar with in the Arduino IDE, but you call them as member functions to the MCP23008 object. For example, to drive DIO0 low on the RFM module you would type "iox.digitalWrite(DIO0, LOW)" instead of the normal "digitalWrite(DIO0, LOW)".

If you want to write your own code for driving the chip, that is certainly possible as well. I broke out the interrupt pin from the MCP23008 to solder jumpers to select one of five digital I/O pins on the Feather to send it to. This could be used to increase efficiency of your code and minimize delays in seeing pin state changes.

The Interrupt pin from the MCP23008 can be sent to a digital pin on the Feather if desired.
The I2C address of the chip is fixed as 0x20.


Example Programs


I have three example programs for this board. Two are very similar to my earlier example programs for the Development Breakout. One configures the Feather as a beacon node that sends periodic data bursts, while the other is a general-purpose Transceiver program that is set up to receive the data from the beacons and print it out to USB serial.

In these examples, I am sending temperature data from an MCP9701 temperature sensor. You can of course modify the programs to send any sensor data you like. I also send the battery voltage reading using the battery monitoring circuit built in to Feather M0 and 32U4.


Receiving data from two different Beacons and viewing it in a serial terminal.


The third program I have provided is a bit more interesting. It is intended for use with the Feather HUZZAH, and not only echoes the received data to USB serial, but also pushes it to Adafruit IO using the MQTT library. Being able to get data into the "cloud" from nodes several kilometers away using LoRa modules instead of cellular could be a great addition to your sensor monitoring project.

Feather HUZZAH with a LoRa FeatherWing IOX.
Push the data to Adafruit IO over Wi-Fi for monitoring, graphing, and logging.


Monitoring the data from the Beacon nodes on Adafruit IO.


Please note that these are very simple programs intended as templates to build in the full functionality your project requires. One issue you might need to solve is how to handle multiple beacons trying to transmit at the same time. The overlapping transmissions will cause un-reliable reception at the gateway. A fix for this is to poll the beacons for updates from the gateway node, and only allow them to transmit when they are polled. Another possible fix is to send a response from the gateway when it successfully receives a data transmission. If a beacon doesn't get an acknowledgment, it should wait a random amount of time and try again. This provides some amount of de-confliction on the wireless link.

Shared as Open Source Hardware (OSHW)


LoRa FeatherWing IOX: Order PCBs on OSHPark!

Eagle Files: Shared on Github



LoRa FeatherWing IOX Schematic

LoRa FeatherWing IOX Board Layout

Assemble Your Own


Here is the information you need if you'd like to order PCBs and make your own LoRa FeatherWing IOX boards.

Parts List:
  • LoRa Module: HopeRF RFM95W or RFM96W (pick the correct frequency for the ISM bands used in your country)
  • I/O Expander: MicroChip MCP23008 18-SOIC
  • RF Connector: SMA or RP-SMA Edge-Launch for 1.6mm/0.062" board thickness 
  • C1: 47uF 1410 Tantalum SMD capacitor, 10V rated minimum
  • C2: 1uF 0603 Ceramic SMD capacitor
  • C3, C4: 100nF 0603 Ceramic SMD capacitors
  • LED: 0805, color of your choice
  • R1: 680 ohm 0603, or adjust value to change brightness of LED
  • R2, R3: 4.7k ohm 0603 resistors (I2C pullups)
  • Headers to connect the FeatherWing to the Feather board
  • Antenna suitable for the frequency range supported by your RFM module
Notes: You can do away with the LED and R1 if you don't want an additional power indicator. Also, if you are using another FeatherWing that has I2C pull-ups on it, omit R2 and R3. Only one set of I2C pull-up resistors should be used on Feather.


Going Forward


I am quite happy with this development in my project to bring LoRa functionality to Adafruit Feather. Please let me know if you assemble one of these boards, I am always looking for feedback. Also, I'm curious to see if someone will modify an existing LoRaWAN library to use this board on a Feather HUZZAH. I believe overcoming the I/O restrictions of the ESP8266 module will help further development in that regard. I know there is much more to be done, but I hope my small contribution to the hardware side of these endeavors is of use.

As to future LoRa boards, I would like to make one additional board with multiple sensors on it to be used as a ready-to-go Beacon node. I am also exploring ways to fit a U-Blox GPS module onto this FeatherWing.

Once I am done developing boards for the RFM95/96(W) modules, I may turn to a more sophisticated LoRaWAN module, such as the MicroChip RN2903. Wouldn't an actual Feather board with that module built in be cool? How about a FeatherWing Doubler with the microcontroller circuitry and a wireless module built directly onto it instead of prototyping area? That would give you two spots for FeatherWings and a huge amount of functionality.

As always, please post comments, corrections, and suggestions below.

Thanks for reading!

- Dan W.

Thursday, March 3, 2016

Schematic of the CTS 1960017 10MHz OCXO

Recently, I posted a teardown of a CTS 10MHz Oven Controlled Crystal Oscillator (OCXO). Using the unit that I opened up, I was able to work out the schematic for the boards inside.

This is what's left of the CTS OCXO I did the teardown on. Poor thing...


Construction


Internally, the OCXO consists of two boards. One is the larger, main board with most of the components. It contains the oscillator circuit, voltage control and voltage reference circuitry, heater control, and output buffering/filtering. The ceramic board adhered to the bottom of it is the heater. It contains two power devices and two temperature monitoring devices. The 10MHz crystal is bonded to that ceramic board, but connects directly to the main board. The two boards connect via five pins that are directly soldered.

The board assembly is mounted on pins inside the can, which also extend to the outside of the unit. The only insulation material in the unit is the small, brown strip seen in the above photo. It wraps around one side of the crystal when everything is assembled.

Externally, the OCXO has five pins: 5V, GND, 10MHz OUTPUT, VREF, and EFC. Those pin names are used as labels for various nodes in the schematic below where they connect.

Schematic


I was able follow the components and traces on the boards to work out the schematic. After getting a rough outline, I removed all of the capacitors and inductors and measured their values out of circuit as accurately as I could.

There are only two ICs on the main board. One is an LM2902 quad opamp. Three of the opamps are used and one is terminated. The other IC is a TC7S00FU single NAND gate that is used as an output buffer.

The two power devices on the heater board are BST50 NPN darlington transistors. The temperature sensors are TI LM45s.

Schematic of the CTS 1960017 10MHz OCXO.
Click to make it larger, then right click to download it.

Wrap Up


So what do you think? Is the circuit simpler than you expected, or more complex? It's very interesting to see this take on a modern 5V, 10MHz OCXO. I suspect internal construction and complexity varies greatly between device families. Please post any questions, comments, or corrections below.

Thanks for reading!

- Dan W.