{"id":3765,"date":"2023-12-09T06:54:40","date_gmt":"2023-12-09T14:54:40","guid":{"rendered":"https:\/\/www.donluc.com\/?p=3765"},"modified":"2023-12-09T06:54:40","modified_gmt":"2023-12-09T14:54:40","slug":"project-28-sensors-hc-sr04-mk12","status":"publish","type":"post","link":"https:\/\/www.donluc.com\/?p=3765","title":{"rendered":"Project #28 &#8211; Sensors &#8211; HC-SR04 &#8211; Mk12"},"content":{"rendered":"<div style=\"width: 720px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3765-1\" width=\"720\" height=\"480\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01W.mp4?_=1\" \/><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01W.mp4\">https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01W.mp4<\/a><\/video><\/div>\n<p>&#8212;&#8212;<\/p>\n<p>#DonLucElectronics #DonLuc #Sensors #LSM9DS1 #IMU #GPSReceiver #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01a.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01a.png\" alt=\"HC-SR04\" width=\"720\" height=\"520\" class=\"alignnone size-full wp-image-3767\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01a.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01a-300x217.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01b.png\" alt=\"HC-SR04\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3768\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01b.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01b-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><a href=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01c.png\" alt=\"HC-SR04\" width=\"720\" height=\"480\" class=\"alignnone size-full wp-image-3769\" srcset=\"https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01c.png 720w, https:\/\/www.donluc.com\/wp-content\/uploads\/2023\/12\/DL2310Mk01c-300x200.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>Pololu 5 Volt Step-Up Voltage Regulator U1V10F5<\/strong><\/p>\n<p>This tiny U1V10F5 switching step-up voltage regulator efficiently generates 5 Volt from input voltages as low as 0.5 Volt. Unlike most boost regulators, the U1V10F5 automatically switches to a linear down-regulation mode when the input voltage exceeds the output.<\/p>\n<p><strong>Ultrasonic Distance Sensor &#8211; HC-SR04 (5 Volt)<\/strong><\/p>\n<p>This is the HC-SR04 ultrasonic distance sensor. This economical sensor provides 2 Centimetres to 400 Centimetres of non-contact measurement functionality with a ranging accuracy that can reach up to 3 Millimetres. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit. There are only four pins that you need to worry about on the HC-SR04: VCC (Power), Trig (Trigger), Echo (Receive), and GND (Ground). This sensor has additional control circuitry that can prevent inconsistent &#8220;Bouncy&#8221; data depending on the application.<\/p>\n<p><strong>DL2310Mk01<\/strong><\/p>\n<p>1 x SparkFun Thing Plus &#8211; ESP32 WROOM<br \/>\n1 x DS3231 Precision RTC FeatherWing<br \/>\n1 x GPS Receiver &#8211; GP-20U7 (56 Channel)<br \/>\n1 x SparkFun 9DoF IMU Breakout &#8211; LSM9DS1<br \/>\n1 x Ultrasonic Distance Sensor &#8211; HC-SR04 (5V)<br \/>\n1 x Pololu 5V Step-Up Voltage Regulator U1V10F5<br \/>\n1 x Rocker Switch &#8211; SPST<br \/>\n1 x Resistor 10K Ohm<br \/>\n1 x CR1220 3V Lithium Coin Cell Battery<br \/>\n1 x 1 x Lithium Ion Battery &#8211; 1000mAh<br \/>\n1 x Terminal Block Breakout FeatherWing<br \/>\n1 x SparkFun Cerberus USB Cable<\/p>\n<p><strong>SparkFun Thing Plus &#8211; ESP32 WROOM<\/strong><\/p>\n<p>LED &#8211; LED_BUILTIN<br \/>\nSDA &#8211; Digital 23<br \/>\nSCL &#8211; Digital 22<br \/>\nSW1 &#8211; Digital 21<br \/>\nGPT &#8211; Digital 17<br \/>\nGPR &#8211; Digital 16<br \/>\nTRI &#8211; Digital 15<br \/>\nECH &#8211; Digital 14<br \/>\nVIN &#8211; +3.3V<br \/>\nVIN &#8211; +5V<br \/>\nGND &#8211; GND<\/p>\n<p>&#8212;&#8212;<\/p>\n<p><strong>DL2310Mk01p.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/****** Don Luc Electronics \u00a9 ******\r\nSoftware Version Information\r\nProject #28 - Sensors - HC-SR04 - Mk12\r\n28-12\r\nDL2310Mk01p.ino\r\n1 x SparkFun Thing Plus - ESP32 WROOM\r\n1 x DS3231 Precision RTC FeatherWing\r\n1 x GPS Receiver - GP-20U7 (56 Channel)\r\n1 x SparkFun 9DoF IMU Breakout - LSM9DS1\r\n1 x Ultrasonic Distance Sensor - HC-SR04 (5V)\r\n1 x Pololu 5V Step-Up Voltage Regulator U1V10F5\r\n1 x Rocker Switch - SPST\r\n1 x Resistor 10K Ohm\r\n1 x Lithium Ion Battery - 1000mAh\r\n1 x CR1220 3V Lithium Coin Cell Battery\r\n1 x Terminal Block Breakout FeatherWing\r\n1 x SparkFun Cerberus USB Cable\r\n*\/\r\n\r\n\/\/ Include the Library Code\r\n\/\/ Bluetooth LE keyboard\r\n#include &lt;BleKeyboard.h&gt;\r\n\/\/ Two Wire Interface (TWI\/I2C)\r\n#include &lt;Wire.h&gt;\r\n\/\/ Serial Peripheral Interface\r\n#include &lt;SPI.h&gt;\r\n\/\/ DS3231 Precision RTC \r\n#include &lt;RTClib.h&gt;\r\n\/\/ GPS Receiver\r\n#include &lt;TinyGPS++.h&gt;\r\n\/\/ ESP32 Hardware Serial\r\n#include &lt;HardwareSerial.h&gt;\r\n\/\/ LSM9DS1 9DOF Sensor\r\n#include &lt;SparkFunLSM9DS1.h&gt;\r\n\r\n\/\/ Bluetooth LE Keyboard\r\nBleKeyboard bleKeyboard;\r\nString sKeyboard = &quot;&quot;;\r\n\/\/ Send Size\r\nbyte sendSize = 0;\r\n\r\n\/\/ DS3231 Precision RTC \r\nRTC_DS3231 rtc;\r\nString dateRTC = &quot;&quot;;\r\nString timeRTC = &quot;&quot;;\r\n\r\n\/\/ GPS Receiver\r\n#define gpsRXPIN 16\r\n\/\/ This one is unused and doesnt have a conection\r\n#define gpsTXPIN 17\r\n\/\/ The TinyGPS++ object\r\nTinyGPSPlus gps;\r\n\/\/ Latitude\r\nfloat TargetLat;\r\n\/\/ Longitude\r\nfloat TargetLon;\r\n\/\/ GPS Date, Time\r\n\/\/ GPS Date\r\nString TargetDat;\r\n\/\/ GPS Time\r\nString TargetTim;\r\n\/\/ GPS Status\r\nString GPSSt = &quot;&quot;;\r\n\r\n\/\/ ESP32 HardwareSerial\r\nHardwareSerial tGPS(2);\r\n\r\n\/\/ LSM9DS1 9DOF Sensor\r\nLSM9DS1 imu;\r\n#define PRINT_CALCULATED\r\n\/\/ Earth&#039;s magnetic field varies by location. Add or subtract\r\n\/\/ a declination to get a more accurate heading. Calculate\r\n\/\/ your&#039;s here: http:\/\/www.ngdc.noaa.gov\/geomag-web\/#declination\r\n\/\/ Declination (degrees) in El Centro, CA\r\n#define DECLINATION 10.4\r\n\/\/ Gyro\r\nfloat fGyroX;\r\nfloat fGyroY;\r\nfloat fGyroZ;\r\n\/\/ Accel\r\nfloat fAccelX;\r\nfloat fAccelY;\r\nfloat fAccelZ;\r\n\/\/ Mag\r\nfloat fMagX;\r\nfloat fMagY;\r\nfloat fMagZ;\r\n\/\/ Attitude\r\nfloat fRoll;\r\nfloat fPitch;\r\nfloat fHeading;\r\n\r\n\/\/ HC-SR04 Ultrasonic Sensor\r\nint iTrig = 15;\r\nint iEcho = 14;\r\n\/\/ Stores the distance measured by the distance sensor\r\nfloat distance = 0;\r\n\r\n\/\/ The number of the Rocker Switch pin\r\nint iSwitch = 21;\r\n\/\/ Variable for reading the button status\r\nint SwitchState = 0;\r\n\r\n\/\/ Software Version Information\r\nString sver = &quot;28-12&quot;;\r\n\r\nvoid loop() {\r\n\r\n  \/\/ Date and Time RTC\r\n  isRTC ();\r\n\r\n  \/\/ isGPS\r\n  isGPS();\r\n  \r\n  \/\/ GPS Keyboard\r\n  isGPSKeyboard();\r\n\r\n  \/\/ Gyro\r\n  isGyro();\r\n\r\n  \/\/ Accel\r\n  isAccel();\r\n\r\n  \/\/ Mag\r\n  isMag();\r\n\r\n  \/\/ Attitude\r\n  isAttitude();\r\n\r\n  \/\/ HC-SR04 Ultrasonic Sensor\r\n  isHCSR04();\r\n\r\n  \/\/ Read the state of the Switch value:\r\n  SwitchState = digitalRead(iSwitch);\r\n\r\n  \/\/ Check if the button is pressed. If it is, the SwitchState is HIGH:\r\n  if (SwitchState == HIGH) {\r\n\r\n    \/\/ Bluetooth LE Keyboard\r\n    isBluetooth();\r\n\r\n  }\r\n\r\n  \/\/ Delay 1 Second\r\n  delay(1000);\r\n\r\n}\r\n<\/pre>\n<p><strong>getBleKeyboard.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Ble Keyboard\r\n\/\/ Bluetooth\r\n\/\/ isBluetooth\r\nvoid isBluetooth() {\r\n\r\n  \/\/ ESP32 BLE Keyboard\r\n  if(bleKeyboard.isConnected()) {\r\n\r\n    \/\/ Send Size Length\r\n    sendSize = sKeyboard.length();\r\n\r\n    \/\/ Send Size, charAt\r\n    for(byte i = 0; i &lt; sendSize+1; i++){\r\n\r\n       \/\/ Write\r\n       bleKeyboard.write(sKeyboard.charAt(i));\r\n       delay(50);\r\n    \r\n    }\r\n    bleKeyboard.write(KEY_RETURN);\r\n\r\n  }\r\n\r\n}\r\n<\/pre>\n<p><strong>getGPS.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ GPS Receiver\r\n\/\/ Setup GPS\r\nvoid isSetupGPS() {\r\n\r\n  \/\/ Setup GPS\r\n  \/\/tGPS.begin( 9600 );\r\n  \/\/ Setup GPS\r\n  tGPS.begin(  9600 , SERIAL_8N1 , gpsRXPIN , gpsTXPIN );\r\n\r\n}\r\n\/\/ isGPS\r\nvoid isGPS(){\r\n\r\n  \/\/ Receives NEMA data from GPS receiver\r\n  \/\/ This sketch displays information every time a new sentence is correctly encoded\r\n  while ( tGPS.available() &gt; 0)\r\n    \r\n    if (gps.encode( tGPS.read() ))\r\n    {\r\n     \r\n       \/\/ GPS Vector Pointer Target\r\n       displayInfo();\r\n\r\n       \/\/ GPS Date, Time\r\n       displayDTS();\r\n\r\n    }\r\n \r\n  if (millis() &gt; 5000 &amp;&amp; gps.charsProcessed() &lt; 10)\r\n  {\r\n   \r\n     while(true);\r\n    \r\n  }\r\n\r\n}\r\n\/\/ GPS Vector Pointer Target\r\nvoid displayInfo(){\r\n\r\n  \/\/ Location\r\n  if (gps.location.isValid())\r\n  {\r\n    \r\n     \/\/ Latitude\r\n     TargetLat = gps.location.lat();\r\n     \/\/ Longitude\r\n     TargetLon = gps.location.lng();\r\n     \/\/ GPS Status 2\r\n     GPSSt = &quot;Yes&quot;;\r\n    \r\n  }\r\n  else\r\n  {\r\n\r\n     \/\/ GPS Status 0\r\n     GPSSt = &quot;No&quot;;\r\n     TargetLat = 0;\r\n     TargetLon = 0;\r\n    \r\n  }\r\n\r\n  \r\n\r\n}\r\n\/\/ GPS Date, Time\r\nvoid displayDTS(){\r\n\r\n  \/\/ Date\r\n  TargetDat = &quot;&quot;; \r\n  if (gps.date.isValid())\r\n  {\r\n    \r\n     \/\/ Date\r\n     \/\/ Year\r\n     TargetDat += String(gps.date.year(), DEC);\r\n     TargetDat += &quot;\/&quot;;\r\n     \/\/ Month\r\n     TargetDat += String(gps.date.month(), DEC);\r\n     TargetDat += &quot;\/&quot;;\r\n     \/\/ Day\r\n     TargetDat += String(gps.date.day(), DEC);\r\n    \r\n  }\r\n\r\n  \/\/ Time\r\n  TargetTim = &quot;&quot;;\r\n  if (gps.time.isValid())\r\n  {\r\n    \r\n     \/\/ Time\r\n     \/\/ Hour\r\n     TargetTim += String(gps.time.hour(), DEC);\r\n     TargetTim += &quot;:&quot;;\r\n     \/\/ Minute\r\n     TargetTim += String(gps.time.minute(), DEC);\r\n     TargetTim += &quot;:&quot;;\r\n     \/\/ Secound\r\n     TargetTim += String(gps.time.second(), DEC);\r\n    \r\n  }\r\n\r\n}\r\n\/\/ GPS Keyboard\r\nvoid isGPSKeyboard(){\r\n\r\n  \/\/ GPS Keyboard\r\n  \/\/ bleKeyboard\r\n  \/\/ GPS Vector Pointer Target\r\n  sKeyboard = sKeyboard + GPSSt + &quot;|&quot; + String(TargetLat) \r\n  + &quot;|&quot; + String(TargetLon) + &quot;|&quot;;\r\n\r\n  \/\/ bleKeyboard\r\n  \/\/ GPS Date, Time\r\n  sKeyboard = sKeyboard + TargetDat + &quot;|&quot; + \r\n  TargetTim + &quot;|&quot;;\r\n\r\n}\r\n<\/pre>\n<p><strong>getHC-SR04.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ HC-SR04 Ultrasonic Sensor\r\n\/\/ Setup HC-SR04\r\nvoid isSetupHCSR04() {\r\n\r\n  \/\/ The trigger iTrig will output pulses of electricity\r\n  pinMode(iTrig, OUTPUT);\r\n  \/\/ The echo iEcho will measure the duration of pulses coming back from the distance sensor\r\n  pinMode(iEcho, INPUT);\r\n  \r\n}\r\n\/\/ HC-SR04\r\nvoid isHCSR04() {\r\n\r\n  \/\/ Variable to store the distance measured by the sensor\r\n  distance = isDistance();\r\n\r\n  sKeyboard = sKeyboard + String(distance) + &quot; cm|*&quot;;\r\n    \r\n}\r\n\/\/ Distance\r\nfloat isDistance() {\r\n  \r\n  \/\/ Variable to store the time it takes for a ping to bounce off an object\r\n  float echoTime;\r\n  \/\/ Variable to store the distance calculated from the echo time\r\n  float calculatedDistance;\r\n\r\n  \/\/ Send out an ultrasonic pulse that&#039;s 10ms long\r\n  digitalWrite(iTrig, HIGH);\r\n  delayMicroseconds(10);\r\n  digitalWrite(iTrig, LOW);\r\n\r\n  \/\/ Use the pulseIn command to see how long it takes for the\r\n  \/\/ pulse to bounce back to the sensor\r\n  echoTime = pulseIn(iEcho, HIGH);\r\n\r\n  \/\/ Calculate the distance of the object that reflected the pulse\r\n  \/\/ (half the bounce time multiplied by the speed of sound)\r\n  \/\/ cm = 58.0\r\n  calculatedDistance = echoTime \/ 58.0;\r\n\r\n  \/\/ Send back the distance that was calculated\r\n  return calculatedDistance;\r\n  \r\n}\r\n<\/pre>\n<p><strong>getLSM9DS1.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ LSM9DS1 9DOF Sensor\r\n\/\/ Gyro\r\nvoid isGyro(){\r\n\r\n  \/\/ Update the sensor values whenever new data is available\r\n  if ( imu.gyroAvailable() )\r\n  {\r\n    \r\n    \/\/ To read from the gyroscope,  first call the\r\n    \/\/ readGyro() function. When it exits, it&#039;ll update the\r\n    \/\/ gx, gy, and gz variables with the most current data.\r\n    imu.readGyro();\r\n    \/\/ If you want to print calculated values, you can use the\r\n    \/\/ calcGyro helper function to convert a raw ADC value to\r\n    \/\/ DPS. Give the function the value that you want to convert.\r\n    fGyroX = imu.calcGyro(imu.gx);\r\n    fGyroY = imu.calcGyro(imu.gy);\r\n    fGyroZ = imu.calcGyro(imu.gz);\r\n\r\n    \/\/ bleKeyboard\r\n    \/\/ Gyro\r\n    sKeyboard = sKeyboard + String(fGyroX)  + &quot;|&quot; + String(fGyroY) \r\n    + &quot;|&quot; + String(fGyroZ) + &quot;|&quot;;\r\n    \r\n  }\r\n  \r\n}\r\n\/\/ Accel\r\nvoid isAccel(){\r\n\r\n    \/\/ Update the sensor values whenever new data is available\r\n  if ( imu.accelAvailable() )\r\n  {\r\n    \r\n    \/\/ To read from the accelerometer, first call the\r\n    \/\/ readAccel() function. When it exits, it&#039;ll update the\r\n    \/\/ ax, ay, and az variables with the most current data.\r\n    imu.readAccel();\r\n    \/\/ If you want to print calculated values, you can use the\r\n    \/\/ calcAccel helper function to convert a raw ADC value to\r\n    \/\/ g&#039;s. Give the function the value that you want to convert.\r\n    fAccelX = imu.calcAccel(imu.ax);\r\n    fAccelY = imu.calcAccel(imu.ay);\r\n    fAccelZ = imu.calcAccel(imu.az);\r\n\r\n    \/\/ bleKeyboard\r\n    \/\/ Accel\r\n    sKeyboard = sKeyboard + String(fAccelX)  + &quot;|&quot; + String(fAccelY) \r\n    + &quot;|&quot; + String(fAccelZ) + &quot;|&quot;;\r\n    \r\n  }\r\n  \r\n}\r\n\/\/ Mag\r\nvoid isMag(){\r\n\r\n  \/\/ Update the sensor values whenever new data is available\r\n  if ( imu.magAvailable() )\r\n  {\r\n    \r\n    \/\/ To read from the magnetometer, first call the\r\n    \/\/ readMag() function. When it exits, it&#039;ll update the\r\n    \/\/ mx, my, and mz variables with the most current data.\r\n    imu.readMag();\r\n    \/\/ If you want to print calculated values, you can use the\r\n    \/\/ calcMag helper function to convert a raw ADC value to\r\n    \/\/ Gauss. Give the function the value that you want to convert.\r\n    fMagX = imu.calcMag(imu.mx);\r\n    fMagY = imu.calcMag(imu.my);\r\n    fMagZ = imu.calcMag(imu.mz);\r\n\r\n    \/\/ bleKeyboard\r\n    \/\/ Mag\r\n    sKeyboard = sKeyboard + String(fMagX)  + &quot;|&quot; + String(fMagY) \r\n    + &quot;|&quot; + String(fMagZ) + &quot;|&quot;;\r\n    \r\n  }\r\n  \r\n}\r\n\/\/ Attitude\r\nvoid isAttitude(){\r\n\r\n  \/\/ Attitude\r\n  \/\/ Roll\r\n  fRoll = atan2(fAccelY, fAccelZ);\r\n  \/\/ Pitch\r\n  fPitch = atan2(-fAccelX, sqrt(fAccelY * fAccelY + fAccelZ * fAccelZ)); \r\n  \/\/ Heading\r\n  if (fMagY == 0) {\r\n    fHeading = (fMagX &lt; 0) ? PI : 0;\r\n  }\r\n  else {\r\n    fHeading = atan2(fMagX, fMagY);\r\n  }\r\n\r\n  fHeading -= DECLINATION * PI \/ 180;\r\n\r\n  if (fHeading &gt; PI) fHeading -= (2 * PI);\r\n  else if (fHeading &lt; -PI) fHeading += (2 * PI);\r\n\r\n  \/\/ Convert everything from radians to degrees:\r\n  fHeading *= 180.0 \/ PI;\r\n  fPitch *= 180.0 \/ PI;\r\n  fRoll  *= 180.0 \/ PI;\r\n\r\n  \/\/ bleKeyboard\r\n  \/\/ Attitude\r\n  sKeyboard = sKeyboard + String(fHeading)  + &quot;|&quot; + String(fPitch) \r\n  + &quot;|&quot; + String(fRoll) + &quot;|&quot;;\r\n  \r\n}\r\n<\/pre>\n<p><strong>getRTC.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Date &amp; Time\r\n\/\/ DS3231 Precision RTC\r\nvoid isSetupRTC() {\r\n\r\n  \/\/ DS3231 Precision RTC\r\n  if (! rtc.begin()) {\r\n    \/\/Serial.println(&quot;Couldn&#039;t find RTC&quot;);\r\n    \/\/Serial.flush();\r\n    while (1) delay(10);\r\n  }\r\n\r\n  if (rtc.lostPower()) {\r\n    \/\/Serial.println(&quot;RTC lost power, let&#039;s set the time!&quot;);\r\n    \/\/ When time needs to be set on a new device, or after a power loss, the\r\n    \/\/ following line sets the RTC to the date &amp; time this sketch was compiled\r\n    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));\r\n    \/\/ This line sets the RTC with an explicit date &amp; time, for example to set\r\n    \/\/ January 21, 2014 at 3am you would call:\r\n    \/\/rtc.adjust(DateTime(2023, 8, 10, 11, 0, 0));\r\n  }\r\n  \r\n}\r\n\/\/ Date and Time RTC\r\nvoid isRTC () {\r\n\r\n  \/\/ Date and Time\r\n  dateRTC = &quot;&quot;;\r\n  timeRTC = &quot;&quot;;\r\n  DateTime now = rtc.now();\r\n  \r\n  \/\/ Date\r\n  dateRTC = now.year(), DEC; \r\n  dateRTC = dateRTC + &quot;\/&quot;;\r\n  dateRTC = dateRTC + now.month(), DEC;\r\n  dateRTC = dateRTC + &quot;\/&quot;;\r\n  dateRTC = dateRTC + now.day(), DEC;\r\n\r\n  \/\/ Time\r\n  timeRTC = now.hour(), DEC;\r\n  timeRTC = timeRTC + &quot;:&quot;;\r\n  timeRTC = timeRTC + now.minute(), DEC;\r\n  timeRTC = timeRTC + &quot;:&quot;;\r\n  timeRTC = timeRTC + now.second(), DEC;\r\n\r\n  \/\/ bleKeyboard\r\n  sKeyboard = &quot;SEN|&quot; + sver + &quot;|&quot; + String(dateRTC) \r\n  + &quot;|&quot; + String(timeRTC) + &quot;|&quot;;\r\n\r\n}\r\n<\/pre>\n<p><strong>setup.ino<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"arduino\" data-enlighter-title=\"\">\r\n\/\/ Setup\r\nvoid setup()\r\n{\r\n  \r\n  \/\/ Give display time to power on\r\n  delay(100);\r\n\r\n  \/\/ Bluetooth LE keyboard\r\n  bleKeyboard.begin();\r\n  \r\n  \/\/ Wire - Inialize I2C Hardware\r\n  Wire.begin();\r\n\r\n  \/\/ Give display time to power on\r\n  delay(100);\r\n\r\n  \/\/ Date &amp; Time RTC\r\n  \/\/ DS3231 Precision RTC \r\n  isSetupRTC();\r\n\r\n  \/\/ Give display time to power on\r\n  delay(100);\r\n  \r\n  \/\/ GPS Receiver\r\n  \/\/ Setup GPS\r\n  isSetupGPS();\r\n\r\n  \/\/ LSM9DS1 9DOF Sensor\r\n  imu.begin();\r\n\r\n  \/\/ Setup HC-SR04\r\n  isSetupHCSR04();\r\n\r\n  \/\/ Initialize the Switch pin as an input\r\n  pinMode(iSwitch, INPUT);\r\n\r\n  \/\/ Initialize digital pin LED_BUILTIN as an output\r\n  pinMode(LED_BUILTIN, OUTPUT);\r\n  \/\/ Turn the LED on HIGH\r\n  digitalWrite(LED_BUILTIN, HIGH);\r\n\r\n  \/\/ Delay 5 Second\r\n  delay( 5000 );\r\n\r\n}\r\n<\/pre>\n<p>&#8212;&#8212;<\/p>\n<p><strong>People can contact us:<\/strong> https:\/\/www.donluc.com\/?page_id=1927<\/p>\n<p><strong>Teacher, Instructor, E-Mentor, R&#038;D and Consulting<\/strong><\/p>\n<ul>\n<li>Programming Language<\/li>\n<li>Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi, Arm, Silicon Labs, Espressif, Etc&#8230;)<\/li>\n<li>IoT<\/li>\n<li>Wireless (Radio Frequency, Bluetooth, WiFi, Etc&#8230;)<\/li>\n<li>Robotics<\/li>\n<li>Automation<\/li>\n<li>Camera and Video Capture Receiver Stationary, Wheel\/Tank and Underwater Vehicle<\/li>\n<li>Unmanned Vehicles Terrestrial and Marine<\/li>\n<li>Machine Learning<\/li>\n<li>Artificial Intelligence (AI)<\/li>\n<li>RTOS<\/li>\n<li>eHealth Sensors, Biosensor, and Biometric<\/li>\n<li>Research &#038; Development (R &#038; D)<\/li>\n<li>Consulting<\/li>\n<\/ul>\n<p><strong>Follow Us<\/strong><\/p>\n<p><strong>Luc Paquin \u2013 Curriculum Vitae &#8211; 2023<\/strong><br \/>\nhttps:\/\/www.donluc.com\/luc\/<\/p>\n<p><strong>Web:<\/strong> https:\/\/www.donluc.com\/<br \/>\n<strong>Facebook:<\/strong> https:\/\/www.facebook.com\/neosteam.labs.9\/<br \/>\n<strong>YouTube:<\/strong> https:\/\/www.youtube.com\/@thesass2063<br \/>\n<strong>Twitter:<\/strong> https:\/\/twitter.com\/labs_steam<br \/>\n<strong>Pinterest:<\/strong> https:\/\/www.pinterest.com\/NeoSteamLabs\/<br \/>\n<strong>Instagram:<\/strong> https:\/\/www.instagram.com\/neosteamlabs\/<\/p>\n<p><strong>Don Luc<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212; #DonLucElectronics #DonLuc #Sensors #LSM9DS1 #IMU #GPSReceiver #Adafruit #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; &#8212;&#8212; Pololu 5 Volt Step-Up Voltage Regulator U1V10F5 This tiny U1V10F5 switching step-up voltage regulator efficiently generates 5 Volt from input voltages as low as 0.5 Volt. Unlike most boost regulators, the U1V10F5 automatically switches to &#8230; <a title=\"Project #28 &#8211; Sensors &#8211; HC-SR04 &#8211; Mk12\" class=\"read-more\" href=\"https:\/\/www.donluc.com\/?p=3765\" aria-label=\"Read more about Project #28 &#8211; Sensors &#8211; HC-SR04 &#8211; Mk12\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[294,47,50,49,38,80,59,5,46,287,58,82,10,43],"tags":[251,86,6,102,4,19,83,85,89,252,183,246,24,103,9,84,27,248,109,33,34,108],"class_list":["post-3765","post","type-post","status-publish","format-standard","hentry","category-sensors","category-adafruit","category-arduino","category-consultant","category-digitalelectronics","category-esp32","category-fritzing","category-microcontrollers","category-pololu","category-program","category-arduino-programming","category-program-esp32","category-projects","category-sparkfun","tag-accelerometer","tag-adafruit","tag-arduino","tag-components","tag-consultant","tag-electronics","tag-esp32","tag-fritzing","tag-gps-receiver","tag-gyroscope","tag-hc-sr04","tag-magnetometer","tag-microcontroller","tag-pololu","tag-programming","tag-programming-esp32","tag-projects-2","tag-sensors","tag-sparkfun","tag-technology","tag-video-blog","tag-vlog"],"_links":{"self":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3765"}],"version-history":[{"count":1,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3765\/revisions"}],"predecessor-version":[{"id":3770,"href":"https:\/\/www.donluc.com\/index.php?rest_route=\/wp\/v2\/posts\/3765\/revisions\/3770"}],"wp:attachment":[{"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.donluc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}