Ardui’Home, temperature and gas alert for home

Updated [24/02]

I’ll move in a new apartment very soon, and i have the idea for a new domotic project, ArduiHome, a Arduino Uno, GSM/GPRS Shield, some sensors to measure temperature, humidity, and gas.

The goal of this project is to display, on a LCD, the temperature from four areas.
Sending back temperature and/or humidity value via SMS (no needed at this moment).
Send an alert when town gas or carbon monoxide reach a critical level.
Drive a relay to turn on lighting, or heating system (no needed at this moment).

- A ArduinoUno or Atmega328P.
- A GSM/GPRS Shield.
- 3x DS18S20 temperature sensor (1x bathroom, 1x sitting room, 1x outside).
- Humidity sensor to be defined, maybe DHT22 in two bedroom.
- Natural-LPG Gas sensor and Carbon Monoxide, (MQ5, MQ7).
- LCD 4×20, with I2C interface, to save I/O.

Right now i do some test with GSM/GPRS shield from ebay, GSMShiled

this shield is cheap , but appear only run with gsmlib libraries, from www.open-electronics.org.

Actually the code do:

- Read and display temps on a 2×16 LCD, from two temp sensor, i wait to receive my 4×20 LCD soon.
- Send SMS when the pin A0 read high value from MQ-5/MQ-7 gas sensor.
- Blink a LED to check if CPU run Ok.

 

 

To be implemented:

- Display temp and humidity from a DHT11 (2x Bedroom).
- Send temperature value from sensor’s via SMS.
- Check if letters come into the mailbox. Yeah, from postman.
- Drive a relay to turn on a light, or heating system.

!!! ANY HELP OR IMPROVEMENT ARE WELCOME !!! :)

Updated [24/02]

I have updated the code, i have just receive my 4×20 LCD screen, now i can display temperature from three DS18B20 sensor’s, alternately with DHT11 sensor (2x Bedroom). I have shorten the « too big » antenna of GSM shield :)


// ArduiHome Test code //

#include « SIM900.h »
#include « sms.h »
#include <OneWire.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#define ONE_WIRE_BUS 4 // DS18S20 wired to digital pin 4 – same bus for all sensor’s



LiquidCrystal_I2C lcd(0x20,20,4); // Liquide crystal is a 4x20 LCD with I2C support
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

DeviceAddress bathroom = { 0x10, 0x5E, 0xE8, 0x33, 0x02, 0x08, 0x00, 0xDB };   //Sensor 1
DeviceAddress room = { 0x10, 0xBE, 0xCA, 0x33, 0x02, 0x08, 0x00, 0x89 };       //Sensor 2
DeviceAddress ext = { 0x28, 0x75, 0x73, 0xBC, 0x05, 0x00, 0x00, 0xF8 };        //Sensor 3

unsigned int swt = 0;  // flip for alternate the display btw temp and humidity

#include "DHT.h"
#define DHTPIN0 A0      // sensor DHT room 1 connected to A0
#define DHTPIN1 A1      // sensor DHT room 2 connected to A1
#define DHTTYPE DHT11   // DHT 11 type

DHT dht_0(DHTPIN0, DHTTYPE);
DHT dht_1(DHTPIN1, DHTTYPE);

SMSGSM sms;

char number[]="XXXXXXXXXX";  // Destination number
char message[180];
char pos;
char *p;
///////////////Var and Int for GAS detection function/////////////////////
int value=0;
int value_old=0;
char gasmessage[45];
char value_str[4];
int pin=A3;

void setup()
{
lcd.init();                      // initialize the lcd
lcd.backlight();                // Backlight ON
lcd.setCursor(0, 1);
lcd.print("     Ardui'Home   ");
lcd.setCursor(0, 2);
lcd.print("     Loading...   ");
sensors.begin();

sensors.setResolution(bathroom, 10);
sensors.setResolution(room, 10);
sensors.setResolution(ext, 10);

value=analogRead(pin);
value_old=analogRead(pin);

dht_0.begin();                // Sensor DHT for room 1
dht_1.begin();               // Sensor DHT for room 2

Serial.begin(9600);
if (gsm.begin(2400))
Serial.println("\nstatus=READY");
else
Serial.println("\nstatus=IDLE");
(sms.SendSMS(number, "Starting ok !")); //sending sms when he starting up
pinMode(7, OUTPUT);                    // Pin 7 for bliking running led
}

void loop()
{
temps(); // calculate and displaying temps from DS18 and DHT sensor's
gas(); // For Gas sensing
runingled();   //loop to displaying a running LED
}

void gas()
{
value=analogRead(pin);
Serial.println(value); // For debug
if(value<50) //Gas value need to be defined
{
message[0]='\0';
while(3) // Try to send the SMS 3x in case of GSM network failure
{
sms.SendSMS(number,"!Alert! - !Gas level reached dangerous limit!"); // Dont forget to set  - char gasmessage[XX]; - if you change the message !
}
}
}

void temps()
{
sensors.requestTemperatures();
float tbathroom = sensors.getTempC(bathroom); // Bathroom sensor
float troom = sensors.getTempC(room); // Sitting room temp sensor
float text = sensors.getTempC(ext); // Outside sensor

swt++; // Alternate displaying betwen DS18 and DHT sensors
if ((swt % 15) > 5 )
{
//////////////DS18B20 Sensors/////////////////
lcd.setCursor(0, 0);
lcd.print("Sdb         ");
lcd.print(tbathroom);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print("Salon       ");
lcd.print(troom);
lcd.print(" C");
lcd.setCursor(0, 2);
lcd.print("Exterieur   ");
lcd.print(text);
lcd.print(" C");
lcd.setCursor(0, 3);
lcd.print("                    ");
} else {
////////////////DHT Sensors//////////////////
float h0 = dht_0.readHumidity();
float t0 = dht_0.readTemperature();

float h1 = dht_1.readHumidity();
float t1 = dht_1.readTemperature();

lcd.clear();
lcd.setCursor(0, 0);
lcd.clear();
lcd.print("Room 1   T: "); // Temperature
lcd.print(t0);
lcd.print(" C");
////////////////////////////////////////
lcd.setCursor(0, 1);
lcd.print("         H: "); // Humidity
lcd.print(h0);
lcd.print(" %");
////////////////////////////////////////
lcd.setCursor(0, 2);
lcd.print("Room 2   T: "); // Temperature
lcd.print(t1);
lcd.print(" C");
////////////////////////////////////////
lcd.setCursor(0, 3);
lcd.print("         H: "); // Humidity
lcd.print(h1);
lcd.print(" %");
}
}
/////////// Blink a Led to check if the code run correctly ///////////
void runingled()
{
digitalWrite(7, HIGH);
delay(80);
digitalWrite(7, LOW);
delay(1000);
}

Build a powerful accuracy power meter for some $$$

I have spend many many hours over Internet with the hope to found a simple but accuracy watt-meter, and i have finally stumbled on the… Trinity Virtual RF Power Meter.

I encourage everybody that looking for a powerful simple power-meter to build the Trinity RF meter, designed by Daniel from rfcandy.

Most important features:

  • Wide frequency range 10 MHz to 2.5 GHz.
  • Measure down to – 60 dBm (0.001 uW or 0.225mV)
  • Absolute and relative power measurement
  • Present measurement in dBm, Watt, Volt and Screen Gauge Meter
  • External Gauge Meter for accurate reading
  • Digital filtering to reject 50/60 Hz noise
  • Optical communication barrier to prevent noise
  • DC input blocking
  • No complex trimming
  • Self-test with LED indication

 

(To reduce the cost, if you don’t want to buy the full kit, you can order only the pcb and the preprogrammed PIC).

2013-11-05 20.35.532013-12-09 17.57.21 (Small)

Don’t buy shitty DDS Function Signal Generator Module Sine Square Sawtooth Triangle Wave from ebay …

Arfff…

2013-11-05 19.03.38I have recently buy from ebay a small board called « DDS Function Signal Generator Module Sine Square Sawtooth Triangle Wave « , first its not a DDS like you think … yes, the wave are produced by a Atmega16, and the signal is very dirty, there is no any output filter.

If you are looking for a true DDS generator, look here

Trackuino APRS Beacon, designed for vehicles.

