As we become more environmentally aware of our surroundings we require more information about it. This series of shields which plugs right onto the Arduino with Arduino compatible pins is capable of sensing a whole bunch of environmental variables including a Digital Gas sensor which measures CO2 and VOC's an Altimeter which measures Barometric Pressure and Altitude, a one wire Temperature Sensor DS18B20 (Non I2C), a Temperature Humidity Sensor and last but not least a Voltage Current sensor which is capable of sensing Input power or using a clip on Current meter you can sense your house power usage.. All this on one small board to see what's happening real time or go on line and watch your house while your away. In addition we will be adding motion sensors and 120 Volts power supply module to power the whole unit with one plug and activate a relay upon motion or by an application.
This project consists of multiple parts:
I build my boards with the fritzing program http://www.fritzing.com and I order them from pcbway out of china. http://www.pcbway.com they are low cost $1.00 per board and are of high quality.
1. Sensors and Board Design
1a. Sensor Board
1b. Relay Board
1c. 120 Volt Power Board with power relay
2. Soldering UpYour Board
3. DF Robot Wifi Module
4. Programming Your Arduino
5. Programming Your Raspberry Pi 3
6. Box Design and Build
7. Putting it all together
1a. Sensor Board and Board DesignIt can be purchased Here zing www.fritzing.com, I will include the Fritzing file for editing and your enjoyment..
The Board's Sensors
CCS811
The CCS811 is an ultra-low power digital gas sensor solution which integrates a metal oxide (MOX) gas sensor to detect a wide range of Volatile Organic Compounds (VOCs) for indoor air quality monitoring with a microcontroller unit (MCU), which includes an Analog-to-Digital converter (ADC), and an I²C interface. CCS811 is based on ams unique micro-hotplate technology which enables a highly reliable solution for gas sensors, very fast cycle times and a significant reduction in average power consumption. The integrated MCU manages the sensor driver modes and measurements. The I²C digital interface significantly simplifies the hardware and software design, enabling a faster time to market. CCS811 supports intelligent algorithms to process raw sensor measurements to output a TVOC value or equivalent CO2 (eCO2) levels, where the main cause of VOCs is from humans. CCS811 supports multiple measurement modes that have been optimized for low-power consumption during an active sensor measurement and idle mode extending battery life in portable applications. CCS811 is available in a 10 lead 2.7mm x 4.0mm x 1.1mm, 0.6mm pitch LGA package.
DS18B20
https://www.mouser.mx/datasheet/2/256/DS18B20-370043.pdf
The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. In addition, the DS18B20 can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply. Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area. Applications that can benefit from this feature include HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or machinery, and process monitoring and control systems.
Si7021 I2C
https://www.mouser.mx/datasheet/2/368/Si7021-A20-707879.pdf
The Si7021 I2C Humidity and Temperature Sensor is a monolithic CMOS IC integrating humidity and temperature sensor elements, an analog-to-digital converter, signal processing, calibration data, and an I2C Interface. The patented use of industry-standard, low-K polymeric dielectrics for sensing humidity enables the construction of low-power, monolithic CMOS Sensor ICs with low drift and hysteresis, and excellent long term stability. The humidity and temperature sensors are factory-calibrated and the calibration data is stored in the on-chip non-volatile memory. This ensures that the sensors are fully interchangeable, with no recalibration or software changes required. The Si7021 is available in a 3x3 mm DFN package and is reflow solderable. It can be used as a hardware- and software-compatible drop-in upgrade for existing RH/ temperature sensors in 3x3 mm DFN-6 packages, featuring precision sensing over a wider range and lower power consumption. The optional factory-installed cover offers a low profile, convenient means of protecting the sensor during assembly (e.g., reflow soldering) and throughout the life of the product, excluding liquids (hydrophobic/oleophobic) and particulates. The Si7021 offers an accurate, low-power, factory-calibrated digital solution ideal for measuring humidity, dew-point, and temperature, in applications ranging from HVAC/R and asset tracking to industrial and consumer platforms.
LTC®2945
The LTC®2945 is a rail-to-rail system monitor that measures current, voltage, and power. It features an operating range of 2.7V to 80V and includes a shunt regulator for supplies above 80V to allow flexibility in the selection of input supply. The current measurement range of 0V to 80V is independent of the input supply. An onboard 0.75% accurate 12-bit ADC measures load current, input voltage and an auxiliary external voltage. A 24-bit power value is generated by digitally multiplying the measured 12-bit load current and input voltage data. Minimum and maximum values are stored and an overrange alert with programmable thresholds minimizes the need for software polling. Data is reported via a standard I2C interface. Shutdown mode reduces power consumption to 20µA. The LTC2945 I2C interface includes separate data input and output pins for use with standard or opto-isolated I2C connections. The LTC2945-1 has an inverted data output for use with inverting opto-isolator configurations.
MPL3115A2
The MPL3115A2 is a compact, piezoresistive, absolute pressure sensor with an I2C digital interface. MPL3115A2 has a wide operating range of 20 kPa to 110 kPa, a range that covers all surface elevations on earth. The MEMS is temperature compensated utilizing an on-chip temperature sensor. The pressure and temperature data is fed into a high resolution ADC to provide fully compensated and digitized outputs for pressure in Pascals and temperature in °C. The compensated pressure output can then be converted to altitude, utilizing the formula stated in Section 9.1.3 "Pressure/altitude" provided in meters.The internal processing in MPL3115A2 removes compensation and unit conversion load from the system MCU, simplifying system design. MPL3115A2's advanced ASIC has multiple user programmable modes such as power saving, interrupt and autonomous data acquisition modes, including programmed acquisition cycle timing, and poll-only modes. Typical active supply current is 40 μA per measurement-second for a stable 10 cm output resolution.
Bill of Materials and Where to Buy
you can purchase the needed materials from either mouser.com or digkey.com the Bill of Materials is below
********NOTE ****** Please pay attention to what voltage regulator you are buying..see below
The images below are of the Arduino shield. I've added a higher amperage and higher voltage regulator. The first voltage regulator is good for 300mA maximum 18 volts DC and the second is good for 1.5 Amps and 30VDC which is more in line with powering off of a larger 24 volt solar array.
1c. 120 Volt Power Board with power relay
It can be purchased Here https://www.mouser.mx/ProductDetail/709-MPM-15-24
Tip #1 when soldering..SolderyourSMDpartsFirst
* when using solder as opposed to solder paste solder 1 pad place your part heat the solder and let cool before moving your tweezers
* when cooled solder the other side optimum temp for this process is 300 degrees
Tip#2 Buy some low temp solder paste (Link Below)for the power chip and deposit 2 thin lines across the pads. *See pictures put the Board in a small oven at 350 degrees until you see the paste turn to solder..Remove and check board before it cools. Keep an eye on the process
Tip#3 Buy some de-soldering Wick for cleaning up the reflow overflow which will happen.(Link Below)
Tip#4 I use a Toaster Oven for the reflow process see below..
Watch very carefully put the Board in Cold and turn on broil..Wait till reflow process does its thing when the paste turns to solder … wait 20 seconds then let cool.
Tip 5# Clean up extra solder
LINKS
DesolderingWick
DE Reflow Paste
3.DF Robot WiFi Module
Introduction
Wido is an Arduino compatible WIFI IoT Node development board, which integrates with WG1300 WIFI solution. The microcontroller of Wido is ATMEL ATmega32U4.
Specification- Power Supply range: 5v or 7-12v
- Arduino Leonardo Compatible
- Integrate with WG1300 WIFI chip and support 2.4GHz IEEE 802.11 b/g network
- WiFi and MicroSD driven by SPI port
- On board 2.4G PCB Antenna
- Driver pins:
- WIFI Module-D7(IRQ), D5(VBAT), D10(CS), D14(MISO), D15(SCK), D16(MOSI)
- MicroSD-D4(CS), D14(MISO), D15(SCK), D16(MOSI)
Programming Your Arduino for the WiFi Shield
https://www.dfrobot.com/wiki/index.php/Wido-WIFI_IoT_Node_SKU:DFR0321
Download this File
Unzip..Navigate through the folder and Zip the Adafruit_CC3000_Master Folder inside
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"
// These are the interrupt and control pins
#define ADAFRUIT_CC3000_IRQ 7 // MUST be an interrupt pin!
// These can be any two pins
#define ADAFRUIT_CC3000_VBAT 5
#define ADAFRUIT_CC3000_CS 10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIVIDER); // you can change this clock speed
#define WLAN_SSID "myNetwork" // cannot be longer than 32 characters!
#define WLAN_PASS "myPassword" // Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY WLAN_SEC_WPA2
#define IDLE_TIMEOUT_MS 3000 // Amount of time to wait (in milliseconds) with no data
// received before closing the connection. If you know the server
// you're accessing is quick to respond, you can reduce this value.
// What page to grab!
#define WEBSITE "www.adafruit.com"
#define WEBPAGE "/testwifi/index.html"
/**************************************************************************/
/*!
@brief Sets up the HW and the CC3000 module (called automatically
on startup)
*/
/**************************************************************************/
uint32_t ip;
void setup(void)
{
Serial.begin(115200);
Serial.println(F("Hello, CC3000!\n"));
Serial.print("Free RAM: "); Serial.println(getFreeRam(), DEC);
/* Initialise the module */
Serial.println(F("\nInitializing..."));
if (!cc3000.begin())
{
Serial.println(F("Couldn't begin()! Check your wiring?"));
while(1);
}
// Optional SSID scan
// listSSIDResults();
Serial.print(F("\nAttempting to connect to ")); Serial.println(WLAN_SSID);
if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
Serial.println(F("Failed!"));
while(1);
}
Serial.println(F("Connected!"));
/* Wait for DHCP to complete */
Serial.println(F("Request DHCP"));
while (!cc3000.checkDHCP())
{
delay(100); // ToDo: Insert a DHCP timeout!
}
/* Display the IP address DNS, Gateway, etc. */
while (! displayConnectionDetails()) {
delay(1000);
}
ip = 0;
// Try looking up the website's IP address
Serial.print(WEBSITE); Serial.print(F(" -> "));
while (ip == 0) {
if (! cc3000.getHostByName(WEBSITE, &ip)) {
Serial.println(F("Couldn't resolve!"));
}
delay(500);
}
cc3000.printIPdotsRev(ip);
// Optional: Do a ping test on the website
/*
Serial.print(F("\n\rPinging ")); cc3000.printIPdotsRev(ip); Serial.print("...");
replies = cc3000.ping(ip, 5);
Serial.print(replies); Serial.println(F(" replies"));
*/
/* Try connecting to the website.
Note: HTTP/1.1 protocol is used to keep the server from closing the connection before all data is read.
*/
Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 80);
if (www.connected()) {
www.fastrprint(F("GET "));
www.fastrprint(WEBPAGE);
www.fastrprint(F(" HTTP/1.1\r\n"));
www.fastrprint(F("Host: ")); www.fastrprint(WEBSITE); www.fastrprint(F("\r\n"));
www.fastrprint(F("\r\n"));
www.println();
} else {
Serial.println(F("Connection failed"));
return;
}
Serial.println(F("-------------------------------------"));
/* Read data until either the connection is closed, or the idle timeout is reached. */
unsigned long lastRead = millis();
while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
while (www.available()) {
char c = www.read();
Serial.print(c);
lastRead = millis();
}
}
www.close();
Serial.println(F("-------------------------------------"));
/* You need to make sure to clean up after yourself or the CC3000 can freak out */
/* the next time your try to connect ... */
Serial.println(F("\n\nDisconnecting"));
cc3000.disconnect();
}
void loop(void)
{
delay(1000);
}
/**************************************************************************/
/*!
@brief Begins an SSID scan and prints out all the visible networks
*/
/**************************************************************************/
void listSSIDResults(void)
{
uint8_t valid, rssi, sec, index;
char ssidname[33];
index = cc3000.startSSIDscan();
Serial.print(F("Networks found: ")); Serial.println(index);
Serial.println(F("================================================"));
while (index) {
index--;
valid = cc3000.getNextSSID(&rssi, &sec, ssidname);
Serial.print(F("SSID Name : ")); Serial.print(ssidname);
Serial.println();
Serial.print(F("RSSI : "));
Serial.println(rssi);
Serial.print(F("Security Mode: "));
Serial.println(sec);
Serial.println();
}
Serial.println(F("================================================"));
cc3000.stopSSIDscan();
}
/**************************************************************************/
/*!
@brief Tries to read the IP address and other connection details
*/
/**************************************************************************/
bool displayConnectionDetails(void)
{
uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
{
Serial.println(F("Unable to retrieve the IP Address!\r\n"));
return false;
}
else
{
Serial.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
Serial.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
Serial.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
Serial.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
Serial.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
Serial.println();
return true;
}
}
FOLLOW THE ABOVE INSTRUCTIONS
Programming Your Arduino
In Conjunction with getting your WiFi Shield on line you need to program in your I2C sensors with the below Code..This will provide you with confirmation that your sensors are working via serial output.
//Go to Github.com and download the necessary .h files
#include <OneWire.h>
#include <DS18B20.h>
#include <Wire.h>
#include <CCS811.h>
#include "MPL3115A2.h"
//===================================Power Sensor
#define LTCADDR 0x69
byte ADCvinMSB, ADCvinLSB, curSenseMSB, curSenseLSB, AinVMSB, AinVLSB;
unsigned int ADCvin, ADCcur, AinV;
float inputVoltage, ADCvoltage, current10, current1, current0p1, current0p01;
//==================================Temperature Sensor
DS18B20 ds(7);
//==================================Air Quality Sensor
#define ADDR 0x66
#define WAKE_PIN 4
CCS811 sensor;
//===================================Pressure Sensor
MPL3115A2 myPressure;
#define relay 5
void setup() {
Serial.begin(9600);
Wire.begin();
Serial.print("Devices: ");
Serial.println(ds.getNumberOfDevices());
if (!sensor.begin(uint8_t(ADDR), uint8_t(WAKE_PIN)))
Serial.println("Initialization failed.");
myPressure.begin(); // Get sensor online
pinMode(5,OUTPUT);
myPressure.setModeAltimeter(); // Measure altitude above sea level in meters
myPressure.setOversampleRate(7); // Set Oversample to the recommended 128
myPressure.enableEventFlags(); // Enable all three pressure and temp event flags
}
void loop() {
digitalWrite(relay,HIGH);
delay(1000);
digitalWrite(relay,LOW);
delay(1000);
Wire.beginTransmission(LTCADDR);//first get Input Voltage - 80V max
Wire.write(0x1E);
Wire.endTransmission(false);
Wire.requestFrom(LTCADDR, 2, true);
delay(1);
ADCvinMSB = Wire.read();
ADCvinLSB = Wire.read();
ADCvin = ((unsigned int)(ADCvinMSB) << 4) + ((ADCvinLSB >> 4) & 0x0F);//formats into 12bit integer
inputVoltage = ADCvin * 0.025; //25mV resolution
Wire.beginTransmission(LTCADDR);//get ADC Input 2V max
Wire.write(0x28);
Wire.endTransmission(false);
Wire.requestFrom(LTCADDR, 2, true);
delay(1);
AinVMSB = Wire.read();
AinVLSB = Wire.read();
AinV = ((unsigned int)(AinVMSB) << 4) + ((AinVLSB >> 4) & 0x0F);//12 bit format
ADCvoltage = AinV * 0.5E-3; //500uV resolution
Wire.beginTransmission(LTCADDR);//get sense current
Wire.write(0x14);
Wire.endTransmission(false);
Wire.requestFrom(LTCADDR, 2, true);
delay(1);
curSenseMSB = Wire.read();
curSenseLSB = Wire.read();
ADCcur = ((unsigned int)(curSenseMSB) << 4) + ((curSenseLSB >> 4) & 0x0F);//12 bit format
//gets voltage across, 25uV resolution, then this converts to voltage for each sense resistor
current10 = ADCcur * (25E-3) / 10.0; //10mA max, unit is mA
current1 = ADCcur * (25E-3) / 1.0; //100mA max, unit is mA
current0p1 = ADCcur * (25E-3) / 0.1; //1A max, unit is mA
current0p01 = ADCcur * (25E-6) / 0.01;//10A max, unit is A
Serial.print(inputVoltage, 2);
Serial.println("V");
delay(1000);
//============================
while (ds.selectNext())
Serial.print("Temperature: ");
Serial.print(ds.getTempC());
Serial.println(" C / ");
//============================
sensor.compensate(22.56, 30.73); // replace with t and rh values from sensor
sensor.getData();
Serial.print("CO2 concentration : ");
Serial.print(sensor.readCO2());
Serial.println(" ppm");
Serial.print("TVOC concentration : ");
Serial.print(sensor.readTVOC());
Serial.println(" ppb");
Serial.println();
delay(2000);
//=============================================
float altitude = myPressure.readAltitude();
Serial.print("Altitude(m):");
Serial.println(altitude, 2);
float pressure = myPressure.readPressure();
Serial.print("Pressure(Pa):");
Serial.println(pressure, 2);
float temperature = myPressure.readTemp();
Serial.print(" Temp(c):");
Serial.println(temperature, 2);
}
Comments