Show Posts
Pages: 1 [2] 3 4
16  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 10, 2014, 01:38:38 pm
First of all.. I put back atmega on arduino duemilanove board and serial print work on serial monitor.
Next I connect another MAX232N on Pin0 and Pin 1, and again everything work.
But when I put atmega on my pcb I get garbage on serial monitor. Here is picture of my test pcb.
I start to think that there is problem with my pcb.
17  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 05:28:14 pm
Nothing is missing on schematic. On the right side only is connectors for gsm click 2
18  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 05:26:35 pm
I dont use normal rx and tx because gsm library use software serial. And in arduino duemilanove ft232 use real atmega hardware serial for upload and monitor serial output
19  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 03:34:34 pm
Entire shematic
20  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 03:25:02 pm
Here is the schematic picture of my project..
21  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 08:41:42 am
I listen to you and I created small code:
Code:
void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps
 
  Serial.println("Hello world!");  // prints hello with ending line break
}

void loop()                       // run over and over again
{
                                  // do nothing!
}
And connected Rx (pin 0 duemilanove w/o atmega) to Rx (PD2 to atmega) and Tx (pin 1 duemilanove w/o atmega) to Tx (PD1 to atmega) .
And guess what...
I still get garbage from serial terminal..
22  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 05:38:50 am
I try to find out if I did something wrong in my pcb.
But when I see on arduino site how to make arduino on breadboard and how to communicate with it, It is the same as I did.
But I cant get communication working
23  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 09, 2014, 05:36:44 am
On serial should write for start:
Code:
Serial.println(F("SMS Messages Receiver"));
As I say again I think it's not problem about code but hardware issue, because everything is working when atmega is on arduino duemilanove board.
24  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 08, 2014, 05:25:11 pm
Yes, I take power from pcb for max232 serial to ttl.
So +5V and GND are same.
25  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 08, 2014, 04:58:27 pm
All I get from terminal is: ?p▒|p
Nothing print on serial port. Clock is 16MHz and I build custom board on schematic from arduino. I know it's working because it turn on test LED on A0,A1,A2,A3 pinout.
On arduino board my program is working very well. But on my pcb I dont recieve sms. So I try to listen serial port to see what could be the problem.
And there is another problem... Serial print not working..
26  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 08, 2014, 03:33:59 pm
I use arduino board (for serial connection)to connect to custom board, Only difference is that I didn't put 1K resistor on RX and TX line.
27  Using Arduino / Microcontrollers / Re: Standalone Arduino Serial debug not working on: February 08, 2014, 03:32:14 pm
Again, everything is working on arduino board including serial, but when I transfer atmega to custom board it's working but I can't check serial communicatiom over RX TX (pin 0 and pin 1).
Here is my code:
Code:
#include <EEPROM.h>
#include <GSM.h> // include the GSM library
#define PINNUMBER "" // PIN Number for the SIM
GSM gsmAccess; // initialize the library instances
GSM_SMS sms;
#define gsm 9 // define pin for startup gsm
int addr = 0; // EEPROM address for storing pin state
unsigned char pins;
void setup()
{
  // restore the lights
  pins = EEPROM.read (addr);
  for (int i=A0; i<A4; i++) {
    digitalWrite(i, bitRead(pins, i-A0));
  }
  gsmOn(); //power up GSM
  Serial.begin(9600);  // initialize serial communications and wait for port to open:
  //while (!Serial) {
  // ; // wait for serial port to connect. Needed for Leonardo only
  //}
  Serial.println(F("SMS Messages Receiver"));
  // connection state
  boolean notConnected = true;
  // Start GSM connection
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println(F("Not connected"));
      delay(1000);
    }
  }
  sms.flush();  // delete all messages
  Serial.println(F("GSM initialized"));
  Serial.println(F("Waiting for messages"));
  showFlags();
}
void loop()
{
 
  // If there are any SMSs available()
  if (sms.available())
  {
    RelaySMS();
    sms.flush();
    //Serial.println("MESSAGE DELETED");
  }
  delay(1000);
}
void gsmOn() // Power up gsm
{
  digitalWrite(gsm, HIGH);
  delay(1000);
  digitalWrite(gsm, LOW);
  delay(5000);
}
void RelaySMS()
{
  char c;
  c=sms.read();         // read sms
  if (c=='1')         // If first sign is 1 do next:
  {
    txt(A3,A3);
  }
  else if (c=='2')
  {
    txt(A2,A2);
  }
  else if (c=='3')
  {
    txt(A1,A1);
  }
  else if (c=='4')
  {
    txt(A0,A0);
  }
}
void txt(int Relay, int pin)
{
  pinMode(Relay, OUTPUT);
  Relay = pin;
  String txtmsg = "";
  char c;
  char remoteNumber[10];
  while(c=sms.read())
    txtmsg += c;
  Serial.println(F("Sadrzaj sms-a:")); //SMS text
  Serial.println(txtmsg);
  if (txtmsg.compareTo("on") == 0)
  {
    if (digitalRead(Relay) == HIGH){
    }
    else if (digitalRead(Relay) == LOW){
      digitalWrite(Relay, HIGH);
      save_pin(Relay); //save to eeprom
    }
  }
  else if (txtmsg.compareTo("off") == 0)
  {
    if (digitalRead(Relay) == LOW){
    }
    else if (digitalRead(Relay) == HIGH){
      digitalWrite(Relay, LOW);
      save_pin(Relay); //save to eeprom
    }
  }
  else if (txtmsg.compareTo("status") == 0)
  {
    /*String statustxt = "";
     pinstate = digitalRead(pin);
     if (pinstate == 1){
     sms.remoteNumber(remoteNumber, 10);
     sms.beginSMS(remoteNumber);
     sms.print(statustxt);
     sms.endSMS();
     }
     */
  }
}
/*void allstatustxt ()
 {
 int pinstate;
 String statustxt = "";
 pinstate = digitalRead(pin);
 if (pinstate == 1){
 
 
 
 sms.remoteNumber(remoteNumber, 10);
 sms.beginSMS(remoteNumber);
 sms.print(pinstate);
 sms.endSMS();
 }
 }
 */
