Friday, December 13, 2013

More ideas for improvement

Change reporting criteria to capture temperature inflections, like when temp. starts declining after successive rises.

Monday, December 2, 2013

Some ideas for improvement

Now that we have a very satisfactory unit in terms of basic functionality, power, cost an reliability, it's time to add some functionality to make more home information available via SMS. This is the first of a number of posts aimed at keeping track of desirable improvements.

  • Add SD-card recording capability if Arduino memory will allow. Stack the SD shield I have now in NH.

  • Change to variable reporting period. More frequent if very cold, or hot outside. 

  • Add ability to change reporting period via SMS, from only some phone numbers.

  • Add ability to turn on or off bits, maybe connected to alternate thermostats so temps can be set remotely.


  • Add a/c electrical power monitoring and UPS backup. Since we are away a lot we need to know when power goes out so we can avoid food rotting in unpowered refrigerators. SInce the unit uses fairly low power a simple low-energy UPS could be used to keep it running while we measure a/c power using a small wall-wart and optical isolator and single digital input on Arduino.

  • Monitor furnace burner  and well pump operational cycles using a/c wiring taps of some sort. Acquire on off times over longer periods and report some sort of statistics, like total running time each day, average, min and max running times, and average time between cycles. Store info in EEPROM (1 kbyte max) to ride through possible power outages.

  • Keep temperature min/max/average for day.

Results of 1 week test run: best system yet!

We just got back from a trip over Thanksgiving during which I left the new monitor running. The latest version measures two temperatures using 10K NTC thermistors, reports them periodically via twitter, and responds to SMS messages it is sent by returning the two temperatures. SMS can be sent via email or cell phone, and will respond in either case via email or SMS depending on where the SMS came from.

Happily the unit performed flawlessly. I got twitter reports as expected and responses to SMS from my iPhone and emails. I had the unit set to tweet every 2 hours, or when the temperature changed more than 5 degrees F.

The unit is much less expensive, simpler, lower power and more reliable than either of my earlier Linux based approaches. The hardware cost is $39 for the SIM900 modem shield and $28.80 for the Arduino, plus $11.99 for the power adapter and $7.99 for the case. I built the 10K NTC temperature sensors my self at negligible cost.

Here's a screenshot of the order from http://store.linksprite.com/:



The SIM card is my old AT&T Gophone account SIM, for which I buy packages of 1000 SMS for $9.99/month. At 30 SMS/day hat is more than enough for experimenting. If I built another for the condo I could probably use the cheaper Arduino pro.

Bottom line is the unit cost total of about $89 for the (unpackaged) hardware and $9.99/month cell service. That's a lot lower monthly cost than a unit that requires an internet connection, at least for moderate data usage packages.

Interestingly, my cell phone SIM from Black Wireless, an AT&T distributor of pay as you go service, worked from the cruise ship, which provided cell service at sea for the same $0.05 per SMS and voice minute (although I did not try to make voice calls.)

Here's a twitter page:



Wednesday, November 13, 2013

Arduino Standard Library and Example Trees in Ubuntu

Example code is found in:   /usr/share/doc/arduino-core/examples

Official Library code is found in:     /usr/share/arduino/libraries

Libraries


/usr/share/arduino
├── arduinopc.jar
├── examples -> ../doc/arduino-core/examples
├── hardware
├── libraries
│   ├── EEPROM
│   │   ├── EEPROM.cpp
│   │   ├── EEPROM.h
│   │   ├── examples
│   │   │   ├── eeprom_clear
│   │   │   │   └── eeprom_clear.ino
│   │   │   ├── eeprom_read
│   │   │   │   └── eeprom_read.ino
│   │   │   └── eeprom_write
│   │   │       └── eeprom_write.ino
│   │   └── keywords.txt
│   ├── Esplora
│   │   ├── Esplora.cpp
│   │   ├── Esplora.h
│   │   ├── examples
│   │   │   ├── EsploraKart
│   │   │   │   └── EsploraKart.ino
│   │   │   ├── EsploraLedShow
│   │   │   │   └── EsploraLedShow.ino
│   │   │   ├── EsploraLedShow2
│   │   │   │   └── EsploraLedShow2.ino
│   │   │   ├── EsploraMusic
│   │   │   │   └── EsploraMusic.ino
│   │   │   ├── EsploraRemote
│   │   │   │   └── EsploraRemote.ino
│   │   │   └── EsploraTable
│   │   │       └── EsploraTable.ino
│   │   └── keywords.txt
│   ├── Ethernet
│   │   ├── Dhcp.cpp
│   │   ├── Dhcp.h
│   │   ├── Dns.cpp
│   │   ├── Dns.h
│   │   ├── EthernetClient.cpp
│   │   ├── EthernetClient.h
│   │   ├── Ethernet.cpp
│   │   ├── Ethernet.h
│   │   ├── EthernetServer.cpp
│   │   ├── EthernetServer.h
│   │   ├── EthernetUdp.cpp
│   │   ├── EthernetUdp.h
│   │   ├── examples
│   │   │   ├── BarometricPressureWebServer
│   │   │   │   └── BarometricPressureWebServer.ino
│   │   │   ├── ChatServer
│   │   │   │   └── ChatServer.ino
│   │   │   ├── DhcpAddressPrinter
│   │   │   │   └── DhcpAddressPrinter.ino
│   │   │   ├── DhcpChatServer
│   │   │   │   └── DhcpChatServer.ino
│   │   │   ├── DnsWebClient
│   │   │   │   └── DnsWebClient.ino
│   │   │   ├── PachubeClient
│   │   │   │   └── PachubeClient.ino
│   │   │   ├── PachubeClientString
│   │   │   │   └── PachubeClientString.ino
│   │   │   ├── TelnetClient
│   │   │   │   └── TelnetClient.ino
│   │   │   ├── TwitterClient
│   │   │   │   └── TwitterClient.ino
│   │   │   ├── UdpNtpClient
│   │   │   │   └── UdpNtpClient.ino
│   │   │   ├── UDPSendReceiveString
│   │   │   │   └── UDPSendReceiveString.ino
│   │   │   ├── WebClient
│   │   │   │   └── WebClient.ino
│   │   │   ├── WebClientRepeating
│   │   │   │   └── WebClientRepeating.ino
│   │   │   └── WebServer
│   │   │       └── WebServer.ino
│   │   ├── keywords.txt
│   │   ├── util.h
│   │   └── utility
│   │       ├── socket.cpp
│   │       ├── socket.h
│   │       ├── w5100.cpp
│   │       └── w5100.h
│   ├── Firmata
│   │   ├── Boards.h
│   │   ├── examples
│   │   │   ├── AllInputsFirmata
│   │   │   │   └── AllInputsFirmata.ino
│   │   │   ├── AnalogFirmata
│   │   │   │   └── AnalogFirmata.ino
│   │   │   ├── EchoString
│   │   │   │   └── EchoString.ino
│   │   │   ├── I2CFirmata
│   │   │   │   └── I2CFirmata.ino
│   │   │   ├── OldStandardFirmata
│   │   │   │   └── OldStandardFirmata.ino
│   │   │   ├── ServoFirmata
│   │   │   │   └── ServoFirmata.ino
│   │   │   ├── SimpleAnalogFirmata
│   │   │   │   └── SimpleAnalogFirmata.ino
│   │   │   ├── SimpleDigitalFirmata
│   │   │   │   └── SimpleDigitalFirmata.ino
│   │   │   └── StandardFirmata
│   │   │       └── StandardFirmata.ino
│   │   ├── Firmata.cpp
│   │   ├── Firmata.h
│   │   ├── keywords.txt
│   │   └── TODO.txt
│   ├── LiquidCrystal
│   │   ├── examples
│   │   │   ├── Autoscroll
│   │   │   │   └── Autoscroll.ino
│   │   │   ├── Blink
│   │   │   │   └── Blink.ino
│   │   │   ├── Cursor
│   │   │   │   └── Cursor.ino
│   │   │   ├── CustomCharacter
│   │   │   │   └── CustomCharacter.ino
│   │   │   ├── Display
│   │   │   │   └── Display.ino
│   │   │   ├── HelloWorld
│   │   │   │   └── HelloWorld.ino
│   │   │   ├── Scroll
│   │   │   │   └── Scroll.ino
│   │   │   ├── SerialDisplay
│   │   │   │   └── SerialDisplay.ino
│   │   │   ├── setCursor
│   │   │   │   └── setCursor.ino
│   │   │   └── TextDirection
│   │   │       └── TextDirection.ino
│   │   ├── keywords.txt
│   │   ├── LiquidCrystal.cpp
│   │   └── LiquidCrystal.h
│   ├── SD
│   │   ├── examples
│   │   │   ├── CardInfo
│   │   │   │   └── CardInfo.ino
│   │   │   ├── Datalogger
│   │   │   │   └── Datalogger.ino
│   │   │   ├── DumpFile
│   │   │   │   └── DumpFile.ino
│   │   │   ├── Files
│   │   │   │   └── Files.ino
│   │   │   ├── listfiles
│   │   │   │   └── listfiles.ino
│   │   │   └── ReadWrite
│   │   │       └── ReadWrite.ino
│   │   ├── File.cpp
│   │   ├── keywords.txt
│   │   ├── README.txt
│   │   ├── SD.cpp
│   │   ├── SD.h
│   │   └── utility
│   │       ├── FatStructs.h
│   │       ├── Sd2Card.cpp
│   │       ├── Sd2Card.h
│   │       ├── Sd2PinMap.h
│   │       ├── SdFat.h
│   │       ├── SdFatmainpage.h
│   │       ├── SdFatUtil.h
│   │       ├── SdFile.cpp
│   │       ├── SdInfo.h
│   │       └── SdVolume.cpp
│   ├── Servo
│   │   ├── examples
│   │   │   ├── Knob
│   │   │   │   └── Knob.ino
│   │   │   └── Sweep
│   │   │       └── Sweep.ino
│   │   ├── keywords.txt
│   │   ├── Servo.cpp
│   │   └── Servo.h
│   ├── SoftwareSerial
│   │   ├── examples
│   │   │   ├── SoftwareSerialExample
│   │   │   │   └── SoftwareSerialExample.ino
│   │   │   └── TwoPortReceive
│   │   │       └── TwoPortReceive.ino
│   │   ├── keywords.txt
│   │   ├── SoftwareSerial.cpp
│   │   └── SoftwareSerial.h
│   ├── SPI
│   │   ├── examples
│   │   │   ├── BarometricPressureSensor
│   │   │   │   ├── BarometricPressureSensor
│   │   │   │   │   └── BarometricPressureSensor.ino
│   │   │   │   └── BarometricPressureSensor.ino
│   │   │   └── DigitalPotControl
│   │   │       └── DigitalPotControl.ino
│   │   ├── keywords.txt
│   │   ├── SPI.cpp
│   │   └── SPI.h
│   ├── Stepper
│   │   ├── examples
│   │   │   ├── MotorKnob
│   │   │   │   └── MotorKnob.ino
│   │   │   ├── stepper_oneRevolution
│   │   │   │   └── stepper_oneRevolution.ino
│   │   │   ├── stepper_oneStepAtATime
│   │   │   │   └── stepper_oneStepAtATime.ino
│   │   │   └── stepper_speedControl
│   │   │       └── stepper_speedControl.ino
│   │   ├── keywords.txt
│   │   ├── Stepper.cpp
│   │   └── Stepper.h
│   ├── WiFi
│   │   ├── examples
│   │   │   ├── ConnectNoEncryption
│   │   │   │   └── ConnectNoEncryption.ino
│   │   │   ├── ConnectWithWEP
│   │   │   │   └── ConnectWithWEP.ino
│   │   │   ├── ConnectWithWPA
│   │   │   │   └── ConnectWithWPA.ino
│   │   │   ├── ScanNetworks
│   │   │   │   └── ScanNetworks.ino
│   │   │   ├── SimpleWebServerWiFi
│   │   │   │   └── SimpleWebServerWiFi.ino
│   │   │   ├── WifiChatServer
│   │   │   │   └── WifiChatServer.ino
│   │   │   ├── WifiPachubeClient
│   │   │   │   └── WifiPachubeClient.ino
│   │   │   ├── WifiPachubeClientString
│   │   │   │   └── WifiPachubeClientString.ino
│   │   │   ├── WifiTwitterClient
│   │   │   │   └── WifiTwitterClient.ino
│   │   │   ├── WifiWebClient
│   │   │   │   └── WifiWebClient.ino
│   │   │   ├── WifiWebClientRepeating
│   │   │   │   └── WifiWebClientRepeating.ino
│   │   │   └── WifiWebServer
│   │   │       └── WifiWebServer.ino
│   │   ├── keywords.txt
│   │   ├── utility
│   │   │   ├── debug.h
│   │   │   ├── server_drv.cpp
│   │   │   ├── server_drv.h
│   │   │   ├── socket.c
│   │   │   ├── socket.h
│   │   │   ├── spi_drv.cpp
│   │   │   ├── spi_drv.h
│   │   │   ├── wifi_drv.cpp
│   │   │   ├── wifi_drv.h
│   │   │   ├── wifi_spi.h
│   │   │   ├── wl_definitions.h
│   │   │   └── wl_types.h
│   │   ├── WiFiClient.cpp
│   │   ├── WiFiClient.h
│   │   ├── WiFi.cpp
│   │   ├── WiFi.h
│   │   ├── WiFiServer.cpp
│   │   └── WiFiServer.h
│   └── Wire
│       ├── examples
│       │   ├── digital_potentiometer
│       │   │   └── digital_potentiometer.ino
│       │   ├── master_reader
│       │   │   └── master_reader.ino
│       │   ├── master_writer
│       │   │   └── master_writer.ino
│       │   ├── SFRRanger_reader
│       │   │   └── SFRRanger_reader.ino
│       │   ├── slave_receiver
│       │   │   └── slave_receiver.ino
│       │   └── slave_sender
│       │       └── slave_sender.ino
│       ├── keywords.txt
│       ├── utility
│       │   ├── twi.c
│       │   └── twi.h
│       ├── Wire.cpp
│       └── Wire.h
├── reference -> ../doc/arduino-core/reference
└── tools
    ├── howto.txt
    └── Mangler
        └── src
            └── Mangler.java

