Saturday, February 13, 2016

Heart for tealights (Valentines Day)

My girlfriend rellay likes burning candles in the evening.

And there is Valentine day. But Valentine day is this year on Sunday. So that is a difficult time to get fresh flowers.

Of course I can overwhelm her with chocolate and mashmellows and other sweets and I certainly will do that but I wanted to make someting special. Something I made myself.

And my faithfull Beagle comes to the rescue.

I started with designing a hearth with a hole in it that is big enough to hold a tealight. I used Tinkercad for this my trusted 3D design program.




You can find my design here:
https://www.tinkercad.com/things/h7paNLQSxEH-candleheart

Next step is to download the design, slice it and print it.



I made 4 of these. I had some red and white tealights so I thought it would be nice to print these hearts in Red and white.



And they fit nice together.

You can find the STL file here:

Candle-heart STL

Just in time if you want to print some for yourself.

Till next time.
Have fun.

Luc Volders

Monday, February 1, 2016

Arduino to Android Using bluetooth

Android as display for your Arduino sensors.

Until now I have demonstrated a few times how to send commands from your Android device (phone or tablet) to an Arduino or Attiny using Bluetooth. I showed you how to command a ledstrip and a relay with our phone. And in the apotheosis of that storyline I even showed you how to do that using spoken words.

However sometimes you need information send the other way round. You can have a sensor or a switch attached to an Arduino or Attiny and want to get the data displayed on the screen of your Android phone. That's just what we are going to do in this story, and we are again using the HC-06 Bluetooth module for the communication.


The hardware

For this project I am using an Arduino Nano. It can however easily be done with an Attiny85 as we are using just a few pins (3 to be exact). 

So what I am going to show you is how to attach the HC-06 module to an Arduino Nano and use an LDR attached to an analogue input for measuring illumination.

Lets start with the schematics:



As you can see I have attached the TX line from the Arduino to the RX line of the HC-06. This way they can communiacte with eachother. 
Then at the analogue input line A6 I put a voltage divider which consists of an LDR and a 10K resistor. And that's it. 

On a breadboard it looks like this:



Not much to it. Easy to implement. In a real world environment it looks like this:



So lets have a look at the Arduino code




Not much to it. You should easily understand this.
First in the setup we set the Baudrate for communication to 9600 baud.
Then in the loop we read the sensor value from pin A6 which will have a value between 500 en 1023 and translate that in a figure from 1 to 100.
Remember Serial.Print wil print a line and the cursor wil stay on that line. Serial.println wil print something and moves on to the next line.

An added bonus for testing purposes is that when you power the Arduino from USB out of your computer you can open the Serial monitor in the Arduino IDE and see the values the Nano will send to the Bluetooth module.

Next step is the Android code.



Again the APP for Android was devellopped in Mitt's App-Inventor. A great free tool for making APP's. Highly recommended.


First design the screen:




The top line does not display well on my computer screen when designing in App Inventor but on the Android screen it looks great. App inventor has a real-time vieuw. So you can see what's happening on your phone/tablet screen when you alter the code you are writing.


So the App has a Clock and a Bluetooth feature and just a Listpicker (which chooses your Bleutooth device) a Button and a Label. That's all. The Vertical Arrangements are used to put everything nicely lined up on your screen.


The codeblocks are even simpler:



In the listpicker we choose the Bluetooth device.

And then there is a trick. We use the Clock function to periodically check if any information is send over Bluetooth. If there is any information coming in we just simply alter the text from the Button in whatever we are receiving over Bluetooth.



So does it work. Yes it does indeed:




The text on the display is not very clear in thsi picture but it says that the value read over Bluetooth is 76. When you move your hand over the LDR the value will get lower. And when you shine a light on the LDR you will get a higher value.


Now this version of Bluetooth has a range of about 10 meter. Enough for a lot of purposes like outdoor temperature measurements etc. I am sure you will find purposes for this.


Rests only to give you the APP and the source codes so you can alter them for your own purposes.


Bluetooth receiver APP


Bluetooth receiver source for App Inventor


Arduino code


So till next time: have fun


Luc Volders