The Alpha Geek – Geeking Out

Environment

Project #21 – Nixie – ArduiNIX – Mk02

——

#DonLucElectronics #DonLuc #NixieTube #Nixie #ArduiNIX #ArduinoUNO #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

ArduiNIX

——

ArduiNIX

——

ArduiNIX

——

ArduiNIX

——

ArduiNIX

The ArduiNIX is an Arduino compatible shield which plugs right onto the top of the Arduino UNO board. ArduiNIX takes care of stepping power from 9 VDC wall adapter power supply up to a maximum of approximately 250 VDC to drive any and all Nixie tubes. ArduiNIX also provides Multiplexed display for up to 80 elements by using 4 anode channels and 20 cathode channels. Multiplexing increases the life expectancy of your Nixie tube investment.

Not only does the ArduiNIX provide a Nixie tube platform for standard clock functions, but it is also user programmable, meaning if you can program it using the arduino environment, you can make it happen on your Nixie display. Take special care when working with the ArduiNIX. The ArduiNIX Shield operates at high voltages. Be careful when handling it while it’s powered up. Normally the Arduino is safe to handle, but when used in conjunction with the ArduiNIX, voltages in excess of 200 volts may be achieved. Use caution. An IN-17 x 8 display board, and 8 x Russian IN-17 Nixie tubes.

DL2209Mk02

1 x Arduino UNO
1 x ArduiNIX V3 Tube Driver Shield Kit
1 x IN-17×8 V1 Tube Board Kit
1 x Anode / Cathode Connector Cable Set
1 x 9V 1000mA Power Supply
1 x SparkFun Cerberus USB Cable

Arduino UNO

SN2 – 2
SN3 – 3
SN4 – 4
SN5 – 5
SN6 – 6
SN7 – 7
SN8 – 8
SN9 – 9
AN10 – 10
AN11 – 11
AN12 – 12
AN13 – 13
VI14 – 14
VI15 – 15
VIN – +9V
GND – GND

DL2209Mk02p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #21 - Nixie - ArduiNIX - Mk02
21-02
DL2209Mk02p.ino
1 x Arduino UNO
1 x ArduiNIX V3 Tube Driver Shield Kit
1 x IN-17x8 V1 Tube Board Kit
1 x Anode / Cathode Connector Cable Set
1 x 9V 1000mA Power Supply
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code

// SN74141 (1)
int ledPin_0_a = 2;                
int ledPin_0_b = 3;
int ledPin_0_c = 4;
int ledPin_0_d = 5;

// SN74141 (2)
int ledPin_1_a = 6;                
int ledPin_1_b = 7;
int ledPin_1_c = 8;
int ledPin_1_d = 9;

// Anode pins
int ledPin_a_1 = 10;
int ledPin_a_2 = 11;
int ledPin_a_3 = 12;
int ledPin_a_4 = 13;

// NOTE: Grounding on virtual pins 14 and 15 
// (analog pins 0 and 1) will set the Hour and Mins.
int iVirtual14 = 14;
int iVirtual15 = 15;

// Fade
float fadeMax = 0.1f;
float fadeStep = 0.1f;
// Number Array
int NumberArray[8]={0,0,0,0,0,0,0,0};
int currNumberArray[8]={0,0,0,0,0,0,0,0};
float NumberArrayFadeInValue[8]={0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f};
float NumberArrayFadeOutValue[8]={5.0f,5.0f,5.0f,5.0f,5.0f,5.0f,5.0f,5.0f};

// Defines
// Sub seconds
long SSECS = 100;
// Milliseconds in a Sec
long SECS = 60;
// 60 Seconds in a Min.
long MINS = 60;
// 60 Mins in an hour
long HOURS = 60 * MINS;
// 24 Hours in a day. > Note: change the 24 to a 12 for non military time.
long DAYS = 12 * HOURS; 

// Time from when we started
long runTime = 0;

// Default time sets. clock will start at 12:34:00.
// This is so we can count the correct order of tubes.
long clockHourSet;
long clockMinSet;
long clockSecSet;
//long clockSSecSet;

int HourButtonPressed = false;
int MinButtonPressed = false;

// Software Version Information
String sver = "21-02";

void loop() {

  // Time
  isTime();
  
}

getDisplayFadeNumber.ino

// Display Fade Number
void DisplayFadeNumberString()
{
 
  // Anode channel 1 - numerals 0,4
  SetSN74141Chips(currNumberArray[0],currNumberArray[4]);   
  digitalWrite(ledPin_a_1, HIGH);   
  delay(NumberArrayFadeOutValue[0]);
  SetSN74141Chips(NumberArray[0],NumberArray[4]);   
  delay(NumberArrayFadeInValue[0]);
  digitalWrite(ledPin_a_1, LOW);
  
    // Anode channel 2 - numerals 1,5
  SetSN74141Chips(currNumberArray[1],currNumberArray[5]);   
  digitalWrite(ledPin_a_2, HIGH);   
  delay(NumberArrayFadeOutValue[1]);
  SetSN74141Chips(NumberArray[1],NumberArray[5]);   
  delay(NumberArrayFadeInValue[1]);
  digitalWrite(ledPin_a_2, LOW);
  
   // Anode channel 3 - numerals 2,6
  SetSN74141Chips(currNumberArray[2],currNumberArray[6]);   
  digitalWrite(ledPin_a_3, HIGH);   
  delay(NumberArrayFadeOutValue[2]);
  SetSN74141Chips(NumberArray[2],NumberArray[6]);   
  delay(NumberArrayFadeInValue[2]);
  digitalWrite(ledPin_a_3, LOW);
  
     // Anode channel 4 - numerals 3,7
  SetSN74141Chips(currNumberArray[3],currNumberArray[7]);   
  digitalWrite(ledPin_a_4, HIGH);   
  delay(NumberArrayFadeOutValue[3]);
  SetSN74141Chips(NumberArray[3],NumberArray[7]);   
  delay(NumberArrayFadeInValue[3]);
  digitalWrite(ledPin_a_4, LOW);
  
  // Loop thru and update all the arrays, and fades.
  for( int i = 0 ; i < 8 ; i ++ ) //equal to & of digits
  {
    if( NumberArray[i] != currNumberArray[i] )
    {
      NumberArrayFadeInValue[i] += fadeStep;
      NumberArrayFadeOutValue[i] -= fadeStep;
  
      if( NumberArrayFadeInValue[i] >= fadeMax )
      {
        NumberArrayFadeInValue[i] = 2.0f;
        NumberArrayFadeOutValue[i] = 4.0f; //affects the refresh cycle
        currNumberArray[i] = NumberArray[i];
      }
    }
  }
  
}

getSN74141.ino

// SN74141
// SN74141 : Truth Table
//D C B A #
//L,L,L,L 0
//L,L,L,H 1
//L,L,H,L 2
//L,L,H,H 3
//L,H,L,L 4
//L,H,L,H 5
//L,H,H,L 6
//L,H,H,H 7
//H,L,L,L 8
//H,L,L,H 9
// isSetupSN74141
void isSetupSN74141(){

  pinMode(ledPin_0_a, OUTPUT);      
  pinMode(ledPin_0_b, OUTPUT);      
  pinMode(ledPin_0_c, OUTPUT);      
  pinMode(ledPin_0_d, OUTPUT);    
  
  pinMode(ledPin_1_a, OUTPUT);      
  pinMode(ledPin_1_b, OUTPUT);      
  pinMode(ledPin_1_c, OUTPUT);      
  pinMode(ledPin_1_d, OUTPUT);      
  
  pinMode(ledPin_a_1, OUTPUT);      
  pinMode(ledPin_a_2, OUTPUT);      
  pinMode(ledPin_a_3, OUTPUT);   
  pinMode(ledPin_a_4, OUTPUT);    
 
  // NOTE: Grounding on virtual pins 14 and 15 
  // (analog pins 0 and 1) will set the Hour and Mins.
  // Set the vertual pin 14 (pin 0 on the analog inputs )
  pinMode( iVirtual14, INPUT );
  // Set pin 14 as a pull up resistor.
  digitalWrite(iVirtual14, HIGH);
  // Set the vertual pin 15 (pin 1 on the analog inputs )
  pinMode( iVirtual15, INPUT );
  // Set pin 15 as a pull up resistor.
  digitalWrite(iVirtual15, HIGH);
  
}
// SetSN74141Chips
void SetSN74141Chips( int num2, int num1 )
{
  
  // Set defaults
  // Will display a zero.
  int a = 0;
  int b = 0;
  int c = 0;
  int d = 0;
  
  // Load the a,b,c,d.. to send to the SN74141 IC (1)
  switch( num1 )
  {
    case 0:
      a=0;
      b=0;
      c=0;
      d=0;
      break;
    case 1:
      a=1;
      b=0;
      c=0;
      d=0;
      break;
    case 2:
      a=0;
      b=1;
      c=0;
      d=0;
      break;
    case 3:
      a=1;
      b=1;
      c=0;
      d=0;
      break;
    case 4:
      a=0;
      b=0;
      c=1;
      d=0;
      break;
    case 5:
      a=1;
      b=0;
      c=1;
      d=0;
      break;
    case 6: 
      a=0;
      b=1;
      c=1;
      d=0;
      break;
    case 7:
      a=1;
      b=1;
      c=1;
      d=0;
      break;
    case 8:
      a=0;
      b=0;
      c=0;
      d=1;
      break;
    case 9:
      a=1;
      b=0;
      c=0;
      d=1;
      break;
    default:
      a=1;
      b=1;
      c=1;
      d=1;
      break;
  }  
  
  // Write to output pins.
  digitalWrite(ledPin_0_d, d);
  digitalWrite(ledPin_0_c, c);
  digitalWrite(ledPin_0_b, b);
  digitalWrite(ledPin_0_a, a);

  // Load the a,b,c,d.. to send to the SN74141 IC (2)
  switch( num2 )
  {
    case 0:
      a=0;
      b=0;
      c=0;
      d=0;
      break;
    case 1:
      a=1;
      b=0;
      c=0;
      d=0;
      break;
    case 2:
      a=0;
      b=1;
      c=0;
      d=0;
      break;
    case 3:
      a=1;
      b=1;
      c=0;
      d=0;
      break;
    case 4:
      a=0;
      b=0;
      c=1;
      d=0;
      break;
    case 5:
      a=1;
      b=0;
      c=1;
      d=0;
      break;
    case 6:
      a=0;
      b=1;
      c=1;
      d=0;
      break;
    case 7:
      a=1;
      b=1;
      c=1;
      d=0;
      break;
    case 8:
      a=0;
      b=0;
      c=0;
      d=1;
      break;
    case 9:
      a=1;
      b=0;
      c=0;
      d=1;
      break;
    default:
      a=1;
      b=1;
      c=1;
      d=1;
      break;
  }
  
  // Write to output pins
  digitalWrite(ledPin_1_d, d);
  digitalWrite(ledPin_1_c, c);
  digitalWrite(ledPin_1_b, b);
  digitalWrite(ledPin_1_a, a);
  
}

getTime.ino

