Hello everyone,
I have a problem with my Ardunio Uno, I ve connected an RFID reader an the LCD display of seeedstudios. The arduino sketch starts only after opening the serial monitor. When connected to only to the power supply or the usb port the programm doesnt start.
#include <SerialLCD.h>
#include <SoftwareSerial.h>
#include <WiFly.h>
#include <SoftwareSerial.h> // for xbee shield v1.1
#ifndef __CREDENTIALS_H__
#define __CREDENTIALS_H__
SoftwareSerial serial2 (3, 4); // for xbee shield v1.1
char passphrase[] = "";
char ssid[] = "camo";
char ntp_server[] = "nist1-la.ustiming.org"; // or your favorite ntp server.
#endif
byte server[] = { xxx, xxx, xxx, xxx}; //
WiFlyClient client("xxx.xxx.xx.xxx", yy);
#define DEVICE_NAME "Alpha"
//RFID
SoftwareSerial RFID (10, 11);
int val = 0;
char code[10];
int bytesread = 0;
//Display
SerialLCD slcd(12,13);
void setup(void)
{
slcd.begin();
Serial.begin(9600);
Serial.println("Setup started");
serial2.begin (9600); // for xbee shield v1.1
delay(1000);
WiFly.setUart(&serial2);
WiFly.begin();
while (!WiFly.join(ssid)){Serial.println("Association failed.");delay(1000);}
// RFID
RFID.begin (9600);
Serial.println("Setup finished");
}
void loop(void)
{
Serial.println("Loop started");
if(RFID.available() > 0) { // if data available from reader
if((val = RFID.read()) == 2) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( RFID.available() > 0) {
val = RFID.read();
if((val == 2)||(val == 3)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
}
if(bytesread == 10) { // if 10 digit read is complete
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(code); // print the TAG code
if (client.connect ())
{
slcd.clear();
client.print ("get http://xxx.xxx.xxx.xxx/sensor/3c1fd199800e47b2fb2735f95ed2af3dcd6e8ceb/device/");
client.print (DEVICE_NAME);
client.print ("/RackNr/");
client.print (code);
slcd.print (code);
Serial.println("RackNr on Display!");
Serial.println("Message sent!");
}
client.stop ();
delay (2000);
}
bytesread = 0;
}
//end
}
}
Would be great to find a solution for this. Thanks!