Show Posts
|
|
Pages: [1] 2 3 ... 5
|
|
1
|
International / Hardware / Re: Problema accensione via SMS
|
on: April 30, 2013, 11:12:45 am
|
Al monitor seriale mi appare questo: GSM initialized Message received from: +39340****** (numero del telefono cellulare) MESSAGE DELETED All'uscita del relè ho collegato il cavo blu (NO e COM),ma la luce non si accende.Il codice è questo: /* SMS heather remote control This sketch, designed for the GSM shield, allows you to remotely control any device connected to your Arduino. By sending an SMS, through certain keywords, it's possible, as in this case, to turn on or off a simple heater. The GSM module, mounted on an Arduino board, processes the message and executes an action. Then, it sends a notification message containing the state of the device. If the message doesn't contain any valid keyword, the Arduino doesn't execute any operation and the message is deleted from the sim card. The sketch also manages keywords with uppercase or lowercase. Circuit: * GSM shield and an Arduino board * SIM card that can send/receive SMS * a relay connected to digital pin 12 based on the ReceiveSMS example by Javier Zorzano / TD modified by Federico Vanzati & Alberto Cicchi (03/2013) */
// include the GSM library #include <GSM.h>
const int heaterControlPin = 12;
// initialize the library instances GSM gsmAccess; GSM_SMS sms;
// Array to hold the number a SMS is retreived from char senderNumber[20];
// String to hold the incoming message String message = "";
// String that will contain the parsed values from the message String commandID, deviceID;
void setup() { // set the pin connected to the relay that control the heater as output pinMode(heaterControlPin, OUTPUT);
// initialize serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
// connection state boolean notConnected = true;
// Start GSM connection while(notConnected) { if(gsmAccess.begin("1234")==GSM_READY) notConnected = false; else { Serial.println("Not connected"); delay(500); } }
Serial.println("GSM initialized");
}
void loop() { char c;
// If there are any SMS available if (sms.available()) { Serial.println("Message received from:");
// Get remote number sms.remoteNumber(senderNumber, 20); Serial.println(senderNumber);
// An example of message disposal // Any messages starting with # should be discarded // usually anonymous messages starts with # if(sms.peek()=='#') { Serial.println("Discarded SMS"); sms.flush(); }
// Read message bytes and print them while(c = sms.read()) message += c;
// cancella message ricevuto sms.flush(); Serial.println("MESSAGE DELETED"); }
// if there is a new message start to parse the command and the device to control if(message != "") {
// put the incoming characters that compose the message to lower case message.toLowerCase();
int i=0;
// deviceID and commandID are separated by a space // find it and store the position in two strings while(message.charAt(i) != ' ') i++;
commandID = message.substring(0,i); deviceID = message.substring(i+1, message.length());
// check the device to control if(deviceID == "stufetta") { //check the command to execute if(commandID == "accendi") { sendFeedbackSMS(senderNumber, deviceID, "ON"); // send the feedback to the sender digitalWrite(heaterControlPin, HIGH); } if(commandID == "spegni") { sendFeedbackSMS(senderNumber, deviceID, "OFF"); // send the feedback to the sender digitalWrite(heaterControlPin, LOW); } }
// clear the message that has just been processed message = ""; }
delay(500); }
// this function, given a phone number and two strings representing the device and // its state send a feedback text message to the phone number void sendFeedbackSMS(char remoteNum[], String devString, String devState) { String txtMsg = devString + " " + devState; Serial.println(txtMsg); Serial.println(remoteNum);
sms.beginSMS(remoteNum); sms.print(txtMsg); sms.endSMS(); }
|
|
|
|
|
3
|
International / Hardware / Re: Problema accensione via SMS
|
on: April 27, 2013, 09:42:14 am
|
Ho provato ad accendere e spegnere la lampadina senza GSM shield.Ho copiato e modificato questo codice script da http://www.tinkerkit.com/relay-tutorial/. /* based on Blink, Arduino's "Hello World!" Turns on an LED on for one second, then off for one second, repeatedly. The Tinkerkit Led Modules (T010110-7) is hooked up on O0
created in Dec 2011 by Federico Vanzati
This example code is in the public domain. */ // include the TinkerKit library #include <TinkerKit.h>
TKLed led(12); // creating the object 'led' that belongs to the 'TKLed' class // and giving the value to the desired output pin
void setup() { // TinkerKit 'object' eliminate the need for pin declaration with pinMode() }
void loop() { led.on(); // set the LED on delay(500); // wait for a second led.off(); // set the LED off delay(500); // wait for a second }
ed ha funzionato.Come faccio con GSM Shield? Ho tolto il PIN della SIM.
|
|
|
|
|
5
|
International / Hardware / Re: Problema accensione via SMS
|
on: April 27, 2013, 06:03:14 am
|
Ciao, ho provato ad inserire la scheda SIM tradizionale,ma non ho ricevuto nessun risultato.Ma la SIM ha il codice PIN,devo modificare lo script?E' dove devo scrivere questo script per fare funzionare? Che cosa devo fare? Grazie. /* SMS heather remote control This sketch, designed for the GSM shield, allows you to remotely control any device connected to your Arduino. By sending an SMS, through certain keywords, it's possible, as in this case, to turn on or off a simple heater. The GSM module, mounted on an Arduino board, processes the message and executes an action. Then, it sends a notification message containing the state of the device. If the message doesn't contain any valid keyword, the Arduino doesn't execute any operation and the message is deleted from the sim card. The sketch also manages keywords with uppercase or lowercase. Circuit: * GSM shield and an Arduino board * SIM card that can send/receive SMS * a relay connected to digital pin 12 based on the ReceiveSMS example by Javier Zorzano / TD modified by Federico Vanzati & Alberto Cicchi (03/2013) */
// include the GSM library #include <GSM.h>
const int heaterControlPin = 12;
// initialize the library instances GSM gsmAccess; GSM_SMS sms;
// Array to hold the number a SMS is retreived from char senderNumber[20];
// String to hold the incoming message String message = "";
// String that will contain the parsed values from the message String commandID, deviceID;
void setup() { // set the pin connected to the relay that control the heater as output pinMode(heaterControlPin, OUTPUT);
// initialize serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
// connection state boolean notConnected = true;
// Start GSM connection while(notConnected) { if(gsmAccess.begin()==GSM_READY) notConnected = false; else { Serial.println("Not connected"); delay(500); } }
Serial.println("GSM initialized");
}
void loop() { char c;
// If there are any SMS available if (sms.available()) { Serial.println("Message received from:");
// Get remote number sms.remoteNumber(senderNumber, 20); Serial.println(senderNumber);
// An example of message disposal // Any messages starting with # should be discarded // usually anonymous messages starts with # if(sms.peek()=='#') { Serial.println("Discarded SMS"); sms.flush(); }
// Read message bytes and print them while(c = sms.read()) message += c;
// cancella message ricevuto sms.flush(); Serial.println("MESSAGE DELETED"); }
// if there is a new message start to parse the command and the device to control if(message != "") {
// put the incoming characters that compose the message to lower case message.toLowerCase();
int i=0;
// deviceID and commandID are separated by a space // find it and store the position in two strings while(message.charAt(i) != ' ') i++;
commandID = message.substring(0,i); deviceID = message.substring(i+1, message.length());
// check the device to control if(deviceID == "stufetta") { //check the command to execute if(commandID == "accendi") { sendFeedbackSMS(senderNumber, deviceID, "ON"); // send the feedback to the sender digitalWrite(heaterControlPin, HIGH); } if(commandID == "spegni") { sendFeedbackSMS(senderNumber, deviceID, "OFF"); // send the feedback to the sender digitalWrite(heaterControlPin, LOW); } }
// clear the message that has just been processed message = ""; }
delay(500); }
// this function, given a phone number and two strings representing the device and // its state send a feedback text message to the phone number void sendFeedbackSMS(char remoteNum[], String devString, String devState) { String txtMsg = devString + " " + devState; Serial.println(txtMsg); Serial.println(remoteNum);
sms.beginSMS(remoteNum); sms.print(txtMsg); sms.endSMS(); }
|
|
|
|
|
8
|
International / Hardware / Re: Problema accensione via SMS
|
on: April 26, 2013, 06:52:32 am
|
Ciao, chi mi può aiutare come inviare SMS per accendere e spegnere?Grazie Il codice è questo: /* SMS heather remote control This sketch, designed for the GSM shield, allows you to remotely control any device connected to your Arduino. By sending an SMS, through certain keywords, it's possible, as in this case, to turn on or off a simple heater. The GSM module, mounted on an Arduino board, processes the message and executes an action. Then, it sends a notification message containing the state of the device. If the message doesn't contain any valid keyword, the Arduino doesn't execute any operation and the message is deleted from the sim card. The sketch also manages keywords with uppercase or lowercase. Circuit: * GSM shield and an Arduino board * SIM card that can send/receive SMS * a relay connected to digital pin 12 based on the ReceiveSMS example by Javier Zorzano / TD modified by Federico Vanzati & Alberto Cicchi (03/2013) */
// include the GSM library #include <GSM.h>
const int heaterControlPin = 12;
// initialize the library instances GSM gsmAccess; GSM_SMS sms;
// Array to hold the number a SMS is retreived from char senderNumber[20];
// String to hold the incoming message String message = "";
// String that will contain the parsed values from the message String commandID, deviceID;
void setup() { // set the pin connected to the relay that control the heater as output pinMode(heaterControlPin, OUTPUT);
// initialize serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
// connection state boolean notConnected = true;
// Start GSM connection while(notConnected) { if(gsmAccess.begin()==GSM_READY) notConnected = false; else { Serial.println("Not connected"); delay(1000); } }
Serial.println("GSM initialized");
}
void loop() { char c;
// If there are any SMS available if (sms.available()) { Serial.println("Message received from:");
// Get remote number sms.remoteNumber(senderNumber, 20); Serial.println(senderNumber);
// An example of message disposal // Any messages starting with # should be discarded // usually anonymous messages starts with # if(sms.peek()=='#') { Serial.println("Discarded SMS"); sms.flush(); }
// Read message bytes and print them while(c = sms.read()) message += c;
// cancella message ricevuto sms.flush(); Serial.println("MESSAGE DELETED"); }
// if there is a new message start to parse the command and the device to control if(message != "") {
// put the incoming characters that compose the message to lower case message.toLowerCase();
int i=0;
// deviceID and commandID are separated by a space // find it and store the position in two strings while(message.charAt(i) != ' ') i++;
commandID = message.substring(0,i); deviceID = message.substring(i+1, message.length());
// check the device to control if(deviceID == "stufetta") { //check the command to execute if(commandID == "accendi") { sendFeedbackSMS(senderNumber, deviceID, "ON"); // send the feedback to the sender digitalWrite(heaterControlPin, HIGH); } if(commandID == "spegni") { sendFeedbackSMS(senderNumber, deviceID, "OFF"); // send the feedback to the sender digitalWrite(heaterControlPin, LOW); } }
// clear the message that has just been processed message = ""; }
delay(1000); }
// this function, given a phone number and two strings representing the device and // its state send a feedback text message to the phone number void sendFeedbackSMS(char remoteNum[], String devString, String devState) { String txtMsg = devString + " " + devState; Serial.println(txtMsg); Serial.println(remoteNum);
sms.beginSMS(remoteNum); sms.print(txtMsg); sms.endSMS(); }
|
|
|
|
|
9
|
International / Hardware / Problema accensione via SMS
|
on: April 25, 2013, 05:40:43 am
|
Salve, ho provato ad accendere e spegnere la lampadina con Arduino Uno R3 e Arduino GSM shield inviando via SMS off (spegni) e on (accendi).Per alimentare la lampadina ho usato questo relè TinkerKit Modulo Relay.All'entrata ho collegato il filo neutro (blu) al NO e il secondo (blu) al COM.L'uscita i tre cavetti ho collegato all'Arduino GSM shield il cavetto nero alla massa (GND), il cavetto rosso all'alimentazione (5V) e il cavetto arancione al PIN 12.Il codice ho copiato da Arduino Tutorial Wired SMSHeather http://playground.arduino.cc/Italiano/TutorialWired#SMSHeather.Mi potete indicarmi che cosa devo scrivere nel codice. Qui ho inserito il mio numero di telefono cellulare // String to hold the incoming message String message = "";
o devo inserire il numero della SIM di Arduino GSM Shield.Grazie.
|
|
|
|
|
11
|
International / Software / Re: Problema sensore di temperatura
|
on: April 20, 2013, 07:09:37 am
|
void loop() { // main program loop if (millis() - lastConnectionTime > connectionInterval) { // read a value from the pin int sensorValue = analogRead(A3); float voltage = sensorValue * (3.3 / 1023.0); float temperature = (3.24 - .48828125) * 100; Serial.println("sensorValue");
Così va bene o ho sbagliato?
|
|
|
|
|
12
|
International / Software / Problema sensore di temperatura
|
on: April 20, 2013, 06:37:06 am
|
Ciao, ho fatto questo misuratore di temperatura con questo sensore LM335Z e ho collegato con Arduino Uno R3 con Arduino GSM Shield che invia dati a Cosm https://cosm.com/feeds/8526 vedi sensor_reading.Ma il codice della temperatura del sensore mi da errati dati.Che cosa devo fare?Grazie. /** * Cosm Arduino sensor GSM client example. * * This sketch demonstrates connecting an Arduino to Cosm (https://cosm.com), * using the new Arduino library to send and receive data and the new GSM library. * * Requirements * * Arduino with (Telefonica-designed) GSM shield * * Arduino software with version >= 1.0 * * An account at Cosm (https://cosm.com) * * * A temperature sensor connected to pin 3 * * Adapted 1 April 2013 by Dan Appelquist from a sample program * created 8th January, 2013 using code written by Adrian McEwen with * modifications by Sam Mulube * * Full cosm tutorial available here: https://cosm.com/docs/quickstart/arduino.html * * This code is in the public domain. */
#include <Cosm.h> #include <HttpClient.h> #include <GSM.h>
#define API_KEY "XXXX" // your Cosm API key #define FEED_ID XXXX // your Cosm feed ID
// PIN Number #define PINNUMBER "" // your sim PIN number if you have one (most don't)
// APN data #define GPRS_APN "bluevia.movistar.es" // replace your GPRS APN #define GPRS_LOGIN "" // replace with your GPRS login #define GPRS_PASSWORD "" // replace with your GPRS password
// initialize the library instance: GSMClient client; GPRS gprs; GSM gsmAccess;
// Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield) int sensorPin = A3;
unsigned long lastConnectionTime = 0; // last time we connected to Cosm const unsigned long connectionInterval = 500; // delay between connecting to Cosm in milliseconds
// Initialize the Cosm library
// Define the string for our datastream ID char sensorId[] = "sensor_reading";
CosmDatastream datastreams[] = { CosmDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT), };
// Wrap the datastream into a feed CosmFeed feed(FEED_ID, datastreams, 1 /* number of datastreams */);
CosmClient cosmclient(client);
void setup() { // put your setup code here, to run once: Serial.begin(9600);
Serial.println("GSM Cosm Sensor Client Example"); Serial.println("==============================");
}
void loop() { // main program loop if (millis() - lastConnectionTime > connectionInterval) { // read a value from the pin int sensorValue = analogRead(A3); float voltage = sensorValue * (3.3 / 1023.0); float temperature = (3.24 - .48828125) * 100; // initialize GPRS connection Serial.println("Initializing network");
// connection state boolean notConnected = true; // After starting the modem with GSM.begin() // attach the shield to the GPRS network with the APN, login and password while(notConnected) { if((gsmAccess.begin(PINNUMBER)==GSM_READY) & (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)) notConnected = false; else { Serial.println("Not connected"); delay(1000); } } Serial.println("Network initialized"); Serial.println();
// send it to Cosm sendData(temperature);
// disconnect the GPRS connection Serial.println("Network disconnected"); client.stop();
// update connection time so we wait before connecting again lastConnectionTime = millis(); } }
// send the supplied value to Cosm, printing some debug information as we go void sendData(float sensorValue) { datastreams[0].setFloat(sensorValue);
Serial.print("Read sensor value "); Serial.println(datastreams[0].getFloat());
Serial.println("Uploading to Cosm"); int ret = cosmclient.put(feed, API_KEY); Serial.print("PUT return code: "); Serial.println(ret);
Serial.println(); }
// get the value of the datastream from Cosm, printing out the value we received // not used for this sample but useful if you want to get data back from cosm void getData() { Serial.println("Reading data from Cosm");
float ret = cosmclient.get(feed, API_KEY); Serial.print("GET return code: "); Serial.println(ret);
if (ret > 0) { Serial.print("Datastream is: "); Serial.println(feed[0]);
Serial.print("Sensor value is: "); Serial.println(feed[0].getFloat()); }
Serial.println(); }
|
|
|
|
|
13
|
International / Hardware / Re: Principiante con Arduino Uno R3 e GSM shield con antenna integrata
|
on: April 06, 2013, 09:13:15 am
|
|
Ho avviato l'applicazione Arduino 1.0.4 e ho seguito lo sketch degli esempi GSM --->Tools----> BandManagement per selezionare tipo di rete GSM ed ho seguito monitor seriale.Prima ho attivato tramite BlueVia e andato tutto bene.Ma la SIM card non aveva bisogno del PIN perché non aveva il codice.Alla fine ce l'ho fatta.Grazie.
|
|
|
|
|
15
|
International / Hardware / Re: Principiante con Arduino Uno R3 e GSM shield con antenna integrata
|
on: April 01, 2013, 09:04:20 am
|
Ho inserito un'altra SIM card e ho impostato PINNUMBER "0000", ma al monitor seriale mi appare "SMS Message Sender" e sotto "Not connected" // If your SIM has PIN, pass it as a parameter of begin() in quotes while(notConnected)
che cosa devo scrivere su questo codice? (vedi sopra).Grazie. /* SMS sender This sketch, for the Arduino GSM shield,sends an SMS message you enter in the serial monitor. Connect your Arduino with the GSM shield and SIM card, open the serial monitor, and wait for the "READY" message to appear in the monitor. Next, type a message to send and press "return". Make sure the serial monitor is set to send a newline when you press return. Circuit: * GSM shield * SIM card that can send SMS created 25 Feb 2012 by Tom Igoe This example is in the public domain. http://arduino.cc/en/Tutorial/GSMExamplesSendSMS */
// Include the GSM library #include <GSM.h>
#define PINNUMBER "0000"
// initialize the library instance GSM gsmAccess; GSM_SMS sms;
void setup() { // initialize serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } Serial.println("SMS Messages Sender");
// connection state boolean notConnected = true;
// Start GSM shield // If your SIM has PIN, pass it as a parameter of begin() in quotes while(notConnected) { if(gsmAccess.begin(PINNUMBER)==GSM_READY) notConnected = false; else { Serial.println("Not connected"); delay(1000); } } Serial.println("GSM initialized"); }
void loop() {
Serial.print("Enter a mobile number: "); char remoteNum[20]; // telephone number to send sms readSerial(remoteNum); Serial.println(remoteNum); // sms text Serial.print("Now, enter SMS content: "); char txtMsg[200]; readSerial(txtMsg); Serial.println("SENDING"); Serial.println(); Serial.println("Message:"); Serial.println(txtMsg); // send the message sms.beginSMS(remoteNum); sms.print(txtMsg); sms.endSMS(); Serial.println("\nCOMPLETE!\n"); }
/* Read input serial */ int readSerial(char result[]) { int i = 0; while(1) { while (Serial.available() > 0) { char inChar = Serial.read(); if (inChar == '\n') { result[i] = '\0'; Serial.flush(); return 0; } if(inChar!='\r') { result[i] = inChar; i++; } } } }
|
|
|
|
|