EMF Meter
Project #19: Time – NeoPixel Stick – 8 – Mk11
——
#DonLucElectronics #DonLuc #Time #EMF #IMU #NeoPixel #RTC #Display #Adalogger #MicroSD #GPSReceiver #CCS811 #BME280 #Arduino #ESP32 #Project #Programming #Electronics #Microcontrollers #Consultant #VideoBlog
——
——
——
——
——
Pololu Adjustable Step-Up Voltage Regulator U1V11A
This compact U1V11A switching step-up voltage regulator efficiently boosts input voltages as low as 0.5 V to an adjustable output voltage between 2 V and 5.25 V. Unlike most boost regulators, the U1V11A offers a true shutdown option that turns off power to the load, and it automatically switches to a linear down-regulation mode when the input voltage exceeds the output. The pins have a 0.1 inch spacing, making this board compatible with standard solderless breadboards.
NeoPixel Stick – 8 x 5050 RGB LED
Make your own little LED strip arrangement with this stick of NeoPixel LEDs. We crammed 8 of the tiny 5050 (5mm x 5mm) smart RGB LEDs onto a PCB with mounting holes and a chainable design. Use only one microcontroller pin to control as many as you can chain together! Each LED is addressable as the driver chip is inside the LED. Each one has ~18mA constant current drive so the color will be very consistent even if the voltage varies, and no external choke resistors are required making the design slim. Power the whole thing with 5VDC.
DL2109Mk02
1 x SparkFun Thing Plus – ESP32 WROOM
1 x Adafruit SHARP Memory Display
1 x Adalogger FeatherWing – RTC + SD
1 x SparkFun Environmental Combo CCS811/BME280 (Qwiic)
1 x Pololu MinIMU-9
1 x Telescopic Antenna SMA – 300 MHz to 1.1 GHz (ANT700)
1 x SMA Connector
1 x NeoPixel Stick – 8 x 5050 RGB LED
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
1 x CR1220 3V Lithium Coin Cell Battery
1 x 32Gb microSD Card
1 x LED Green
1 x Rocker Switch – SPST (Round)
1 x Terminal Block Breakout FeatherWing
1 x Lithium Ion Battery – 850mAh
1 x GPS Receiver – GP-20U7
1 x Rotary Switch – 10 Position
1 x SparkFun Rotary Switch – 10 Position
1 x Black Knob
2 x Spring Terminals – PCB Mount (6-Pin)
2 x Screw Terminals 5mm Pitch (2-Pin)
2 x Breadboard Solderable
12 x 1K Ohm
1 x 3.3m Ohm
1 x FeatherWing Proto
1 x Acrylic Orange 5.75 inches x 3.75 inches x 1/8 inch
1 x Acrylic Black 5.75 inches x 3.75 inches x 1/8 inch
54 x Screw – 4-40
19 x Standoff – Metal 4-40 – 3/8″
8 x Standoff – Metal 4-40 – 1″
1 x SparkFun Cerberus USB Cable
SparkFun Thing Plus – ESP32 WROOM
NEO – Digital 15
SCK – Digital 13
MSI – Digital 12
SS0 – Digital 27
GRX – Digital 16
GTX – Digital 17
SDA – Digital 23
SDL – Digital 22
SCK – Digital 5
MSO – Digital 19
MSI – Digital 18
SS1 – Digital 33
LEG – Digital 21
SW0 – Digital 32
ROT – Analog A0
EMF – Analog A1
VIN – +3.3V
GND – GND
——
DL2109Mk02p.ino
/* ***** Don Luc Electronics © ***** Software Version Information Project #19: Time - NeoPixel Stick - 8 - Mk11 09-02 DL2109Mk02p.ino 1 x SparkFun Thing Plus - ESP32 WROOM 1 x Adafruit SHARP Memory Display 1 x Adalogger FeatherWing - RTC + SD 1 x SparkFun Environmental Combo CCS811/BME280 (Qwiic) 1 x Pololu MinIMU-9 1 x Telescopic Antenna SMA - 300 MHz to 1.1 GHz (ANT700) 1 x SMA Connector 1 x NeoPixel Stick - 8 x 5050 RGB LED 1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A 1 x CR1220 3V Lithium Coin Cell Battery 1 x 32Gb microSD Card 1 x LED Green 1 x Rocker Switch - SPST (Round) 1 x Terminal Block Breakout FeatherWing 1 x Lithium Ion Battery - 850mAh 1 x GPS Receiver - GP-20U7 1 x Rotary Switch - 10 Position 1 x SparkFun Rotary Switch – 10 Position 1 x Black Knob 2 x Spring Terminals - PCB Mount (6-Pin) 2 x Screw Terminals 5mm Pitch (2-Pin) 2 x Breadboard Solderable 12 x 1K Ohm 1 x 3.3m Ohm 1 x FeatherWing Proto 1 x Acrylic Orange 5.75 inches x 3.75 inches x 1/8 inch 1 x Acrylic Black 5.75 inches x 3.75 inches x 1/8 inch 54 x Screw - 4-40 19 x Standoff - Metal 4-40 - 3/8" 8 x Standoff - Metal 4-40 - 1" 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" // Wire #include <Wire.h> // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // Date and time RTC #include "RTClib.h" // GPS Receiver #include <TinyGPS++.h> // ESP32 Hardware Serial #include <HardwareSerial.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // SparkFun CCS811 - eCO2 & tVOC #include <SparkFunCCS811.h> // SparkFun BME280 - Humidity, Temperature, Altitude and Barometric Pressure #include <SparkFunBME280.h> // 9DoF IMU // STMicroelectronics LSM6DS33 #include <LSM6.h> // STMicroelectronics LIS3MDL #include <LIS3MDL.h> // NeoPixels #include <Adafruit_NeoPixel.h> // SHARP Memory Display #define SHARP_SCK 13 #define SHARP_MOSI 12 #define SHARP_SS 27 // Set the size of the display here, e.g. 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 // Date and Time // PCF8523 Precision RTC RTC_PCF8523 rtc; // Date String dateRTC = ""; // Time String timeRTC = ""; // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 16 // This one is unused and doesnt have a conection #define gpsTXPIN 17 // The TinyGPS++ object TinyGPSPlus gps; // Latitude float TargetLat; // Longitude float TargetLon; // GPS Date, Time, Speed, Altitude // GPS Date String TargetDat; // GPS Time String TargetTim; // GPS Speeds M/S String TargetSMS; // GPS Speeds Km/h String TargetSKH; // GPS Altitude Meters String TargetALT; // GPS Status String GPSSt = ""; // Rotary Switch - 10 Position // Number 1 => 10 int iRotNum = A0; // iRotVal - Value int iRotVal = 0; // Number int z = 0; // MicroSD Card const int chipSelect = 33; String zzzzzz = ""; // LED Green int iLEDGreen = 21; // Rocker Switch - SPST (Round) int iSS1 = 32; // State int iSS1State = 0; // SparkFun CCS811 - eCO2 & tVOC // Default I2C Address #define CCS811_ADDR 0x5B CCS811 myCCS811(CCS811_ADDR); // eCO2 float CCS811CO2 = 0; // TVOC float CCS811TVOC = 0; // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure BME280 myBME280; // Temperature Celsius float BMEtempC = 0; // Humidity float BMEhumid = 0; // Altitude Meters float BMEaltitudeM = 0; // Barometric Pressure float BMEpressure = 0; // 9DoF IMU // STMicroelectronics LSM6DS33 LSM6 imu; // // Accelerometer and Gyroscopes // Accelerometer int imuAX; int imuAY; int imuAZ; // Gyroscopes int imuGX; int imuGY; int imuGZ; // STMicroelectronics LIS3MDL LIS3MDL mag; // Magnetometer int magX; int magY; int magZ; // NeoPixels // On digital pin 15 #define PIN 15 // NeoPixels NUMPIXELS = 8 #define NUMPIXELS 8 // Pixels Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); // Red int red = 0; // Green int green = 0; // Blue int blue = 0; // Neopix int iNeo = 0; // Value int zz = 0; // EMF Meter (Single Axis) int iEMF = A1; // 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 val = 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; // Display EMF int iEMFDis = 0; int iEMFRect = 0; // Software Version Information // EEPROM Unique ID Information #define EEPROM_SIZE 64 String uid = ""; // Version String sver = "19-11"; void loop() { // Dates and Time isRTC(); // isGPS isGPS(); // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure isBME280(); // SparkFun CCS811 - eCO2 & tVOC isCCS811(); // Accelerometer and Gyroscopes isIMU(); // Magnetometer isMag(); // EMF Meter (Single Axis) isEMF(); // 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 HIGH digitalWrite(iLEDGreen, HIGH ); // MicroSD Card isSD(); } else { // iLEDGreen LOW digitalWrite(iLEDGreen, LOW ); } delay( 1000 ); }
getAccelGyro.ino
// Accelerometer and Gyroscopes // Setup IMU void setupIMU() { // Setup IMU imu.init(); // Default imu.enableDefault(); } // Accelerometer and Gyroscopes void isIMU() { // Accelerometer and Gyroscopes imu.read(); // Accelerometer x, y, z imuAX = imu.a.x; imuAY = imu.a.y; imuAZ = imu.a.z; // Gyroscopes x, y, z imuGX = imu.g.x; imuGY = imu.g.y; imuGZ = imu.g.z; }
getBME280.ino
// SparkFun BME280 - Temperature, Humidity, 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
// SHARP Memory 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,95); display.println( sver ); // EEPROM display.setCursor(0,120); display.println( "EEPROM" ); display.setCursor(0,140); display.println( uid ); // 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( "Date" ); display.setCursor(0,30); display.println( dateRTC ); // Time display.setCursor(0,55); display.println( "Time" ); display.setCursor(0,75); display.println( timeRTC ); // Refresh display.refresh(); delay( 100 ); } // Display GPS void isDisplayGPS() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // GPS Status display.setCursor(0,5); display.print( "GPS: " ); display.println( GPSSt ); // Target Latitude display.setCursor(0,25); display.println( "Latitude" ); display.setCursor(0,45); display.println( TargetLat ); // Target Longitude display.setCursor(0,65); display.println( "Longitude" ); display.setCursor(0,90); display.println( TargetLon ); // Refresh display.refresh(); delay( 100 ); } // GPS Date, Time, Speed, Altitude void isDisplayGPSDate() { // Text Display Date // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // GPS display.setCursor(0,5); display.println( "GPS" ); // Date display.setCursor(0,30); display.println( TargetDat ); // Time display.setCursor(0,55); display.println( TargetTim ); // Speed display.setCursor(0,75); display.print( "M/S: " ); display.println( TargetSMS ); display.setCursor(0,95); display.print( "Km/h: " ); display.println( TargetSKH ); display.setCursor(0,115); display.print( "Alt: " ); display.println( TargetALT ); // Refresh display.refresh(); delay( 100 ); } // Display SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure void isDisplayBME280() { // Text Display BME280 // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Temperature Celsius display.setCursor(0,5); display.println( "Temperature" ); display.setCursor(0,25); display.print( BMEtempC ); display.println( " C" ); // Humidity display.setCursor(0,45); display.println( "Humidity" ); display.setCursor(0,65); display.print( BMEhumid ); display.println( "%" ); // Altitude Meters display.setCursor(0,85); display.println( "Altitude M" ); display.setCursor(0,105); display.print( BMEaltitudeM ); display.println( " m" ); // Pressure display.setCursor(0,125); display.println( "Barometric" ); display.setCursor(0,145); 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,5); display.println( "eCO2" ); display.setCursor(0,25); display.print( CCS811CO2 ); display.println( " ppm" ); // tVOC Concentration display.setCursor(0,55); display.println( "tVOC" ); display.setCursor(0,75); display.print( CCS811TVOC ); display.println( " ppb" ); // Refresh display.refresh(); delay( 100 ); } // Display Accelerometer and Gyroscopes void isDisplayAccGyr() { // Text Display Accelerometer and Gyroscopes // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Accelerometer display.setCursor(0,5); display.println( "Accelero" ); display.setCursor(0,25); display.print( "X: " ); display.println( imuAX ); display.setCursor(0,45); display.print( "Y: " ); display.println( imuAY ); display.setCursor(0,65); display.print( "Z: " ); display.println( imuAZ ); display.setCursor(0,85); display.println( "Gyro" ); display.setCursor(0,105); display.print( "X: " ); display.println( imuGX ); display.setCursor(0,125); display.print( "Y: " ); display.println( imuGY ); display.setCursor(0,145); display.print( "Z: " ); display.println( imuGZ ); // Refresh display.refresh(); delay( 100 ); } // Display Magnetometer void isDisplayMag() { // Text Display Magnetometer // Clear Display display.clearDisplay(); display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Magnetometer display.setCursor(0,5); display.println( "Magnetometer" ); display.setCursor(0,25); display.print( "X: " ); display.println( magX ); display.setCursor(0,45); display.print( "Y: " ); display.println( magY ); display.setCursor(0,65); display.print( "Z: " ); display.println( magZ ); // 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( iEMFDis ); display.setTextSize(1); display.println( "0 1 2 3 4 5 6 7 8 9 10" ); display.setCursor(0,70); display.drawRect(0, 70, iEMFRect , display.height(), BLACK); display.fillRect(0, 70, iEMFRect , display.height(), BLACK); // 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) // EMF Meter void isEMF() { isNUMPIXELSoff(); // Probe EMF Meter for (int i = 0; i < NUMREADINGS; i++){ // Readings readings[ i ] = analogRead( iEMF ); // Average averageEMF += readings[i]; } // Calculate the average val = averageEMF / NUMREADINGS; // If the reading isn't zero, proceed if( val >= 1 ){ // Turn any reading higher than the senseLimit value into the senseLimit value val = constrain( val, 1, senseLimit ); // Remap the constrained value within a 1 to 1023 range val = map( val, 1, senseLimit, 1, 1023 ); // Subtract the last reading totalEMF -= readings[ indexEMF ]; // Read from the sensor readings[ indexEMF ] = val; // Add the reading to the total totalEMF += readings[ indexEMF ]; // Advance to the next index indexEMF = ( indexEMF + 1 ); // If the average is over 50 ... if (averageEMF > 50){ zz = 0; isNUMPIXELS(); } // If the average is over 250 ... if (averageEMF > 250){ zz = 1; isNUMPIXELS(); } // If the average is over 350 ... if (averageEMF > 350){ zz = 2; isNUMPIXELS(); } // If the average is over 500 ... if (averageEMF > 500){ zz = 3; isNUMPIXELS(); } // If the average is over 650 ... if (averageEMF > 650){ zz = 4; isNUMPIXELS(); } // If the average is over 750 ... if (averageEMF > 750){ zz = 5; isNUMPIXELS(); } // If the average is over 850 ... if (averageEMF > 850){ zz = 6; isNUMPIXELS(); } // If the average is over 950 ... if (averageEMF > 950){ zz = 7; isNUMPIXELS(); } iEMFDis = averageEMF; iEMFRect = map( averageEMF, 1, 1023, 1, 144 ); // Average averageEMF = 0; } else { // Average 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() )) { // GPS Vector Pointer Target displayInfo(); // GPS Date, Time, Speed, Altitude displayDTS(); } if (millis() > 5000 && gps.charsProcessed() < 10) { while(true); } } // GPS Vector Pointer Target void displayInfo(){ // Location if (gps.location.isValid()) { // Latitude TargetLat = gps.location.lat(); // Longitude TargetLon = gps.location.lng(); // GPS Status 2 GPSSt = "Yes"; } else { // GPS Status 0 GPSSt = "No"; } } // GPS Date, Time, Speed, Altitude void displayDTS(){ // Date TargetDat = ""; if (gps.date.isValid()) { // Date // Year TargetDat += String(gps.date.year(), DEC); TargetDat += "/"; // Month TargetDat += String(gps.date.month(), DEC); TargetDat += "/"; // Day TargetDat += String(gps.date.day(), DEC); } // Time TargetTim = ""; if (gps.time.isValid()) { // Time // Hour TargetTim += String(gps.time.hour(), DEC); TargetTim += ":"; // Minute TargetTim += String(gps.time.minute(), DEC); TargetTim += ":"; // Secound TargetTim += String(gps.time.second(), DEC); } // Speed TargetSMS = ""; TargetSKH = ""; if (gps.speed.isValid()) { // Speed // M/S int x = gps.speed.mps(); TargetSMS = String( x, DEC); // Km/h int y = gps.speed.kmph(); TargetSKH = String( y, DEC); } // Altitude TargetALT = ""; if (gps.altitude.isValid()) { // Altitude // Meters int z = gps.altitude.meters(); TargetALT = String( z, DEC); } }
getMagnetometer.ino
// Magnetometer // Setup Magnetometer void setupMag() { // Setup Magnetometer mag.init(); // Default mag.enableDefault(); } // Magnetometer void isMag() { // Magnetometer mag.read(); // Magnetometer x, y, z magX = mag.m.x; magY = mag.m.y; magZ = mag.m.z; }
getNeopix.ino
// NeoPixels // Neopix void isNeopix() { // Pixels pixels.setBrightness( 150 ); // Pixels color takes RGB values, from 0,0,0 up to 255,255,255 pixels.setPixelColor( iNeo, pixels.Color(red,green,blue) ); // This sends the updated pixel color to the hardware pixels.show(); // Delay for a period of time (in milliseconds) delay(50); } // isNUMPIXELS void isNUMPIXELS() { // Neopix Value switch ( zz ) { case 0: // NeoPixels // Green // Red red = 0; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 0; isNeopix(); break; case 1: // NeoPixels // Green // Red red = 0; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 1; isNeopix(); break; case 2: // NeoPixels // Green // Red red = 0; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 2; isNeopix(); break; case 3: // NeoPixels // Yellow // Red red = 255; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 3; isNeopix(); break; case 4: // NeoPixels // Yellow // Red red = 255; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 4; isNeopix(); break; case 5: // NeoPixels // Yellow // Red red = 255; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 5; isNeopix(); break; case 6: // NeoPixels // Yellow // Red red = 255; // Green green = 255; // Blue blue = 0; // Neopix iNeo = 6; isNeopix(); break; case 7: // NeoPixels // Red // Red red = 255; // Green green = 0; // Blue blue = 0; // Neopix iNeo = 7; isNeopix(); break; } } // isNUMPIXELSoff void isNUMPIXELSoff() { // Black Off // NeoPixels for(int y=0; y < NUMPIXELS; y++) { red = 0; // Red green = 0; // Green blue = 0; // Blue iNeo = y; // Neopix isNeopix(); } }
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(2014, 1, 21, 3, 0, 0)); // rtc.adjust(DateTime(2021, 8, 18, 8, 48, 0)); } } // Date and Time RTC PCF8523 void isRTC () { // Date and Time dateRTC = ""; timeRTC = ""; DateTime now = rtc.now(); // Date // Year dateRTC = now.year(), DEC; dateRTC = dateRTC + "/"; // Month dateRTC = dateRTC + now.month(), DEC; dateRTC = dateRTC + "/"; // Day dateRTC = dateRTC + now.day(), DEC; // Time // Hour timeRTC = now.hour(), DEC; timeRTC = timeRTC + ":"; // Minute timeRTC = timeRTC + now.minute(), DEC; timeRTC = timeRTC + ":"; // Second timeRTC = timeRTC + now.second(), DEC; }
getRot.ino
// Rotary Switch // isRot - iRotVal - Value void isRot() { // Rotary Switch z = analogRead( iRotNum ); // Rotary Switch - 10 Position // Number 1 => 10 if ( z >= 3600 ) { // Z iRotVal = 10; } else if ( z >= 3200 ) { // Z iRotVal = 9; } else if ( z >= 2700 ) { // Z iRotVal = 8; } else if ( z >= 2400 ) { // Z iRotVal = 7; } else if ( z >= 2000 ) { // Z iRotVal = 6; } else if ( z >= 1600 ) { // Z iRotVal = 5; } else if ( z >= 1200 ) { // Z iRotVal = 4; } else if ( z >= 900 ) { // Z iRotVal = 3; } else if ( z >= 500 ) { // Z iRotVal = 2; } else { // Z iRotVal = 1; } // Range Value switch ( iRotVal ) { case 1: // Display Date, Time isDisplayDate(); break; case 2: // Display GPS isDisplayGPS(); break; case 3: // GPS Date, Time, Speed, Altitude //isDisplayGPSDate(); break; case 4: // GPS Display Date, Time, Speed isDisplayGPSDate(); break; case 5: // Display SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure isDisplayBME280(); break; case 6: // Display CCS811 - eCO2 & tVOC isDisplayCCS811(); break; case 7: // Accelerometer and Gyroscopes isDisplayAccGyr(); break; case 8: // Display Magnetometer isDisplayMag(); break; case 9: // EMF Meter (Single Axis) isDisplayEMF(); break; case 10: // Display UID isDisplayUID(); break; } }
getSD.ino
// MicroSD Card // MicroSD Setup void setupSD() { // MicroSD Card pinMode( chipSelect , OUTPUT ); if(!SD.begin( chipSelect )){ ; return; } uint8_t cardType = SD.cardType(); // CARD NONE if(cardType == CARD_NONE){ ; return; } // SD Card Type if(cardType == CARD_MMC){ ; } else if(cardType == CARD_SD){ ; } else if(cardType == CARD_SDHC){ ; } else { ; } // Size uint64_t cardSize = SD.cardSize() / (1024 * 1024); } // MicroSD Card void isSD() { zzzzzz = ""; // EEPROM Unique ID|Version|Date|Time|GPS Status|Target Latitude|Target Longitude|GPS Date|GPS Time|GPS Speed M/S|GPS Speed Km/h|GPS Altitude //|Temperature Celsius|Humidity|Altitude Meters|Barometric Pressure|eCO2 Concentration|tVOC Concentration|Accelerometer X|Accelerometer Y|Accelerometer Z| //Gyroscopes X|Gyroscopes Y|Gyroscopes Z|Magnetometer X|Magnetometer Y|Magnetometer Z|EMF|\r zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + GPSSt + "|" + TargetLat + "|" + TargetLon + "|" + TargetDat + "|" + TargetTim + "|" + TargetSMS + "|" + TargetSKH + "|" + TargetALT + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + CCS811CO2 + "|" + CCS811TVOC + "|" + imuAX + "|" + imuAY + "|" + imuAZ + "|" + imuGX + "|" + imuGY + "|" + imuGZ + "|" + magX + "|" + magY + "|" + magZ + "|" + iEMFDis + "|\r"; // msg + 1 char msg[zzzzzz.length() + 1]; zzzzzz.toCharArray(msg, zzzzzz.length() + 1); // Append File appendFile(SD, "/espdata.txt", msg ); } // List Dir void listDir(fs::FS &fs, const char * dirname, uint8_t levels){ // List Dir 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){ // Write File 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){ // Append File 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(); // NeoPixels // This initializes the NeoPixel library pixels.begin(); // GPS Receiver // Setup GPS setupGPS(); // Set up I2C bus Wire.begin(); // SparkFun BME280 - Temperature, Humidity, Altitude and Barometric Pressure myBME280.begin(); // CCS811 - eCO2 & tVOC myCCS811.begin(); // SHARP Display Start & Clear the Display display.begin(); // Clear Display display.clearDisplay(); // Date & Time RTC // PCF8523 Precision RTC isDisplayUID(); // Setup RTC setupRTC(); //MicroSD Card setupSD(); // Setup IMU setupIMU(); // Setup Magnetometer setupMag(); // NeoPixels // isNUMPIXELS Off isNUMPIXELSoff(); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // Slide Switch pinMode(iSS1, INPUT); 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
- 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
- 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/CV/LucPaquinCVEngMk2021c.pdf
https://www.jlpconsultants.com/CV/LucPaquinCVEspMk2021c.pdf
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 – PIR Motion Sensor – Mk12
——
#DonLuc #Environment #ESP32 #MQ #GPS #EMF #PIR #SparkFun #Adafruit #Pololu #Fritzing #Programming #Arduino #Consultant #Electronics #Microcontrollers #Vlog #Aphasia
——
——
——
——
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
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 – Humidity and Temperature Sensor – RHT03 – Mk11
——
#DonLuc #Environment #ESP32 #MQ #GPS #EMF #SparkFun #Adafruit #Pololu #Fritzing #Programming #Arduino #Consultant #Electronics #Microcontrollers #Vlog #Aphasia
——
——
——
——
Humidity and Temperature Sensor – RHT03
SparkFun Item: SEN-10167
The RHT03 is a low cost humidity and temperature sensor with a single wire digital interface. The sensor is calibrated and doesn’t require extra components so you can get right to measuring relative humidity and temperature.
DL2006Mk01
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 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
10 x Jumper Wires 3in M/M
12 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
VIN – +3.3V
GND – GND
DL2006Mk01p.ino
// ***** Don Luc Electronics © ***** // Software Version Information // Project #15: Environment - Humidity and Temperature Sensor - RHT03 - Mk11 // 06-01 // DL2006Mk01p.ino 15-11 // 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 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 // 10 x Jumper Wires 3in M/M // 12 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; // Software Version Information String sver = "15-11"; // 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(); // 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 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; }
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 UID isDisplayUID(); break; case 8: // Z isDisplayZ(); 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) zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + GPSStatus + "|" + TargetLat + "|" + TargetLon + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + latestTempC + "|" + latestTempF + "|" + latestHumidity + "|" + CCS811CO2 + "|" + CCS811TVOC + "|" + iMQ8ppm + "|" + iMQ9ppm + "|" + iMQ7ppm + "|" + iMQ9ppm + "|" + iMQ3ppm + "|" + averageEMF + "|\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(); 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
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 – EMF Meters – Mk10
——
#DonLuc #Environment #Microcontrollers #EMF #ESP32 #MQ #GPS #SparkFun #Adafruit #Pololu #Fritzing #Programming #Arduino #Electronics #Consultant #Vlog #Aphasia
——
——
——
——
DL2005Mk012
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 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
10 x Jumper Wires 3in M/M
10 x Jumper Wires 6in M/M
18 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
VIN – +3.3V
GND – GND
DL2005Mk12p.ino
// ***** Don Luc Electronics © ***** // Software Version Information // Project #15: Environment - EMF Meters - Mk10 // 05-12 // DL2005Mk12p.ino 15-10 // 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 Pololu Carbon Monoxide & Flammable Gas Sensor - MQ-9 // 1 x SparkFun Hydrogen Gas Sensor - MQ-8 // 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 Qwiic Cable - 100mm // 1 x LED Green // 11 x 1K Ohm // 1 x 4.7K Ohm // 1 x 10K Ohm // 1 x 20K Ohm // 1 x 200k Ohm // 1 x 3.3m Ohm // 10 x Jumper Wires 3in M/M // 10 x Jumper Wires 6in M/M // 18 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> // 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; // Software Version Information String sver = "15-10"; // 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(); // 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 Sensors" ); display.setCursor(0,30); display.println( "Gas H2 MQ8" ); display.setCursor(0,50); display.print( iMQ8ppm ); display.println( " ppm" ); display.setCursor(0,70); display.println( "Gas CO MQ9" ); display.setCursor(0,90); display.print( iMQ9ppm ); display.println( " ppm" ); display.setCursor(0,110); display.println( "Gas CO MQ7" ); display.setCursor(0,130); display.print( iMQ7ppm ); display.println( " ppm" ); display.setCursor(0,150); display.println( "BAC MQ3" ); display.setCursor(0,170); 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 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; }
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: // Display CCS811 - eCO2 & tVOC isDisplayCCS811(); break; case 4: // Display Gas Sensors MQ isDisplayMQ(); break; case 5: // EMF Meter (Single Axis) isDisplayEMF(); break; case 6: // Display UID isDisplayUID(); break; case 7: // Z isDisplayZ(); break; case 8: // Z isDisplayZ(); 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|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) zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + GPSStatus + "|" + TargetLat + "|" + TargetLon + "|" + BMEtempC + "|" + BMEhumid + "|" + BMEaltitudeM + "|" + BMEpressure + "|" + CCS811CO2 + "|" + CCS811TVOC + "|" + iMQ8ppm + "|" + iMQ9ppm + "|" + iMQ7ppm + "|" + iMQ9ppm + "|" + iMQ3ppm + "|" + averageEMF + "|\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(); delay( 5000 ); }
Technology Experience
- 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
- DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
- Linux-Apache-PHP-MySQL
- Robotics
- Arduino
- Raspberry Pi
- Espressif
Follow Us
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 #14: Components – EMF Meters – Mk19
——
#DonLuc #Electronics #Components #EMF #Microcontrollers #Environment #SparkFun #Consultant #Vlog #Aphasia
——
——
——
Telescopic Antenna SMA – 300 MHz to 1.1 GHz (ANT700)
SparkFun Item: WRL-13982
This ANT700 is a telescopic antenna designed for operation from 300 MHz to 1.1 GHz with a total length that is configurable from 9.5 cm to 24.5 cm. Each ANT700 is constructed of stainless steel and features an SMA male connector, rotating shaft, and adjustable elbow.
SMA Connector
SparkFun Item: WRL-00593
PCB edge mount – SMA RF connector. Perfect for prototyping with the GPS and Cellular devices that require an antenna connection. These connectors have a female signal pin and will correctly mate with the original SMA type antennas.
EMF Meter
An EMF meter is a scientific instrument for measuring electromagnetic fields. Most meters measure the electromagnetic radiation flux density or the change in an electromagnetic field over time, essentially the same as a radio antenna, but with quite different detection characteristics. Single axis meters are cheaper than tri-axis meters, but take longer to complete a survey because the meter only measures one dimension of the field. Single axis instruments have to be tilted and turned on all three axes to obtain a full measurement.
1 x Antenna SMA
1 x SMA Connector
1 x 3.3M Ohm
Technology Experience
- 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
- DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
- Linux-Apache-PHP-MySQL
- Robotics
- Arduino
- Raspberry Pi
- Espressif
Follow Us
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 #11: ESP32 Feather – PIR Motion Sensor – Mk11
PIR Motion Sensor
——
——
——
——
——
——
PIR Motion Sensor
Passive infrared (PIR) sensors are motion-detecting devices used in security systems across the world, even though you may not see them, they probably see you.
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.
Pololu Adjustable Boost Regulator 2.5-9.5V
This powerful, adjustable boost regulator can generate an output voltage as high as 9.5 V from an input voltage as low as 1.5 V, all in a compact, 0.42″ x 0.88″ x 0.23″ package. A trimmer potentiometer lets you set the boost regulator’s output voltage to a value between 2.5 and 9.5 V.
DL1911Mk02
1 x Adafruit HUZZAH32 ESP32 Feather
1 x Adafruit SHARP Memory Display
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x CR1220 12mm Lithium Battery
1 x 8Gb Micro SD Card
1 x RHT03 Humidity and Temperature Sensor
1 x GPS Receiver GP-20U
1 x LED Green
1 x Rocker Switches
1 x 100 Ohm
1 x 10K Ohm
1 x 3.3M Ohm
1 x Antenna
1 x Lithium Ion Battery – 2.5Ah
1 x PIR Motion Sensor
1 x Pololu Adjustable Boost Regulator 2.5-9.5V
1 x LED Green 1
14 x Jumper Wires 3″ M/M
10 x Jumper Wires 6″ M/M
2 x Wire
1 x Full-Size Breadboard
2 x Breadboard
1 x SparkFun Cerberus USB Cable
Adafruit HUZZAH32 ESP32 Feather
LG0 – Digital 21
RO1 – Digital 16
RHT – Digital 17
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
GPS – Digital 4
EMF – Analog A0
BAT – Analog A13
MOT – Digital 32
LG1 – Digital 14
GND – GND
VIN – +3.3V
DL1911Mk02.ino
// ***** Don Luc Electronics ***** // Software Version Information // Project #11: HUZZAH32 ESP32 Feather - PIR Motion - Mk11 // 11-02 // DL1911Mk02p.ino 11-11 // Adafruit HUZZAH32 ESP32 Feather Board // SHARP Display // LED Green // Adalogger FeatherWing - RTC + SD // EEPROM // RHT03 Humidity and Temperature Sensor // Rocker Switches // GPS Receiver // EMF Meter (Single Axis) // Lithium Ion Battery - 2.5Ah // PIR Motion // Pololu Adjustable Boost Regulator 2.5-9.5V // LED Green 1 // include Library Code // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // Date and Time #include "RTClib.h" // EEPROM library to read EEPROM with unique ID for unit #include "EEPROM.h" // RHT Humidity and Temperature Sensor #include <SparkFun_RHT03.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // GPS Receiver #include <TinyGPS++.h> #include <HardwareSerial.h> // 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, e.g. 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 int minorHalfSize; // 1/2 of lesser of display width or height // LED Green int iLEDGreen = 21; // LED Green // PCF8523 Precision RTC RTC_PCF8523 rtc; String dateRTC = ""; String timeRTC = ""; // RHT Humidity and Temperature Sensor const int RHT03_DATA_PIN = 17; // RHT03 data pin Digital 17 RHT03 rht; // This creates a RTH03 object, which we'll use to interact with the sensor float latestHumidity; float latestTempC; float latestTempF; // SD Card const int chipSelect = 33; // SD Card String zzzzzz = ""; // Rocker Switches int iRow1 = 16; // Rocker Switches Digital 16 int iRow1State = 0; // Variable for reading the pushbutton status // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 4 #define gpsTXPIN 36 // This one is unused and doesnt have a conection // The TinyGPS++ object TinyGPSPlus gps; float TargetLat; float TargetLon; int Status = 0; // EMF Meter (Single Axis) #define NUMREADINGS 15 // Raise this number to increase data smoothing int senseLimit = 15; // Raise this number to decrease sensitivity (up to 1023 max) int val = 0; // Val int iEMF = A0; // EMF Meter int readings[ NUMREADINGS ]; // Readings from the analog input int ind = 0; // Index of the current reading int total = 0; // Running total int average = 0; // Final average of the probe reading int iEMFDis = 0; int iEMFRect = 0; // LiPo Battery const int bat = A13; // LiPo Battery uint16_t vbat = 0; int iBat = 0; // PIR Motion const int iMotion = 32; // Motion detector const int iLEDGreen1 = 14; // LED Green 1 int proximity = LOW; // Proximity String Det = ""; // The current address in the EEPROM (i.e. which byte // we're going to read to next) #define EEPROM_SIZE 64 String sver = "11-2.p"; // Unit ID information String uid = ""; void loop() { // 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); } // Date and Time isRTC(); // RHT03 Humidity and Temperature Sensor isRHT03(); // SHARP Memory Display On isDisplayOn(); // Rocker Switched // Read the state of the iRow1 value iRow1State = digitalRead(iRow1); // EMF Meter (Single Axis) isEMF(); // LiPo Battery isBattery(); // isPIR Motion isPIR(); // Check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (iRow1State == HIGH) { // iLEDGreen digitalWrite(iLEDGreen, HIGH ); // SD Card isSD(); } else { // iLEDGreen digitalWrite(iLEDGreen, LOW ); } // Delay delay( 1000 ); }
getBattery.ino
// LiPo Battery void isBattery() { // Battery vbat = analogRead(bat); vbat = vbat / 2; iBat = map( vbat, 1, 1064, 1, 100); }
getDisplay.ino
// SHARP Memory Display On void isDisplayOn() { // Clear Display display.clearDisplay(); // Text display date, time, LED on, Etc... display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // Date display.setCursor(0,1); display.println( dateRTC ); // Time display.setCursor(0,17); display.println( timeRTC ); // Longitude display.setCursor(0,35); display.print("Lon: "); display.println( TargetLon ); // Latitude display.setCursor(0,55); display.print("Lat: "); display.println( TargetLat ); // Humidity display.setCursor(0,74); display.print("Hum: "); display.print( latestHumidity ); display.println("%"); // Temp C display.setCursor(0,94); display.print("Cel: "); display.print( latestTempC ); display.println("*C"); // EMF Meter display.setCursor(0,114); display.print("EMF: "); display.println( iEMFDis ); // Battery display.setCursor(0,134); display.print("Bat: "); display.print( iBat ); display.println( "%" ); // PIR Motion display.println( Det ); display.setCursor(0,154); // Refresh display.refresh(); } // SHARP Memory Display - UID void isDisplayUID() { // Clear Display display.clearDisplay(); // text display EEPROM display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); // EEPROM with Unique ID display.setCursor(0,20); display.print( "UID: " ); display.println( uid ); // Version display.setCursor(0,45); display.print( "VER: "); display.println( sver ); // Refresh display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM void GetUID() { // Get unit ID uid = ""; for (int x = 0; x < 5; x++) { uid = uid + char(EEPROM.read(x)); } }
getEMF.ino
// EMF Meter (Single Axis) // setupEMF void setupEMF() { // EMF Meter (Single Axis) pinMode( iEMF, OUTPUT ); // EMF Meter for (int i = 0; i < NUMREADINGS; i++){ readings[ i ] = 0; // Initialize all the readings to 0 } } // isEMF void isEMF(){ // Probe val = analogRead( iEMF ); // Take a reading from the probe if( val >= 1 ){ // If the reading isn't zero, proceed val = constrain( val, 1, senseLimit ); // Turn any reading higher than the senseLimit value into the senseLimit value val = map( val, 1, senseLimit, 1, 1023 ); // Remap the constrained value within a 1 to 1023 range total -= readings[ ind ]; // Subtract the last reading readings[ ind ] = val; // Read from the sensor total += readings[ ind ]; // Add the reading to the total ind = ( ind + 1 ); // Advance to the next index if ( ind >= NUMREADINGS ) { // If we're at the end of the array... ind = 0; // ...wrap around to the beginning } average = total / NUMREADINGS; // Calculate the average // average = val; } else { iEMFRect = 0; val = 0; average = 0; } iEMFDis = average; iEMFRect = map( average, 1, 1023, 1, 144 ); }
getGPS.ino
// GPS Receiver void setupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1, gpsRXPIN, gpsTXPIN ); } // GPS Vector Pointer Target void displayInfo() { // Location if (gps.location.isValid()) { TargetLat = gps.location.lat(); TargetLon = gps.location.lng(); Status = 2; } else { Status = 0; } }
getPIR.ino
// PIR Motion void setupPIR() { // Setup PIR Montion pinMode(iMotion, INPUT_PULLUP); pinMode(iLEDGreen1, OUTPUT); } // isPIR Motion void isPIR() { // Proximity proximity = digitalRead(iMotion); if (proximity == LOW) { // PIR Motion Sensor's LOW, Motion is detected // LED Green 1 - HIGH digitalWrite(iLEDGreen1, HIGH); Det = "Motion!"; } else { // PIR Motion Sensor's HIGH // LED Green 1 - LOW digitalWrite(iLEDGreen1, LOW); Det = "****"; } }
getRHT.ino
// 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(); }
getRTCpcf8523.ino
// PCF8523 Precision RTC void setupRTC() { // 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 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; }
getSD.ino
// SD Card void setupSD() { // SD 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); } // SD Card void isSD() { zzzzzz = ""; zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + Status + "|" + TargetLon + "|" + TargetLat + "|" + latestHumidity + "|" + latestTempC + "|" + latestTempF + "|" + average + "|" + iBat + "|" + 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){ //Serial.printf("Appending to file: %s\n", path); path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // EEPROM with Unique ID EEPROM.begin(EEPROM_SIZE); // Get Unit ID GetUID(); // GPS Receiver // Setup GPS setupGPS(); // SHARP Display start & clear the display display.begin(); display.clearDisplay(); isDisplayUID(); delay( 5000 ); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // PCF8523 Precision RTC setupRTC(); // Date and Time RTC isRTC(); // RHT03 Humidity and Temperature Sensor // Call rht.begin() to initialize the sensor and our data pin rht.begin(RHT03_DATA_PIN); // SD Card setupSD(); // Rocker Switches pinMode(iRow1, INPUT); // EMF Meter (Single Axis) setupEMF(); // PIR Motion setupPIR(); }
Follow Us
Web: https://www.donluc.com/
Web: http://neosteamlabs.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Project #11: ESP32 Feather – LiPo 2.5Ah – Mk10
——
——
——
——
——
Lithium Ion Battery – 2.5Ah
These are very slim, extremely light weight batteries based on Lithium Ion chemistry. Each cell outputs a nominal 3.7V at 2500mAh. Comes terminated with a standard 2-pin JST-PH connector – 2mm spacing between pins. These batteries require special charging. Do not attempt to charge these with anything but a specialized Lithium Polymer charger.
DL1911Mk01
1 x Adafruit HUZZAH32 ESP32 Feather
1 x Adafruit SHARP Memory Display
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x CR1220 12mm Lithium Battery
1 x 8Gb Micro SD Card
1 x RHT03 Humidity and Temperature Sensor
1 x GPS Receiver GP-20U
1 x LED Green
1 x Rocker Switches
1 x 100 Ohm
1 x 10K Ohm
1 x 3.3M Ohm
1 x Antenna
1 x Lithium Ion Battery – 2.5Ah
14 x Jumper Wires 3″ M/M
6 x Jumper Wires 6″ M/M
2 x Wire
1 x Full-Size Breadboard
1 x Breadboard
1 x SparkFun Cerberus USB Cable
Adafruit HUZZAH32 ESP32 Feather
LG1 – Digital 21
RO1 – Digital 16
RHT – Digital 17
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
GPS – Digital 4
EMF – Analog A0
BAT – Analog A13
GND – GND
VIN – +3.3V
DL1911Mk01.ino
// ***** Don Luc Electronics ***** // Software Version Information // Project #11: HUZZAH32 ESP32 Feather - LiPo 2.5Ah - Mk10 // 11-01 // DL1911Mk01p.ino 11-10 // Adafruit HUZZAH32 ESP32 Feather Board // SHARP Display // LED Green // Adalogger FeatherWing - RTC + SD // EEPROM // RHT03 Humidity and Temperature Sensor // Rocker Switches // GPS Receiver // EMF Meter (Single Axis) // Lithium Ion Battery - 2.5Ah // include Library Code // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // Date and Time #include "RTClib.h" // EEPROM library to read EEPROM with unique ID for unit #include "EEPROM.h" // RHT Humidity and Temperature Sensor #include <SparkFun_RHT03.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // GPS Receiver #include <TinyGPS++.h> #include <HardwareSerial.h> // 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, e.g. 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 int minorHalfSize; // 1/2 of lesser of display width or height // LED Green int iLEDGreen = 21; // LED Green // PCF8523 Precision RTC RTC_PCF8523 rtc; String dateRTC = ""; String timeRTC = ""; // RHT Humidity and Temperature Sensor const int RHT03_DATA_PIN = 17; // RHT03 data pin Digital 17 RHT03 rht; // This creates a RTH03 object, which we'll use to interact with the sensor float latestHumidity; float latestTempC; float latestTempF; // SD Card const int chipSelect = 33; // SD Card String zzzzzz = ""; // Rocker Switches int iRow1 = 16; // Rocker Switches Digital 16 int iRow1State = 0; // Variable for reading the pushbutton status // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 4 #define gpsTXPIN 36 // This one is unused and doesnt have a conection // The TinyGPS++ object TinyGPSPlus gps; float TargetLat; float TargetLon; int Status = 0; // EMF Meter (Single Axis) #define NUMREADINGS 15 // Raise this number to increase data smoothing int senseLimit = 15; // Raise this number to decrease sensitivity (up to 1023 max) int val = 0; // Val int iEMF = A0; // EMF Meter int readings[ NUMREADINGS ]; // Readings from the analog input int ind = 0; // Index of the current reading int total = 0; // Running total int average = 0; // Final average of the probe reading int iEMFDis = 0; int iEMFRect = 0; // LiPo Battery const int bat = A13; // LiPo Battery uint16_t vbat = 0; int iBat = 0; // The current address in the EEPROM (i.e. which byte // we're going to read to next) #define EEPROM_SIZE 64 String sver = "11-1.p"; // Unit ID information String uid = ""; void loop() { // 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); } // Date and Time isRTC(); // RHT03 Humidity and Temperature Sensor isRHT03(); // SHARP Memory Display On isDisplayOn(); // Rocker Switched // Read the state of the iRow1 value iRow1State = digitalRead(iRow1); // EMF Meter (Single Axis) isEMF(); // LiPo Battery isBattery(); // Check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (iRow1State == HIGH) { // iLEDGreen digitalWrite(iLEDGreen, HIGH ); // SD Card isSD(); } else { // iLEDGreen digitalWrite(iLEDGreen, LOW ); } // Delay delay( 1000 ); }
getBattery.ino
// LiPo Battery void isBattery() { // Battery vbat = analogRead(bat); vbat = vbat / 2; iBat = map( vbat, 1, 1064, 1, 100); }
getDisplay.ino
// SHARP Memory Display On void isDisplayOn() { // Clear Display display.clearDisplay(); // text display date, time, LED on display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); display.setCursor(0,1); display.println( dateRTC ); display.setCursor(0,17); display.println( timeRTC ); display.setCursor(0,35); display.print("Lon: "); display.println( TargetLon ); display.setCursor(0,55); display.print("Lat: "); display.println( TargetLat ); display.setCursor(0,74); display.print("Hum: "); display.print( latestHumidity ); display.println("%"); display.setCursor(0,94); display.print("Cel: "); display.print( latestTempC ); display.println("*C"); display.setCursor(0,114); display.print("EMF: "); display.println( iEMFDis ); display.setCursor(0,134); display.print("Bat: "); display.print( iBat ); display.println( "%" ); display.refresh(); } // SHARP Memory Display - UID void isDisplayUID() { // text display EEPROM display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); display.setCursor(0,20); display.print( "UID: " ); display.println( uid ); // display.setTextSize(); display.setTextColor(BLACK); display.setCursor(0,45); display.print( "VER: "); display.println( sver ); display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM void GetUID() { // Get unit ID uid = ""; for (int x = 0; x < 5; x++) { uid = uid + char(EEPROM.read(x)); } }
getEMF.ino
// EMF Meter (Single Axis) // setupEMF void setupEMF() { // EMF Meter (Single Axis) pinMode( iEMF, OUTPUT ); // EMF Meter for (int i = 0; i < NUMREADINGS; i++){ readings[ i ] = 0; // Initialize all the readings to 0 } } // isEMF void isEMF(){ // Probe val = analogRead( iEMF ); // Take a reading from the probe if( val >= 1 ){ // If the reading isn't zero, proceed val = constrain( val, 1, senseLimit ); // Turn any reading higher than the senseLimit value into the senseLimit value val = map( val, 1, senseLimit, 1, 1023 ); // Remap the constrained value within a 1 to 1023 range total -= readings[ ind ]; // Subtract the last reading readings[ ind ] = val; // Read from the sensor total += readings[ ind ]; // Add the reading to the total ind = ( ind + 1 ); // Advance to the next index if ( ind >= NUMREADINGS ) { // If we're at the end of the array... ind = 0; // ...wrap around to the beginning } average = total / NUMREADINGS; // Calculate the average // average = val; } else { iEMFRect = 0; val = 0; average = 0; } iEMFDis = average; iEMFRect = map( average, 1, 1023, 1, 144 ); }
getGPS.ino
// GPS Receiver void setupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1, gpsRXPIN, gpsTXPIN ); } // GPS Vector Pointer Target void displayInfo() { // Location if (gps.location.isValid()) { TargetLat = gps.location.lat(); TargetLon = gps.location.lng(); Status = 2; } else { Status = 0; } }
getRHT.ino
// 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(); }
getRTCpcf8523.ino
// PCF8523 Precision RTC void setupRTC() { // 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 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; }
getSD.ino
// SD Card void setupSD() { // SD 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); } // SD Card void isSD() { zzzzzz = ""; zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + Status + "|" + TargetLon + "|" + TargetLat + "|" + latestHumidity + "|" + latestTempC + "|" + latestTempF + "|" + average + "|\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){ //Serial.printf("Appending to file: %s\n", path); path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // EEPROM with unique ID EEPROM.begin(EEPROM_SIZE); // Get Unit ID GetUID(); // GPS Receiver // Setup GPS setupGPS(); // SHARP Display start & clear the display display.begin(); display.clearDisplay(); isDisplayUID(); delay( 5000 ); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // PCF8523 Precision RTC setupRTC(); // Date and Time RTC isRTC(); // RHT03 Humidity and Temperature Sensor // Call rht.begin() to initialize the sensor and our data pin rht.begin(RHT03_DATA_PIN); // SD Card setupSD(); // Rocker Switches pinMode(iRow1, INPUT); // EMF Meter (Single Axis) setupEMF(); }
Follow Us
Web: https://www.donluc.com/
Web: http://neosteamlabs.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc
Project #11: ESP32 Feather – EMF Meter – Mk09
——
——
——
——
EMF Meter
EMF measurements are measurements of ambient electromagnetic fields that are performed using particular sensors or probes, such as EMF meters. These probes can be generally considered as antennas although with different characteristics. In fact probes should not perturb the electromagnetic field and must prevent coupling and reflection as much as possible in order to obtain precise results.
EMF probes may respond to fields only on one axis. Amplified, active, probes can improve measurement precision and sensitivity but their active components may limit their speed of response.
DL1910Mk01
1 x Adafruit HUZZAH32 ESP32 Feather
1 x Adafruit SHARP Memory Display
1 x Adafruit Adalogger FeatherWing – RTC + SD
1 x CR1220 12mm Lithium Battery
1 x 8Gb Micro SD Card
1 x RHT03 Humidity and Temperature Sensor
1 x GPS Receiver GP-20U
1 x LED Green
1 x Rocker Switches
1 x 100 Ohm
1 x 10K Ohm
1 x 3.3M Ohm
1 x Antenna
14 x Jumper Wires 3″ M/M
6 x Jumper Wires 6″ M/M
2 x Wire
1 x Full-Size Breadboard
1 x Breadboard
1 x SparkFun Cerberus USB Cable
Adafruit HUZZAH32 ESP32 Feather
LG1 – Digital 21
RO1 – Digital 16
RHT – Digital 17
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
GPS – Digital 4
EMF – Analog A0
GND – GND
VIN – +3.3V
DL1910Mk01.ino
// ***** Don Luc Electronics ***** // Software Version Information // Project #11: HUZZAH32 ESP32 Feather - EMF - Mk09 // 10-01 // DL1910Mk01p.ino 11-09 // Adafruit HUZZAH32 ESP32 Feather Board // SHARP Display // LED Green // Adalogger FeatherWing - RTC + SD // EEPROM // RHT03 Humidity and Temperature Sensor // Rocker Switches // GPS Receiver // EMF Meter (Single Axis) // include Library Code // SHARP Memory Display #include <Adafruit_SharpMem.h> #include <Adafruit_GFX.h> // Date and Time #include "RTClib.h" // EEPROM library to read EEPROM with unique ID for unit #include "EEPROM.h" // RHT Humidity and Temperature Sensor #include <SparkFun_RHT03.h> // SD Card #include "FS.h" #include "SD.h" #include "SPI.h" // GPS Receiver #include <TinyGPS++.h> #include <HardwareSerial.h> // 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, e.g. 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 int minorHalfSize; // 1/2 of lesser of display width or height // LED Green int iLEDGreen = 21; // LED Green // PCF8523 Precision RTC RTC_PCF8523 rtc; String dateRTC = ""; String timeRTC = ""; // RHT Humidity and Temperature Sensor const int RHT03_DATA_PIN = 17; // RHT03 data pin Digital 17 RHT03 rht; // This creates a RTH03 object, which we'll use to interact with the sensor float latestHumidity; float latestTempC; float latestTempF; // SD Card const int chipSelect = 33; // SD Card String zzzzzz = ""; // Rocker Switches int iRow1 = 16; // Rocker Switches Digital 16 int iRow1State = 0; // Variable for reading the pushbutton status // ESP32 HardwareSerial HardwareSerial tGPS(2); // GPS Receiver #define gpsRXPIN 4 #define gpsTXPIN 36 // This one is unused and doesnt have a conection // The TinyGPS++ object TinyGPSPlus gps; float TargetLat; float TargetLon; int Status = 0; // EMF Meter (Single Axis) #define NUMREADINGS 15 // Raise this number to increase data smoothing int senseLimit = 15; // Raise this number to decrease sensitivity (up to 1023 max) int val = 0; // Val int iEMF = A0; // EMF Meter int readings[ NUMREADINGS ]; // Readings from the analog input int ind = 0; // Index of the current reading int total = 0; // Running total int average = 0; // Final average of the probe reading int iEMFDis = 0; int iEMFRect = 0; // The current address in the EEPROM (i.e. which byte // we're going to read to next) #define EEPROM_SIZE 64 String sver = "10-1.p"; // Unit ID information String uid = ""; void loop() { // 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); } // Date and Time isRTC(); // RHT03 Humidity and Temperature Sensor isRHT03(); // SHARP Memory Display On isDisplayOn(); // Rocker Switched // Read the state of the iRow1 value iRow1State = digitalRead(iRow1); // EMF Meter (Single Axis) isEMF(); // Check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (iRow1State == HIGH) { // iLEDGreen digitalWrite(iLEDGreen, HIGH ); // SD Card isSD(); } else { // iLEDGreen digitalWrite(iLEDGreen, LOW ); } // Delay delay( 1000 ); }
getDisplay.ino
// SHARP Memory Display On void isDisplayOn() { // Clear Display display.clearDisplay(); // text display date, time, LED on display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); display.setCursor(0,1); display.println( dateRTC ); display.setCursor(0,17); display.println( timeRTC ); //display.setTextSize(2); display.setCursor(0,35); display.print("Lon: "); display.println( TargetLon ); display.setCursor(0,55); display.print("Lat: "); display.println( TargetLat ); display.setCursor(0,74); display.print("Hum: "); display.print( latestHumidity ); display.println("%"); display.setCursor(0,94); display.print("Cel: "); display.print( latestTempC ); display.println("*C"); display.setCursor(0,114); display.print("EMF: "); display.println( iEMFDis ); display.setCursor(0,134); display.setTextSize(1); display.println( "0 1 2 3 4 5 6 7 8 9 10" ); display.setCursor(0,144); display.drawRect(0, 144, iEMFRect , display.height(), BLACK); display.fillRect(0, 144, iEMFRect , display.height(), BLACK); display.refresh(); } // SHARP Memory Display - UID void isDisplayUID() { // text display EEPROM display.setRotation(4); display.setTextSize(2); display.setTextColor(BLACK); display.setCursor(0,20); display.print( "UID: " ); display.println( uid ); // display.setTextSize(); display.setTextColor(BLACK); display.setCursor(0,45); display.print( "VER: "); display.println( sver ); display.refresh(); delay( 100 ); }
getEEPROM.ino
// EEPROM void GetUID() { // Get unit ID uid = ""; for (int x = 0; x < 5; x++) { uid = uid + char(EEPROM.read(x)); } }
getEMF.ino
// EMF Meter (Single Axis) // setupEMF void setupEMF() { // EMF Meter (Single Axis) pinMode( iEMF, OUTPUT ); // EMF Meter for (int i = 0; i < NUMREADINGS; i++){ readings[ i ] = 0; // Initialize all the readings to 0 } } // isEMF void isEMF(){ // Probe val = analogRead( iEMF ); // Take a reading from the probe if( val >= 1 ){ // If the reading isn't zero, proceed val = constrain( val, 1, senseLimit ); // Turn any reading higher than the senseLimit value into the senseLimit value val = map( val, 1, senseLimit, 1, 1023 ); // Remap the constrained value within a 1 to 1023 range total -= readings[ ind ]; // Subtract the last reading readings[ ind ] = val; // Read from the sensor total += readings[ ind ]; // Add the reading to the total ind = ( ind + 1 ); // Advance to the next index if ( ind >= NUMREADINGS ) { // If we're at the end of the array... ind = 0; // ...wrap around to the beginning } average = total / NUMREADINGS; // Calculate the average } else { iEMFRect = 0; val = 0; average = 0; } iEMFDis = average; iEMFRect = map( average, 1, 1023, 1, 144 ); }
getGPS.ino
// GPS Receiver void setupGPS() { // Setup GPS tGPS.begin( 9600 , SERIAL_8N1, gpsRXPIN, gpsTXPIN ); } // GPS Vector Pointer Target void displayInfo() { // Location if (gps.location.isValid()) { TargetLat = gps.location.lat(); TargetLon = gps.location.lng(); Status = 2; } else { Status = 0; } }
getRHT.ino
// 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(); }
getRTCpcf8523.ino
// PCF8523 Precision RTC void setupRTC() { // 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 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; }
getSD.ino
// SD Card void setupSD() { // SD 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); } // SD Card void isSD() { zzzzzz = ""; zzzzzz = uid + "|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + Status + "|" + TargetLon + "|" + TargetLat + "|" + latestHumidity + "|" + latestTempC + "|" + latestTempF + "|" + average + "|\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){ //Serial.printf("Appending to file: %s\n", path); path; File file = fs.open(path, FILE_APPEND); if(!file){ return; } if(file.print(message)){ ; } else { ; } file.close(); }
setup.ino
// Setup void setup() { // EEPROM with unique ID EEPROM.begin(EEPROM_SIZE); // Get Unit ID GetUID(); // GPS Receiver // Setup GPS setupGPS(); // SHARP Display start & clear the display display.begin(); display.clearDisplay(); isDisplayUID(); delay( 5000 ); // Initialize the LED Green pinMode(iLEDGreen, OUTPUT); // PCF8523 Precision RTC setupRTC(); // Date and Time RTC isRTC(); // RHT03 Humidity and Temperature Sensor // Call rht.begin() to initialize the sensor and our data pin rht.begin(RHT03_DATA_PIN); // SD Card setupSD(); // Rocker Switches pinMode(iRow1, INPUT); // EMF Meter (Single Axis) setupEMF(); }
Follow Us
Web: https://www.donluc.com/
Web: http://neosteamlabs.com/
Web: http://www.jlpconsultants.com/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Facebook: https://www.facebook.com/neosteam.labs.9/
Instagram: https://www.instagram.com/neosteamlabs/
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Twitter: https://twitter.com/labs_steam
Etsy: https://www.etsy.com/shop/NeoSteamLabs
Don Luc