domingo, 27 de diciembre de 2015

relay with gsm/ acticacion de reles con un SMS

the following components allow to control differents devices via SMS.
(this control will allow to make a irrigation smart system )




code to gsm shield:

       
#include "SIM900.h"
#include "sms.h"
#include "SoftwareSerial.h"
#include "sms.h"
SMSGSM sms;

boolean started=false;
char smsbuffer[160];
char n[20];
int inc=10;
int  porta = 13;
//inserir o número telefonico
char number[]="+56963022591";

int pinmotor=13;
int i=0;
void setup() 
{
  
  pinMode(pinmotor,OUTPUT);
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  if(started){
    delsms();
  }

};

void loop() 
{
   
  int pos=0;
  //Serial.println("Loop");
  if(started){
    pos=sms.IsSMSPresent(SMS_ALL);
    if(pos){
      sms.GetSMS(pos,n,smsbuffer,100);
      if(!strcmp(smsbuffer,"luz off")){
     
        digitalWrite(pinmotor,LOW);
        delay(100);
      }      
      if(!strcmp(smsbuffer,"luz on")){
       
       // for(i=0; i<256 10="" at="" code="" del="" delay="" delsms="" digitalwrite="" do="" else="" for="" i="" if="" int="" it="" max="" ncant="" ndeleted="" nfind="" pinmotor="" pos="" serial.print="" serial.println="" sms.deletesms="" sms="" the="" times="" void="">

sábado, 24 de octubre de 2015

temperatura

the following code we are going to see how to connect arduino with MatLab and how to graph the temperature in real time.

ingredientes:

  • Arduino Uno.
  • sensor LM35
  • Led
  • Protoboard
  • resistencia 220 Ohm
Connection diagram:
       

   float temperatura;
   int pinTemp=0;

   void setup() {
    Serial.begin(115200);
   }

   void loop() {
    temperatura=analogRead(pinTemp);
    temperatura=temperatura*0.48828125;  //500 grados es 5v a 10mV por 1°C
    Serial.println(temperatura);
    delay(1000);
   }

       
 
once that We Have the temperature from device, we are going to go Matlab plataform
       

  int pinTemp=0
  int pinTemp=0;
  clc;
  clear all;
  comport = serial('COM5', 'BaudRate', 115200); % setup comport
  fopen(comport);  % Open comport
  x=0;
  while(x<500)
  x=x+1;
  y1(x)=fscanf(comport, '%d'); % receive ADC1
  %y2....
  drawnow; 
  plot(y1,'r-','linewidth',1)
  grid on;
  hold on;
  title('temperature sequence');
  xlabel('Time');
  ylabel('Temperature');
  pause(30);
  end
  fclose(comport); % Close comport
  delete(comport); % Clear comport