I work right now on the Trackuino APRS Beacon, but especially a version for vehicles.  Trackuino is a APRS tracker based on Arduino. Is intended for use by licensed radio amateurs. « By operating on the standard APRS frequency, the signal can be picked up by an Internet gateway and reported on www.aprs.fi, so anyone with an Internet connection can track the beacon in live ». I’ll add two temperatures sensors for monitor indoor/outdoor temperatures.

A first idea of the system, the project is under prototyping.

 

Retro engineering on a pager, Tatoo Hack

This hack, backward me in 1996/1998 during my college years, the pager system was at its peak, there was 3 commercial services and networks here, in France:

  • TamTam, the Cegetel/SFR paging services, stopped in 1999, using ERMES protocol.
  • KOBBY, from Bouygue Telecom, stopped during 2005, using ERMES/FLEX protocol.
  • TATOO, from FT/Orange, using POCSAG, the only still functioning, right now, since 2000, exploited by a Deutsch company, E-Message.

The Kobby and TamTam use VHF frequency band (Update 18/03/14 – 169,425-169,800 Mhz), and the TATOO receiver use UHF band (466.025 MHz – 466.05 MHz – 466.075 MHz – 466.175 MHz – 466.20625 MHz – 466.23125 MHz.). POCSAG protocol is basically easy to decode, with software like POC32 or PDW

« POCSAG is an asynchronous protocol used to transmit data to pagers. The name comes from Post Office Code Standardization Advisory Group, this being the British Post Office which used to run nearly all telecommunications in Britain before privatization. The modulation used is FSK with a ±4.5 kHz shift on the carrier. The high frequency represents a 0 and the low frequency a 1. Often single transmission channels contain blocks of data at more than one of the rates. »  wikipedia

Bellow is a dessication of a MOTOROLA MEMO Pager Receiver (Tatoo, commercial name).

_tatoodissoc2

The pager is composed of two circuits,  a board with a displaying circuit for the lcd, a vibrator, a piezzo buzzer, a backup batterie for the RTC, and a MC68HC68 microcontroler, he probably contain the program to decode/translate the signal and pager ARP address.

_displaypart2

The another board is dedicated to RF reception, you can see a antenna, simple loop of metal, probably a narrow rf input filter, and a strange unidentified IC « 99Z32″, maybe a RF IC Receiver …

_rfpart

Now the goal is to identified the pin’s function on the connector. I have already put my Rigol probe on the Pin 4,  and i can see a low/high signal (see bellow). I’ll will try to translate this signal for PDW or POC32 software soon. Any help is welcome.

POCSAG_signal

 Update 26/04

I started to listening the signal (blue) from my UBC 785 on 466.20625 Mhz, in parallel with the signal from the pager (yellow), it seem to be a inverted signal.

NewFile1outfromscan_outfrompager

After feed the signal through a Max232, but no good result with the decoder software! *sic*, maybe need a little amplification before …

reforeafte

 

FM-Broacaster with Arduino and NS73

Few months ago, i have been looking for a robust easy FM broadcast solution, basically, i want simple solution, not the classic complex plan like > Stereo encoder = PLL = VCO = PA … < after some investigations i have found the NS73M FM Transmitter module from Niigata Seimitsu Co is a hight quality transmitter IC, can be controlled by a controller (via SPI/I2C), the features are:

87.5 – 108 Mhz Coverage
Stereo Modulation
Very Small package
I2C or SPI control
No tuning
Low Cost

The source of the project come from here and here

I have made 3 boards for this projects:
ArduiFM_Unit, its the main board with the NS73 and controller (Atmega328P)
BackConnector, the back board with input-sound, jack/RCA, and RS232 connector (future option for RDS)
Control_Cmd, is the front board with the button, up/down/backlight/set

The one of disadvantage have found is not RDS possibility because the sound is already modulated and mixed into the NS73, you cannot add signal.

fmbroadcast2

fmbroadcast1

right now, you can see the main µC board, LCD, audio connector, IHM board mounted, a DB9 connector is installed for a RDS future option. Now, the project need a power amplifier … stay tuned.

TeenLogger, a Teensy GPS Logger

The goal
In the past two years, i have released two version of GPS logger, with a lot of default like, poor autonomy, need to take off the sdcard to get the log, no function to upgrade the code easily, by the way, i have redesigned a new version with a lot of news feature, see bellow.

- Better autonomy.
- Be lightweight and portable.
- Be rechargeable easily.
- Got log directly from USB.
- Upgrade code via IDE Arduino through USB.
- Future options implemented for improvement.
- Many more …

teenlogger

teenlogger2

Hardware
- µC Section
The hardware run around a Teensy 2 this very small board run with a ATMEGA32U4 8bit AVR 16 MHz Processor, 25 I/O.

- GPS Section
The GPS NMEA sentences comes from a PA6B module, i choose this because he is very sensitive and small, better than EM406. The MTK Command Packet can be found here.

Issue encountered: On the first board prototyp i have mounted a PA6B without problem, when i powered up the pcb for the first time the GPS try to lock to satellite, in this case the 3d fix output should continuously output one-second high-level with one-second low-level signal, in theorical, regarding the data sheet, when the GPS is locked on the satellite, the output pin should continuously output low-level signal, but in my case, the output give me a high level signal, probably du to the firmware, so i decided to re-upgrade with the default factory firmware, the software, firmware, and guideline are available here. Be careful, the factory firmware set the baud rate to 9600bps, not 4800.

Batteries backup
To ensure fast hot start, the batteries pin is connected directly to the li-ion batt, the receiver has valid time, position, almanac, and ephemeris data, enabling a rapid acquisition of satellite signals.The voltage should be kept between 2.0V~4.3V. So, its OK.

- Power Section
The power come from a BlackBerry batteries (1100mha in this case), a charge pump, DC/DC converter (LT1302) give 5v/600ma from the 3,7v batt, available in SOIC-8 package, it’s a very powerful converter and can start as low as 2v. Two LP2981 give two separate 3,3v power line for the GPS and Teensy.

- Charging the Batt
Power charging is assumed via a LTC4054-4.2 a standalone Li-Ion Battery Charger with Thermal Regulation in ThinSOT package, the charging current is set with a simple resistor, i found 1,5k good value for around 1h30 of charge, the charge control is drive thought a N Channel MOSFET (2n7002) the signal come from the Teensy, just plug the USB cable and push the button to turn the PIN 17 High. Another option,  is play with a « usb_configured » variable inside Teensy’s USB code which indicates if the PC has configured the USB device. Accessing that variable is the best way to know if a PC is connected to Teensy. But its not implemented yet.

The code
Original code come from Adafruit, and it run on Teensy with some majors modification.

I  have removed unused libraries like avr/sleep.h, and GPSconfig.h header, the SoftwareSerial.h, NewSoftSerial.h libraries was replaced by <AltSoftSerial.h> for better performance. More informations are available in the commented sketch.

Loading the code

  • First, download and install Teensyduino software and libraries, complete instruction are here.
  • Download and unpack AltSoftSerial Library to /libraries directories.
  • Run Arduino 1.0 and load the code.
  • Select Teensy 2.0 in the tool menu.

Image3

  •  Select USB Type Disk SD Card + Keyboard

Image2

  • Finnaly, select CPU Speed to 8Mhz

Image3

Option
A « N Channel MOSFET » (2n7002) is connected to the Enable pin of GPS, in case of you need to drive the GPS. In normal operation keep Enable Pin floated or connected to Vcc.

Power saving method
Since is a embedded project, for better batteries life, we need to run with a maximum save of power, some good way:

- Run Teensy and GPS with 3,3v power supply.
- Lowering the clock speed at 8Mhz.
- Write GPS data only every 10 seconds, in hiking we no need very accuracy in fact.
- The data is stored only when the GPS give valid fix.
- Disabling the « Analog to Digital Converter ».

With this power measure, we can switch from 27.3 mA power consumption to only 10.6 mA
The total power of TeenLogger is around 45ma with GPS satellite tracking, and give around 15/17 hours of complete logging.

The data
The data is logged into a txt file, (GPSLOG0x.txt) you can easily convert this file directly into a KML format with, NMEA to KMZ file converter, or use gpsvisualizer.com and everytrail.com

Design
teenlogger

 

 

 

 

 

 

shem

 

teenlogger

Resources
Global Positioning System
NMEA sentence information

Teensy Board
Arduino Sketch

TeenLogger Shematic (PROTEUS File)
TeenLogger Layout (PROTEUS File)

GPS PA6B Datasheet
LT1302 Datasheet
LTC4054 Datasheet