Pages: 1 [2]   Go Down
Author Topic: Idea: Home guardian sends e-mail when door stays open  (Read 3764 times)
0 Members and 1 Guest are viewing this topic.
Czech Republic
Offline Offline
Sr. Member
****
Karma: 3
Posts: 311
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

...

Thank for helping me, I do this and it works as requested!

Code:
#include <avr/pgmspace.h>

//do not exceed 80 characters per line!
static char buffer[80+1]; // must be big enough for longest string and the terminating null
char TextMailSubject[] PROGMEM = "Garage alarm: door not closed at Street/City!";
char TextMailBodyLn1[] PROGMEM = "This is an automated message - please do not reply directly to this email!\r\n";
char TextMailBodyLn2[] PROGMEM = "Hi there!";
char TextMailBodyLn3[] PROGMEM = "Garage door at Street/City stays accidentally left open.";
char TextMailBodyLn4[] PROGMEM = "Please take appropriate steps to remedy the situation.\r\n";
char TextMailBodyLn5[] PROGMEM = "My sincere thanks for your time and consideration, your Arduino\r\n";
char TextMailBodyLn6[] PROGMEM = "Date and time of incident:";
char* TextItemPointers[] PROGMEM = {
  TextMailSubject, TextMailBodyLn1, TextMailBodyLn2, TextMailBodyLn3, TextMailBodyLn4, TextMailBodyLn5, TextMailBodyLn6};
String Message = "";

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

int GetFreeRAM() {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

/* function to return string by index */

String GetTextFromFlashMemory(int ItemIndex)
{
  int i = 0;
  char c;
  while (c != '\0')
  {
    c = pgm_read_byte(pgm_read_word(&TextItemPointers[ItemIndex]) + i);
    buffer[i] = c;
    i++;
  }
  buffer[i] = '\0';
  return String(buffer);
}

void loop(){
  Serial.print(F("Free SRAM: "));
  Serial.print(GetFreeRAM());
  Serial.println(F(" bytes"));
  int thisItem;
  for (thisItem = 0; thisItem < 7; thisItem++) {
    Message = "Item #"+String(thisItem);
    Serial.println(Message);
    Message = GetTextFromFlashMemory(thisItem);
    Serial.println(Message);
  };
  Serial.print(F("Free SRAM: "));
  Serial.print(GetFreeRAM());
  Serial.println(F(" bytes"));
  delay(5000);
};
Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

Czech Republic
Offline Offline
Sr. Member
****
Karma: 3
Posts: 311
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Next attempt: attached program sends e-mail with timestamp (IP leased form DHCP, current time obtained from NTP)
memory (SRAM) consumption: about 1,5 KB
sketch size: about 20 KB

* send_mail.txt (15.45 KB - downloaded 31 times.)
Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

Czech Republic
Offline Offline
Sr. Member
****
Karma: 3
Posts: 311
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The figures below shows the scheme of electrical circuit as I currently use when debugging my program


click to enlarge


click to enlarge

It is working well, but only one I/O pin left unused. I have not tried SD card yet (so A0 and A1 are free too).
« Last Edit: July 31, 2013, 04:43:07 pm by K5CZ » Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

Offline Offline
Jr. Member
**
Karma: 4
Posts: 93
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


It is working well, but only one I/O pin left unused. I have not tried SD card yet (so A0 and A1 are free too).

While connected to internet the hardware RTC is superfluous, you can drop the RTC and use software RTC with NTP sync every hour.
Logged


Czech Republic
Offline Offline
Sr. Member
****
Karma: 3
Posts: 311
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

My first project is a bit closer to implementation, so this is way how I connected the RGB LED to Crib for Arduino. The LED can be disconnected or easy replaced.



* RGB_LED_attach.jpg (229.55 KB, 1024x1280 - viewed 47 times.)
Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

Czech Republic
Offline Offline
Sr. Member
****
Karma: 3
Posts: 311
Absolute Beginner, yet.
Newbie in Arduino
since May 2013
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A few days ago... putting into operation (description in czech language).
Logged

Arduino Uno R3, Arduino Mega 2560 R3, Ethermega (R3), and some Ethernet Shields (R3), Chronodots, TMP36 sensors, DS18B20 sensors, LCDs/TFTs, RS232C to learn and play...

Pages: 1 [2]   Go Up
Jump to: