Show Posts
Pages: [1] 2
1  Products / Arduino Yún / Re: Arduino Yun Vin on: March 18, 2014, 03:03:56 pm
Thank you Duke for the suggestion, I appreciate!

elle
2  Products / Arduino Yún / Arduino Yun Vin on: March 15, 2014, 06:01:13 am
Hi,

I read from the Arduino Yun webpage the following:

Quote
It is recommended to power the board via the micro-USB connection with 5VDC.

So what are, in your opinion, the risks of using the Vin pin instead of the micro-USB? It is because of the lack of the 5V regulator, so you have to be sure to provide exact 5V? or there is something else?

Thanks,
elle
3  Products / Arduino GSM Shield / Re: Arduino Uno + Gsm Shield issue: unresponsive on: February 26, 2014, 03:03:40 am
Any ideas?

Thanks
elle
4  Products / Arduino GSM Shield / Arduino Uno + Gsm Shield issue: unresponsive on: February 24, 2014, 04:08:46 pm
Hi,

I'm using an Arduino UNO + Gsm shield in a project  that aims at controlling an instrument remotely. It runs continuously without problems for the first week approximately, but after that the Uno seems unresponsive and it does not process any sms received and looks unresponsive. The only way in order to get back to the normal functioning is by pushing the reset button on the UNO board.

I don't know whether it can help to understand the issue, but when I call the mobile number, the line is ok.

Thank you for help

The following is the code:

Code:
# www.biemmeitalia.net

#include <GSM.h>
#include <MemoryFree.h>    //library for calculate free memory
#define WATCHDOG 1         //commentare questa riga per disabilitare il watchdog

#ifdef WATCHDOG
  #include <avr/wdt.h>        //watchdog library
#endif

//#define DEBUG 1          

#define SOGLIA_MEMORIA_DISPONIBILE 600

#define SENDSMS 1

#define PIN_SONDATEMP 1
#define PINCALDAIA_ON 8
#define PIN_TEMP_MINIMA 9
#define ledantigelo 4
#define PINALARM 10

//impostazione da pulsanti su box
#define PIN_ON 5
#define PIN_OFF 6

//numero di campionamenti analogica
#define NUM_LETTURE_AN 30

#define SET_TEMP 2.0
#define DELTA 5.0

// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;

char senderNumber[20];  

char remoteNumM[20]="33912345678";
char remoteNumCliente[20]="34712345677";

byte flagAbilitaLogica = 1;
byte flagSMSAllarme    = 0;
byte flagSMSRicevutoON = 0;
byte flagSMSRicevutoOFF= 0;
byte flagTempSottoZero = 0;
byte flagTempNegativa  = 0;

byte flagSMSDestinatarioM = 0;

//stato letture pin digitali
byte statoPinON     = 0;
byte statoPinOFF    = 0;
byte statoPinALARM = 0;

//logica temperatura
int count = 0;
unsigned long cum = 0;
int reading;
double temp_avg = 150.0;
double temperatureC = 15.0;


void setup()
{
  #ifdef DEBUG
    Serial.begin(9600);
  #endif
  
  #ifdef DEBUG
   Serial.println("init pins");
  #endif

  pinMode(PINCALDAIA_ON, OUTPUT);
  pinMode(PIN_TEMP_MINIMA, OUTPUT);
  pinMode(PINALARM, INPUT_PULLUP);
  pinMode(ledantigelo,OUTPUT);
  pinMode(PIN_ON, INPUT_PULLUP);
  pinMode(PIN_OFF,INPUT_PULLUP);
  digitalWrite(PINCALDAIA_ON,LOW);
  digitalWrite(PIN_TEMP_MINIMA,LOW);

  // connection state
  boolean notConnected = true;

  // Start GSM connection
  while(notConnected)
  
  {
    if(gsmAccess.begin()==GSM_READY)
      notConnected = false;
    else
    {
      #ifdef DEBUG
        Serial.println("Not connected");
      #endif
      delay(1000);
      LogicaTemperatura();
      
    }
  }
  #ifdef DEBUG
   Serial.println("GSM initialized");
   Serial.println("Waiting for messages");
  #endif
  delay(1000);
  
  #ifndef WATCHDOG
   sendAlarmSMS("ENEL riattivato.");
  #endif
  
  #ifdef WATCHDOG
   wdt_enable(WDTO_8S);
  #endif
}


