2015Arduino Total Control Manual Juan Luis Gonzalez EMIM 1/1/2015 Setting up a layout a. Communication via WiFi (click here for common issues) i. Setting commands iv. FAQ . What is Arduino Total control? 2. Communicating with the app a. Seek Bars d. Setting Emphasis Color e. Editing Button i. Setting IP or address 2. Setting up WiFi connection 1. Editing Text i. Communication tags i. Setting pictures as push buttons iii. Setting commands d. Setting Extra State (State 2) b. Setting Pressed State (State 1) 3. Using auto connect iii. Setting text content iii. Arduino circuitry iv. Displaying data on top of the app c. Enabling text as sensor source c. Setting button visibility ii. Sending data from app to Arduino overview b. Setting Default State (State 0) 2. Arduino Sketch e. Setting Layout orientation f. Communication via Bluetooth (click here for common issues) i. Switching layouts 5.Index 1. Using auto connect to connect one single device iii. Image tags iv. Arduino sketch 4. Text tags ii. Setting text visibility ii. Button tags iii. Using Connection manager to connect multiple devices ii. Arduino Total Control Main features 3. Sending data from Arduino to App overview i. Setting picture visibility ii. Enabling layout scroll g. Arduino circuitry iv. Editing Pictures i. Setting images displayed 1. Setting TCP Port ii. You can manage the layout as you like the most! Using its Matrix like layout. ATC can be set up for controlling or monitoring any kind of system. as sensor sources. thus encouraging the growing of the maker’s community. ATC will let you share information between your mobile device (like accelerometer. Fully Customizable From colors to layout arrangement. Build up to 4 different layouts. Different layouts for multiple projects. take pictures of what you want to control or choose a picture from your gallery and have fun controlling and switching your circuits. Descriptor texts can be modified from Arduino commands Toggle button state can be set from Arduino commands. touches events. control up to 24 x 2 circuits on 7 different devices at the same time. internal program values. physical sensor’s data.). build your own Bluetooth personal network. it is and Human Machine Interface for smartphones and tablets. Arduino Total Control can be fully customized. button strokes. providing real feedback. 3. In other words. 2. Can be used as descriptors. Arduino Total Control Main Features 1. or to display data from Arduino Toggle Buttons (with editable commands) ATC is a window between your smartphone or tablet and your physical surroundings using Bluetooth or WiFi. Arduino was chosen as firmware platform since it based on easy to use hardware and software. through a smartphone controlled robotic arm to a smart RC Car. etc. from a remote control for your home lighting automation. etc.What is Arduino Total Control Arduino Total Control (ATC) is an app which enables your smartphone to control your makings and surroundings via Bluetooth and WiFi. Images: visual dynamic indicators and / or push buttons (with editable commands) Text Tags. Connect and control multiple devices at a time on four different layouts Connect via WiFi or… Share data from 7 different devices. Dynamic visual indicators Images have three states which can be set via Camera or Gallery and controlled from Arduino commands or App events.) and your microcontroller based system (systems states. just hide and show elements to form different layouts. . Sending data from Arduino to App overview Arduino can control pictures. <AccelX b. On: 1. Use this feature to display information (e. Any string is the information that will be displayed as Text XX content. For Bluetooth: Serial. for more details please refer to the following sections of this manual. sensor data). The current special commands are accelerometer data and seek bar information: a. <AccelY c. You can change picture state by sending the appropriate command tag.Communicating with the app For either Bluetooth or WiFi communication.5 seconds in order to let the microcontroller know we are still connected 2. . Text content can be changed via Arduino. Pressed and Extra state respectively Z is the state of the button XX. For Bluetooth: Serial.. The way of sending data is exactly the same when the app runs on Bluetooth or WiFi.. OFF) via these command tags. “<ButnXX:Z”.09…23. Character ‘<’ means that the following data will be a special command. Y is the state of the image XX. Any character or string send by buttons or push buttons 3. it can be 0. or 2 for Default. 1. <Skb0…7 e. Arduino can control buttons states (ON.println(…. sharing data between the app and the Arduino board is as easy as using a serial terminal. More special commands will be included in the future. Where: XX is the object/relay number from 00. “<TextXX:Any string…”. Off: 0. Character ‘[‘ is sent every 2. For WiFi: server.g. buttons and text via special commands called “Tags”: “<ImgsXX:Y”.available() For WiFi: server.available() Sending data from app to Arduino overview There are three cases when the app will send data to Arduino: 1.println(… The same applies when data is received from the app. <AccelZ d. print(“Any string \n”). Button tags Use Button tags to button state on app: <ButnXX:Z Where: XX.println ("<Text01:A1: 253"). Figure 1 Displaying “ATC Online” text on top of the app Communication tags Communication tags are special strings sent to the app which activate special features of the app. Any of the following will do the trick. will turn the app button 5 on.Displaying data on top of the app To display data in top of the app (next to the green connected text) just print any string followed by a new line character. . In other words. Figure 2 Result of sending photo resistor data: Serial. from 00 to 23 is the text number Any String is the string to be displayed Example: Serial.println ("<Butn05:1 "). println(“Any string”). Text tags Use text tags to modify text content on app: <TextXX:Any String Where: XX. from 00 to 23 is the text number Z 0 or 1 is the button state Example: server. will display "A1: 253" at Text 1. communication tags let you control your layout behavior via Arduino.println(“<Text01:Lum: 560”). will change image 2 to the pressed state. .println (“<Imgs00:1”). which are available from any Arduino.Image tags Use Button tags to button state on app: <ImgsXX:Y XX. S Is the value sign (+ or -) Communication via Bluetooth Arduino Total Control supports any Bluetooth Serial Port Profile enabled device. or 2 for Default. Seek bars send data to Arduino in tag format: Figure Example of two seek bars at different values <SkbX:SYYYYY X. from 0 to 7.println(“<Imgs00:0”). (right) Seek Bars Seek bars emulate analog controls or dimmers.println ("<Imgs02:1 "). 1. Pressed and Extra state respectively Example: Serial. Most Bluetooth modules will only need a serial TTL port for communicating with Arduino. is the seek-bar number. This mean you will need a TX and a RX pin. (left) and Serial. Figure 4 A commonly used Bluetooth module. YYYYY from 00000 to 00255 is the seek bar value. from 00 to 23 is the text number Y 0. Figure 3 Example of Image Tag use: Serial. Select your correct board and COM port for programming. ATC for Bluetooth uses “Serial” by default. If using mega or other Arduino having more than one serial port.Before using Bluetooth. proven and functional Arduino sketch can be found in the app. Don’t use Pin 0 and 1 as inputs/Outputs since they will be used as serial port TX and RX. . You can also check our Facebook pages for some early releases and examples: https://www.com/ArduinoTotalControlApp There are some warnings to take into account when downloading the Sketch into your Arduino board!!! Disconnect Bluetooth module’s TX when downloading. Figure 6 Basic Arduino – Bluetooth circuitry. Open app menu then touch Arduino Code then select Beginner Code. or 3. Set the correct baud rate for your board. Figure 5 Enabling Bluetooth Communication via ATC App Arduino circuitry In most cases.3V Connect Bluetooth board GND to Arduino GND Connect Bluetooth Rx to Arduino Tx Connect Bluetooth Tx to Arduino Rx. the basic communication circuit is well represented by the following Connect Bluetooth board Vcc to 5V or 3. Once you have programmed your Arduino and paired your Bluetooth module with your Android powered device. Change it looking for the #define BAUD_RATE and setting your correct number.2. then reconnect. you can change the serial port used changing every Serial to Serial1. you can connect either via connection manager or auto-connect. Check your BT module back for correct wiring Arduino Sketch The most recent. Most boards default is 9600 bits/second which is the default in the Beginner sketch. Connect your Bluetooth on the correct serial port.facebook. please open App menu and check BT Enable box to allow Bluetooth communication. . You can select more than one or all devices. open app Menu. connect to the actual devices using the connect button next to app title. Figure 9 Auto connect enabled Note: Unchecking Auto Connect will reset the auto connect MAC address. then click on Connection Manager. Figure 7 Connection manager dialog Select all devices you want to send the button or Picture data to. All paired devices which support Serial Port Profile will be listed. for each image. button or picture connection management. From now on. button or seek bar you press the dialog shown in figure 7 will appear.Using Connection manager to connect multiple devices If you want to connect more than one device at a time. Figure 8 Bluetooth Connect dialog Note: Accelerometer data (if enabled) will be sent to all connected Bluetooth devices Using auto connect to connect one single device When only one device is required. The next dialog will appear. uses Auto connect to connect all objects to this device. Once you have set every element. 162. For more details on IP addresses please refer to http://en. Then you can select from 198. Open app menu then touch Arduino Code then select Beginner Eth Code.1.2 to 198. 12 and 13 are dedicated.facebook. Most Wireless Routers will use a local IP like 198. proven and functional Arduino sketch can be found in the app. click on connect button next to App Title.1.253. Figure 10 Enabling WiFi Communication via ATC App Arduino circuitry In its simplest form. For MEGA pins 10. 11.org/wiki/IP_address. select WiFi TCP/Communication and the following dialog will appear. the first you need to do is to set a proper IP address for your board. 50. WiFi control can be achieved using an Ethernet shield attached to any Arduino and to a WiFi Wireless router (like the one in our homes).wikipedia. You can also check our Facebook pages for some early releases and examples: https://www. To connect to an IP address.1. you will need either an Ethernet shield connected to a WiFi router or a WiFi shield or module.162. Figure 11 Basic Ethernet shield connection Arduino sketch The most recent.162. In order to connect. The only software requirement is to set a TCP/IP server with a suitable IP and PORT. Figure Setting up a WiFi connection . Setting up WiFi connection In order to connect to your Arduino via WiFi.1. please open App menu and check BT Enable box to allow Bluetooth communication. 51 and 52 are dedicated In other words do not use these PINS for INPUT or OUTPUT!!! Select the correct board and COM port for programming.Communication via WiFi Arduino Total Control supports connection via WiFi using an Arduino as a TCP/IP Server. Before using Bluetooth. Setting IP address Type exactly the same address you have set on the Arduino Sketch on the Set Ip Address field.com/ArduinoTotalControlApp There are some warnings to take into account when downloading the Sketch into your Arduino board!!! For UNO pins 10. If selected. Setting up a layout In order to get the most of the app. Please type the port numbers exactly the same you did on the Arduino Sketch. To start building a layout check menu -> Edit properties as displayed in figure 12. ATC will retry each 2. the current object will be visible Invisible. Using auto connect for WiFi When WiFi communication is active and enabled. the current picture will be invisible. auto connect will behave in the next way. the current picture will be invisible. touch any picture and a dialog like shown at figure 13 will appear. ATC will try to connect to desired IP and port.Setting TCP Port TCP/IP communication uses ports to send and receive data. If connection fails. this will put in the app in layout configuration mode. to build a proper layout is recommended. Figure 14 illustrates the difference between invisible and gone pictures. Figure 12 App Menu showing Edit Properties checkbox Setting picture visibility Figure 13 Picture properties dialog There are tree visibility states: Visible. Editing Pictures Once you have checked edit properties. If selected. .5 seconds until the app is closed. If selected. and its layout footprint will be absorbed by rest of the pictures in the same row. but the space it uses will remain Gone. This section includes all you need to know to build a nice looking and useful layout. When app starts. long press on a picture and the dialog shown in figure 15 will appear. use this dialog to change each of the image states. then select the source from gallery or from camera. If selected. the current text will be invisible. pictures will send commands or data to Arduino when they are pressed and when they are released. You can set the same image displayed for more than one state as displayed on figure 16. this state is displayed on touch. After enabling edit properties. the current object will be visible Invisible. Extra state. text will be invisible. . displayed only via a command from Arduino. but the space it uses will remain Gone. Open the edit properties dialog and set the data send on touch and on untouch as shown on the figure 18. touch any text and the following dialog will appear. Use this property to enable images as long touch events.Setting images displayed Each picture has tree states: Default state. Figure 17 Setting a picture as a push button When Action on pic touch property is enabled. If selected. image will send data and enter to pressed state after one second of being pressed approx. action on long touch box will appear. Pressed state. Commands can be a single character or multiple characters or strings. Setting commands When enabled as buttons. Figure 15 Image Chooser Dialog Setting Default State (State 0) Check default state box. Setting Extra State (State 2) Check extra state box. Setting text visibility There are tree visibility states: Figure 19 Text properties dialog Visible. Figure 16 Selecting more than one state for an image displayed Setting pictures as push buttons To set a picture to be used as a push button. then select the source from gallery or from camera. Figure 18 Setting commands send by picture Editing Text After enabling edit properties from app menu. when a picture is enabled as a button. Setting Pressed State (State 1) Check pressed state box. then select the source from gallery or from camera. then check “Action on pic touch” box. which is displayed most of the time. open the properties dialog by touching any picture. In other words. If selected. and its layout footprint will be absorbed by the rest of the texts in the same row. When text is set as sensor source. Setting text content Text content can be any string as shown in figure 20. If selected. Once checked the available source will appear. Please note that a very long text will affect layout proportions. invisible and gone buttons. the current text will be invisible. If selected. text content will be replaced by sensor data. Figure 23 illustrates the difference between visible. but the space it uses will remain Gone. Figure 21 Setting Text as sensor source Editing Buttons Once you have checked edit properties. Axis X. The sensor data available is Accelerometer data.Figure 19 illustrates the difference between invisible and gone texts. and its layout footprint will be absorbed by rest of the texts in the same row. Setting button visibility There are tree visibility states: Figure 22 Button properties dialog Visible. the current text will be invisible. If selected. Figure 20 Setting text content Enabling text as sensor source In the properties window check the “Use as sensor source” box. . Axis Y and Axis Z. and sensor data will be sent to Arduino via special command tags. the current object will be visible Invisible. touch any toggle button and a dialog will appear. Figure 24 Setting commands send by button Setting Emphasis Color Emphasis color makes reference to button colors. etc. Figure 25 Emphasis color selector dialog Setting Layout orientation For a better user experience. and image color shading when they are enabled as push buttons. You will notice the app is arranged in different ways for landscape and portrait modes. Touch the circle in the middle to set a selected color. Figure 26 Selecting a layout orientation . To change emphasis color.Setting commands Buttons will send commands or data to Arduino when they are checked (YES. The dialog shown at figure 25 will appear. open the app menu and select “Emphasis Color”. etc.). OFF. app layout is fixed. To change layout orientation. Open the edit properties dialog and set the data send on checked and on unchecked as shown on the figure 24. Commands can be a single character or multiple characters or strings. open the app menu and select from portrait or landscape this will set up the layout orientation for the current layout. ON.) and when they are unchecked (NO. Enabling layout scroll If there is no need to scroll. the app will regenerate the layout with its particular configurations. If your implementation needs scrolling. disabling layout scroll is recommended. the dialog shown in figure will appear. Figure 28 Select layout dialog . This dialog shows the current selected layout. open app menu and “select layout”. Figure 27 enabling layout scroll Switching layouts To change from one layout to another. Once a layout is selected. just open the app menu and check scroll enable. Declare a global boolean variable which will tell us the button latch status. pin 13 is not available.Frequently Asked Questions These are some tips and questions not covered in the manual regarding mostly to programming in Arduino. Seek bar 0 will act as a dimmer for LED 13 (which is available on every Arduino board). Figure Basic button wiring All provided sketches include an example of how to add physical buttons. which indicates a special command has been sent. These values are stored in the integer array: In other words. so use another PWM enabled pin. It is an alternative to control circuits or relays. DecodeSpecialCommand method will extract the important information from special commands such as accelerometer and seek bar data. . input voltage drops to 0 volts). How to add physical buttons Physical buttons are switches or push buttons connected to Arduino input pins. Since physical buttons are not as simple to implement as one may think (because they have to be synced with actual relay states) you have to follow the next steps in order to program a physical button: 1. Then all you have to do is to add some code after DecodeSpecialCommand is called to do something with this information like the following: For this example. The easiest way to implement physical buttons is to enable internal pull up resistors which will pull the voltage up to 5 volts when the switch is open (when switch is closed. How to use Seek Bars? The latest Arduino beginner and advanced sketches include the following function: This function is called when a “<” is received. Please note that if you are using Ethernet. DecodeSpecialCommand is called and variables updated. every time special command data is sent. Declare a global boolean array which will tell us each button latch status. if “relay 0” is “on” then it will be turned “off” when button is pressed. Don’t forget to declare an int array for button input pins. 3.2. Declare a suitable pin as input and enable pull up resistor via digitalWrite() at setup(). But I want to add more physical buttons!!! Let’s say you want a physical button for more than one relay. 2. Please note that this code will toggle relay or circuit 0 when button at PIN A5 is pressed. 3. In other words. Then just follow the following three steps: 1. Add the following code for each physical button you want to use at the end of loop(). One array for input pins and one array for latch states (be careful of available I/O management). Set each input as digital input + pull up resistor at setup(). Add a for cycle which will check and set states for each ButtonPins (MAX_INPUTS = 3) at the end of loop(). one cool way you may want to try is to use arrays. If “relay 0” is “off” it will be turned “on” when button is pressed. . you have to add more commands in the #define form If using beginner codes. change the “RelayStatus = EEPROM. However. you have to follow the next steps: 1.read(REL_ADD).dropbox. RelayStatus).How to use more than 8 relays The first thing you have to consider is the available I/O.com/sh/sgycfab71mch2r0/AAARbcJODcxRY29ag3qOFTVPa?dl=0 ): 1. Add more pins to the RelayPins array (Note that they have to match MAX_RELAYS): 3. On setup. Add more Commands according to MAX_RELAYS: This is most of you have to do to use more outputs mapped to the app. Change the number of MAX_RELAYS to the desired quantity: 2. Add the RELAY_SATUS_SIZE constant and change RelayStatus to long: 2. for UNO it will be difficult to get 24 outputs. Since using more than 8 relays will require storing data in more than 8 bits. To set the Arduino to handle more than 8 relays please follow the next steps (It will be easier to achieve this using the Advanced codes for either Ethernet or Bluetooth https://www.” for the following at set relay state function: . you can use this tutorial as an example of how to get more than 8 commands from the app. Arduino is not remembering all relay states on reset There is one more thing you may want to add to your code in order to make it completely functional for more than 8 relays. Add more ID’s to RelayAppId array (Note that they have to match MAX_RELAYS): 4. for example.” for the next: This will read the whole RelayStatus byte by byte. Note: if using beginner codes. change the simple “EEPROM.write(STATUS_EEADR. you have to add more “case CMD_XX:” to the switch located at loop. Finally. Eight relay codes use EEPROM_READ and EEPROM_WRITE which read and store byte values to EEPROM memory on the Arduino. 3. END OF MANUAL Manual Version: 2.1 Please feel free to make any suggestion or correction .