void save_pin (byte pin) // Save pin to EEPROM
{
  pins = EEPROM.read (addr) ;
  bitWrite (pins, pin - A0, digitalRead(pin)) ;  //assuming A0 is stored in bit 0
  EEPROM.write(addr, pins);
}
void showFlags()  // Only to control byte variable that is stored to EEPROM
{
  for(int flag=0; flag < 8; flag++)
  {
    if (bitRead(pins, flag) == true)
    Serial.println(F("Flagovi su sledeci:"));
    Serial.println(pins);
  }
  Serial.println();
}
int getFlag( int flagNumber) // Only to control byte variable that is stored to EEPROM
{
  return bitRead(pins, flagNumber);
}
28  Using Arduino / Microcontrollers / Standalone Arduino Serial debug not working on: February 08, 2014, 01:35:28 pm
Hi guys,
I create GSM controled arduino with GSM 2 Click (form Mikroelektronika) and its working ok when Atmega 328p is in arduino board.
But when I put atmega in custom board its its working but  I have some problems with communication with GSM, so I try to connect arduino board w/o atmega to see serial print on pin 0 and 1. But all I get is some artefacts in serial window.
What do I do wrong?
29  Using Arduino / Programming Questions / Re: Help about arduino and EEPROM on: February 06, 2014, 02:41:33 am
So if I understand correctly,
"bitWrite (pins, pin - A0, digitalRead(pin)) ;  assuming A0 is stored in bit 0"
Is A0 bit position or what?
What exactly define bit position in bitWrite function?
I use analog ports A0-A3 as digital output for relays.
30  Using Arduino / Programming Questions / Help about arduino and EEPROM on: February 05, 2014, 03:46:40 pm
Hi follks,
I need a little help about writing to EEPROM.
Well I wrote a program for remote gsm relay control. And it's working ok but I want to add function to save pin state if a power failure occur. For example if I send "turn on relay 1" and shortly after that there was a power failure, state of the pin must return to previous state.
So I find a little help on this topic but I dont understand this code (I mean I understand but not at all):
Code:
// restore the lights
  pins = EEPROM.read(addr);
  for (int i=A0; i<A4; i++) {
    digitalWrite(i, bitRead(pins, i-A0));
  }
// Save the state of the lights
  unsigned char pins = 0;
  for (int i=A0; i<A4; i++) {
   bitWrite(pins, i-A0, digitalRead(i));
   }
   EEPROM.write(addr, pins);

It's ok to read at startup all 4 pins, but in my program I heed to save every pin for itself.
How to save and read one pin at one address?
If I understand correctly I can save all 4 pins in one EEPROM address and read it, but how to save one by one in one EEPROM address?
Pages: 1 [2] 3 4