——
#DonLucElectronics #DonLuc #Sensors #PIR #Adafruit #SparkFun #Pololu #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant
——
——
——
——
PIR Motion Sensor (JST)
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. This unit works great from 5 to 12 Volt. 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.
At their most fundamental level, PIR sensor’s are infrared-sensitive light detectors. By monitoring light in the infrared spectrum, PIR sensors can sense subtle changes in temperature across the area they’re viewing. When a human or some other object comes into the PIR’s field-of-view, the radiation pattern changes, and the PIR interprets that change as movement. All that’s left for us to connect is three pins: power, ground, and the output signal.
DL2401Mk02
1 x SparkFun Thing Plus – ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x PIR Motion Sensor
1 x Pololu 5V Step-Up Voltage Regulator U1V10F5
1 x Rocker Switch – SPST
1 x Resistor 10K Ohm
1 x CR1220 3V Lithium Coin Cell Battery
1 x 1 x Lithium Ion Battery – 1000mAh
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
SparkFun Thing Plus – ESP32 WROOM
LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
SW1 – Digital 21
PIR – Digital 14
VIN – +3.3V
VIN – +5V
GND – GND
——
DL2401Mk01p.ino
/****** Don Luc Electronics © ******
Software Version Information
Project #28 - Sensors - PIR Motion Sensor - Mk13
28-13
DL2401Mk01p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x DS3231 Precision RTC FeatherWing
1 x PIR Motion Sensor
1 x Pololu 5V Step-Up Voltage Regulator U1V10F5
1 x Rocker Switch - SPST
1 x Resistor 10K Ohm
1 x Lithium Ion Battery - 1000mAh
1 x CR1220 3V Lithium Coin Cell Battery
1 x Terminal Block Breakout FeatherWing
1 x SparkFun Cerberus USB Cable
*/
// Include the Library Code
// Bluetooth LE keyboard
#include <BleKeyboard.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// Serial Peripheral Interface
#include <SPI.h>
// DS3231 Precision RTC
#include <RTClib.h>
// Bluetooth LE Keyboard
BleKeyboard bleKeyboard;
String sKeyboard = "";
// Send Size
byte sendSize = 0;
// DS3231 Precision RTC
RTC_DS3231 rtc;
String dateRTC = "";
String timeRTC = "";
// PIR Motion
// Motion detector
const int iMotion = 14;
// Proximity
int proximity = LOW;
String Det = "";
// The number of the Rocker Switch pin
int iSwitch = 21;
// Variable for reading the button status
int SwitchState = 0;
// Software Version Information
String sver = "28-13";
void loop() {
// Date and Time RTC
isRTC ();
// isPIR Motion
isPIR();
// Read the state of the Switch value:
SwitchState = digitalRead(iSwitch);
// Check if the button is pressed. If it is, the SwitchState is HIGH:
if (SwitchState == HIGH) {
// Bluetooth LE Keyboard
isBluetooth();
}
// Delay 1 Second
delay(1000);
}
getBleKeyboard.ino
// Ble Keyboard
// Bluetooth
// isBluetooth
void isBluetooth() {
// ESP32 BLE Keyboard
if(bleKeyboard.isConnected()) {
// Send Size Length
sendSize = sKeyboard.length();
// Send Size, charAt
for(byte i = 0; i < sendSize+1; i++){
// Write
bleKeyboard.write(sKeyboard.charAt(i));
delay(50);
}
bleKeyboard.write(KEY_RETURN);
}
}
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";
}
sKeyboard = sKeyboard + String(Det) + "|*";
}
getRTC.ino
// Date & Time
// DS3231 Precision RTC
void isSetupRTC() {
// DS3231 Precision RTC
if (! rtc.begin()) {
//Serial.println("Couldn't find RTC");
//Serial.flush();
while (1) delay(10);
}
if (rtc.lostPower()) {
//Serial.println("RTC lost power, let's set the time!");
// When time needs to be set on a new device, or after a power loss, the
// 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(2023, 8, 10, 11, 0, 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;
// bleKeyboard
sKeyboard = "SEN|" + sver + "|" + String(dateRTC)
+ "|" + String(timeRTC) + "|";
}
setup.ino
// Setup
void setup()
{
// Give display time to power on
delay(100);
// Bluetooth LE keyboard
bleKeyboard.begin();
// Wire - Inialize I2C Hardware
Wire.begin();
// Give display time to power on
delay(100);
// Date & Time RTC
// DS3231 Precision RTC
isSetupRTC();
// Give display time to power on
delay(100);
// PIR Motion
// Setup PIR
setupPIR();
// Initialize the Switch pin as an input
pinMode(iSwitch, INPUT);
// Initialize digital pin LED_BUILTIN as an output
pinMode(LED_BUILTIN, OUTPUT);
// Turn the LED on HIGH
digitalWrite(LED_BUILTIN, HIGH);
// Delay 5 Second
delay( 5000 );
}
——
People can contact us: https://www.donluc.com/?page_id=1927
Teacher, Instructor, E-Mentor, R&D and Consulting
- Programming Language
- Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc…)
- IoT
- Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
- Robotics
- Automation
- Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
- Unmanned Vehicles Terrestrial and Marine
- Machine Learning
- Artificial Intelligence (AI)
- RTOS
- eHealth Sensors, Biosensor, and Biometric
- Research & Development (R & D)
- Consulting
Follow Us
Luc Paquin – Curriculum Vitae – 2024
https://www.donluc.com/luc/
Web: https://www.donluc.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/@thesass2063
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/
Don Luc


