Home sensor project ( temp, humidity, CO etc) help

Hi,

As a first project of some importance, I decided to combine several sensors into one project for the home

  • DHT22 for indoor temp/ humidity
  • DHT22 (or adequate alternative) for outdoor temp/ humidity
  • Atmospheric pressure
  • Time /date
  • MQ7 CO sensor
  • MQ2 smoke sensor

Features of the project

  • Display temp/humidity indoor /outdoor
  • Display pressure
  • Display CO values (approx)
  • Alarm on high CO (following guidelines from gov.). Using active buzzer (not in diagram yet)
  • Display date and time
  • Store any run values/settings in EEPROM (or perhaps flash card)
  • Store historical data on flash card of sensor values at frequency T.B.D.
  • Options to see min/max temp/ humidity for the day
  • Options to see min/max temp/humidity for past few days reading from memory or flash card (T.B.D.)
  • Options to see min/max temp humidity since last 'reset'
  • buttons (3 or 4) to navigate options
  • setup menus for date /time and other settings. (later?)
  • powered by wall wart, as MQ7 is relatively power hungry.

I included the schematic, here are some comments

  • The LCD, RTC, Barometer, EEPROM are I2C connected
  • SD card is SPI
  • DHT is using digital pins
  • MQ7 is using 2 digital pins + 1 analog for reading. This one is annoying, as the datasheets say power heater at 5v for 60s, then at 1.4V for 90 seconds. I used a N channel mosfet to turn it on, and a P mosfet to swith between 1.4V and 5V on the heater.
  • MQ2 is simpler, 1 N mosfet to turn the heater on, 1 analog for readout.
  • All the components I have tested or used, except for the MQ7, MQ2.
  • If I run out of digital pins, I will use a shift register or an i2c I/O extender.

Can you comment on the project itself?

Would you look at the schematic? it is a first draft and I am sure there are mistakes, and being new to electronics, there might be conceptual mistakes as well.

Best wishes.

5V I2C bus or 3.3V I2C bus ?
You can't connect 3.3V devices to a 5V I2C bus.
Since the 4k7 pullup resistors are connected tot the 5V, you have a 5V I2C bus.

SD card SPI 3.3V
You connect the 5V signals of the Arduino to the 3.3V SPI for the SD card.
The signals (at least the output signals of the Arduino) should be 3.3V.

Modular
You might want to add sensors later on.
Have you thought a making it more modular ?
With a I2C connector, so you can add modules.

MQ sensors A2, B2 pins
It is preferred that A1 is connected ot A2 and B1 to B2.

MQ-7 at 1.4V
The 1.4V can be created with a PWM signal.
You can use Q1 for on/off and for PWM.
So you don't need IC2 or Q3.

Sensors or sensor modules/boards ?
Do you want to use the sensors itself, or sensor modules ?
The sensor modules are very cheap on Ebay.

Buttons
I don't see any buttons.
There are cursor buttons in an array. And there is a library for that (I forgot the name).

Extras
You still have 5 unused pins. There are many things you can do with 5 pins.

What if you decide to show the values on a tablet or phone ?
With an Arduino Mega + Ethernet Shield, there are more possibilities.
The microSD card is already on the Ethernet Shield.
And it is possible to use www.ThingSpeak.com to upload the data.

Erdin:
5V I2C bus or 3.3V I2C bus ?
You can't connect 3.3V devices to a 5V I2C bus.
Since the 4k7 pullup resistors are connected tot the 5V, you have a 5V I2C bus.

Yes I have a 5v bus. I have logic level converters if I need to talk 3.3V on the i2c bus

Erdin:
SD card SPI 3.3V
You connect the 5V signals of the Arduino to the 3.3V SPI for the SD card.
The signals (at least the output signals of the Arduino) should be 3.3V.

I learned that the hard way when I tried a cheap EBAY sd card reader. I will use the level shifter chips (not in diagram) or use an ethernet shield

Erdin:
Modular
You might want to add sensors later on.
Have you thought a making it more modular ?
With a I2C connector, so you can add modules.

Very good idea, thanks, I can even take it one step further and have the program auto-scan the bus :slight_smile:

Erdin:
MQ sensors A2, B2 pins
It is preferred that A1 is connected ot A2 and B1 to B2.

Noted thanks.

Erdin:
MQ-7 at 1.4V
The 1.4V can be created with a PWM signal.
You can use Q1 for on/off and for PWM.
So you don't need IC2 or Q3.

Good idea, more elegant. I will do that.
For my own information: Assuming I was not able to use PWM, would the circuit I made for it be appropriate? Would it be the right way to do it?