// Time
void isTime(){

  // Get milliseconds.
  runTime = millis();
  //int ssTime = millis();
  
  int hourInput = digitalRead(iVirtual14);  
  int minInput  = digitalRead(iVirtual15);

  if( hourInput == 0 )
    HourButtonPressed = true;
  if( minInput == 0 )
    MinButtonPressed = true;
  if( HourButtonPressed == true && hourInput == 1 )
  {
    clockHourSet++;
    HourButtonPressed = false;
  }
  if( MinButtonPressed == true && minInput == 1 )
  {
    clockMinSet++;
    MinButtonPressed = false;
  }

  // Get time in seconds.
  // Change this value to speed up or
  // slow down the clock, set to smaller number such as 10, 1, or 100 for debugging
  long time = (runTime) / 1000;
  int sstime = (runTime) / 10;
  // Set time based on offset..
  // long hbump = 60*60*clockHourSet;
  //long sbump = 60*60*60*clockHourSet; //change hourset to secondset
  long hbump = 60*60*clockHourSet;
  long mbump = 60*clockMinSet;
  time += mbump + hbump;

  // Convert time to days,hours,mins,seconds
  long days  = time / DAYS;    time -= days  * DAYS; 
  long hours = time / HOURS;   time -= hours * HOURS; 
  long minutes  = time / MINS;    time -= minutes  * MINS; 
  long seconds  = time;      
//  long sseconds  = 76;// time -= seconds  * SECS;
  long sseconds  = runTime / SECS; time -= sseconds  * SECS; 

  // Get the high and low order values for hours,min,seconds. 
  int lowerHours = hours % 10;
  int upperHours = hours - lowerHours;
  int lowerMins = minutes % 10;
  int upperMins = minutes - lowerMins;
  int lowerSeconds = seconds % 10;
  int upperSeconds = seconds - lowerSeconds;
  int lowerSSeconds = sseconds % 10;
  //- lowerSSeconds;
  int upperSSeconds = lowerSSeconds % 10; upperSSeconds = upperSSeconds /10;
  
  if( upperSSeconds >= 10 )  upperSSeconds = upperSSeconds / 10;
  if( upperSeconds >= 10 )   upperSeconds = upperSeconds / 10;
  if( upperMins >= 10 )      upperMins = upperMins / 10;
  if( upperHours >= 10 )     upperHours = upperHours / 10;
 
  if( upperHours == 0 && lowerHours == 0 )
  {
    upperHours = 1;
    lowerHours = 2;
  }
  
  // Fill in the Number array used to display on the tubes.
  
  NumberArray[7] = upperHours;
  NumberArray[6] = lowerHours;
  NumberArray[5] = upperMins;
  NumberArray[4] = lowerMins;
  NumberArray[3] = upperSeconds;  
  NumberArray[2] = lowerSeconds;
  NumberArray[1] = lowerSSeconds; //upperSSeconds;  
  NumberArray[0] = lowerSSeconds; //lowerSSeconds;
  
  Serial.print(lowerSSeconds);
  Serial.println();
  // Display.
  //DisplayFadeNumberString();
  // Display.
  DisplayFadeNumberString();
  
}

setup.ino

// Setup
void setup() {

  // isSetupSN74141
  isSetupSN74141();

  // Open serial communications
 Serial.begin(9600);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics

Follow Us

J. Luc Paquin – Curriculum Vitae – 2022 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – MQ, PIR, HCSR04, RHT03, RTC and MicroSD – Mk19

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #HCSR04 #RHT03 #RTC #MicroSD #ArduinoUNO #Arduino #PowerBoost #Project #Programming #Electronics #Microcontrollers #Consultant

——

MQ, PIR, HCSR04, RHT03, RTC and MicroSD

——

MQ, PIR, HCSR04, RHT03, RTC and MicroSD

——

MQ, PIR, HCSR04, RHT03, RTC and MicroSD

——

MQ, PIR, HCSR04, RHT03, RTC and MicroSD

——

MQ, PIR, HCSR04, RHT03, RTC and MicroSD

——

Project enclosure for protecting your electronic. You’ve got too much stuff to fit into a so you need an upgrade and here it is.

  • Arduino UNO
  • ProtoScrewShield
  • RGB LCD Character
  • HC-SR04 Ultrasonic Sensor
  • ChronoDot – Real Time Clock, Batteries
  • MicroSD Card Board, MicroSD 2.0 GB
  • Adafruit PowerBoost 500 Shield, Lithium Ion Battery – 3.7v 2000mAh
  • Hydrogen Gas Sensor
  • Carbon Monoxide & Flammable Gas Sensor
  • Carbon Monoxide Gas Sensor
  • Alcohol Gas Sensor
  • Temperature and Humidity Sensor
  • PIR Motion Sensor
  • Breadboard Solderables, Acrylics, Wood, Rocker Switch, LED Green, Resistors, USB Cable, Etc…

DL2111Mk01

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16×2 Character Negative Display
1 x HC-SR04 Ultrasonic Sensor
1 x ChronoDot – Ultra-Precise Real Time Clock – v2.1
1 x CR1632 Batteries
1 x MicroSD Card Breakout Board+
1 x MicroSD 2.0 GB
1 x Rocker Switch – SPST (Round)
1 x 10K Ohm
1 x LED Green
1 x 220 Ohm
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Breadboard Solderable
1 x Adafruit Perma-Prote Half-Size Breadboard
1 x Acrylic Blue 5.75 inches x 3.75 inches x 1/8 inch
1 x Acrylic Ivory 5.75 inches x 3.75 inches x 1/8 inch
1 x Wood
2 x Union Squad – 1 Inch
4 x Screw 6-32, Flat Washer, Lock Washer, Hex Nut
28 x Screw – 4-40
14 x Standoff – Metal 4-40 – 3/8″
8 x Standoff – Metal 4-40 – 1″
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

CLK – Digital 13
DO – Digital 12
DI – Digital 11
CS – Digital 10
ECH – Digital 9
TIR – Digital 8
PIR – Digital 7
RHT – Digital 5
RS0 – Digital 3
LEG – Digital 2
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
SDA – Analog 4
SCL – Analog 5
VIN – +5V
GND – GND

DL2111Mk01p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – MQ, PIR, HCSR04, RHT03, RTC and MicroSD – Mk19
11-01
DL2111Mk01p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16x2 Character Negative Display
1 x HC-SR04 Ultrasonic Sensor
1 x ChronoDot - Ultra-Precise Real Time Clock - v2.1
1 x CR1632 Batteries
1 x MicroSD Card Breakout Board+
1 x MicroSD 2.0 GB
1 x Rocker Switch - SPST (Round)
1 x 10K Ohm
1 x LED Green
1 x 220 Ohm
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery - 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Breadboard Solderable
1 x Adafruit Perma-Prote Half-Size Breadboard
1 x Acrylic Blue 5.75 inches x 3.75 inches x 1/8 inch
1 x Acrylic Ivory 5.75 inches x 3.75 inches x 1/8 inch
1 x Wood
2 x Union Squad - 1 Inch
4 x Screw 6-32, Flat Washer, Lock Washer, Hex Nut
28 x Screw - 4-40
14 x Standoff - Metal 4-40 - 3/8"
8 x Standoff - Metal 4-40 - 1"d
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>
// Adafruit RGB LCD Shield 16x2
#include <Adafruit_RGBLCDShield.h>
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>
// SD Card
#include <SPI.h>
#include <SD.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

// SD Card
const int chipSelect = 10;
String zzzzzz = "";

// LED Green
int iLEDGreen = 2;

// Rocker Switch - SPST (Round)
int iSS1 = 3;
// State
int iSS1State = 0;

// HC-SR04 Ultrasonic Sensor
int iTrig = 8;
int iEcho = 9;
// Stores the distance measured by the distance sensor
float distance = 0;

// Software Version Information
String uid = "";
// Version
String sver = "15-19";

void loop()
{
     
  // Adafruit RGB LCD Shield
  // Clear
  RGBLCDShield.clear();

  // iLEDGreen LOW
  digitalWrite(iLEDGreen,  LOW );
  
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // DS3231 RTC Date and Time
  isRTC();
  
  // HC-SR04 Ultrasonic Sensor
  isHCSR04();

  // Adafruit RGB LCD Shield
  // Display
  isDisplay();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen HIGH
    digitalWrite(iLEDGreen,  HIGH );
    
    // MicroSD Card
    isSD();

  } else {

    // iLEDGreen LOW
    digitalWrite(iLEDGreen,  LOW );
  
  }

  // Delay
  delay( 500 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getHC-SR04.ino

// HC-SR04 Ultrasonic Sensor
// Setup HC-SR04
void setupHCSR04() {

  // The trigger iTrig will output pulses of electricity
  pinMode(iTrig, OUTPUT);
  // The echo iEcho will measure the duration of pulses coming back from the distance sensor
  pinMode(iEcho, INPUT);
  
}
// HC-SR04
void isHCSR04() {

  // Variable to store the distance measured by the sensor
  distance = isDistance();
    
}
// Distance
float isDistance() {
  
  // Variable to store the time it takes for a ping to bounce off an object
  float echoTime;
  // Variable to store the distance calculated from the echo time
  float calculatedDistance;

  // Send out an ultrasonic pulse that's 10ms long
  digitalWrite(iTrig, HIGH);
  delayMicroseconds(10);
  digitalWrite(iTrig, LOW);

  // Use the pulseIn command to see how long it takes for the
  // pulse to bounce back to the sensor
  echoTime = pulseIn(iEcho, HIGH);

  // Calculate the distance of the object that reflected the pulse
  // (half the bounce time multiplied by the speed of sound)
  // cm = 58.0
  calculatedDistance = echoTime / 58.0;

  // Send back the distance that was calculated
  return calculatedDistance;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";

  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }
  
}

getRGBLCDShield.ino

// Adafruit RGB LCD Shield
// Setup RGB LCD Shield
void isSetupRGBLCDShield() {

  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(RED);
  // Don luc 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Don Luc");
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Electronics
  RGBLCDShield.print("Electronics");
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(TEAL);
  // Version 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Version: " + sver);
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Unit ID
  RGBLCDShield.print("Unit ID: " + uid);
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();
  
}
// isDisplay
void isDisplay() {

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // RHT Temperature and Humidity Sensor
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Temperature C
      RGBLCDShield.print( "Temp C: " );
      RGBLCDShield.print( latestTempC );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Humidity
      RGBLCDShield.print( "Humidity: " );
      RGBLCDShield.print( latestHumidity );

      break;
    case 2:
    
      // Set the cursor to column 0, line 0
      // PIR Motion Sensor
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( "PIR: " );
      RGBLCDShield.print( Det );
      // Set the cursor to column 0, line 1
      // HC-SR04 Ultrasonic Sensor
      RGBLCDShield.setCursor(0, 1);
      RGBLCDShield.print( "HC-SR04: " );
      RGBLCDShield.print( distance );
      
      break;
    case 3:

      // Gas Sensors 1
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Hydrogen Gas Sensor - MQ-8
      RGBLCDShield.print( "MQ-8: " );
      RGBLCDShield.print( iMQ8ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Carbon Monoxide & Flammable Gas Sensor - MQ-9
      RGBLCDShield.print( "MQ-9: " );
      RGBLCDShield.print( iMQ9ppm );
      
      break;
    case 4:

      // Gas Sensors 2
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Carbon Monoxide Gas Sensor - MQ-7
      RGBLCDShield.print( "MQ-7: " );
      RGBLCDShield.print( iMQ7ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Alcohol Gas Sensor - MQ-3
      RGBLCDShield.print( "MQ-3: " );
      RGBLCDShield.print( iMQ3ppm );
      
      break;
    case 5:

      // DS3231 RTC Date and Time
      // Date and Time
      DateTime now = rtc.now();
      // Set the cursor to column 0, line 0
      // Date 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( sDate );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Time
      RGBLCDShield.print( sTime );
      
      break;
    default:

      // Don luc Electronics
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      // Set the cursor to column 0, line 0
      // Don luc 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print("Don Luc");
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Electronics
      RGBLCDShield.print("Electronics");

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // RHT Temperature and Humidity Sensor
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // PIR Motion Sensor
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Gas Sensors 1
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Gas Sensors 2
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // DS3231 RTC Date and Time
      RGBLCDShield.setBacklight(WHITE);
   
    }
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();

}

getRTC.ino

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);
  
    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);
    
}

getSD.ino

// MicroSD Card
// MicroSD Setup
void setupSD() {

  // MicroSD Card
  if (!SD.begin(chipSelect)) {

     while (true);

  }
 
}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  // Don Luc Electronics © (1983-2021)
  // Arduino Data
  // EEPROM Unique ID
  // Version
  // Date
  // Time
  // Temperature Celsius
  // Humidity
  // Hydrogen Gas Sensor - MQ-8
  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  // Carbon Monoxide Gas Sensor - MQ-7
  // Alcohol Gas Sensor - MQ-3
  // PIR Motion
  // HC-SR04 Ultrasonic Sensor
  // EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity|MQ-8|MQ-9|MQ-7|MQ-3|PIR Motion|HC-SR04|
  zzzzzz = uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + latestTempC + "|" + latestHumidity + "|"
  + iMQ8ppm + "|" + iMQ9ppm + "|" + iMQ7ppm + "|" + 
  iMQ3ppm + "|" + Det + "|" + distance + "|";

  
  // Open the file. Note that only one file can be open at a time,
  // so you have to close this one before opening another.

  File dataFile = SD.open("arddata.txt", FILE_WRITE);

  // If the file is available, write to it:
  if ( dataFile ) {

    dataFile.println( zzzzzz );

    dataFile.close();

  }
  
}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();
  
  // RHT Temperature and Humidity Sensor
  // Setup RTH03 Temperature and Humidity Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Setup DS3231 RTC
  isSetupRTC();

  //MicroSD Card
  setupSD();

  // Initialize the LED Green
  pinMode(iLEDGreen, OUTPUT);
  // iLEDGreen LOW
  digitalWrite(iLEDGreen,  LOW );

  // Slide Switch
  pinMode(iSS1, INPUT);

  // Setup HC-SR04
  setupHCSR04();

  // Adafruit RGB LCD Shield
  isSetupRGBLCDShield();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – HC-SR04 Ultrasonic Sensor – Mk18

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #HCSR04 #RHT03 #RTC #ArduinoUNO #Arduino #AdafruitPowerBoost #Project #Programming #Electronics #Microcontrollers #Consultant

——

HC-SR04

——

HC-SR04

——

HC-SR04

——

HC-SR04

——

HC-SR04 Ultrasonic Sensor

This is the HC-SR04 ultrasonic distance sensor. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit.

There are only four pins that you need to worry about on the HC-SR04: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground). You will find this sensor very easy to set up and use for your next range-finding project. This sensor has additional control circuitry that can prevent inconsistent “bouncy” data depending on the application.

DL2110Mk05

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16×2 Character Negative Display
1 x HC-SR04 Ultrasonic Sensor
1 x ChronoDot – Ultra-Precise Real Time Clock – v2.1
1 x CR1632 Batteries
1 x MicroSD Card Breakout Board+
1 x MicroSD 2.0 GB
1 x Rocker Switch – SPST (Round)
1 x 10K Ohm
1 x LED Green
1 x 220 Ohm
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Half-Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

CLK – Digital 13
DO – Digital 12
DI – Digital 11
CS – Digital 10
ECH – Digital 9
TIR – Digital 8
PIR – Digital 7
RHT – Digital 5
RS0 – Digital 3
LEG – Digital 2
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
SDA – Analog 4
SCL – Analog 5
VIN – +5V
GND – GND

DL2110Mk05p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – HC-SR04 Ultrasonic Sensor – Mk18
10-05
DL2110Mk05p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16x2 Character Negative Display
1 x HC-SR04 Ultrasonic Sensor
1 x ChronoDot - Ultra-Precise Real Time Clock - v2.1
1 x CR1632 Batteries
1 x MicroSD Card Breakout Board+
1 x MicroSD 2.0 GB
1 x Rocker Switch - SPST (Round)
1 x 10K Ohm
1 x LED Green
1 x 220 Ohm
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery - 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Half-Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>
// Adafruit RGB LCD Shield 16x2
#include <Adafruit_RGBLCDShield.h>
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>
// SD Card
#include <SPI.h>
#include <SD.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

// SD Card
const int chipSelect = 10;
String zzzzzz = "";

// LED Green
int iLEDGreen = 2;

// Rocker Switch - SPST (Round)
int iSS1 = 3;
// State
int iSS1State = 0;

// HC-SR04 Ultrasonic Sensor
int iTrig = 8;
int iEcho = 9;
// Stores the distance measured by the distance sensor
float distance = 0;

// Software Version Information
String uid = "";
// Version
String sver = "15-18";

void loop()
{
     
  // Adafruit RGB LCD Shield
  // Clear
  RGBLCDShield.clear();

  // iLEDGreen LOW
  digitalWrite(iLEDGreen,  LOW );
  
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // DS3231 RTC Date and Time
  isRTC();
  
  // HC-SR04 Ultrasonic Sensor
  isHCSR04();

  // Adafruit RGB LCD Shield
  // Display
  isDisplay();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen HIGH
    digitalWrite(iLEDGreen,  HIGH );
    
    // MicroSD Card
    isSD();

  } else {

    // iLEDGreen LOW
    digitalWrite(iLEDGreen,  LOW );
  
  }

  // Delay
  delay( 500 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getHC-SR04.ino

// HC-SR04 Ultrasonic Sensor
// Setup HC-SR04
void setupHCSR04() {

  // The trigger iTrig will output pulses of electricity
  pinMode(iTrig, OUTPUT);
  // The echo iEcho will measure the duration of pulses coming back from the distance sensor
  pinMode(iEcho, INPUT);
  
}
// HC-SR04
void isHCSR04() {

  // Variable to store the distance measured by the sensor
  distance = isDistance();
    
}
// Distance
float isDistance() {
  
  // Variable to store the time it takes for a ping to bounce off an object
  float echoTime;
  // Variable to store the distance calculated from the echo time
  float calculatedDistance;

  // Send out an ultrasonic pulse that's 10ms long
  digitalWrite(iTrig, HIGH);
  delayMicroseconds(10);
  digitalWrite(iTrig, LOW);

  // Use the pulseIn command to see how long it takes for the
  // pulse to bounce back to the sensor
  echoTime = pulseIn(iEcho, HIGH);

  // Calculate the distance of the object that reflected the pulse
  // (half the bounce time multiplied by the speed of sound)
  // cm = 58.0
  calculatedDistance = echoTime / 58.0;

  // Send back the distance that was calculated
  return calculatedDistance;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";

  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }
  
}

getRGBLCDShield.ino

// Adafruit RGB LCD Shield
// Setup RGB LCD Shield
void isSetupRGBLCDShield() {

  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(RED);
  // Don luc 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Don Luc");
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Electronics
  RGBLCDShield.print("Electronics");
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(TEAL);
  // Version 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Version: " + sver);
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Unit ID
  RGBLCDShield.print("Unit ID: " + uid);
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();
  
}
// isDisplay
void isDisplay() {

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // RHT Temperature and Humidity Sensor
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Temperature C
      RGBLCDShield.print( "Temp C: " );
      RGBLCDShield.print( latestTempC );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Humidity
      RGBLCDShield.print( "Humidity: " );
      RGBLCDShield.print( latestHumidity );

      break;
    case 2:
    
      // Set the cursor to column 0, line 0
      // PIR Motion Sensor
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( "PIR: " );
      RGBLCDShield.print( Det );
      // Set the cursor to column 0, line 1
      // HC-SR04 Ultrasonic Sensor
      RGBLCDShield.setCursor(0, 1);
      RGBLCDShield.print( "HC-SR04: " );
      RGBLCDShield.print( distance );
      
      break;
    case 3:

      // Gas Sensors 1
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Hydrogen Gas Sensor - MQ-8
      RGBLCDShield.print( "MQ-8: " );
      RGBLCDShield.print( iMQ8ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Carbon Monoxide & Flammable Gas Sensor - MQ-9
      RGBLCDShield.print( "MQ-9: " );
      RGBLCDShield.print( iMQ9ppm );
      
      break;
    case 4:

      // Gas Sensors 2
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Carbon Monoxide Gas Sensor - MQ-7
      RGBLCDShield.print( "MQ-7: " );
      RGBLCDShield.print( iMQ7ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Alcohol Gas Sensor - MQ-3
      RGBLCDShield.print( "MQ-3: " );
      RGBLCDShield.print( iMQ3ppm );
      
      break;
    case 5:

      // DS3231 RTC Date and Time
      // Date and Time
      DateTime now = rtc.now();
      // Set the cursor to column 0, line 0
      // Date 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( sDate );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Time
      RGBLCDShield.print( sTime );
      
      break;
    default:

      // Don luc Electronics
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      // Set the cursor to column 0, line 0
      // Don luc 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print("Don Luc");
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Electronics
      RGBLCDShield.print("Electronics");

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // RHT Temperature and Humidity Sensor
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // PIR Motion Sensor
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Gas Sensors 1
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Gas Sensors 2
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // DS3231 RTC Date and Time
      RGBLCDShield.setBacklight(WHITE);
   
    }
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();

}

getRTC.ino

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);
  
    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);
    
}

getSD.ino

// MicroSD Card
// MicroSD Setup
void setupSD() {

  // MicroSD Card
  if (!SD.begin(chipSelect)) {

     while (true);

  }
 
}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  // Don Luc Electronics © (1983-2021)
  // Arduino Data
  // EEPROM Unique ID
  // Version
  // Date
  // Time
  // Temperature Celsius
  // Humidity
  // Hydrogen Gas Sensor - MQ-8
  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  // Carbon Monoxide Gas Sensor - MQ-7
  // Alcohol Gas Sensor - MQ-3
  // PIR Motion
  // HC-SR04 Ultrasonic Sensor
  // EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity|MQ-8|MQ-9|MQ-7|MQ-3|PIR Motion|HC-SR04|
  zzzzzz = uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + latestTempC + "|" + latestHumidity + "|"
  + iMQ8ppm + "|" + iMQ9ppm + "|" + iMQ7ppm + "|" + 
  iMQ3ppm + "|" + Det + "|" + distance + "|";

  
  // Open the file. Note that only one file can be open at a time,
  // so you have to close this one before opening another.

  File dataFile = SD.open("arddata.txt", FILE_WRITE);

  // If the file is available, write to it:
  if ( dataFile ) {

    dataFile.println( zzzzzz );

    dataFile.close();

  }
  
}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();
  
  // RHT Temperature and Humidity Sensor
  // Setup RTH03 Temperature and Humidity Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Setup DS3231 RTC
  isSetupRTC();

  //MicroSD Card
  setupSD();

  // Initialize the LED Green
  pinMode(iLEDGreen, OUTPUT);
  // iLEDGreen LOW
  digitalWrite(iLEDGreen,  LOW );

  // Slide Switch
  pinMode(iSS1, INPUT);

  // Setup HC-SR04
  setupHCSR04();

  // Adafruit RGB LCD Shield
  isSetupRGBLCDShield();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – MicroSD Card – Mk17

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #RHT03 #RTC #ArduinoUNO #Arduino #AdafruitPowerBoost #Project #Programming #Electronics #Microcontrollers #Consultant

——

MicroSD Card

——

MicroSD Card

——

MicroSD Card

——

MicroSD Card

——

MicroSD Card Breakout Board+

Not just a simple breakout board, this microSD adapter goes the extra mile – designed for ease of use.

  • -Onboard 5v->3v regulator provides 150mA for power-hungry cards
  • -3v level shifting means you can use this with ease on either 3v or 5v systems
  • -Uses a proper level shifting chip, not resistors: less problems, and faster read/write access
  • -Use 3 or 4 digital pins to read and write 2Gb+ of storage
  • -Activity LED lights up when the SD card is being read or written
  • -Push-push socket with card slightly over the edge of the PCB so its easy to insert and remove
  • -Comes with 0.1″ header so you can get it on a breadboard or use wires

To use with an Arduino, connect GND to ground, 5V to 5V, CLK to pin 13, DO to pin 12, DI to pin 11, and CS to pin 10.

DL2110Mk04

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16×2 Character Negative Display
1 x ChronoDot – Ultra-Precise Real Time Clock – v2.1
1 x MicroSD Card Breakout Board+
1 x MicroSD 2.0 GB
1 x Rocker Switch – SPST (Round)
1 x 10K Ohm
1 x LED Green
1 x 220 Ohm
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Half-Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

CLK – Digital 13
DO – Digital 12
DI – Digital 11
CS – Digital 10
PIR – Digital 7
RHT – Digital 5
RS0 – Digital 3
LEG – Digital 2
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
SDA – Analog 4
SCL – Analog 5
VIN – +5V
GND – GND

——

DL2110Mk04p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – MicroSD Card – Mk17
10-04
DL2110Mk04p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16x2 Character Negative Display
1 x ChronoDot - Ultra-Precise Real Time Clock - v2.1
1 x MicroSD Card Breakout Board+
1 x MicroSD 2.0 GB
1 x Rocker Switch - SPST (Round)
1 x 10K Ohm
1 x LED Green
1 x 220 Ohm
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery - 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Half-Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>
// Adafruit RGB LCD Shield 16x2
#include <Adafruit_RGBLCDShield.h>
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>
// SD Card
#include <SPI.h>
#include <SD.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

// SD Card
const int chipSelect = 10;
String zzzzzz = "";

// LED Green
int iLEDGreen = 2;

// Rocker Switch - SPST (Round)
int iSS1 = 3;
// State
int iSS1State = 0;

// Software Version Information
String uid = "";
// Version
String sver = "15-17";

void loop()
{
     
  // Adafruit RGB LCD Shield
  // Clear
  RGBLCDShield.clear();

  // iLEDGreen LOW
  digitalWrite(iLEDGreen,  LOW );
  
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // DS3231 RTC Date and Time
  isRTC();

  // Adafruit RGB LCD Shield
  // Display
  isDisplay();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen HIGH
    digitalWrite(iLEDGreen,  HIGH );
    
    // MicroSD Card
    isSD();

  } else {

    // iLEDGreen LOW
    digitalWrite(iLEDGreen,  LOW );
  
  }

  // Delay
  delay( 1000 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";

  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }
  
}

getRGBLCDShield.ino

// Adafruit RGB LCD Shield
// Setup RGB LCD Shield
void isSetupRGBLCDShield() {

  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(RED);
  // Don luc 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Don Luc");
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Electronics
  RGBLCDShield.print("Electronics");
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(TEAL);
  // Version 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Version: " + sver);
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Unit ID
  RGBLCDShield.print("Unit ID: " + uid);
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();
  
}
// isDisplay
void isDisplay() {

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // RHT Temperature and Humidity Sensor
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Temperature C
      RGBLCDShield.print( "Temp C: " );
      RGBLCDShield.print( latestTempC );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Humidity
      RGBLCDShield.print( "Humidity: " );
      RGBLCDShield.print( latestHumidity );

      break;
    case 2:
    
      // PIR Motion Sensor
      // Set the cursor to column 0, line 0
      // PIR Motion Sensor
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( "PIR Motion" );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Det
      RGBLCDShield.print( Det );
      
      break;
    case 3:

      // Gas Sensors 1
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Hydrogen Gas Sensor - MQ-8
      RGBLCDShield.print( "MQ-8: " );
      RGBLCDShield.print( iMQ8ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Carbon Monoxide & Flammable Gas Sensor - MQ-9
      RGBLCDShield.print( "MQ-9: " );
      RGBLCDShield.print( iMQ9ppm );
      
      break;
    case 4:

      // Gas Sensors 2
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Carbon Monoxide Gas Sensor - MQ-7
      RGBLCDShield.print( "MQ-7: " );
      RGBLCDShield.print( iMQ7ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Alcohol Gas Sensor - MQ-3
      RGBLCDShield.print( "MQ-3: " );
      RGBLCDShield.print( iMQ3ppm );
      
      break;
    case 5:

      // DS3231 RTC Date and Time
      // Date and Time
      DateTime now = rtc.now();
      // Set the cursor to column 0, line 0
      // Date 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( sDate );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Time
      RGBLCDShield.print( sTime );
      
      break;
    default:

      // Don luc Electronics
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      // Set the cursor to column 0, line 0
      // Don luc 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print("Don Luc");
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Electronics
      RGBLCDShield.print("Electronics");

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // RHT Temperature and Humidity Sensor
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // PIR Motion Sensor
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Gas Sensors 1
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Gas Sensors 2
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // DS3231 RTC Date and Time
      RGBLCDShield.setBacklight(WHITE);
   
    }
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();

}

getRTC.ino

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);
  
    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);
    
}

getSD.ino

// MicroSD Card
// MicroSD Setup
void setupSD() {

  // MicroSD Card
  if (!SD.begin(chipSelect)) {

     while (true);

  }
 
}
// MicroSD Card
void isSD() {

  zzzzzz = "";

  // Don Luc Electronics © (1983-2021)
  // Arduino Data
  // EEPROM Unique ID
  // Version
  // Date
  // Time
  // Temperature Celsius
  // Humidity
  // Hydrogen Gas Sensor - MQ-8
  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  // Carbon Monoxide Gas Sensor - MQ-7
  // Alcohol Gas Sensor - MQ-3
  // PIR Motion
  // EEPROM Unique ID|Version|Date|Time|Temperature Celsius|Humidity|MQ-8|MQ-9|MQ-7|MQ-3|PIR Motion|\r
  zzzzzz = uid + "|" + sver + "|" + sDate + "|" + sTime + "|" + latestTempC + "|" + latestHumidity + "|"
  + iMQ8ppm + "|" + iMQ9ppm + "|" + iMQ7ppm + "|" + 
  iMQ3ppm + "|" + Det + "|";

  
  // Open the file. Note that only one file can be open at a time,
  // so you have to close this one before opening another.

  File dataFile = SD.open("arddata.txt", FILE_WRITE);

  // If the file is available, write to it:
  if ( dataFile ) {

    dataFile.println( zzzzzz );

    dataFile.close();

  }
  
}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();
  
  // RHT Temperature and Humidity Sensor
  // Setup RTH03 Temperature and Humidity Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Setup DS3231 RTC
  isSetupRTC();

  //MicroSD Card
  setupSD();

  // Initialize the LED Green
  pinMode(iLEDGreen, OUTPUT);
  // iLEDGreen LOW
  digitalWrite(iLEDGreen,  LOW );

  // Slide Switch
  pinMode(iSS1, INPUT);

  // Adafruit RGB LCD Shield
  isSetupRGBLCDShield();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – ChronoDot – Mk16

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #RHT03 #RTC #ArduinoUNO #Arduino #AdafruitPowerBoost #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog

——

ChronoDot

——

ChronoDot

——

ChronoDot

——

ChronoDot

——

ChronoDot – Ultra-Precise Real Time Clock – v2.1

The ChronoDot RTC is an extremely accurate real time clock module, based on the DS3231 temperature compensated RTC. It includes a CR1632 battery, which should last at least 8 years if the I2C interface is only used while the device has 5V power available. No external crystal or tuning capacitors are required.

The top side of the Chronodot now features a battery holder for 16mm 3V lithium coin cells. It pairs particularly well with CR1632 batteries. The DS3231 has an internal crystal and a switched bank of tuning capacitors. The temperature of the crystal is continously monitored, and the capacitors are adjusted to maintain a stable frequency. Other RTC solutions may drift minutes per month, especially in extreme temperature ranges…the ChronoDot will drift less than a minute per year. This makes the ChronoDot very well suited for time critical applications that cannot be regularly synchronized to an external clock.

DL2110Mk03

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16×2 Character Negative Display
1 x ChronoDot – Ultra-Precise Real Time Clock – v2.1
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Half-Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

RHT – Digital 5
PIR – Digital 7
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
SDA – Analog 4
SCL – Analog 5
VIN – +5V
GND – GND

——

DL2110Mk03p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – ChronoDot – Mk16
10-03
DL2110Mk03p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16x2 Character Negative Display
1 x ChronoDot - Ultra-Precise Real Time Clock - v2.1
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery - 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x Half-Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>
// Adafruit RGB LCD Shield 16x2
#include <Adafruit_RGBLCDShield.h>
// Wire
#include <Wire.h>
// DS3231 RTC Date and Time
#include <RTClib.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// DS3231 RTC Date and Time
RTC_DS3231 rtc;
String sDate;
String sTime;

// Software Version Information
String uid = "";
// Version
String sver = "15-16";

void loop()
{
     
  // Adafruit RGB LCD Shield
  // Clear
  RGBLCDShield.clear();
  
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // DS3231 RTC Date and Time
  isRTC();

  // Adafruit RGB LCD Shield
  // Display
  isDisplay();

  // Delay
  // Turn the LED on HIGH is the voltage level
  digitalWrite(LED_BUILTIN, HIGH);
  // Wait for a 0.5 second
  delay( 500 );
  // Turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);
  // Wait for a 0.5 second
  delay( 500 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";

  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }
  
}

getRGBLCDShield.ino

