Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Here is a short video showing an example app I created. I'll describe how to do the wiring, write an arduino sketch that can accept basic commands
and send them and how to write the app itself. I asume you're already familiar with some of the basics, you made a few arduino projects and are
familiar with the arduino IDE. If you have attempted serial communication with the arduino board everything should be fully comprehensible. If you
have any problems or questions feel free to ask them in the comments section.
...and here is an example of receiving the data from the arduino board on the mobile. The temperature sensor connected to the arduino board is a
ds18b20 sensor. Just to show how awesome app inventor is I added text to speech functionality - the app says the temperature every 15 seconds. The
arduino code and the app is described in more detail in steps 4,5 and 6.
The circuit is as simple as it gets so you probably already have most of them.
The only problematic part here is the bluetooth module. There are different modules all over the internet so be sure you check the pinout in the
datasheet of the one you get as it can differ.
Also notice that there are two general classes of bluetooth modules:
Class 1 has range of about 100 meter (300 feet)
Class 2 has range of about 10meter (30 feet)
In case you're wondering they are entirely compatible and you can only get 100 meter range if both of the devices (ie the mobile and the serial module)
are class one. If one of it is class 1 the maximum range is lower.
The bluetooth serial module I got has the following pins from left to right (ground, RX, TX, not connected, VCC). Obviously ground and VCC goes
respectively to ground and +5V pin on the arduino board. Since we will be receiveing the data through the module and then in turn sending it to the
arduino board we only need to use the TX pin on the module. Run a wire from that pin to the RX pin on the arduino board. The Led is controlled
through PIN 2 on the arduino.
The important aspect here is the baud rate - make sure it matches the baud rate of your module - check the datasheet or use AT commands to do it.
byte serialA;
void setup()
{
// initialize the serial communication:
Serial.begin(19200); //baud rate - make sure it matches that of the module you got:
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
switch (serialA) {
case 1:
digitalWrite(ledPin, HIGH);
break;
case 2:
digitalWrite(ledPin, LOW);
break;
case 3:digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
default:
break;
}
If all you want is to get the app and see it running then download the app then upload it to your phone.
Download at -> https://drive.google.com/folderview?id=0B_PfPoEotOF8N2JwT3RSX011SjQ&usp=sharing
Your phone has to be set to allow apps from outside the android market/google play to be able to download them - so check the settings on your
mobile.
Below is the source of the app that I used. You can upload it to the app inventor and then upload to your phone or modify it.
https://drive.google.com/folderview?id=0B_PfPoEotOF8N2JwT3RSX011SjQ&usp=sharing
I decided to make something useful so I chose a ds18b20 temperature sensor. The arduino board communicates with the sensor using 1 wire interface,
calculates the temperature with the help of OneWire library for arduino and sends the readings through the bluetooth module every 500 ms.
The app checks every 500 ms if there is any data available from the serial port. If data is present it is read and displayed on the screen. Additionally,
there is an option to activate text to speech function and make the app say the temperature readings every 15 seconds.
#include <OneWire.h>
int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2
void setup()
{
// initialize the serial communication:
Serial.begin(19200);
// initialize the ledPin as an output:
void loop() {
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -100;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
ds.reset_search();
return TemperatureSum;}