Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Programming Questions / Re: send email with ethernet shield on: December 04, 2013, 11:35:55 am
i have tried with my gmail account and a get 

"530 5.7.0 Must issue a STERTTLS comand first. qc10sm8407064wic.9 - gsmtp"

 as the gmail image shows PLEASE SOMEONE HELP !!!!!!!
2  Using Arduino / Programming Questions / Re: send email with ethernet shield on: December 04, 2013, 09:09:25 am
thanks for replying. So if i setup an hot mail account would this work ?
3  Using Arduino / Programming Questions / send email with ethernet shield on: December 04, 2013, 02:52:58 am
can any one tell me why this is happening PLEASE

Code:
/*
   Email client sketch for IDE v1.0.1 and w5100/w5200
   Posted December 2012 by SurferTim
*/

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

// this must be unique
byte mac[] = {
  0x00, 0x02, 0x00, 0x08, 0x00, 0xf2 };
IPAddress ip(192,168,0, 7);
IPAddress gateway(192,168,0, 1);
IPAddress subnet(255, 255, 255, 255);

// change server to your email server ip or domain
// IPAddress server( 205,188,157,37 );
//char server[] = "barrdav6@aol.com";
char server[] = "smtp.aol.com";
EthernetClient client;

void setup()
{
  Serial.begin(9600);
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  delay(2000);
  Serial.println(F("Ready. Press 'e' to send."));
}

void loop()
{
  byte inChar;

  inChar = Serial.read();

  if(inChar == 'e')
  {
      if(sendEmail()) Serial.println(F("Email sent"));
      else Serial.println(F("Email failed"));
  }
}

byte sendEmail()
{
  byte thisByte = 0;
  byte respCode;

  if(client.connect(server,25)) {
    Serial.println(F("connected"));
  } else {
    Serial.println(F("connection failed"));
    return 0;
  }

  if(!eRcv()) return 0;
  Serial.println(F("Sending helo"));

// change to your public ip
  client.println(F("helo 90.204.237.173"));

  if(!eRcv()) return 0;
  Serial.println(F("Sending From"));

// change to your email address (sender)
  client.println(F("MAIL From: <barrdav7@aol.com>"));

  if(!eRcv()) return 0;

// change to recipient address
  Serial.println(F("Sending To"));
  client.println(F("RCPT To: <barrdav6@aol.com>"));

  if(!eRcv()) return 0;

  Serial.println(F("Sending DATA"));
  client.println(F("DATA"));

  if(!eRcv()) return 0;

  Serial.println(F("Sending email"));

// change to recipient address
  client.println(F("To: You <barrdav7@aol.com>"));

// change to your address
  client.println(F("From: Me <barrdav6@aol.com>"));

  client.println(F("Subject: Arduino email test\r\n"));

  client.println(F("This is from my Arduino!"));

  client.println(F("."));

  if(!eRcv()) return 0;

  Serial.println(F("Sending QUIT"));
  client.println(F("QUIT"));

  if(!eRcv()) return 0;

  client.stop();

  Serial.println(F("disconnected"));

  return 1;
}

byte eRcv()
{
  byte respCode;
  byte thisByte;
  int loopCount = 0;

  while(!client.available()) {
    delay(1);
    loopCount++;

    // if nothing received for 10 seconds, timeout
    if(loopCount > 10000) {
      client.stop();
      Serial.println(F("\r\nTimeout"));
      return 0;
    }
  }

  respCode = client.peek();

  while(client.available())
  { 
    thisByte = client.read();   
    Serial.write(thisByte);
  }

  if(respCode >= '4')
  {
    efail();
    return 0; 
  }

  return 1;
}


void efail()
{
  byte thisByte = 0;
  int loopCount = 0;

  client.println(F("QUIT"));

  while(!client.available()) {
    delay(1);
    loopCount++;

    // if nothing received for 10 seconds, timeout
    if(loopCount > 10000) {
      client.stop();
      Serial.println(F("\r\nTimeout"));
      return;
    }
  }

  while(client.available())
  { 
    thisByte = client.read();   
    Serial.write(thisByte);
  }

  client.stop();

  Serial.println(F("disconnected"));
}



hope someone can help thanks
4  Using Arduino / Programming Questions / Re: onewire temp sensor on: December 23, 2012, 02:15:29 pm
thanks bill think i have got it
5  Using Arduino / Programming Questions / Re: onewire temp sensor on: December 23, 2012, 01:43:15 pm
thanks bill but will not compile !!!

Code:
[#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: ");
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  // assign address manually.  the addresses below will beed to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then
  // use those addresses and manually assign them (see above) once you know
  // the devices on your bus (and assuming they don't change).
  //
  // method 1: by index
//  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
//  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");

  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices,
  // or you have already retrieved all of them.  It might be a good idea to
  // check the CRC to make sure you didn't get garbage.  The order is
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  Serial.print("Device 1 Address: ");
  printAddress(outsideThermometer);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);

  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC);
  Serial.println();

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer), DEC);
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();   
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  // print the device information
  printData(insideThermometer);
  printData(outsideThermometer);
}
/code]
6  Using Arduino / Programming Questions / Re: onewire temp sensor on: December 23, 2012, 10:09:02 am
thanks wild bill when i looked at dallas code one of the Examples   was exactly what I was looking for but I have spent 3 days trying to work out  how it works ….. can any one help me ?.... i know I need to use    insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }…..outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };”
But I can’t work out where to put them and what to take out
Code:
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();

  // locate devices on the bus
  Serial.print("Locating devices...");
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // report parasite power requirements
  Serial.print("Parasite power is: ");
  if (sensors.isParasitePowerMode()) Serial.println("ON");
  else Serial.println("OFF");

  // assign address manually.  the addresses below will beed to be changed
  // to valid device addresses on your bus.  device address can be retrieved
  // by using either oneWire.search(deviceAddress) or individually via
  // sensors.getAddress(deviceAddress, index)
  //insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
  //outsideThermometer   = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };

  // search for devices on the bus and assign based on an index.  ideally,
  // you would do this to initially discover addresses on the bus and then
  // use those addresses and manually assign them (see above) once you know
  // the devices on your bus (and assuming they don't change).
  //
  // method 1: by index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");

  // method 2: search()
  // search() looks for the next device. Returns 1 if a new address has been
  // returned. A zero might mean that the bus is shorted, there are no devices,
  // or you have already retrieved all of them.  It might be a good idea to
  // check the CRC to make sure you didn't get garbage.  The order is
  // deterministic. You will always get the same devices in the same order
  //
  // Must be called before search()
  //oneWire.reset_search();
  // assigns the first address found to insideThermometer
  //if (!oneWire.search(insideThermometer)) Serial.println("Unable to find address for insideThermometer");
  // assigns the seconds address found to outsideThermometer
  //if (!oneWire.search(outsideThermometer)) Serial.println("Unable to find address for outsideThermometer");

  // show the addresses we found on the bus
  Serial.print("Device 0 Address: ");
  printAddress(insideThermometer);
  Serial.println();

  Serial.print("Device 1 Address: ");
  printAddress(outsideThermometer);
  Serial.println();

  // set the resolution to 9 bit
  sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
  sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);

  Serial.print("Device 0 Resolution: ");
  Serial.print(sensors.getResolution(insideThermometer), DEC);
  Serial.println();

  Serial.print("Device 1 Resolution: ");
  Serial.print(sensors.getResolution(outsideThermometer), DEC);
  Serial.println();
}

// function to print a device address
void printAddress(DeviceAddress deviceAddress)
{
  for (uint8_t i = 0; i < 8; i++)
  {
    // zero pad the address if necessary
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
}

// function to print the temperature for a device
void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  Serial.print("Temp C: ");
  Serial.print(tempC);
  Serial.print(" Temp F: ");
  Serial.print(DallasTemperature::toFahrenheit(tempC));
}

// function to print a device's resolution
void printResolution(DeviceAddress deviceAddress)
{
  Serial.print("Resolution: ");
  Serial.print(sensors.getResolution(deviceAddress));
  Serial.println();   
}

// main function to print information about a device
void printData(DeviceAddress deviceAddress)
{
  Serial.print("Device Address: ");
  printAddress(deviceAddress);
  Serial.print(" ");
  printTemperature(deviceAddress);
  Serial.println();
}