141 directories, 325 files



Examples



/usr/share/doc/arduino-core/examples
├── 01.Basics
│   ├── AnalogReadSerial
│   │   └── AnalogReadSerial.ino
│   ├── BareMinimum
│   │   └── BareMinimum.ino
│   ├── Blink
│   │   └── Blink.ino
│   ├── DigitalReadSerial
│   │   └── DigitalReadSerial.ino
│   ├── Fade
│   │   └── Fade.ino
│   └── ReadAnalogVoltage
│       └── ReadAnalogVoltage.ino
├── 02.Digital
│   ├── BlinkWithoutDelay
│   │   └── BlinkWithoutDelay.ino
│   ├── Button
│   │   └── Button.ino
│   ├── Debounce
│   │   └── Debounce.ino
│   ├── DigitalIputPullup
│   │   └── DigitalIputPullup.ino
│   ├── StateChangeDetection
│   │   └── StateChangeDetection.ino
│   ├── toneKeyboard
│   │   ├── pitches.h
│   │   └── toneKeyboard.ino
│   ├── toneMelody
│   │   ├── pitches.h
│   │   └── toneMelody.ino
│   ├── toneMultiple
│   │   ├── pitches.h
│   │   └── toneMultiple.ino
│   └── tonePitchFollower
│       └── tonePitchFollower.ino
├── 03.Analog
│   ├── AnalogInOutSerial
│   │   └── AnalogInOutSerial.ino
│   ├── AnalogInput
│   │   └── AnalogInput.ino
│   ├── AnalogWriteMega
│   │   └── AnalogWriteMega.ino
│   ├── Calibration
│   │   └── Calibration.ino
│   ├── Fading
│   │   └── Fading.ino
│   └── Smoothing
│       └── Smoothing.ino
├── 04.Communication
│   ├── ASCIITable
│   │   └── ASCIITable.ino
│   ├── Dimmer
│   │   └── Dimmer.ino
│   ├── Graph
│   │   └── Graph.ino
│   ├── MIDI
│   │   └── Midi.ino
│   ├── MultiSerialMega
│   │   └── MultiSerialMega.ino
│   ├── PhysicalPixel
│   │   └── PhysicalPixel.ino
│   ├── ReadASCIIString
│   │   └── ReadASCIIString.ino
│   ├── SerialCallResponse
│   │   └── SerialCallResponse.ino
│   ├── SerialCallResponseASCII
│   │   └── SerialCallResponseASCII.ino
│   ├── SerialEvent
│   │   └── SerialEvent.ino
│   └── VirtualColorMixer
│       └── VirtualColorMixer.ino
├── 05.Control
│   ├── Arrays
│   │   └── Arrays.ino
│   ├── ForLoopIteration
│   │   └── ForLoopIteration.ino
│   ├── IfStatementConditional
│   │   └── IfStatementConditional.ino
│   ├── switchCase
│   │   └── switchCase.ino
│   ├── switchCase2
│   │   └── switchCase2.ino
│   └── WhileStatementConditional
│       └── WhileStatementConditional.ino
├── 06.Sensors
│   ├── ADXL3xx
│   │   └── ADXL3xx.ino
│   ├── Knock
│   │   └── Knock.ino
│   ├── Memsic2125
│   │   └── Memsic2125.ino
│   └── Ping
│       └── Ping.ino
├── 07.Display
│   ├── barGraph
│   │   └── barGraph.ino
│   └── RowColumnScanning
│       └── RowColumnScanning.ino
├── 08.Strings
│   ├── CharacterAnalysis
│   │   └── CharacterAnalysis.ino
│   ├── StringAdditionOperator
│   │   └── StringAdditionOperator.ino
│   ├── StringAppendOperator
│   │   └── StringAppendOperator.ino
│   ├── StringCaseChanges
│   │   └── StringCaseChanges.ino
│   ├── StringCharacters
│   │   └── StringCharacters.ino
│   ├── StringComparisonOperators
│   │   └── StringComparisonOperators.ino
│   ├── StringConstructors
│   │   └── StringConstructors.ino
│   ├── StringIndexOf
│   │   └── StringIndexOf.ino
│   ├── StringLength
│   │   └── StringLength.ino
│   ├── StringLengthTrim
│   │   └── StringLengthTrim.ino
│   ├── StringReplace
│   │   └── StringReplace.ino
│   ├── StringStartsWithEndsWith
│   │   └── StringStartsWithEndsWith.ino
│   ├── StringSubstring
│   │   └── StringSubstring.ino
│   ├── StringToInt
│   │   └── StringToInt.ino
│   └── StringToIntRGB
│       └── StringToIntRGB.ino
├── 09.USB
│   ├── Keyboard
│   │   ├── KeyboardLogout
│   │   │   └── KeyboardLogout.ino
│   │   ├── KeyboardMessage
│   │   │   └── KeyboardMessage.ino
│   │   ├── KeyboardReprogram
│   │   │   └── KeyboardReprogram.ino
│   │   └── KeyboardSerial
│   │       └── KeyboardSerial.ino
│   ├── KeyboardAndMouseControl
│   │   └── KeyboardAndMouseControl.ino
│   └── Mouse
│       ├── ButtonMouseControl
│       │   └── ButtonMouseControl.ino
│       └── JoystickMouseControl
│           └── JoystickMouseControl.ino
├── 10.StarterKit
│   ├── p02_SpaceshipInterface
│   │   └── p02_SpaceshipInterface.ino
│   ├── p03_LoveOMeter
│   │   └── p03_LoveOMeter.ino
│   ├── p04_ColorMixingLamp
│   │   └── p04_ColorMixingLamp.ino
│   ├── p05_ServoMoodIndicator
│   │   └── p05_ServoMoodIndicator.ino
│   ├── p06_LightTheremin
│   │   └── p06_LightTheremin.ino
│   ├── p07_Keyboard
│   │   └── p07_Keyboard.ino
│   ├── p08_DigitalHourglass
│   │   └── p08_DigitalHourglass.ino
│   ├── p09_MotorizedPinwheel
│   │   └── p09_MotorizedPinwheel.ino
│   ├── p10_Zoetrope
│   │   └── p10_Zoetrope.ino
│   ├── p11_CrystalBall
│   │   └── p11_CrystalBall.ino
│   ├── p12_KnockLock
│   │   └── p12_KnockLock.ino
│   ├── p13_TouchSensorLamp
│   │   └── p13_TouchSensorLamp.ino
│   ├── p14_TweakTheArduinoLogo
│   │   └── p14_TweakTheArduinoLogo.ino
│   └── p15_HackingButtons
│       └── p15_HackingButtons.ino
└── ArduinoISP
    └── ArduinoISP.ino

