Powering Arduino from a Capacitor

Sometimes batteries suck. They are expensive, can be dangerous and tricky to handle. And it takes often too long, to load them again.

Think of an experimental board with an Atmel 328 microprocessor (the one that powers Arduino UNO) that should run for an hour or so to do some experiments, like in a classroom for instance. Imagine the teacher having to handle 30 different Lipo-Batteries that have to be charged in advance of the lesson. You get my point.

So there are these fabulous Super-Caps, that are available for not so long. Instead of dealing with micro and nano-Farads, these suddenly are carrying “FARADS”, no nano or micro! You can get an 15 FARAD surface mountable thing at digikey easily.

Of course, compared to real batteries this still is not a lot, but you can actually run something for quite some time from this capacitance. So i just gave it a try. Below you see my custom 328 circuit which runs two LEDs and has no power-saving modes activated whatsoever. Which means, it consumes about 6mA when LEDs are off, and roughly 12mA when they are turned on. I attached a 2.7v 5F SuperCap, which was able to run this guy for 7:30minutes. This translates roughly into 1mAh power, so this device could run a circuit which consumes 1mA for one hour. But of course energy consumption of the 328 could be drastically lower if energy saving modes would be activated when LEDs are off. If you take the 4micro-amp measured here you could run that device for 10 days with that SuperCap.

But for one hour of teaching a 15F Cap combined with a slightly less hungry circuit could be sufficient. And if not – it take just 30seconds to charge the cap from a 3v source again.

Another field where this could be of significant relevance is wearables of course.

 

Posted in Allgemein, educational, Wearables | 1 Comment

Crappy Arduino M0+ Pro

Recently Arduino launched a new ARM-based Board, the M0+ Pro. Well, actually it’s Arduino.org, who launched the guy, not the well known team around Arduino.cc…

Until know i only read about this weird fight between the Arduino Founders around Massimo Banzi and the producers of the boards – but today it hit me right in the face.

As we are currently investigating the ARM-Platform i was at first deligthed to see an Arduino Board with the ARM Cortex M0+ as a processor instead of the well known 8-bit ATMEL guy. Ordered it at my distributor and it arrived this morning.

