Control with Bluetooth Nano

With a little’ the time available I thought of putting on a via bluetooth control. The thing is quite simple using those modules available on the market. I took a HC-06, which enables simple communication via serial data. The project is not recent, forgive any lack of inexperience.

I also tried with a PIC 16F84A, with some success, but for scheduling problems microcontroller I suspended the project. A micro rather outdated, but I think I could do it with a 16F628A or 16F182x, which are pin compatible. Also because now I no longer have those microcontrollers in drawers.

It is a simple operation of connecting the outputs of’ Arduino with the following modules and a handful of discrete components to drive a speaker and to remove the’ power to the Bluetooth module in order to disconnect from connected devices when one forgets.


A project consists of Arduino Nano, a Bluetooth module and a relay’ opto-isolated.

The project includes some special features :

  • The number of exits and ports are configurable via firmware. You have to adjust 2 variables [1].

  • The outputs are configurable high or low active. In the default program has taken active low outputs.

  • The outputs can be configured either as fixed or as timed. L’ Arduino takes care of keeping count, even if those who call the command is no longer present. I do this because I noticed timing programs with your smartphone, which must take the count of the period set. That implies a constant connection with your phone.

  • commands [2] They send a command ending through space character or one return-to-head, to the limit when they were sent 6 characters It finishes alone. Why this, for the simple fact that many programs, per Android, do not give the ability to add non-printing characters such as return-to-head.
    I chose the program
    DCmote. Somewhat spartan for configuration, but then easy to understand. Especially for those who do not know much l’ use of smartphone complicated functions. L’ interface specification, and as simple as possible and allows quick access to commands, after having connected to the control.

  • The control disconnects the’ user inactive (without carriage returns) after 30 seconds. This allows other users to access the control. Maybe it's a bluetooth receiver gap, rather than an improvement. In this way, if one forgets the active connection, It is disconnected and the other members (of my family) They can access commands.

  • flashing, just to see that the system is up and running.

  • A command to sound an alarm or a another sound.

    Le-mail [1] e [2] see lower.

Electric Scheme

Obviously the transistors are not critical, any NPN and PNP do the work. The R2 has a value of 330 Ohm, so as to drive an LED to be put on the container panel.

The jumpers will be used for on-site programming, removing them one could program the’ Arduino, without interference, but so I inclined so much that I expected hooves to accommodate the Nano. This will avoid possible voltage leaks towards the’ power supply.

L’ power supply must be from 5 Volt stabilized and somewhat robust to power the relay, if powered from the card. Better than both an Ampere.

L’ Arduino not’ included in the print. In this diagram it denotes a series of connectors (4 gives 8 poli) to accommodate the’ Arduino.

Printed circuits




The printed below is corretto, to put it on the face coppery.



As defined by the peculiarities you can also modify the firmware in order to obtain the flexibility desired.

[1] The variables that are used to configure the following:

#define ACTIVE_LOW if it came with commentary line, the outputs become active high. I rele’ I used instead work in negative logic.

#define BUFLEN You are altered if you can use a different capacity from the serial input. For those wishing to modify the firmware for different purposes.

#define OUTPUTMASK It defines those outputs that will not be affected by a general ignition. In my case, I can not keep closed contact for command defined for use impulse to move the gate. The gate system already has its securities, obviously.

#define NUMTIMER You are altered if you can determine how many outputs you want to bind. I have a module 4 relay, so there put four. But you can increase up to eight taking into account that assignments defined by the program are the 12,11,10,9 legs, A0, A1, A2, A3. These too can be easily modified, look down.

#define INPUT_TMO a definition of how long to wait before disconnecting an inactive user. The value is in seconds means. The maximum value is 255 (over 4 minutes), without affecting other parts of the program.

array port_pin[] you can define which feet assign. From left as first assigned.

As you might guess the values ​​have been put on a list to’ start firmware. For those who understand the programming it will be easy to spot.

[2] The commands to be sent to the control are such:

  1. For ignition of a fixed output is controlled with a letter capital gives A a H. Interverra’ the limit imposed by how many outputs hath been configured with NUMTIMER.

  2. To start a melody using a letter p, regardless of whether capitalized or miniscola. The melodies are performed in sequence. For the more experienced you can configure it for even play a kind of siren or other. Just put on the list const uint16_t melody and change TUNENUM which establishes how many are. There is a limit in the Mon-Ghezza of an array that is 127. For safety, the only the first charge function 126 values, or stops with two zeros conseguitivi. To clarify, the function expects a pair of values ​​that are the frequency and duration.

  3. To turn off all outputs using the letter x tiny including outputs timed.

  4. For the’ Ignition of all outputs, using a letter X capital. They will be excluded those defined not accessible from the output mask.

  5. For commands with timers using the following string:

    t (leading character)
    definition to indicate a timer, no matter whether upper or lower case.

    a number from 0 the number of timers
    defined by the firmware. CAUTION that’ HEX charge for 4 outputs. (second character). Now it only counts 4. If there was enabled serial communication, you see the error messages. So for example 0 a 3. Indexing starts at zero.

    s O m or h
    definition of unit’ measures to set. With s It indicates the seconds, m It will indicate the minutes and h the hours.

    by a three-digit
    valore to set the timer with the previous size desired. For hours is the limit in 9 ore. There may be a problem to set 999 minutes. I think we will update the program early.

    a space
    He concludes the string received. DCmote then the program should set the controls with a termination with space. The return-to-head ends.

    For example t3s45, if translates l’ Exit 4 active for 45 seconds.

borderline case, by sending a zero value to a timer, this is concluded.

The package It is always available in its entirety including the sketch for Arduino. If there was some difficulty in compiling it, let me know.



I also made the program that converts RTTTL in values ​​to be loaded into C. As you can notice from the listing there are several melodie I converted my program. Included in package. To function need python version 3.5 .


1 reply
  1. Amilcare
    Amilcare says:

    Are you sure you can not get one printed in only face extremely easier to achieve for a hobbyist, I intend to carry it to my garage / workshop when I have created a reliable wifi network
    For the moment I can get internet there just carrying the line superimposed on the cables of the 230V power supply and decode site. While reaching the goal I have strong limitation in the amount of data that can convey it, other solutions have proved to be more expensive and less efficient or less reliable.


Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply