How to not drive a motor with an Arduino

If you are like me, when you were an absolute beginner, you tried to wire a motor up to some batteries, saw the motor was spinning, and thought out loud: “It’s working! How hard could it be to turn it on and off with an Arduino?”

Actually a little more than it seemed at first. There are several problems I encountered and slowly fixed, and I’ll try to sum up in this post the kind of iterative reasoning that led to a decent circuit design.

motor1

So, first thing you try is to attach the battery poles to the motor, keeping the wires in place with your fingers. Everything seems to work fine! So what’s next? What’s the most obvious attempt to control it?

(more…)

Bluetooth low-energy temperature beacon using the nRF24L01: cheap and compatible with existing smartphone apps!

The reason I did this project is because I have a slight overheating issue in a server room; I was wondering if there would be some way to check another room’s temperature from my desk. That’s how I came up with a “wireless thermometer” that can send readings to my Android phone, and my colleagues can use it too!

You might have heard about the nRF24L01: it is a cheap (0.80€) radio frequency module that, back in 2013, Dmitry Grinberg was able to use to “fake” a BTLE beacon. Real Bluetooth 4.0 modules are, nowadays, about 5€ each.

I wondered if I could use it to make a BTLE compatible temperature beacon. Turns out there are 3 major BTLE beacon protocols: iBeacon (by Apple), Eddystone (by Google), and AltBeacon (by Radius Networks). And well, none of them can be emulated with the nRF24L01, since it is only able to send a 16-byte payload (among other limitations), and all three of those protocols require bigger PDUs.

BUT!!! Although I didn’t find a name for it, Nordic Semiconductors Bluetooth ICs (namely the nRF8001 and nRF51822) have their own protocol they use to send telemetry data (which means: temperature, battery level and device ID); turns out this protocol is simple enough to be emulated by the nRF24L01 as well, although with some limitations. They also are so nice to distribute a suite of Android and iOS apps to work with them; the most relevant apps are nRF Master Control Panel (useful for debugging BTLE devices) and nRF Temp 2.0 (a temperature logger; I think it was meant to track device overheating, but hey). You can also download the source code from the app page!

(more…)

The Arduino Pro Mini, the Baite BTE13-010, and the ultra low power consumption I achieved thanks to new programming tools

Please welcome my latest programming tool, the Arduino Power Cutter:

IMG_20150726_232059

The BTE13-010 is a cheap Chinese clone of the Arduino Pro Mini, manufactured by Baite, which can be found from their Aliexpress store (among other places). The internets and the producer are unfortunately lacking much documentation about it.

Today I was trying to achieve a very low power consumption on the BTE13-010. You might already have had a look to popular pages when it comes to power saving on the Arduino, two popular ones being Power saving techniques for microprocessors on Gammon Forum and Arduino sleep mode basics on EngBlaze.

However, at first I struggled to achieve the promised great savings, possibly because I was using the BTE13-010 instead of rebuilding a circuit from scratch, like many of them suggest?

To make a long story short, after browsing everywhere, I came up with these two subroutines that will cut (no pun intended) through your power consumption:

The power_saving_init() should be the first thing to be called at setup(), it will initialize all your pins to LOW. power_saving_sleep() will put everything to sleep, and wake up every 8 seconds. With these two, with the regular board (no bootloader modifications, with the power regulator on, etc) when sleeping I was able to achieve 3.24mA of power consumption, which is already pretty good considering it was draining about 10.2mA when fully powered on in the first place.

(I also tried to change the board internal clock with avrdude options, but that didn’t seem to be possible on this board. I also tried to clock it down via clock_prescale_set(), but nothing was gained).

But it doesn’t end here! That’s were the Power Cutter comes in. Thanks to Talpa PCB retrace of the BTE13-010 I was able to elaborate an evil power saving plan:

arduino_cutting

[Credits for this picture to Talpa, with a few corrections/additions by me]

With a cutter, I was able to cut (pun intended) thru power consumption by cutting the two traces in the picture (in light blue in the upper right), thus phisically cutting out the power LED and the regulation circuit (I wasn’t using that regulator anyway, both USB power and my batteries bypass it). The LED and the regulator were draining about 0.47mA and 2.44mA respectively. Note to adventurers: always check with a multimeter before and after attempting to cut traces.

Without those two components, my power consumption went down to 4uA.

For best results, use batteries with low self-discharge rates, like coin cell! AA batteries can have discharge rates up to 30 mA, it’s a lot!

Let me know your thoughts in the comments!