Erdin:
Sensors or sensor modules/boards ?
Do you want to use the sensors itself, or sensor modules ?
The sensor modules are very cheap on Ebay.

The DHT sensors are stand alone, the EEPROM chip as well. The barometer, RTC, MQ2, MQ7 are modules.
I bought most of my sensors and generic components on ebay. A lot of components (mosfets, I/Cs, sockets, a good multimeter some tools) I also bought at digikey.

Erdin:
Buttons
I don't see any buttons.
There are cursor buttons in an array. And there is a library for that (I forgot the name).

I did not put the buttons in yet, Sorry :slight_smile:
I will check on the array of cursor buttons. Can be practical for navigation.
Is there code out there for a menu system for arduino? I don;t want to re-invent the wheel.

Erdin:
Extras
You still have 5 unused pins. There are many things you can do with 5 pins.

What if you decide to show the values on a tablet or phone ?
With an Arduino Mega + Ethernet Shield, there are more possibilities.
The microSD card is already on the Ethernet Shield.
And it is possible to use www.ThingSpeak.com to upload the data.

Humm, I already noticed that if I add the ethernet AND the sd card module (on the ethernet shield), the program size gets WAY bigger so the 32k in the UNO (328p) might be too small for both. This is where the mega would come in? What do you mean by more possibilities aside from the memory?

Thanks a bunch for taking the time to answer!

With 'possibilities' I mean sites like: www.ThingSpeak.com but also requesting a time service NTP. ThingSpeak is able to send a message to Twitter.

NTP : http://arduino.cc/en/Tutorial/UdpNTPClient

I found the name for the matrix keys: Keypad library
http://playground.arduino.cc/Main/KeypadTutorial

Why would the circuit not be right for PWM for the MQ-7 ?
The Arduino PWM frequency is about 500Hz. The heater inside the sensor is slow, so that is no problem. Perhaps some 500Hz noise will be introduced in the analog output. Using the average of a number of values should fix that.

There are menu libraries. I use webpages, so I don't use menus. Perhaps you could request that in a new topic "what menus for lcd are out there?" or something like that. Or if you see a project (also check www.hackaday.com ) you like, try to find in the source the menu library that is used.

The Arduino Mega 2560 is needed very quickly when using Ethernet and the SD library. I still have to be carefull with ram, but the code size can be up to 256kbyte, which is a lot.
http://arduino.cc/en/Main/arduinoBoardMega2560

Erdin:
Why would the circuit not be right for PWM for the MQ-7 ?
The Arduino PWM frequency is about 500Hz. The heater inside the sensor is slow, so that is no problem. Perhaps some 500Hz noise will be introduced in the analog output. Using the average of a number of values should fix that.

Sorry for the misunderstanding: I agree with you 100% I realize that pwm at the proper level for the heater inside the sensor would be exactly the same as a straight 1.4v. The PWM solution is better. I just meant, if it was not for PWM, would the circuit be adequate and designed properly?

I realize now, after testing ethernet and SD libraries, that I was at 28k/32k or so, coming very close already. So if I add the other libraries on top, the 328P is not enough. Either I drop SD & ethernet, perhaps just ethernet or I get a mega.

Is serving webpages on the mega generally acceptable? I mean in this case I could serve historical data and status pages...

Thanks.

DroidDr:
I just meant, if it was not for PWM, would the circuit be adequate and designed properly?

I have my doubts.
The BSS110 is not a 'logic level' mosfet, I think.
The diode decreases the accuracy of the 1.4V. And it is essential that the 1.4V is the same every time.

The n-channel mosfets are also not 'logic level' mosfets. Please use 'logic level' mosfets.

DroidDr:
Is serving webpages on the mega generally acceptable? I mean in this case I could serve historical data and status pages...

The speed is the same for the Uno and the Mega.

It is slow. During building the webpage, I collect the data via I2C. That makes the webpage load even slower. It takes a little more than 1 second (collecting all sorts of data and about 10 data values via I2C).
But since I use only text and a table with colored cells, it is no problem at all.

Reading from the SD card is even slower. A picture for the webpage from the SD card is about 4kbyte/s. With a buffer to write more at once, it can be between 12 and 16 kbyte/s.

You could use and HTML5.
http://www.worldwidewhat.net/2011/06/draw-a-line-graph-using-html5-canvas/
With canvas you could request only the data from the Arduino for an live update, and not the entire page.

Well, it shows I did the schematic in a hurry, the mosfets I have here are logic level (not the ones in the drawing). I just started to learn Eagle and did the schematic quickly.

Thanks for the insights, that was very kind of you and instrucional.