// Adafruit RGB LCD Shield
// Setup RGB LCD Shield
void isSetupRGBLCDShield() {

  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(RED);
  // Don luc 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Don Luc");
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Electronics
  RGBLCDShield.print("Electronics");
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(TEAL);
  // Version 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Version: " + sver);
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Unit ID
  RGBLCDShield.print("Unit ID: " + uid);
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();
  
}
// isDisplay
void isDisplay() {

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // RHT Temperature and Humidity Sensor
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Temperature C
      RGBLCDShield.print( "Temp C: " );
      RGBLCDShield.print( latestTempC );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Humidity
      RGBLCDShield.print( "Humidity: " );
      RGBLCDShield.print( latestHumidity );

      break;
    case 2:
    
      // PIR Motion Sensor
      // Set the cursor to column 0, line 0
      // PIR Motion Sensor
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( "PIR Motion" );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Det
      RGBLCDShield.print( Det );
      
      break;
    case 3:

      // Gas Sensors 1
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Hydrogen Gas Sensor - MQ-8
      RGBLCDShield.print( "MQ-8: " );
      RGBLCDShield.print( iMQ8ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Carbon Monoxide & Flammable Gas Sensor - MQ-9
      RGBLCDShield.print( "MQ-9: " );
      RGBLCDShield.print( iMQ9ppm );
      
      break;
    case 4:

      // Gas Sensors 2
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Carbon Monoxide Gas Sensor - MQ-7
      RGBLCDShield.print( "MQ-7: " );
      RGBLCDShield.print( iMQ7ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Alcohol Gas Sensor - MQ-3
      RGBLCDShield.print( "MQ-3: " );
      RGBLCDShield.print( iMQ3ppm );
      
      break;
    case 5:

      // DS3231 RTC Date and Time
      // Date and Time
      DateTime now = rtc.now();
      // Set the cursor to column 0, line 0
      // Date 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( sDate );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Time
      RGBLCDShield.print( sTime );
      
      break;
    default:

      // Don luc Electronics
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      // Set the cursor to column 0, line 0
      // Don luc 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print("Don Luc");
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Electronics
      RGBLCDShield.print("Electronics");

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // RHT Temperature and Humidity Sensor
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // PIR Motion Sensor
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Gas Sensors 1
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Gas Sensors 2
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // DS3231 RTC Date and Time
      RGBLCDShield.setBacklight(WHITE);
   
    }
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();

}

getRTC.ino

// DS3231 RTC Date and Time
// Setup DS3231 RTC
void isSetupRTC() {

  if (! rtc.begin()) {
    while (1);
  }

  if (rtc.lostPower()) {
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  
}
// DS3231 RTC Date and Time
void isRTC(){
 
    // Date and Time
    sDate = "";
    sTime = "";
    // Date Time
    DateTime now = rtc.now();

    // sData
    sDate += String(now.year(), DEC);
    sDate += "/";
    sDate += String(now.month(), DEC);
    sDate += "/";
    sDate += String(now.day(), DEC);
  
    // sTime
    sTime += String(now.hour(), DEC);
    sTime += ":";
    sTime += String(now.minute(), DEC);
    sTime += ":";
    sTime += String(now.second(), DEC);
    
}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();
  
  // RHT Temperature and Humidity Sensor
  // Setup RTH03 Temperature and Humidity Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Setup DS3231 RTC
  isSetupRTC();

  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  // Adafruit RGB LCD Shield
  isSetupRGBLCDShield();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Web: https://www.donluc.com/DLE/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: https://zoom.us/
Patreon: https://www.patreon.com/DonLucElectronics
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – RGB LCD Shield 16×2 Character Display – Mk15

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #RHT03 #ArduinoUNO #Arduino #AdafruitPowerBoost #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog

——

RGB LCD Shield 16x2 Character Display

——

RGB LCD Shield 16x2 Character Display

——

RGB LCD Shield 16x2 Character Display

——

RGB LCD Shield 16x2 Character Display

——

RGB LCD Shield 16×2 Character Negative Display

With this in mind, we wanted to make it easier for people to get these LCD into their projects so we devised a shield that lets you control a 16×2 Character LCD, up to 3 backlight pins AND 5 keypad pins using only the two I2C pins on the Arduino. The shield is designed for Arduinos Uno. It uses the I2C pins at Analog 4 and Analog 5.

At this time, the library and shield can control the RGB backlight of our character LCDs by turning each LED on or off. This means you can display the following colors: Red, Yellow, Green, Teal, Blue, Violet, White and all off. This shield is perfect for when you want to build a stand-alone project with its own user interface. The 4 directional buttons plus select button allows basic control without having to attach a bulky computer.

Adjusting Contrast

The shield uses a character LCD with an external contrast potentiometer. The first time you use it, adjust the potentiometer in the bottom right until you see the text clearly.

DL2110Mk02

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16×2 Character Negative Display
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

RHT – Digital 5
PIR – Digital 7
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
SDA – Analog 4
SCL – Analog 5
VIN – +5V
GND – GND

DL2110Mk02p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – RGB LCD Shield 16x2 Character Display – Mk15
10-02
DL2110Mk02p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
1 x RGB LCD Shield 16x2 Character Negative Display
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery - 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>
// Adafruit RGB LCD Shield 16x2
#include <Adafruit_RGBLCDShield.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Adafruit RGB LCD Shield
Adafruit_RGBLCDShield RGBLCDShield = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
// Momentary Button
int yy = 0;
uint8_t momentaryButton = 0;

// Software Version Information
String uid = "";
// Version
String sver = "15-15";

void loop()
{
     
  // Adafruit RGB LCD Shield
  // Clear
  RGBLCDShield.clear();
  
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // Adafruit RGB LCD Shield
  // Display
  isDisplay();

  // Delay
  // Turn the LED on HIGH is the voltage level
  digitalWrite(LED_BUILTIN, HIGH);
  // Wait for a 0.5 second
  delay( 500 );
  // Turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);
  // Wait for a 0.5 second
  delay( 500 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";

  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }
  
}

getRGBLCDShield.ino

// Adafruit RGB LCD Shield
// Setup RGB LCD Shield
void isSetupRGBLCDShield() {

  // Adafruit RGB LCD Shield
  // Set up the LCD's number of columns and rows: 
  RGBLCDShield.begin(16, 2);

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(RED);
  // Don luc 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Don Luc");
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Electronics
  RGBLCDShield.print("Electronics");
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();

  // Set the cursor to column 0, line 0
  RGBLCDShield.setBacklight(TEAL);
  // Version 
  RGBLCDShield.setCursor(0,0);
  RGBLCDShield.print("Version: " + sver);
  // Set the cursor to column 0, line 1
  RGBLCDShield.setCursor(0, 1);
  // Unit ID
  RGBLCDShield.print("Unit ID: " + uid);
  // Delay
  delay(5000);
  // Clear
  RGBLCDShield.clear();
  
}
// isDisplay
void isDisplay() {

  // Momentary Button
  momentaryButton = RGBLCDShield.readButtons();

  switch ( yy ) {
    case 1:
    
      // RHT Temperature and Humidity Sensor
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Temperature C
      RGBLCDShield.print( "Temp C: " );
      RGBLCDShield.print( latestTempC );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Humidity
      RGBLCDShield.print( "Humidity: " );
      RGBLCDShield.print( latestHumidity );

      break;
    case 2:
    
      // PIR Motion Sensor
      // Set the cursor to column 0, line 0
      // PIR Motion Sensor
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print( "PIR Motion" );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Det
      RGBLCDShield.print( Det );
      
      break;
    case 3:

      // Gas Sensors 1
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Hydrogen Gas Sensor - MQ-8
      RGBLCDShield.print( "MQ-8: " );
      RGBLCDShield.print( iMQ8ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Carbon Monoxide & Flammable Gas Sensor - MQ-9
      RGBLCDShield.print( "MQ-9: " );
      RGBLCDShield.print( iMQ9ppm );
      
      break;
    case 4:

      // Gas Sensors 2
      // Set the cursor to column 0, line 0
      RGBLCDShield.setCursor(0,0);
      // Carbon Monoxide Gas Sensor - MQ-7
      RGBLCDShield.print( "MQ-7: " );
      RGBLCDShield.print( iMQ7ppm );
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Alcohol Gas Sensor - MQ-3
      RGBLCDShield.print( "MQ-3: " );
      RGBLCDShield.print( iMQ3ppm );
      
      break;
    case 5:

      // Don luc Electronics
      // Set the cursor to column 0, line 0
      // Don luc 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print("Don Luc");
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Electronics
      RGBLCDShield.print("Electronics");
      
      break;
    default:

      // Don luc Electronics
      yy = 5;
      RGBLCDShield.setBacklight(RED);
      // Set the cursor to column 0, line 0
      // Don luc 
      RGBLCDShield.setCursor(0,0);
      RGBLCDShield.print("Don Luc");
      // Set the cursor to column 0, line 1
      RGBLCDShield.setCursor(0, 1);
      // Electronics
      RGBLCDShield.print("Electronics");

   }
   
   if ( momentaryButton ) {
    
    if ( momentaryButton & BUTTON_UP ) {
      
      yy = 1;
      // RHT Temperature and Humidity Sensor
      RGBLCDShield.setBacklight(GREEN);
      
    }
    
    if ( momentaryButton & BUTTON_DOWN ) {
      
      yy = 2;
      // PIR Motion Sensor
      RGBLCDShield.setBacklight(VIOLET);
      
    }
    
    if ( momentaryButton & BUTTON_LEFT ) {
      
      yy = 3;
      // Gas Sensors 1
      RGBLCDShield.setBacklight(TEAL);
      
    }
    
    if ( momentaryButton & BUTTON_RIGHT ) {

      yy = 4;
      // Gas Sensors 2
      RGBLCDShield.setBacklight(YELLOW);
    }
    
    if ( momentaryButton & BUTTON_SELECT ) {

      yy = 5;
      // Don luc Electronics
      RGBLCDShield.setBacklight(RED);
   
    }
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();

}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();
  
  // RHT Temperature and Humidity Sensor
  // Setup RTH03 Temperature and Humidity Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  // Adafruit RGB LCD Shield
  isSetupRGBLCDShield();

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Web: https://www.donluc.com/DLE/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: https://zoom.us/
Patreon: https://www.patreon.com/DonLucElectronics
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – Adafruit PowerBoost – Mk14

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #RHT03 #ArduinoUNO #Arduino #AdafruitPowerBoost #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog

——

Adafruit PowerBoost

——

Adafruit PowerBoost

——

Adafruit PowerBoost

——

Adafruit PowerBoost

——

Adafruit PowerBoost 500 Shield – Rechargeable 5V Power Shield

What’s a project if it’s trapped on your desk? Now you can take your Arduino anywhere you wish with the PowerBoost shield. This stackable shield goes onto your Arduino and provides a slim rechargeable power pack, with a built in battery charger as well as DC/DC booster.

Compatible with Arduino Uno basically any Arduino-pinout-shaped Arduino as only the GND and 5V pins are used. You can stack shields on top, or stack the PowerBoost on top. The PowerBoost shield can run off of any Lithium Ion or Lithium Polymer battery but we suggest our 2000mAh capacity batteries, both of which fits very nicely in the empty space of the shield. Plug in the battery and recharge it via the microUSB jack. When you’re ready to go, just unplug the Arduino from USB or the wall adapter and it will automatically switch over to shield power. Use only Lipoly batteries with protection circuitry.

The onboard boost converter can provide at least 500mA current, and can peak at 1A. There’s an onboard fuse to protect against higher current draws which could damage the boost converter or battery. The boost converter can be damaged by high current spikes and is not recommended for driving motors or robots where the stall current can cause high current spikes. It will let you turn the shield and Arduino power on/off.

Lithium Ion Battery – 3.7v 2000mAh

Lithium ion polymer batteries are thin, light and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 2000mAh. If you need a larger battery. The batteries come pre-attached with a genuine 2-pin JST-PH connector as shown and include the necessary protection circuitry. Because they have a genuine JST connector, not a knock-off, the cable wont snag or get stuck in a matching JST jack, they click in and out smoothly.

DL2110Mk01

1 x Arduino UNO – R3
1 x ProtoScrewShield
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery – 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

RHT – Digital 5
PIR – Digital 7
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
VIN – +5V
GND – GND

DL2110Mk01p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – Adafruit PowerBoost – Mk14
10-01
DL2110Mk01p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
1 x Adafruit PowerBoost 500 Shield
1 x Lithium Ion Battery - 3.7v 2000mAh
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;
float latestTempF;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Software Version Information
String uid = "";
// Version
String sver = "15-14";

void loop()
{
     
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // Delay
  // Turn the LED on HIGH is the voltage level
  digitalWrite(LED_BUILTIN, HIGH);
  // Wait for a 0.5 second
  delay( 500 );
  // Turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);
  // Wait for a 0.5 second
  delay( 500 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

  // Serial
  // Hydrogen Gas Sensor - MQ-8
  Serial.print( "MQ-8: " );
  Serial.println( iMQ8ppm );
  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  Serial.print( "MQ-9: " );
  Serial.println( iMQ9ppm );
  // Carbon Monoxide Gas Sensor - MQ-7
  Serial.print( "MQ-7: " );
  Serial.println( iMQ7ppm );
  // Alcohol Gas Sensor - MQ-3 
  Serial.print( "MQ-3: " );
  Serial.println( iMQ3ppm );
  
}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";
    // Serial
    Serial.println( Det );
    
  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    // Serial
    Serial.println( Det );
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();
  latestTempF = rht.tempF();

  // Serial
  // RHT Temperature and Humidity Sensor
  // Temperature F
  Serial.print( "Temp F: " );
  Serial.println( latestTempF );
  // Temperature C
  Serial.print( "Temp C: " );
  Serial.println( latestTempC );
  // Humidity
  Serial.print( "Humidity: " );
  Serial.println( latestHumidity );
  
}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();

  // Serial
  Serial.begin( 9600 );
  
  // RHT Temperature and Humidity Sensor
  // setup RTH03 Humidity and Temperature Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  // Don Luc Electronics
  Serial.println( "Don Luc Electronics" );
  // Version
  Serial.println( sver );
  // Is Unit ID
  Serial.println( uid );
  
  delay( 5000 );
  
}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Web: https://www.donluc.com/DLE/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: https://zoom.us/
Patreon: https://www.patreon.com/DonLucElectronics
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #15: Environment – ProtoScrewShield – Mk13

——

#DonLucElectronics #DonLuc #Environment #MQ #PIR #RHT03 #ArduinoUNO #Arduino #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog

——

ProtoScrewShield

——

ProtoScrewShield

——

ProtoScrewShield

——

ProtoScrewShield

——

ProtoScrewShield

The ScrewShield extends all pins of the Arduino out to 3.5 mm pitch screw terminals. It also has a lot of the utility provided by Arduino Protoshield, including: a large prototyping space of both connected and unconnected 0.1 inch spaced through-holes, a couple 5V and GND busses, a reset button, general use push button, and a 5 mm yellow LED. This product includes all the parts shown and comes in kit form and must be soldered together by the end user.

DL2109Mk03

1 x Arduino UNO – R3
1 x ProtoScrewShield
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor- RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x SparkFun Cerberus USB Cable

Arduino UNO – R3

RHT – Digital 5
PIR – Digital 7
MQ8 – Analog 0
MQ9 – Analog 1
MQ7 – Analog 2
MQ3 – Analog 3
VIN – +5V
GND – GND

DL2109Mk03p.ino

/* 
***** Don Luc Electronics © *****
Software Version Information
Project #15: Environment – ProtoScrewShield – Mk13
09-03
DL2109Mk03p.ino
1 x Arduino UNO - R3
1 x ProtoScrewShield
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor - MQ-8
1 x 4.7K Ohm
1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
1 x 22k Ohm
1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
1 x 10K Ohm
1 x SparkFun Alcohol Gas Sensor - MQ-3
1 x 220k Ohm
1 x Temperature and Humidity Sensor - RHT03
1 x PIR Motion Sensor (JST)
1 x SparkFun Solderable Half-Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include <EEPROM.h>
// RHT Temperature and Humidity Sensor
#include <SparkFun_RHT03.h>

// RHT Temperature and Humidity Sensor
// RHT03 data pin Digital 5
const int RHT03_DATA_PIN = 5;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;
float latestTempF;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A0;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet.
// With these two points, a line is formed which is
// "approximately equivalent" to the original curve.
float H2Curve[3] = {2.3, 0.93,-1.44};

// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A1;
int iMQ9Raw = 0;
int iMQ9ppm = 0;

// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A2;
int iMQ7Raw = 0;
int iMQ7ppm = 0;

// Alcohol Gas Sensor - MQ-3
int iMQ3 = A3;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// PIR Motion
// Motion detector
const int iMotion = 7;
// Proximity
int proximity = LOW;
String Det = "";

// Software Version Information
String uid = "";
// Version
String sver = "15-13";

void loop()
{
     
  // RHT Temperature and Humidity Sensor
  isRHT03();

  // Gas Sensors MQ
  isGasSensor();

  // isPIR Motion
  isPIR();

  // Delay
  // Turn the LED on HIGH is the voltage level
  digitalWrite(LED_BUILTIN, HIGH);
  // Wait for a 0.5 second
  delay( 500 );
  // Turn the LED off by making the voltage LOW
  digitalWrite(LED_BUILTIN, LOW);
  // Wait for a 0.5 second
  delay( 500 );
 
}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 

  // Serial
  // Hydrogen Gas Sensor - MQ-8
  Serial.print( "MQ-8: " );
  Serial.println( iMQ8ppm );
  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  Serial.print( "MQ-9: " );
  Serial.println( iMQ9ppm );
  // Carbon Monoxide Gas Sensor - MQ-7
  Serial.print( "MQ-7: " );
  Serial.println( iMQ7ppm );
  // Alcohol Gas Sensor - MQ-3 
  Serial.print( "MQ-3: " );
  Serial.println( iMQ3ppm );
  
}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";
    // Serial
    Serial.println( Det );
    
  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    // Serial
    Serial.println( Det );
    
  }
  
}

getRHT.ino

// RHT Temperature and Humidity Sensor
// setup RHT Temperature and Humidity Sensor
void setupRTH03() {

  // RHT Temperature and Humidity Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT Temperature and Humidity Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();
  latestTempF = rht.tempF();

  // Serial
  // RHT Temperature and Humidity Sensor
  // Temperature F
  Serial.print( "Temp F: " );
  Serial.println( latestTempF );
  // Temperature C
  Serial.print( "Temp C: " );
  Serial.println( latestTempC );
  // Humidity
  Serial.print( "Humidity: " );
  Serial.println( latestHumidity );
  
}

setup.ino

// Setup
void setup()
{
    
  // EEPROM Unique ID
  isUID();

  // Serial
  Serial.begin( 9600 );
  
  // RHT Temperature and Humidity Sensor
  // setup RTH03 Humidity and Temperature Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);

  // Don Luc Electronics
  Serial.println( "Don Luc Electronics" );
  // Version
  Serial.println( sver );
  // Is Unit ID
  Serial.println( uid );
  
  delay( 5000 );
  
}

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Web: https://www.donluc.com/DLE/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Web: https://zoom.us/
Patreon: https://www.patreon.com/DonLucElectronics
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Project #14: Components – SparkFun Solderable Breadboard – Mk20

——

#DonLuc #Electronics #Components #SolderableBreadboard #Microcontrollers #Environment #SparkFun #Consultant #Vlog #Aphasia

——

Components

——

Components

——

SparkFun Solderable Breadboard

SparkFun Item: PRT-12070

This is the SparkFun Solderable Breadboard. A bare PCB that is the exact size as our regular breadboard with the same connections to pins and power rails. This board is especially useful for preserving a prototype or experiment you just created on a solderless breadboard by soldering all the pieces in place.

Technology Experience

  • Single-Board Microcontrollers (Arduino, Raspberry Pi,Espressif, etc…)
  • Robotics
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/luc.paquin/

Don Luc

Project #15: Environment – PIR Motion Sensor – Mk12

——

#DonLuc #Environment #ESP32 #MQ #GPS #EMF #PIR #SparkFun #Adafruit #Pololu #Fritzing #Programming #Arduino #Consultant #Electronics #Microcontrollers #Vlog #Aphasia

——

Environment

——

Environment

——

Environment

——

PIR Motion Sensor (JST)

SparkFun Item: SEN-13285

This is a simple to use motion sensor. Power it up and wait 1-2 seconds for the sensor to get a snapshot of the still room. If anything moves after that period, the ‘alarm’ pin will go low. The alarm pin is an open collector meaning you will need a pull up resistor on the alarm pin. The open drain setup allows multiple motion sensors to be connected on a single input pin. If any of the motion sensors go off, the input pin will be pulled low.

We’ve finally updated the connector! Gone is the old “odd” connector, now you will find a common 3-pin JST! This makes the PIR Sensor much more accessible for whatever your project may need. Red = Power, White = Ground, and Black = Alarm.

DL2006Mk02

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x SparkFun Environmental Combo Breakout – CCS811/BME280
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x SparkFun GPS Receiver – GP-20U7
1 x CR1220 12mm Lithium Battery
1 x 32Gb microSD Card
1 x Mountable Slide Switch
1 x SparkFun Rotary Switch – 10 Position
1 x Black Knob
1 x Breadboard Solderable
4 x Pololu Carrier for MQ Gas Sensors
1 x SparkFun Hydrogen Gas Sensor – MQ-8
1 x Pololu Carbon Monoxide & Flammable Gas Sensor – MQ-9
1 x SparkFun Carbon Monoxide Gas Sensor – MQ-7
1 x SparkFun Alcohol Gas Sensor – MQ-3
1 x Telescopic Antenna SMA – 300 MHz to 1.1 GHz (ANT700)
1 x SMA Connector
1 x Humidity and Temperature Sensor – RHT03
1 x PIR Motion Sensor (JST)
1 x Qwiic Cable – 100mm
1 x LED Green
11 x 1K Ohm
1 x 4.7K Ohm
2 x 10K Ohm
1 x 20k Ohm
1 x 200k Ohm
1 x 3.3m Ohm
12 x Jumper Wires 3in M/M
13 x Jumper Wires 6in M/M
20 x Wire Solid Core – 22 AWG
2 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable
1 x DC Power Supply

SparkFun Thing Plus – ESP32 WROOM

LEG – Digital 21
SCK – Digital 13
MOS – Digital 12
SSD – Digital 27
SDA – Digital 23
SCL – Digital 22
SD1 – Digital 33
SC2 – Digital 5
MO2 – Digital 18
MI2 – Digital 19
SS1 – Digital 16
ROT – Analog A1
MH1 – Analog A0
MC1 – Analog A2
MC2 – Analog A3
MA1 – Analog A4
EMF – Analog A5
GPS – Digital 14
RHT – Digital 15
PIR – Digital 17
VIN – +3.3V
GND – GND

DL2006Mk02p.ino

// ***** Don Luc Electronics © *****
// Software Version Information
// Project #15: Environment - PIR Motion Sensor (JST) - Mk12
// 06-02
// DL2006Mk02p.ino 15-12
// EEPROM with Unique ID
// 1 x SparkFun Thing Plus - ESP32 WROOM
// 1 x Adafruit SHARP Memory Display
// 1 x SparkFun Environmental Combo Breakout - CCS811/BME280
// 1 x Adafruit Adalogger FeatherWing - RTC + SD
// 1 x SparkFun GPS Receiver - GP-20U7
// 1 x CR1220 12mm Lithium Battery
// 1 x 32Gb microSD Card
// 1 x Mountable Slide Switch
// 1 x SparkFun Rotary Switch - 10 Position
// 1 x Black Knob
// 1 x Breadboard Solderable
// 4 x Pololu Carrier for MQ Gas Sensors
// 1 x SparkFun Hydrogen Gas Sensor - MQ-8
// 1 x Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9
// 1 x SparkFun Carbon Monoxide Gas Sensor - MQ-7
// 1 x SparkFun Alcohol Gas Sensor - MQ-3
// 1 x Telescopic Antenna SMA - 300 MHz to 1.1 GHz (ANT700)
// 1 x SMA Connector
// 1 x Humidity and Temperature Sensor - RHT03
// 1 x PIR Motion Sensor (JST)
// 1 x Qwiic Cable - 100mm
// 1 x LED Green
// 11 x 1K Ohm
// 1 x 4.7K Ohm
// 2 x 10K Ohm
// 1 x 20k Ohm
// 1 x 200k Ohm
// 1 x 3.3m Ohm
// 12 x Jumper Wires 3in M/M
// 13 x Jumper Wires 6in M/M
// 20 x Wire Solid Core - 22 AWG
// 2 x Full-Size Breadboard
// 1 x SparkFun Cerberus USB Cable
// 1 x DC Power Supply

// Include the Library Code
// EEPROM Library to Read and Write EEPROM with Unique ID for Unit
#include "EEPROM.h"
// Wire
#include <Wire.h>
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
#include <Adafruit_GFX.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
#include <SparkFunBME280.h>
// Date and Time
#include "RTClib.h"
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// GPS Receiver
#include <TinyGPS++.h>
// Hardware Serial
#include <HardwareSerial.h>
// RHT Humidity and Temperature Sensor
#include <SparkFun_RHT03.h>

// LED Green
int iLEDGreen = 21;

// SHARP Memory Display
// any pins can be used
#define SHARP_SCK  13
#define SHARP_MOSI 12
#define SHARP_SS   27
// Set the size of the display here - 144x168
Adafruit_SharpMem display(SHARP_SCK, SHARP_MOSI, SHARP_SS, 144, 168);
// The currently-available SHARP Memory Display (144x168 pixels)
// requires > 4K of microcontroller RAM; it WILL NOT WORK on Arduino Uno
// or other <4K "classic" devices!
#define BLACK 0
#define WHITE 1
// 1/2 of lesser of display width or height
int minorHalfSize; 

// SparkFun CCS811 - eCO2 & tVOC
// Default I2C Address
#define CCS811_ADDR 0x5B 
CCS811 myCCS811(CCS811_ADDR);
float CCS811CO2 = 0;
float CCS811TVOC = 0;

// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
BME280 myBME280;
float BMEtempC = 0;
float BMEhumid = 0;
float BMEaltitudeM = 0;
float BMEpressure = 0;

// Date and Time
// PCF8523 Precision RTC 
RTC_PCF8523 rtc;
String dateRTC = "";
String timeRTC = "";

// microSD Card
const int chipSelect = 33;
String zzzzzz = "";

// Mountable Slide Switch
int iSS1 = 16;
// State
int iSS1State = 0;

// ESP32 HardwareSerial
HardwareSerial tGPS(2);

// GPS Receiver
#define gpsRXPIN 14
// This one is unused and doesnt have a conection
#define gpsTXPIN 32
// The TinyGPS++ object
TinyGPSPlus gps;
float TargetLat;
float TargetLon;
int GPSStatus = 0;

// Rotary Switch - 10 Position
// Number 1 => 10
int iRotNum = A0;
// iRotVal - Value 
int iRotVal = 0;
// Number
int z = 0;
int x = 0;

// Gas Sensors MQ
// Hydrogen Gas Sensor - MQ-8
int iMQ8 = A1;
int iMQ8Raw = 0;
int iMQ8ppm = 0;
// Two points are taken from the curve in datasheet
// With these two points, a line is formed which is "approximately equivalent" to the original curve
float H2Curve[3] = {2.3, 0.93,-1.44};
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int iMQ9 = A2;
int iMQ9Raw = 0;
int iMQ9ppm = 0;
// Carbon Monoxide Gas Sensor - MQ-7
int iMQ7 = A3;
int iMQ7Raw = 0;
int iMQ7ppm = 0;
// Alcohol Gas Sensor - MQ-3
int iMQ3 = A4;
int iMQ3Raw = 0;
int iMQ3ppm = 0;

// EMF Meter (Single Axis)
int iEMF = A5;
// Raise this number to increase data smoothing
#define NUMREADINGS 15
// Raise this number to decrease sensitivity (up to 1023 max)
int senseLimit = 15;
// EMF Value
int valEMF = 0;
// Readings from the analog input
int readings[ NUMREADINGS ];
// Index of the current reading
int indexEMF = 0;
// Running total
int totalEMF = 0;
// Final average of the probe reading
int averageEMF = 0;
int iEMFDis = 0;
int iEMFRect = 0;

// RHT Humidity and Temperature Sensor
// RHT03 data pin Digital 15
const int RHT03_DATA_PIN = 15;
// This creates a RTH03 object, which we'll use to interact with the sensor
RHT03 rht;
float latestHumidity;
float latestTempC;
float latestTempF;

// PIR Motion
// Motion detector
const int iMotion = 17;
// Proximity
int proximity = LOW;
String Det = "";

// Software Version Information
String sver = "15-12";
// EEPROM Unique ID Information
#define EEPROM_SIZE 64
String uid = "";

void loop() {

  // Receives NEMA data from GPS receiver
  isGPS();
  
  // Date and Time 
  isRTC();
  
  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  isBME280();

  // SparkFun CCS811 - eCO2 & tVOC
  isCCS811();

  // Gas Sensors MQ
  isGasSensor();

  // EMF Meter (Single Axis)
  isEMF();

  // RHT03 Humidity and Temperature Sensor
  isRHT03();

  // isPIR Motion
  isPIR();

  // Rotary Switch
  isRot();

  // Slide Switch
  // Read the state of the iSS1 value
  iSS1State = digitalRead(iSS1);
  
  // If it is the Slide Switch State is HIGH
  if (iSS1State == HIGH) {

    // iLEDGreen
    digitalWrite(iLEDGreen,  HIGH );
    
    // microSD Card
    isSD();

  } else {

    // iLEDGreen
    digitalWrite(iLEDGreen,  LOW );
  
  }

  delay( 1000 );
  
}

getBME280.ino

// SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
// isBME280 - Temperature, Humidity, Altitude and Barometric Pressure
void isBME280(){

  // Temperature Celsius
  BMEtempC = myBME280.readTempC();
  // Humidity
  BMEhumid = myBME280.readFloatHumidity();
  // Altitude Meters
  BMEaltitudeM = (myBME280.readFloatAltitudeMeters(), 2);
  // Barometric Pressure
  BMEpressure = myBME280.readFloatPressure();
  
}

getCCS811.ino

// CCS811 - eCO2 & tVOC
// isCCS811 - eCO2 & tVOC
void isCCS811(){

  // This sends the temperature & humidity data to the CCS811
  myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);

  // Calling this function updates the global tVOC and eCO2 variables
  myCCS811.readAlgorithmResults();

  // eCO2 Concentration
  CCS811CO2 = myCCS811.getCO2();
  
  // tVOC Concentration
  CCS811TVOC = myCCS811.getTVOC();
  
}

getDisplay.ino

// Display
// SHARP Memory Display - UID
void isDisplayUID() {

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Don Luc Electronics
    display.setCursor(0,10);
    display.println( "Don Luc" );
    display.setTextSize(2);
    display.setCursor(0,40);
    display.println( "Electronics" );
    // Version
    display.setTextSize(3);
    display.setCursor(0,70);
    display.println( "Version" );
    display.setTextSize(2);
    display.setCursor(0,100);   
    display.println( sver );
    // EEPROM Unique ID
    display.setTextSize(1);
    display.setCursor(0,130);
    display.println( "EEPROM Unique ID" );
    display.setTextSize(2);
    display.setCursor(0,145);
    display.println( uid );
    // Refresh
    display.refresh();
    delay( 100 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(1);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,0);
    display.println( "Temperature Celsius" );
    display.setCursor(0,10);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,20);
    display.println( "Humidity" );
    display.setCursor(0,30);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,40);
    display.println( "Altitude Meters" );
    display.setCursor(0,50);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,60);    
    display.println( "Barometric Pressure" );
    display.setCursor(0,70);
    display.print( BMEpressure );
    display.println( " Pa" );
    // eCO2 Concentration
    display.setCursor(0,80);
    display.println( "eCO2 Concentration" );
    display.setCursor(0,90);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,100);
    display.println( "tVOC Concentration" );
    display.setCursor(0,110);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Date
    display.setCursor(0,120);
    display.println( dateRTC );
    // Time
    display.setCursor(0,130);
    display.println( timeRTC );
    // GPS Status
    display.setCursor(0,140);
    display.println( GPSStatus );
    // Target Latitude
    display.setCursor(0,150);
    display.println( TargetLat );
    // Target Longitude
    display.setCursor(0,160);
    display.println( TargetLon );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Date
void isDisplayDate() {

    // Text Display Date
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Date
    display.setCursor(0,5);
    display.println( dateRTC );
    // Time
    display.setCursor(0,30);
    display.println( timeRTC );
    // GPS Status
    display.setCursor(0,60);
    display.print( "GPS: " );
    display.println( GPSStatus );
    // Target Latitude
    display.setCursor(0,80);
    display.println( "Latitude" );
    display.setCursor(0,100);
    display.println( TargetLat );
    // Target Longitude
    display.setCursor(0,120);
    display.println( "Longitude" );
    display.setCursor(0,140);
    display.println( TargetLon );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display BME280
void isDisplayBME280() {

     // Text Display BME280
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,10);
    display.println( "Temperature" );
    display.setCursor(0,30);
    display.print( BMEtempC );
    display.println( " C" );
    // Humidity
    display.setCursor(0,50);
    display.println( "Humidity" );
    display.setCursor(0,70);
    display.print( BMEhumid );
    display.println( "%" );
    // Altitude Meters
    display.setCursor(0,90);
    display.println( "Altitude M" );
    display.setCursor(0,110);
    display.print( BMEaltitudeM );
    display.println( " m" );
    // Pressure
    display.setCursor(0,130);    
    display.println( "Barometric" );
    display.setCursor(0,150);
    display.print( BMEpressure );
    display.println( "Pa" );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display CCS811 - eCO2 & tVOC
void isDisplayCCS811() {

    // Text Display CCS811
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // eCO2 Concentration
    display.setCursor(0,10);
    display.println( "eCO2" );
    display.setCursor(0,30);
    display.print( CCS811CO2 );
    display.println( " ppm" );
    // tVOC Concentration
    display.setCursor(0,60);
    display.println( "tVOC" );
    display.setCursor(0,80);
    display.print( CCS811TVOC );
    display.println( " ppb" );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Gas Sensors MQ
void isDisplayMQ() {

    // Text Display MQ
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Gas Sensors MQ
    display.setCursor(0,10);
    display.println( "Gas H2 MQ8" );
    display.setCursor(0,30);
    display.print( iMQ8ppm );
    display.println( " ppm" );
    display.setCursor(0,50);
    display.println( "Gas CO MQ9" );
    display.setCursor(0,70);
    display.print( iMQ9ppm );
    display.println( " ppm" );
    display.setCursor(0,90);
    display.println( "Gas CO MQ7" );
    display.setCursor(0,110);
    display.print( iMQ7ppm );
    display.println( " ppm" );
    display.setCursor(0,130);
    display.println( "BAC MQ3" );
    display.setCursor(0,150);
    display.print( iMQ3ppm );
    display.println( "%" );
    // Refresh
    display.refresh();
    delay( 100 );

}
// EMF Meter (Single Axis)
void isDisplayEMF() {

    // Text Display EMF Meter
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // EMF Meter
    display.setCursor(0,10);
    display.println( "EMF Meter" );
    display.setCursor(0,30);
    display.print( "EMF: " );
    display.println( averageEMF );
    display.setCursor(0,50);
    display.println( iEMFDis );
    display.setCursor(0,70);
    display.setTextSize(1);
    display.println( "0  1 2 3 4 5 6 7 8 9  10" );
    display.setCursor(0,90);
    display.drawRect(0, 90, iEMFRect , display.height(), BLACK);
    display.fillRect(0, 90, iEMFRect , display.height(), BLACK);
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display PIR Motion
void isDisplayPIR() {

    // Text Display PIR
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // PIR Motion
    display.setCursor(0,10);
    display.println( "PIR Motion" );
    display.setCursor(0,30);
    display.println( Det );
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display RHT
void isDisplayRHT() {

    // Text Display RHT
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Temperature
    display.setCursor(0,10);
    display.println( "Temp C" );
    display.setCursor(0,30);
    display.print( latestTempC );
    display.println( "C" );
    // Temp F
    display.setCursor(0,60);
    display.println( "Temp F" );
    display.setCursor(0,80);
    display.print( latestTempF );
    display.println( "F" );
    // Humidity
    display.setCursor(0,110);
    display.println( "Humidity" );
    display.setCursor(0,130);
    display.print( latestHumidity );
    display.println( " %" );    
    // Refresh
    display.refresh();
    delay( 100 );

}
// Display Z
void isDisplayZ() {

    // Text Display Z
    // Clear Display
    display.clearDisplay();
    display.setRotation(4);
    display.setTextSize(3);
    display.setTextColor(BLACK);
    // Z
    display.setCursor(0,10);
    display.print( "Z: " );
    display.println( z );
    // Refresh
    display.refresh();
    delay( 100 );

}

getEEPROM.ino

// EEPROM
// isUID EEPROM Unique ID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getEMF.ino

// EMF Meter (Single Axis)
// Setup EMF Meter
void isSetupEMF() {

  // EMF Meter (Single Axis)
  pinMode( iEMF, OUTPUT );
  for (int i = 0; i < NUMREADINGS; i++){
    readings[ i ] = 0;     // Initialize all the readings to 0
  }
  
}
// EMF Meter
void isEMF() {

  // Probe EMF Meter
  // Take a reading from the probe
  valEMF = analogRead( iEMF );

  // If the reading isn't zero, proceed
  if( valEMF >= 1 ){

    // Turn any reading higher than the senseLimit value into the senseLimit value
    valEMF = constrain( valEMF, 1, senseLimit );
    // Remap the constrained value within a 1 to 1023 range
    valEMF = map( valEMF, 1, senseLimit, 1, 1023 );
    
    // Subtract the last reading
    totalEMF -= readings[ indexEMF ];
    // Read from the sensor
    readings[ indexEMF ] = valEMF;
    // Add the reading to the total
    totalEMF += readings[ indexEMF ];
    // Advance to the next index
    indexEMF = ( indexEMF + 1 );
    
    // If we're at the end of the array...
    if ( indexEMF >= NUMREADINGS ) {

      // Wrap around to the beginning
      indexEMF = 0;
      
    }  

    // Calculate the average
    averageEMF = totalEMF / NUMREADINGS;

    iEMFDis = averageEMF;
    iEMFRect = map( averageEMF, 1, 1023, 1, 144 );

  }
  else
  {

    averageEMF = 0;
    
  }
  
}

getGPS.ino

// GPS Receiver
// Setup GPS
void setupGPS() {

  // Setup GPS
  tGPS.begin(  9600 , SERIAL_8N1, gpsRXPIN, gpsTXPIN );
  
}
// isGPS
void isGPS(){

  // Receives NEMA data from GPS receiver
  // This sketch displays information every time a new sentence is correctly encoded.
  while ( tGPS.available() > 0)
    if (gps.encode( tGPS.read() ))
    {
     displayInfo();
    }
  
  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    while(true);
  }

}
// GPS Vector Pointer Target
void displayInfo(){

  // Location
  if (gps.location.isValid())
  {
    
    TargetLat = gps.location.lat();
    TargetLon = gps.location.lng();
    GPSStatus = 2;
    
  }
  else
  {

    GPSStatus = 0;
    
  }

}

getGasSensorMQ.ino

// Gas Sensors MQ
// Gas Sensor
void isGasSensor() {

  // Read in analog value from each gas sensors
  
  // Hydrogen Gas Sensor - MQ-8
  iMQ8Raw = analogRead( iMQ8 );

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9Raw = analogRead( iMQ9 );  

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7Raw = analogRead( iMQ7 );

  // Alcohol Gas Sensor - MQ-3
  iMQ3Raw = analogRead( iMQ3 );
  
  // Caclulate the PPM of each gas sensors

  // Hydrogen Gas Sensor - MQ-8
  iMQ8ppm = isMQ8( iMQ8Raw ); 

  // Carbon Monoxide & Flammable Gas Sensor - MQ-9
  iMQ9ppm = isMQ9( iMQ9Raw ); 

  // Carbon Monoxide Gas Sensor - MQ-7
  iMQ7ppm = isMQ7( iMQ7Raw ); 

  // Alcohol Gas Sensor - MQ-3
  iMQ3ppm = isMQ3( iMQ3Raw ); 
  
}
// Hydrogen Gas Sensor - MQ-8 - PPM
int isMQ8(double rawValue) {

  // RvRo
  double RvRo = rawValue * (3.3 / 1023);

  return (pow(4.7,( ((log(RvRo)-H2Curve[1])/H2Curve[2]) + H2Curve[0])));
  
}
// Carbon Monoxide & Flammable Gas Sensor - MQ-9
int isMQ9(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Carbon Monoxide Gas Sensor - MQ-7
int isMQ7(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double ppm = 3.027*exp(1.0698*( RvRo ));
  return ppm;
  
}
// Alcohol Gas Sensor - MQ-3
int isMQ3(double rawValue) {

  double RvRo = rawValue * 3.3 / 4095;

  double bac = RvRo * 0.21;
  return bac;
  
}

getPIR.ino

// PIR Motion
// Setup PIR
void setupPIR() {

  // Setup PIR Montion
  pinMode(iMotion, INPUT_PULLUP);
  
}
// isPIR Motion
void isPIR() {

  // Proximity
  proximity = digitalRead(iMotion);
  if (proximity == LOW) 
  {

    // PIR Motion Sensor's LOW, Motion is detected
    Det = "Motion Yes";
    
  }
  else
  {

    // PIR Motion Sensor's HIGH
    Det = "No";
    
  }
  
}

getRHT.ino

// RHT03 Humidity and Temperature Sensor
// setup RTH03 Humidity and Temperature Sensor
void setupRTH03() {

  // RHT03 Humidity and Temperature Sensor
  // Call rht.begin() to initialize the sensor and our data pin
  rht.begin(RHT03_DATA_PIN);
  
}
// RHT03 Humidity and Temperature Sensor
void isRHT03(){

  // Call rht.update() to get new humidity and temperature values from the sensor.
  int updateRet = rht.update();

  // The humidity(), tempC(), and tempF() functions can be called -- after 
  // a successful update() -- to get the last humidity and temperature value 
  latestHumidity = rht.humidity();
  latestTempC = rht.tempC();
  latestTempF = rht.tempF();
  
}

getRTC.ino

// Date & Time
// PCF8523 Precision RTC 
void setupRTC() {

  // Date & Time
  // pcf8523 Precision RTC   
  if (! rtc.begin()) {
    while (1);
  }  
  
  if (! rtc.initialized()) {
    // Following line sets the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    // rtc.adjust(DateTime(2018, 9, 29, 12, 17, 0));
  }
  
}
// Date and Time RTC
void isRTC () {

  // Date and Time
  dateRTC = "";
  timeRTC = "";
  DateTime now = rtc.now();
  
  // Date
  dateRTC = now.year(), DEC; 
  dateRTC = dateRTC + "/";
  dateRTC = dateRTC + now.month(), DEC;
  dateRTC = dateRTC + "/";
  dateRTC = dateRTC + now.day(), DEC;
  
  // Time
  timeRTC = now.hour(), DEC;
  timeRTC = timeRTC + ":";
  timeRTC = timeRTC + now.minute(), DEC;
  timeRTC = timeRTC + ":";
  timeRTC = timeRTC + now.second(), DEC;
  
}

getRot.ino

// Rotary Switch
// isRot - iRotVal - Value
void isRot() {

  // Rotary Switch
  z = analogRead( iRotNum );
  x = map(z, 0, 4095, 0, 9);
  iRotVal = map(z, 0, 4095, 0, 10);

  // Range Value
  switch ( iRotVal ) {
    case 0:

      // Display Environmental
      isDisplayEnvironmental();
      
      break;
    case 1:

      // Display Date
      isDisplayDate();
      
      break;
    case 2:

      // Display BME280
      isDisplayBME280();
      
      break;  
    case 3:

      // RHT03 Humidity and Temperature Sensor
      isDisplayRHT();
      
      break;
    case 4:

      // Display CCS811 - eCO2 & tVOC
      isDisplayCCS811();
      
      break;
    case 5:

      // Display Gas Sensors MQ
      isDisplayMQ();
      
      break;       
    case 6:

      // EMF Meter (Single Axis)
      isDisplayEMF();
      
      break; 
    case 7:
         
      // Display PIR Motion
      isDisplayPIR();
      
      break; 
    case 8:

      // Display UID
      isDisplayUID();
      
      break;
    case 9:

      // Z
      isDisplayZ();
      
      break;
  }

}

getSD.ino

// microSD Card
// microSD Setup
void setupSD() {

    // microSD Card
    pinMode( chipSelect , OUTPUT );
    if(!SD.begin( chipSelect )){
        ;  
        return;
    }
    
    uint8_t cardType = SD.cardType();

    if(cardType == CARD_NONE){
        ; 
        return;
    }

    //Serial.print("SD Card Type: ");
    if(cardType == CARD_MMC){
        ; 
    } else if(cardType == CARD_SD){
        ; 
    } else if(cardType == CARD_SDHC){
        ; 
    } else {
        ; 
    } 

    uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  
}
// microSD Card
void isSD() {

  zzzzzz = "";

  // EEPROM Unique ID|Version|Date|Time|GPS Status|Target Latitude|Target Longitude|Temperature Celsius|Humidity|Altitude Meters|Barometric Pressure|Latest Temp C|Latest Temp F|Latest Humidity|eCO2 Concentration|tVOC Concentration|H2 Gas Sensor MQ-8|CO Gas Sensor MQ-9|CO Gas Sensor MQ-7|Alcohol Gas Sensor MQ-3|EMF Meter (Single Axis)|PIR Motion
  zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + GPSStatus + "|" + TargetLat + "|" + TargetLon + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + latestTempC + "|" + latestTempF + "|" + latestHumidity + "|" + CCS811CO2 + "|" + CCS811TVOC + "|" + iMQ8ppm + "|" + iMQ9ppm + "|" + iMQ7ppm + "|" + iMQ9ppm + "|" + iMQ3ppm + "|" + averageEMF + "|" + Det + "|\r";

  char msg[zzzzzz.length() + 1];

  zzzzzz.toCharArray(msg, zzzzzz.length() + 1);

  appendFile(SD, "/espdata.txt", msg );
  
}
// List Dir
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
    
    dirname;
    
    File root = fs.open(dirname);
    
    if(!root){
        return;
    }
    
    if(!root.isDirectory()){
        return;
    }

    File file = root.openNextFile();
    
    while(file){
        if(file.isDirectory()){
            file.name();
            if(levels){
                listDir(fs, file.name(), levels -1);
            }
        } else {
            file.name();
            file.size();
        }
        file = root.openNextFile();
    }
    
}
// Write File
void writeFile(fs::FS &fs, const char * path, const char * message){
    
    path;
    
    File file = fs.open(path, FILE_WRITE);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}
// Append File
void appendFile(fs::FS &fs, const char * path, const char * message){
    
    path;
    
    File file = fs.open(path, FILE_APPEND);
    
    if(!file){
        return;
    }
    
    if(file.print(message)){
        ;  
    } else {
        ;  
    }
    
    file.close();
    
}

setup.ino

// Setup
void setup() {

  // EEPROM Size
  EEPROM.begin(EEPROM_SIZE);
  
  // EEPROM Unique ID
  isUID();
  
  // GPS Receiver
  // Setup GPS
  setupGPS();
  
  // SHARP Display Start & Clear the Display
  display.begin();
  // Clear Display
  display.clearDisplay();
  
  // Display UID
  isDisplayUID();

  // Wire - Inialize I2C Hardware
  Wire.begin();

  // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure
  myBME280.begin();
  
  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Initialize the LED Green
  pinMode(iLEDGreen, OUTPUT);

  // Date & Time RTC
  // PCF8523 Precision RTC 
  setupRTC();
  
  // Date & Time
  isRTC();
  
  // microSD Card
  setupSD();

  // Slide Switch
  pinMode(iSS1, INPUT);

  // EMF Meter (Single Axis) - Setup
  isSetupEMF();

  // RHT03 Humidity and Temperature Sensor
  // setup RTH03 Humidity and Temperature Sensor
  setupRTH03();

  // PIR Motion
  // Setup PIR
  setupPIR();

  delay( 5000 );

}

Technology Experience

  • Single-Board Microcontrollers (Arduino, Raspberry Pi,Espressif, etc…)
  • Robotics
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor

  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

The Alpha Geek

Why “The Alpha Geek”?

Aphasia
https://www.donluc.com/?page_id=2149

J. Luc Paquin – Curriculum Vitae
https://www.donluc.com/DLHackster/LucPaquinCVEngMk2020a.pdf

Web: https://www.donluc.com/
Web: http://www.jlpconsultants.com/
Web: https://www.donluc.com/DLHackster/
Web: https://www.hackster.io/neosteam-labs
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/luc.paquin/

Don Luc

Categories
Archives