Android tutorial part 3 : Android handshakes with Arduino and does magic

View sensor reading taken on Arduino on the Android App


Things to do on Arduino :

1.      Read DHT Sensor

This is final part. In this part the Arduino will send/ read the DHT sensor and display it on the app.

 Hardware setup for this part (continued from previous part)

Image 19

Pin Layout              

Arduino

Bluetooth

1 (TX)

RX

0 (RX)

TX

GRD

GRD

5 V

VCC

 

1 Channel Relay

5 V

VCC

GRD

GRD

7

IN

 

OLED Display

5V

VCC

GRD

GRD

4

SDA

5

SCL

 

DHT Sensor

5V

VCC

GRD

GRD

A0

DATA


Arduino Code
[ Arduino2Android_final_setup.ino code available on purchase ]
[DHT Library - DHT]
- download into Arduino IDE->libraries folder
- Restart IDE after doing above to access the libraries
DHT Library needs to be installed before you strat using it.
How To Install a Arduino Library
Things to do on Android:
Arduino App
  • Add the components as below:
  • 1 HorizentalArranagment
  • 1 Textbox
  • Clock (this is a invisible component)
HorizentalArrangment properties
  • Height = 10 pixel 
TextBox Properties
  • Height = 100 pixel
  • Width = 300 pixel
  • MiultiLine = true
  • TextAligment = Centre
  • Enabled = False
  • Rename = txtSensorData
 Clock
  • TimerInterval = 50
 

Drag the components and connect them as shown below. Se the required properties.

Image 20

Open the Block Editor and Drag and connect Blocks are shown below:

  • Create two variables; buffer and incomingData and set text on both to blank

Image 21

  • Drag and connect the blocks as show below to create a Timer code. The code checks if there is a bluetooth connection. If connection is there its starts reading the sensor data into buffer variable till it read *.
  • It then transfers the data  from buffer to incomingdata variable. The incomingData is display on the app textbox as text and Incoming variable is emptied to receive new Data.
  • If the connection is not there it display “Connect Bluetooth to Re4ad Sensor” on the app textbox.  

Image 22

This almost completes the tutorial for the Kit. Install the arduino code and test your App.

Android App - [MyApp Install File]

MIT App Inventor - [Source Code]  


Part 4 - Adding Blutooth Pair Option and Application Changes


Zircon - This is a contributing Drupal Theme
WeebPal