void loop()
{
  String smsTextReceived;
  char c;

  // If there are any SMSs available()  
  if (sms.available()){

    Serial.println("Message received from:");

    sms.remoteNumber(senderNumber, 20);
    #ifdef DEBUG
     Serial.println(senderNumber);
    #endif

    smsTextReceived="";

    while(c=sms.read()){
      smsTextReceived+=c;
      #ifdef DEBUG
       Serial.print(c);
      #endif
    }
    #ifdef DEBUG
     Serial.println("\nEND OF MESSAGE");
    #endif

    // Delete message from modem memory
    sms.flush();
    #ifdef DEBUG
     Serial.println("MESSAGE DELETED");
    #endif

    //se ricevo un sms con il testo "on"
    if (smsTextReceived.equalsIgnoreCase("on")){
      flagSMSRicevutoON = 1;
    }

    if (smsTextReceived.equalsIgnoreCase("off")){
      flagSMSRicevutoOFF = 1;
    }
    if (smsTextReceived.equalsIgnoreCase("mario")){
      flagSMSDestinatarioM = 1;
      sendAlarmSMS_M("Messaggi diretti a M.");
    }
    if (smsTextReceived.equalsIgnoreCase("cliente")){
      flagSMSDestinatarioM = 0;
      sendAlarmSMS_M("Messaggi diretti al C.");
    }
    
    if (smsTextReceived.equalsIgnoreCase("temp")){
      char messaggio[100];
      
      String mess;
      String str_intero;
      String str_virgola;
      int intero;
      int virgola;
      
      Serial.println(temperatureC);
      
      flagTempNegativa = 0;
      if (temperatureC < 0){
        flagTempNegativa = 1;
        temperatureC = abs(temperatureC);
      }    
      intero = (int)temperatureC;
      virgola = (int)((temperatureC - (double)intero)*100.0);
      
      #ifdef DEBUG
       Serial.println(intero);
       Serial.println(virgola);
      #endif
      
      str_intero = String(intero);
      str_virgola = String(virgola);
      
      if (flagTempNegativa == 0){
        mess = String("Temperatura corrente: " + str_intero + "," + str_virgola);
      }else{
        mess = String("Temperatura corrente: -" + str_intero + "," + str_virgola);
      }
      mess.toCharArray(messaggio, mess.length());
      sendAlarmSMS(messaggio);
      delay(100);
    }
    
  }
  
  statoPinON  = digitalRead(PIN_ON);
  statoPinOFF = digitalRead(PIN_OFF);
    
  if ((flagSMSRicevutoON) || (statoPinON == LOW)){
      #ifdef DEBUG
       Serial.println("ON");
      #endif
      digitalWrite(PINCALDAIA_ON, HIGH);
      digitalWrite(PIN_TEMP_MINIMA, LOW);
      digitalWrite(ledantigelo,LOW);
      
      flagAbilitaLogica = 0;
      sendAlarmSMS("Caldaia attiva da termostato ambiente.");
  }else{
    if ((flagSMSRicevutoOFF) || (statoPinOFF == LOW)){
      #ifdef DEBUG
       Serial.println("OFF");
      #endif
      digitalWrite(PINCALDAIA_ON, LOW);
      digitalWrite(ledantigelo,HIGH);
      
      cum = 0;      //azzera la variabile per il calcolo delle temp medie
      flagAbilitaLogica = 1;
      count = 0;
      sendAlarmSMS("Abilitazione temperatura minima.");
    }
  }
  
  LogicaTemperatura();

  delay(10);
  
  statoPinALARM = digitalRead(PINALARM);
  
  if (statoPinALARM == LOW){  
    if (!flagSMSAllarme){
      sendAlarmSMS("Blocco.");
      flagSMSAllarme=!flagSMSAllarme;
    }
  }else{
    flagSMSAllarme=0;
  }
  flagSMSRicevutoON  = 0;
  flagSMSRicevutoOFF = 0;

  #ifdef WATCHDOG
    int mem = freeMemory();
    if (mem > SOGLIA_MEMORIA_DISPONIBILE){
      wdt_reset();
    }
  #endif
}



void LogicaTemperatura(){

  if (count < NUM_LETTURE_AN){
    
    count++;
    reading = analogRead(PIN_SONDATEMP);
    cum += reading;
    
  }
  else{
    
    temp_avg = (double)cum/(double)NUM_LETTURE_AN;
    
    double voltage = temp_avg * 5.0;
    voltage /= 1024.0;

    temperatureC = ((voltage - 0.5) * 100)-5.0 ;

    #ifdef DEBUG
     Serial.print(temperatureC);
     Serial.println(" degrees C");
    #endif

    if (flagAbilitaLogica){
      if (temperatureC < SET_TEMP){
        #ifdef DEBUG
         Serial.println("temp bassa");
        #endif
        digitalWrite(PIN_TEMP_MINIMA, HIGH);
      }else if (temperatureC > SET_TEMP + DELTA){
        #ifdef DEBUG
         Serial.println("temp alta");
        #endif
        digitalWrite(PIN_TEMP_MINIMA, LOW);
      }
    }
    count = 0;
    cum   = 0;  
  }
}