void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
  // request to all devices on the bus
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");

  // print the device information
  printData(insideThermometer);
  printData(outsideThermometer);
}
7  Using Arduino / Programming Questions / onewire temp sensor on: December 20, 2012, 03:39:17 am


Code:
#include <OneWire.h>

// OneWire DS18S20, DS18B20, DS1822 Temperature Example
//
// http://www.pjrc.com/teensy/td_libs_OneWire.html
//
// The DallasTemperature library can do all this work for you!
// http://milesburton.com/Dallas_Temperature_Control_Library

OneWire  ds(10);  // on pin 10

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

void loop(void) {
  byte i;
  byte present = 0;
  byte type_s;
  byte data[12];
  byte addr[8];
  float celsius, fahrenheit;
 
  if ( !ds.search(addr)) {
 
    Serial.println();
    ds.reset_search();
    delay(250);
    return;
  }
 
  Serial.print("ROM =");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
     
    Serial.print(addr[i], HEX);
  }

  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return;
  }
 

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1);         // start conversion, with parasite power on at the end
 
  delay(1000);     // maybe 750ms is enough, maybe not
  // we might do a ds.depower() here, but the reset will take care of it.
 
  present = ds.reset();
  ds.select(addr);   
  ds.write(0xBE);         // Read Scratchpad
Serial.println();
//  Serial.print("  Data = ");
  //Serial.print(present,HEX);
  Serial.print(" ");
  for ( i = 0; i < 9; i++) {           // we need 9 bytes
    data[i] = ds.read();
   // Serial.print(data[i], HEX);
    Serial.print(" ");
  }

  // convert the data to actual temperature

  unsigned int raw = (data[1] << 8) | data[0];
  if (type_s) {
    raw = raw << 3; // 9 bit resolution default
    if (data[7] == 0x10) {
      // count remain gives full 12 bit resolution
      raw = (raw & 0xFFF0) + 12 - data[6];
    }
  } else {
    byte cfg = (data[4] & 0x60);
    if (cfg == 0x00) raw = raw << 3;  // 9 bit resolution, 93.75 ms
    else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
    else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
    // default is 12 bit resolution, 750 ms conversion time
  }
  celsius = (float)raw / 16.0;
 
  Serial.print("  Temperature = ");
  Serial.print(celsius);
  Serial.print(" Celsius, ");
   Serial.println();
  Serial.println();

}

Hello again
I am playing about with some “OneWire”  temperature sensors that I have almost got then to do what I want. as you can see the arduino reads the address of each sensor and displays it to the screen the problem I have is I need do stuff with each sensor separately ….


 Eg .   if ROM = 28 9 85 71 4 0 0 28   Serial.print("  sensor 1 ");
          if ROM = 28 B4 67 72 0 0 B4   Serial.print("  sensor  2");


so on the screen it would look like this…
sensor1
 Temperature = 20.19 Celsius,

Sensor2
 Temperature = 19.44 Celsius,

8  Using Arduino / Programming Questions / Re: input from barcode on: November 29, 2012, 03:42:17 am
For some reason the it is not reading all the number’s … the barcode is 5060048310337 it  reads 5060041033. But this is not a problem as long as if reads the same number for that barcode every time ……. So is this how it should look  ?
9  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 06:34:57 pm
10  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 06:23:45 pm
thanks for that but no matter what barcode i scan it prints good match even one's thats not registered
11  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 06:02:28 pm
error: 'cardcnt' was not declared in scope





Code:
/*
Barcode Scanner                                                       
This code reads the input from a ps/2 keyboard or keyboard-like       
device (e.g. a barcode scanner), translates the scan-codes into       
numbers (only numbers from 0 to 9 can be used at the moment)           
It is nowhere near a complete implementation of the ps/2 protocol,     
but it should give you a starting point.                               
mys .// Benjamin Maus ( benjamin.maus <at> allesblinkt.com )         
2007                                                                   
*/
char *goodCards[] = { "3455192327218", "4005209057240", "5060048310337" };
int SCAN_ENTER = 0x5a; int SCAN_BREAK = 0xf0;
int breakActive = 0;
int clockPin = 3; // Clock is only output.
int dataPin = 2; // The data pin is bi-directional
// But at the moment we are only interested in receiving   
int ledPin = 13;  // When a SCAN_ENTER scancode is received the LED blink
int clockValue = 0; byte dataValue;
byte scanCodes[10] = {0x45,0x16,0x1e,0x26,0x25,0x2e,0x36,0x3d,0x3e,0x46}; char characters[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int quantityCodes = 10;
char buffer[64] = {}; // This saves the characters (for now only numbers)
int bufferPos = 0;
int bufferLength = 64;





void setup() {
pinMode(dataPin, INPUT);                                               
pinMode(clockPin, INPUT);                                             
pinMode(ledPin, OUTPUT);                                               
Serial.begin(9600);                                                   
}

void loop() {
dataValue = dataRead();                                               
// If there is a break code, skip the next byte                       
if (dataValue == SCAN_BREAK) {                                         
breakActive = 1;                                                     
}                                                                     
// Translate the scan codes to numbers                                 
// If there is a match, store it to the buffer                         
for (int i = 0; i < quantityCodes; i++) {                             
byte temp = scanCodes[i];                                           
if(temp == dataValue){                                               
if(!breakActive == 1){                                             
buffer[bufferPos] = characters[i];                               
bufferPos++;                                                     
}                                                                 
}                                                                   
}                                                                     
//Serial.print('*'); // Output an asterix for every byte               
// Print the buffer if SCAN_ENTER is pressed.                         
if(dataValue == SCAN_ENTER){                                           
Serial.print("\nbuffer: ");                                         
// Read the buffer                                                   
int goodMatch = -1;
for(int c=0; c<cardCnt; c++)

{
   if(strcmp(buffer, goodCards[c]) == 0)
   {
      goodMatch = c;
      break;
   }
}

Serial.print("goodMatch  = ");
Serial.println(goodMatch);     // Will print index of good card in array

                int i=0;                          
if (buffer[i] != 0) {                                               
while(buffer[i] != 0) {                                           
Serial.print( buffer[i] );                                       
buffer[i] = 0;                                                   
i++;                                                             
}                                                                 
}                                                                   
Serial.println(" [Enter]");                                         
bufferPos = 0;                                                       
// Blink the LED                                                    
digitalWrite(ledPin, HIGH);                                         
delay(300);                                                         
digitalWrite(ledPin, LOW);                                           
}                                                                     
int goodMatch = -1;

for(int c=0; c<cardCnt; c++)
{
   if(strcmp(buffer, goodCards[c]) == 0)
   {
      goodMatch = c;
      break;
   }
}

Serial.print("goodMatch  = ");
Serial.println(goodMatch);     // Will print index of good card in array// Reset the SCAN_BREAK state if the byte was a normal one             
if(dataValue != SCAN_BREAK){                                           
breakActive = 0;                                                     
}                                                                     
dataValue = 0;                                                         
}

int dataRead() {
byte val = 0;                                                         
// Skip start state and start bit                                     
while (digitalRead(clockPin));  // Wait for LOW.                       
// clock is high when idle                                             
while (!digitalRead(clockPin)); // Wait for HIGH.                     
while (digitalRead(clockPin));  // Wait for LOW.                       
for (int offset = 0; offset < 8; offset++) {                           
while (digitalRead(clockPin));         // Wait for LOW               
val |= digitalRead(dataPin) << offset; // Add to byte               
while (!digitalRead(clockPin));        // Wait for HIGH             
}                                                                     
// Skipping parity and stop bits down here.                           
while (digitalRead(clockPin));           // Wait for LOW.             
while (!digitalRead(clockPin));          // Wait for HIGH.             
while (digitalRead(clockPin));           // Wait for LOW.             
while (!digitalRead(clockPin));          // Wait for HIGH.             
return val;                                                           
}
12  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 05:47:12 pm
think i better start again
13  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 05:44:02 pm
scalar object 'goodCard' requires one element in initialiaer
14  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 05:40:14 pm
error: 'cardcnt' was not declared in scope
15  Using Arduino / Programming Questions / Re: input from barcode on: November 28, 2012, 05:37:25 pm
will not complile
Pages: [1] 2 3 ... 8
Powered by SMF 1.1.19 | SMF © 2013, Simple Machines