Saturday, January 16, 2016

USB Power meter

I stumbled upon this small gadget at the local dollar shop (called Action) which was on sale for below 3 Euro. It looks like this:



So what is it. It is a usb power meter. It measures the voltage that your USB port supplies but more important it also measures how much Ampere is drawn from that port.

This is great for measuring the current a project draws.

First I attached it to mu computer's USB port:




Well it shows that my computer just supplies 4.87 volts.

Next step was to attach it to a power bank I have been using regularly for all kinds of projects.





So my power bank supplies a bit more as 5 volts. As there was nothing attached to it there was no current withdrawn.

Next step was to attach my electronic hour-glass. This starts with ten leds on. That must draw some current:




And yes it does. It draws 0.02 amps. Now that is not a lot. That is just 20 miliamps. Not bad for 10 glowing leds. If you wonder how this is possible check a technique called Charlieplexing. I am going to do a series about this.

Now lets look at my Larson Scanner:




Just 0.03 Amps. 2 leds are on. Again not bad and again due to the Charlieplexing technique.

As my powerbank has a capacity of 2 amps the Larson Scanner should work for about 60 hour !!!!

So this little device shows me how much current a project is using, and that tells me what capacity my power source needs to supply. 

Ah you might say: not all projects are powered over USB. That is true. However most prototypes are made by powering therm over USB and this will tell me the power it will draw.


As told I found this at my local Euro shop, but most Chinese verdors sell it also.

Till next time.
Have fun.
Luc Volders

Saturday, January 2, 2016

Voice command

Command your electronics : 
the great Dictator part III

So this is the apotheosis of a series of articles. Let me explain.

In the previous articles I showed you first how you could speak to your web-browser and that would be translated into written text.  The next article showed you that you could also use your Android device as a dictation machine


So you can give your Android device commands by speaking to it. Now wouldn't it be really cool if you could not only transform spoken text to written words but actually speak commands to your electronic projects.

Just imagine how the looks on the faces of friends and relatives if you spoke into your phone and the lights would get on...... Well actually it is easier as you think. Here we go.

App inventor

For those amongst you who have not followed this weblog a short explanation.  App inventor is a great web-based programming environment in which you can actually create your own Android APP's. App inventor is a project from the MIT and is free to use for everyone.  So go ahead, create an account and start making your ow app's.
What we are going to do is to use App-Inventor to create a program that translates your spoken word into plain text and then send that text using bluetooth to your Arduino.

I am not giving you a course in programming in App-Inventor. There is plenty of information on the web, there is actually a course which is free to take, and there is at least one book about this programming method. 

So after you logged into your account start a new project and design your screen like this:




The top button is a list-picker which allows you to connect to your bluetooth module attached to your Arduino. The big button in the middel labeled - Click to speak - does not need any explanation. and at the bottom I put a label with my copyright notice. But do not be afraid, I just think that looks impressive to my friends. The code is actually free and downloadable from the bottom of this page.

There are two modules incorprated in this page. First the Bluetooth module which is needed to communicate with your Arduino, and second the SpeechRecognizer module. This module actually translates your spoken words into text.

The code looks like this:




Yep that is all !!!!

And pretty simple to.
First you choose your bluetooth connection with the Listpicker. Next step is that the connection is actually made. Then the program waits till your press the button and if you do it activates Googles SpeechRecognizer. The SpeechRecognizer translates your spoken word(s) in to text and send it over to your chosen bluetoothdevice.

Download the App at the bottom of this article and install it. If you don't know how to do that look at this article that explains installing App's.

 
The Arduino side.


Well actually I have covered this already. It is the same kind of program used in the Relay Commander and the Ledstrip Commander. I'll give an example for the Attiny85 here anyhow. Please do remember to translate the Dutch language command into your native language.




OK let me explain the code a bit.

First you need to know that the Attiny has no USB connection like an Arduino. So you need to include the Softwareserial library. This is used to communicate between the tiny and the bluettoth module. The Tiny uses pin 0 for transmitting and pin 1 for receiving through bluetooth. The are connected to the transmit and receive pins on the bluetooth module.

Leds are attached to pin 2,3 and 4.

The code then starts by listening if there are any characteds received through bluetooth. If there are they are added together in the string called 'voice'. The string 'voice' is then analysed and the corresponding command is executed.

Please make sure that you Attach RX from the Attiny to the TX of the bluetooth module and vise-versa otherwise there will be no communication between the two,

The hardware

In this case we use the same hardware as we did in the Ledstrip Commander so I'll give you the schematics and breadboard layout without any further comment here:



And off course you can change the commands in someting more usefull like 'lights on' or 'sprinkler on' or 'door open'. And needless to say (but I'll do it anyhow) you can change the leds into relays like I showed you in the Relay Commander story.

How does it work.

This really looks like magic but it is actually quite simple. Your Android Phone picks up your spoken words and sends it to Google which translates it into a written word. These written words are then send over bluetooth to your Attiny which interprets it and puts the right i/o pins on or off. That's all.

How to use it.

Well first your phone needs to have a Wifi-connection. This is the cheapest method. You can use a data-connection but that will likely cost you a bit.
Second step is to pair your phone with the bluetooth module but you will likely have done that already.
Next open the App and  pick your bluetooth device. Wait till you have a decent connection. Now tap on the blue field where it says 'Click to Speak' and indeed speak to your phone. That's it.

Only thing that rests is to give you a link to the App-Inventor Source code, The App itself and the Arduino code, here they are:

Bluetalk App Inventor source code 

Bluetalk App

Bluetalk Arduino source code 

Till next time.
Have fun with all this like I do.

Luc Volders