void sendAlarmSMS(char * txtMsg){
#ifdef SENDSMS
  
  #ifdef DEBUG
   Serial.println("SPEDISCO:");
   Serial.println();
   Serial.println("il seguente messaggio:");
   Serial.println(txtMsg);
  #endif

  if (flagSMSDestinatarioM){
    sms.beginSMS(remoteNumM);
  }else{
    sms.beginSMS(remoteNumCliente);
  }
  
  sms.print(txtMsg);
  sms.endSMS();
  #ifdef DEBUG
   Serial.println("\nSpedito!\n");
  #endif
#endif
delay(10);
}

void sendAlarmSMS_M(char * txtMsg){
#ifdef SENDSMS
  #ifdef DEBUG
   Serial.println("SPEDISCO:");
   Serial.println();
   Serial.println("il seguente messaggio:");
   Serial.println(txtMsg);
  #endif

  sms.beginSMS(remoteNumM);
  sms.print(txtMsg);
  sms.endSMS();
  #ifdef DEBUG
   Serial.println("\nSpedito!\n");
  #endif
#endif
delay(10);
}
5  Topics / Home Automation and Networked Objects / Re: Looking for arduino controlled 220V outlet or powercord on: January 10, 2014, 04:48:53 pm
hi
This Bmini shield might be good for your project. Just use the 24V/220V relays and control them through ethernet or modbus.

Take a look at the infographics for understanding how to use the pins

hope it helps

elle
6  Using Arduino / Networking, Protocols, and Devices / Re: Modbus TCP Slave best library on: January 01, 2014, 07:56:34 am
Did you include the following statements at the top of your sketch?

Code:
#include <SPI.h>
#include <Ethernet.h>

Elle
7  Using Arduino / Networking, Protocols, and Devices / Re: Modbus TCP multiple registers R/W on: January 01, 2014, 07:46:53 am
I use the Mudbus library without any particular problem. It seems strange to me that it does not work with 4 words only.
What kind of error did you get?

Elle
8  Using Arduino / Networking, Protocols, and Devices / Re: Implementation of MODBUS TCP on a very basic level on: January 01, 2014, 06:38:58 am
Even though you probably figured out how to use modbus tcp, I would like to add some useful pointers.

Like ryardman said, you can use the Mudbus library for Arduino (at least for the slave device). It supports modbus function 1 and 3 for reading, 5 and 6 for writing.
This tutorial on how to set up a modbus TCP slave should be a good starting point.

Hope it helps

Elle
9  Using Arduino / Networking, Protocols, and Devices / Re: MODBUS RTU sensor on: January 01, 2014, 05:58:00 am
Hi
I think you should start by getting the modbus master library for Arduino. This is one of the most widely used:

Than take a look at the examples of the library. You have to use the function 4 of the modbus libray (i.e., Read Input Registers) in order to read the register 7533.

Hope this helps

Elle
10  International / Hardware / Re: Arduino Pro Mini MAX485 rts on: November 02, 2013, 09:57:01 am
Se puo' essere di aiuto: Comunicazione Arduino via RS485

elle
11  International / Software / Re: Chiarimento su libreria Simple Modbus Master / Slave on: November 02, 2013, 09:49:21 am
Ciao

Devi usare una libreria modbus per il master, diversa da quella che andrai ad usare negli slave.

Un buon punto di partenza: Come impostare uno slave modbus in Arduino

elle
12  Using Arduino / Networking, Protocols, and Devices / Re: Connect an Arduino to a Siemens PLC S7-1200 on: July 03, 2013, 08:21:07 am
I don't know exactly whether the Siemens S7-1200 supports modbus communication protocol but in case it is, you can use serial RX/TX Arduino lines, some MAX485 chips together with the Arduino modbus RTU library. It works fine.

A good pointer for Arduino rs485 communication might be the following:

http://t.co/r26H2axo

eventually, if it supports modbus tcp:

http://www.biemmeitalia.net/blog/arduino-android-communication-modbus-tcp/

I hope it helps

elle
13  Using Arduino / Networking, Protocols, and Devices / Re: PLC with MEGA using modbusmaster library on: June 12, 2013, 02:55:21 pm
hi
I would suggest you to check whether your PLC communicates through RS232... many PLCs I know uses RS485, and this maybe is the cause of your issue...

elle
14  International / Generale / Re: 5 arduino e un pc connessi con rs485 on: June 12, 2013, 02:46:18 pm
ciao
ci sono per esempio delle librerie modbus per Arduino che funzionano a meraviglia... considera di dargli un'occhiata

elle
15  Using Arduino / Networking, Protocols, and Devices / Re: communication modbus rs485, HELP!! on: June 12, 2013, 02:42:21 pm
hi,
I use SimpleModbus[Master/Slave] library too, and it works great.

Take a look at this walkthrough on modbus through rs485, it contains examples that can help you

elle
Pages: [1] 2