The experience with this board is really a mess. Tried to install support via the board-manager on my 1.6 IDE – and got the support, but it didn’t work (couldn’t find any board while flashing). Upgraded to the new Version 7, which in fact is a fork that only comes with support for the new Board but nothing else (in fact the new invented board-manager from Version 1.6 is missing again…). Now i had three ways to program the Board, “Arduino M0 Pro (Programming Port”, “Arduino M0 Pro (Native Port)” and finally “Arduino M0”. Awesome. Indeed the board comes with two Micro-USB connectors as well – one named “Programming”, the other “Native USB”. Once cable gets plugged into one of them also the Serial-Port changes, so be aware to change that as well (does not work automatically). It turned out the only the Option “Arduino M0” combined with the native Port worked and i could finally upload a Blink-Sketch to the board.

But the weirdness did not stop. Our code uses Hardware-Serial and for some reasons the M0+ Pro has only Support for SerialUSB and Serial5. But even as we changed the code accordingly we got compiling errors all over the place.

Guys, please settle this fight as soon as possible. At this level of quality and user experience i see the whole Arduino project at risk in the near future.

Posted in Allgemein | 1 Comment

How to flash an Arduino over the Air with Bluetooth

As mentioned in the previous article i wanted to figure out how to connect the Arduino over Bluetooth to my Mac, including flashing the device.
I managed to get the serial console over the air with the HM-13 module as described before, but unfortunately flashing seemed to be a bit of an issue.
This is because the Arduino needs a clean reset signal which usually comes out of the DTR-Line of the module. But: most BT-Modules (and FTDI-Cables etc.) do not make this port available.
But i found three solutions that work nevertheless.
1. easiest and most straightforward, but also most expensive: buy the EZ-Link module from Adafruit. It has the DTR pin (don’t forget to use a 100nF ceramic capacitor “104” to connect to the reset pin) and everything works well just out of the box. This module also has an automatic baud-rate detection and some other useful features like voltage regulation both for power and the TX/RX Pins. The other modules below require 3.3 voltage for power and also for the logic, so be careful if you plan to work with a 5v controller like the UNO.
2. the RN-42 BT Module comes with a DTR-Pin as well, but unfortunately it has a reverse signal on that pin – when it should be high it is actually low and vice-versa. If you want to use it nevertheless you have ot apply an invert circuit or buy an inverter module. You can find a nice explanation on this and the module in general in this video. Although i believe from the video that this setup can work, it did not for me – the DTR-PIN just did not generate any signal…
3. You can also use the above mentioned HM-13 module from Seeed – although it does not have the DTR PIn available. I used a nice little hack described here to make it work. Just reuse the status-led pin to trigger the reset signal! To do this you have to use a short AT-Command on the module “AT+PIO11” which will tell the module to shut off the LED when unconnected and turn it on while connected. This again has to be inverted to be useful as a reset-signal, but if you do so it really works (other modules like the HC-05 for instance even make this available via another AT-command, so no inversion is needed here). The good thing with this solution: the HM-13 is a dual-mode BT-Module which can work as classic BT to simulate a serial connection _and_ as BLE Module at the same time!

Posted in Allgemein | 1 Comment

Control your Arduino with Scratch over Bluetooth

Yes, really. Scratch is this wonderful MIT visual programming toolbox that you can get for free in many different languages. Its an excellent starting point to teach children how to program. But you can go even further: Some weird spanic guys wrote an Arduino sketch that let’s the Arduino interface with a modified version of Scratch called S4A (“scratch for arduino”). Brilliant. Yes, you can build robots and control them with the visual programming language. But: the Arduino has to stay connected to the computer permanently because the interaction works over a Serial connection. Hm… As i am working on some kind of school teaching electronic project at the moment (some info in german) i wanted to bring that further by introducing Bluetooth (the docs are mentioning an xbee RF connection but i can’t believe this would be a feasible way for a normal teacher + it requires an adpator on the pc side as well). So i wanted to control the serial connection to the Arduino over the air, ideally from o broad set of possible devices like Laptop, Tablet, iPhone etc. – wait: iPhone?

The iPhone introduces another special hurdle to the project as Apple decided not to support standard ‘classic’ Bluetooth connections, but only BLE (“bluetooth low energy”). I am pretty sure there is no technical background for this as Android phones have no trouble to support all kinds of BT connectivity, but anyway, i had to deal with that as well.

Fortunately there are numerous BT-boards and adaptors out there so it shouldn’t be hard to find one matching my requirements. I quickly digged into the modules from itead/seeed that are easily available, cheap and normally well documented etc.

I first tried the HM-06 module, connected it to my Arduino Uno just like described in this nice tutorial  on instructables, launched S4A and voilá – Scratch was reporting values from the distant Arduino!

But it didn’t work for my iPhone or iPad – so i tried the HM-11 which works with a TI CC2541 chip. Although the documentation mentioned a passthrough-mode for UART and the module came with TX/RX connections, it was not possible to pair it to a computer or mac and get the serial link over the air. Obviously a misunderstanding as the TI-Chip clearly only supports BLE 4.0 and no “classic” Bluetooth.

So i ordered another module, this time the HM-13 which can be ordered on a nice Grove-Breakout board including voltage regulator etc. (which is very important – the modules are quite sensitive regarding over-voltage and require straight 3.3 volts on VCC).

After some struggles i managed to get this working as desired – had to fix the baud-rate as the module is communicating with 115200 baud by default and Scratch tries to do 38400 initially. So please check the baud-rate at which your BT-module is communicating and try to set the Serial-speed in the S4A-scetch accordingly.

As the HM-13 is a dual-mode BT chip it can be run in both modes – as classic BT device that has to be paired to the other device and then simulates a serial connection, or as BLE 4.0 device, that can be seen on an iPhone with a specific app (i used the ones from TI that ship with their SensorTag.

Of course this setup cannot only be used for Scratch but any Serial connection can be routed over the air – it should even be possible to flash new firmware onto the Arduino that way (will be tested once i get my 100nF capacitor to connect the reset line). And BTW – if you only need serial over the air i’d recommend the HM-06 module mentioned above – it does this job very nicely as a single purpose device.

 

Posted in Arduino, educational | Tagged , , , | 1 Comment

There shall be sensors, Mysensors…

One of the coolest projects i stumpled upon recently is the mysensors project by Henrik Ekblad and his team. The aim of the project is to offer a framework for a network of sensors and actuators in an environment like your house or appartment. The sensors are connected with 2.4Ghz RF technology, and the system comes with a sophisticated network management including a controller, a gateway and even a repeater functionality that can be enabled on any node with just a flag.
The idea as such is already brilliant because everyone wants to have sensors and it’s just frustrating to a) build everything on your own or b) use crappy and proprietary technology from specific vendors.
Mysensors is open-source, but even more important: IT JUST WORKS!
I have come across many projects, platforms and technologies but this is really not the usual experience, especially for an early stage open source project. The project is extremely well an even nicely documented, you pick up your Arduino Uno, Upload the gateway code with not a single modification and it just worked. I then plugged it into my Raspberry where my FHEM home-controller was running, installed the mysensors module there and…baam…had my sensors integrated into that place as well.
But it doesn’t end here: The mysensors package comes with tons of just working examples for different kinds of sensors and even actuators. I tried light, moisture, binary switch (for my doorbell), relay actuator and many others. And believe me – every single example just worked without any problem (ok i had some issues with the rf-connection, but the excellent forum helped me out of that quickly).
This is just a brilliant job Henrik, if every open-source project out there would work like that we would be in heaven.
The list of supported controllers is growing and there even is MQTT support built in for some.
Want something more? They should think about customized, low-power optimized hardware? Even that is available, i ordered the brand-new Itead Sensebender Micro which is a tiny (really tiny) Atmel 328 with a few Pins, absolutely low-power focussed and can hook up the recommended NRf24l01+ RF-Board easily. Can run with two AAA-batteries for months (if not years). Although this is really a rough and specialized board for experienced users (no power-regulators or reverse polarity protection etc.) it’s exactly what you would want to have for setting up your own low-power sensor network.
Just awesome.