93 directories, 84 files

Monday, November 4, 2013

First Things

I wanted a simpler, lower powered monitor so I am investigating using an Arduino Uno with a Linksprite SIM900-based GPRS card. My appreciation to http://tronixstuff.com/tutorials/ for the core code example used in this post.

I have an initial trial setup working and able to send and receive text messages and call my cell phone using the GoPhone sim card (443 379-XXXX) I have been using in my USB modem with the Beaglebone Linux card. I did not need to change the sim card account to do this.

This (a simple hack, admittedly) sketch sends text messages to my iPhone:

// Send text to iphone via Linksprite SIM900 arduino shield
// Works 11/4/2013

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);

void setup()
{
  SIM900.begin(19200);
  SIM900power();  
  delay(20000);  // give time to log on to network. 
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
}

void sendSMS(char *textmsg)
{
  SIM900.print("AT+CMGF=1\r");                                                        // AT command to send SMS message
  delay(100);
  SIM900.println("AT + CMGS = \"+1410XXXXXXX\"");                                     // recipient's mobile number, in international format
  delay(100);
  SIM900.println(textmsg);        // message to send
  delay(100);
  SIM900.println((char)26);       // End AT command with a ^Z, ASCII code 26
  delay(100); 
  SIM900.println();
  delay(5000);                    // give module time to send SMS
}

void loop()
{
  sendSMS("Message 1");
  delay(10000);
  sendSMS("Message 2");
  SIM900power();                  // turn off module
  do {} while (1);
}