Posted in Allgemein | Leave a comment

How to fire an IFTT Event with a custom http request

Recently the guys from IFTT integrated a new way to trigger events – now you can call the platform with so called “Maker Events”, which are basically customizable http/api requests. Find more details here: iftt.com/maker

The request looks like this: https://maker.ifttt.com/trigger/plant_thirsty/with/key/[your key]

“plant_thirsty” is the name of the trigger that i created. If this request is fired it can trigger anything IFTT can do, you even can install the IFTT app on your iOS/Android device and get event notifications.

This is a feature that has been requested by the community since ages, but it is really awesome that it is now available!

Posted in Allgemein | Leave a comment

Waking up an Arduino with Input from a Sensor

Currently i am investigating ways to wakeup an Arduino out of deep sleep mode with an IRQ Event. If you think of low power standalone measurement applications, this can be very interesting, because the board can sleep with very low power-consumption (less than 10 milli-amps) until something happens.

It works that way (see code example below): After starting the Arduino you call the function sleepNow() which does two things. Define an interrupt for waking up and attach him and then put the device to sleep. For waking up different patterns can be defined, “LOW”, “RISING” and “FALLING”. If the according event is being observed on the wakeup pin the device will wakeup, proceed with the wakeup function (in this case wakeUpNow()) and then execute the loop again.

In my example i am using a tiny solar cell that can output up to 4volts under full sunlight to trigger the RISING-Event on PIN2. The interesting detail about that is that this sensor can power itself obviously, therefore the Arduino could even shut down it’s PINs during sleep and would still wakeup. This setup could be used to turn on a sensor if a box is opened for instance (think of a intrusion detection in your house or a smart geo-cache for instance). In combination with our ArduFona Board this could then trigger a GSM action or call a WEB-API etc.

In my future research i will try to identify more sensors that can be put to work like this – which is not as trivial as you might think because most sensors are working with a more complex output like I2C or do not provide the right output by other means in the first place. But i think many cases can indeed work like this, ultrasonic-sensors for distance, acceleration sensors with analog outputs etc. – i’ll keep this blog posted.

See it in full operation here:

Here is the code for the above example:

#include <avr/sleep.h>
#define buzzer 9
#define led 13

int wakePin = 2; // pin used for waking up

void wakeUpNow() // here the interrupt is handled after wakeup
{
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, HIGH);
delay(4000);
digitalWrite(buzzer, LOW);
delay(100);
}

void setup()
{
Serial.begin(9600);
pinMode(wakePin, INPUT);
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
Serial.begin(9600);
attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
digitalWrite(led, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
}

void loop()
{
digitalWrite(led, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
sleepNow(); // sleep function called here

}

void sleepNow() // here we put the arduino to sleep
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here
sleep_enable(); // enables the sleep bit in the mcucr register
attachInterrupt(0,wakeUpNow, RISING); // use interrupt 0 (pin 2) and run function
sleep_mode(); // here the device is actually put to sleep!!
sleep_disable(); // first thing after waking from sleep:
detachInterrupt(0); // disables interrupt 0 on pin 2 so the
}

Posted in Arduino | Tagged | Leave a comment