The Alpha Geek – Geeking Out

ESP32

Project #26 – Radio Frequency – Universally Unique IDentifier – Mk27

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #UUID #Display #SparkFun #Adafruit #BME280 #CCS811 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Universally Unique IDentifier

——

Universally Unique IDentifier

——

Universally Unique IDentifier

——

Universally Unique IDentifier

A Universally Unique IDentifier (UUID) is a 128-bit label used for information in computer systems. When generated according to the standard methods, UUIDs are, for practical purposes, unique. Their uniqueness does not depend on a central registration authority or coordination between the parties generating them, unlike most other numbering schemes. While the probability that a UUID will be duplicated is not zero, it is generally considered close enough to zero to be negligible.

Thus, anyone can create a UUID and use it to identify something with near certainty that the identifier does not duplicate one that has already been, or will be, created to identify something else. Information labeled with UUIDs by independent parties can therefore be later combined into a single database or transmitted on the same channel, with a negligible probability of duplication. Adoption of UUIDs is widespread, with many computing platforms providing support for generating them and for parsing their textual representation.

DL2307Mk08

2 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Adafruit SHARP Memory Display Breakout
1 x Adalogger FeatherWing – RTC + SD
1 x 8 GB MicroSD Memory Card
1 x CR1220 3V Lithium Coin Cell Battery
2 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM (Server)

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk08ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Universally Unique IDentifier - Mk27
26-27
DL2307Mk08ps.ino
2 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Adafruit SHARP Memory Display Breakout
1 x Adalogger FeatherWing - RTC + SD
1 x 8 GB MicroSD Memory Card
1 x CR1220 3V Lithium Coin Cell Battery
2 x Lithium Ion Battery - 850mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// BLE Device
#include <BLEDevice.h>
// BLE Utils
#include <BLEUtils.h>
// BLE Serve
#include <BLEServer.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
#define SERVICE_UUID            "7c394dc4-49a8-4c22-8a5b-b1612d8c13c1"
#define CHARACTERISTIC_UUID     "a4c4cec2-f394-4f7a-b9de-89047feca74b"
#define CHARACTERISTIC_TEM_UUID "74bd92c6-89d0-4387-823e-97e7e0fb7a2b"
#define CHARACTERISTIC_HUM_UUID "1b63f246-b97f-4d2e-b8eb-f69e20a23a34"
#define CHARACTERISTIC_BAR_UUID "43788175-37a7-4280-93c6-c690324d088e"
#define CHARACTERISTIC_ALT_UUID "609deed9-a72d-45c3-aaba-14a73b0d8fda"
#define CHARACTERISTIC_ECO_UUID "ab17aace-c0b9-4bd3-bb93-7715d9afaeea"
#define CHARACTERISTIC_VOC_UUID "6a8bf86a-9d40-457c-9f7f-f13a3d6803f1"
// Makes the chracteristic globlal
static BLECharacteristic *pCharacteristicTEM;
static BLECharacteristic *pCharacteristicHUM;
static BLECharacteristic *pCharacteristicBAR;
static BLECharacteristic *pCharacteristicALT;
static BLECharacteristic *pCharacteristicECO;
static BLECharacteristic *pCharacteristicVOC;

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

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

// Software Version Information
String sver = "26-27";

void loop() {

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

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

  // Delay 1 sec
  delay(1000);

}

getBME280.ino

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

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

  // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string
  pCharacteristicTEM->setValue(BMEtempC);
  pCharacteristicHUM->setValue(BMEhumid);
  pCharacteristicBAR->setValue(BMEpressure);
  pCharacteristicALT->setValue(BMEaltitudeM);

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

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();

  // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string
  pCharacteristicECO->setValue(CCS811CO2);
  pCharacteristicVOC->setValue(CCS811TVOC);

  // FullStringA
  FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = "
  + String(CCS811CO2,2) + "\r\n";

  // FullStringA Bluetooth Serial + Serial
  for(int i = 0; i < FullStringA.length(); i++)
  {

    // Serial
    Serial.write(FullStringA.c_str()[i]);
    
  }


}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

  // BLE Device Init
  BLEDevice::init("Don Luc Electronics Server");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristicTEM = pService->createCharacteristic(
                                         CHARACTERISTIC_TEM_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
                                       
  pCharacteristicHUM = pService->createCharacteristic(
                                         CHARACTERISTIC_HUM_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicBAR = pService->createCharacteristic(
                                         CHARACTERISTIC_BAR_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicALT = pService->createCharacteristic(
                                         CHARACTERISTIC_ALT_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicVOC = pService->createCharacteristic(
                                         CHARACTERISTIC_VOC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicECO = pService->createCharacteristic(
                                         CHARACTERISTIC_ECO_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristic->setValue("Luc Paquin");
  pService->start();

  // This still is working for backward compatibility
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();
  // BLE Advertising
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  // Functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x06);
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();

}

——

SparkFun Thing Plus – ESP32 WROOM (Client)

LED – Digital 21
SCK – Digital 13
MOSI – Digital 12
SS – Digital 27
MISO – Digital 19
MOSI – Digital 18
SCK – Digital 5
CS – Digital 33
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk08pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Universally Unique IDentifier - Mk27
26-27
DL2307Mk08pr.ino
2 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Adafruit SHARP Memory Display Breakout
1 x Adalogger FeatherWing - RTC + SD
1 x 8 GB MicroSD Memory Card
1 x CR1220 3V Lithium Coin Cell Battery
2 x Lithium Ion Battery - 850mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth BLE Device
#include "BLEDevice.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
// Adafruit GFX Library
#include <Adafruit_GFX.h>
// Date and Time
#include "RTClib.h"
// SD Card
#include "FS.h"
#include "SD.h"
#include "SPI.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
// 1/2 of lesser of display width or height
int minorHalfSize;

// The remote service we wish to connect to.
static BLEUUID serviceUUID("7c394dc4-49a8-4c22-8a5b-b1612d8c13c1");
// The characteristic of the remote service we are interested in.
static BLEUUID    charUUID("a4c4cec2-f394-4f7a-b9de-89047feca74b");
// Use the same UUID as on the server
static BLEUUID    charTEMUUID("74bd92c6-89d0-4387-823e-97e7e0fb7a2b");
static BLEUUID    charHUMUUID("1b63f246-b97f-4d2e-b8eb-f69e20a23a34");
static BLEUUID    charBARUUID("43788175-37a7-4280-93c6-c690324d088e");
static BLEUUID    charALTUUID("609deed9-a72d-45c3-aaba-14a73b0d8fda");
static BLEUUID    charECOUUID("ab17aace-c0b9-4bd3-bb93-7715d9afaeea");
static BLEUUID    charVOCUUID("6a8bf86a-9d40-457c-9f7f-f13a3d6803f1");
static boolean doConnect = false;
static boolean connected = false;
static boolean doScan = false;
static BLERemoteCharacteristic* pRemoteCharacteristic;
static BLERemoteCharacteristic* pRemoteCharacteristicTEM;
static BLERemoteCharacteristic* pRemoteCharacteristicHUM;
static BLERemoteCharacteristic* pRemoteCharacteristicBAR;
static BLERemoteCharacteristic* pRemoteCharacteristicALT;
static BLERemoteCharacteristic* pRemoteCharacteristicECO;
static BLERemoteCharacteristic* pRemoteCharacteristicVOC;

static BLEAdvertisedDevice* myDevice;
float TEMValue;
float HUMValue;
float BARValue;
float ALTValue;
float ECOValue;
float VOCValue;

int iLED = 21;

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

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

// Software Version Information
String sver = "26-27";

void loop() {

  // Bluetooth BLE
  isBluetoothBLE();

  // Date and Time 
  isRTC();

  // Display Environmental
  isDisplayEnvironmental();

  // microSD Card
  isSD();

}

getBluetoothBLE.ino

// Bluetooth BLE
// isBluetoothBLE
void isBluetoothBLE(){

  // If the flag "doConnect" is true then we have scanned for 
  // and found the desired
  // BLE Server with which we wish to connect.  Now we connect to it.
  // Once we are connected we set the connected flag to be true.
  if (doConnect == true) {
    if (connectToServer()) {
      Serial.println("We are now connected to the BLE Server.");
    } else {
      Serial.println("We have failed to connect to the server; there is nothin more we will do.");
    }
    doConnect = false;
  }

  // If we are connected to a peer BLE Server, update the characteristic each time we are reached
  // with the current time since boot.
  if (connected) {
    String newValue = "Time since boot: " + String(millis()/1000);
    //Serial.println("Setting new characteristic value to \"" + newValue + "\"");

    // Set the characteristic's value to be the array of bytes that is actually a string.
   // pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());//***********JKO
  }else if(doScan){
    BLEDevice::getScan()->start(0);  // this is just example to start scan after disconnect, most likely there is better way to do it in arduino
  }

  // read the Characteristics and store them in a variable
  // This also makes the print command do float handling
  TEMValue = pRemoteCharacteristicTEM->readFloat();
  HUMValue = pRemoteCharacteristicHUM->readFloat();
  BARValue = pRemoteCharacteristicBAR->readFloat();
  ALTValue = pRemoteCharacteristicALT->readFloat();
  ECOValue = pRemoteCharacteristicECO->readFloat();
  VOCValue = pRemoteCharacteristicVOC->readFloat();
  
}
// Notify Callback
static void notifyCallback(
  BLERemoteCharacteristic* pBLERemoteCharacteristic,
  uint8_t* pData,
  size_t length,
  bool isNotify) {
    Serial.print("Notify callback for characteristic ");
    Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str());
    Serial.print(" of data length ");
    Serial.println(length);
    Serial.print("data: ");
    Serial.println((char*)pData);
}
// My Client Callback
class MyClientCallback : public BLEClientCallbacks {
  void onConnect(BLEClient* pclient) {
  }

  void onDisconnect(BLEClient* pclient) {
    connected = false;
    Serial.println("onDisconnect");
  }
};
// Connect To Server
bool connectToServer() {
    Serial.print("Forming a connection to ");
    Serial.println(myDevice->getAddress().toString().c_str());

    BLEClient*  pClient  = BLEDevice::createClient();
    Serial.println(" - Created client");

    pClient->setClientCallbacks(new MyClientCallback());

    // Connect to the remove BLE Server.
    // if you pass BLEAdvertisedDevice instead of address,
    //it will be recognized type of peer device address (public or private)
    pClient->connect(myDevice);  
    Serial.println(" - Connected to server");
    //set client to request maximum MTU from server (default is 23 otherwise)
    pClient->setMTU(517); 

    // Obtain a reference to the service we are after in the remote BLE server.
    BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
    if (pRemoteService == nullptr) {
      Serial.print("Failed to find our service UUID: ");
      Serial.println(serviceUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    Serial.println(" - Found our service");

    // Obtain a reference to the characteristic in the service of the remote BLE server.
    pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
    if (pRemoteCharacteristic == nullptr) {
      Serial.print("Failed to find our characteristic UUID: ");
      Serial.println(charUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    Serial.println(" - Found our characteristic");
    // Temperature Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicTEM = pRemoteService->getCharacteristic(charTEMUUID);
    if (pRemoteCharacteristicTEM == nullptr) {
      Serial.print("Failed to find our characteristic UUID Temperature: ");
      Serial.println(charTEMUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    // Humidity Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicHUM = pRemoteService->getCharacteristic(charHUMUUID);
    if (pRemoteCharacteristicHUM == nullptr) {
      Serial.print("Failed to find our characteristic UUID Temperature: ");
      Serial.println(charHUMUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    Serial.println(" - Found our characteristic");

    // Barometric Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicBAR = pRemoteService->getCharacteristic(charBARUUID);
    if (pRemoteCharacteristicBAR == nullptr) {
      Serial.print("Failed to find our characteristic UUID Barometric: ");
      Serial.println(charBARUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    Serial.println(" - Found our characteristic");
    
    // Altitude Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicALT = pRemoteService->getCharacteristic(charALTUUID);
    if (pRemoteCharacteristicALT == nullptr) {
      Serial.print("Failed to find our characteristic UUID Altitude: ");
      Serial.println(charALTUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    // eCO2 Concentration Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicECO = pRemoteService->getCharacteristic(charECOUUID);
    if (pRemoteCharacteristicECO == nullptr) {
      Serial.print("Failed to find our characteristic UUID eCO2 Concentration: ");
      Serial.println(charECOUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    Serial.println(" - Found our characteristic");
    
    // tVOC Concentration Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicVOC = pRemoteService->getCharacteristic(charVOCUUID);
    if (pRemoteCharacteristicVOC == nullptr) {
      Serial.print("Failed to find our characteristic UUID tVOC Concentration: ");
      Serial.println(charVOCUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    
    
    Serial.println(" - Found our characteristic");
    // Read the value of the characteristic.
    if(pRemoteCharacteristic->canRead()) {
      std::string value = pRemoteCharacteristic->readValue();
      Serial.print("The characteristic value was: ");
      Serial.println(value.c_str());
    }

    if(pRemoteCharacteristic->canNotify())
      pRemoteCharacteristic->registerForNotify(notifyCallback);

    connected = true;
    return true;
    
}
/**
 * Scan for BLE servers and find the first one that advertises the service we are looking for.
 */
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
 /**
   * Called for each advertising BLE server.
   */
  void onResult(BLEAdvertisedDevice advertisedDevice) {
    Serial.print("BLE Advertised Device found: ");
    Serial.println(advertisedDevice.toString().c_str());

    // We have found a device, let us now see if it contains the service we are looking for.
    if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) {

      BLEDevice::getScan()->stop();
      myDevice = new BLEAdvertisedDevice(advertisedDevice);
      doConnect = true;
      doScan = true;

    } // Found our server
  } // onResult
}; // MyAdvertisedDeviceCallbacks

getDisplay.ino

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

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(2);
    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 );
    display.setCursor(0,125);   
    display.println( dateRTC );
    display.setCursor(0,150);   
    display.println( timeRTC );
    // Refresh
    display.refresh();
    delay( 5000 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(2);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,5);
    display.print( "T: " );
    display.print( TEMValue );    
    display.println( "C" );
    // Humidity
    display.setCursor(0,25);
    display.print( "H: " );
    display.print( HUMValue );
    display.println( "%" );
    // Pressure
    display.setCursor(0,45);
    display.print( "B: " );
    display.print( BARValue );
    display.println( "" );
    // Altitude Meters
    display.setCursor(0,65);
    display.print( "A: " );   
    display.print( ALTValue );
    display.println( "M" );
    // eCO2 Concentration
    display.setCursor(0,85);
    display.print( "C: " );
    display.print( ECOValue );
    display.println( "ppm" );
    // tVOC Concentration
    display.setCursor(0,105);
    display.print( "V: " );
    display.print( VOCValue );
    display.println( "ppb" );
    // Date
    display.setCursor(0,125);
    display.println( dateRTC );
    // Time
    display.setCursor(0,145);
    display.println( timeRTC );
    // Refresh
    display.refresh();
    delay( 100 );

}

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(2023, 7, 24, 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;
  
}

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 = "";

  // BLE|Version|Date|Time|Temperature Celsius|Humidity|Barometric Pressure
  //|Altitude Meters|eCO2 Concentration|tVOC Concentration|*
  zzzzzz = "BLE|" + sver + "|" + dateRTC + "|" + timeRTC + "|" + TEMValue 
  + "|" + HUMValue + "|" + BARValue + "|" + ALTValue + "|" + ECOValue
  + "|" + VOCValue + "|*\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()
{
  
  // Serial
  Serial.begin(115200);
  Serial.println("Starting Arduino BLE Client application...");

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(iLED, HIGH);

  // SHARP Display start & clear the display
  display.begin();
  display.clearDisplay();

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

  // Display UID
  isDisplayUID();

  // microSD Card
  setupSD();

  // Bluetooth BLE
  BLEDevice::init("");
  
  // Give display time to power on
  delay(100);
  
  BLEScan* pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setInterval(1349);
  pBLEScan->setWindow(449);
  pBLEScan->setActiveScan(true);
  pBLEScan->start(5, false);

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth Server and Client – Mk26

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Display #SparkFun #BME280 #CCS811 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth Server and Client

——

Bluetooth Server and Client

——

Bluetooth Server and Client

——-

Bluetooth Server and Client

Connect the SparkFun BME280 and CCS811 this is the “Server” board. Upload SparkFun Thing Plus the Server code to the board using the USB cable. When uploading is complete, disconnect this board from the computer. Now, connect the Lithium Ion battery to the “Server”. Next, connect the second SparkFun Thing Plus to your computer and upload the Client code to the board. We have two Arduino sketches to upload to the SparkFun Thing Plus boards. Upload the first sketch to the Server SparkFun Thing Plus and the second sketch to the Client SparkFun Thing Plus.

DL2307Mk07

2 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Adafruit SHARP Memory Display Breakout
2 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM (Server)

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk07ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth Server and Client - Mk26
26-26
DL2307Mk07ps.ino
2 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Adafruit SHARP Memory Display Breakout
2 x Lithium Ion Battery - 850mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// BLE Device
#include <BLEDevice.h>
// BLE Utils
#include <BLEUtils.h>
// BLE Serve
#include <BLEServer.h>
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>

// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
#define SERVICE_UUID            "7c394dc4-49a8-4c22-8a5b-b1612d8c13c1"
#define CHARACTERISTIC_UUID     "a4c4cec2-f394-4f7a-b9de-89047feca74b"
#define CHARACTERISTIC_TEM_UUID "74bd92c6-89d0-4387-823e-97e7e0fb7a2b"
#define CHARACTERISTIC_HUM_UUID "1b63f246-b97f-4d2e-b8eb-f69e20a23a34"
#define CHARACTERISTIC_BAR_UUID "43788175-37a7-4280-93c6-c690324d088e"
#define CHARACTERISTIC_ALT_UUID "609deed9-a72d-45c3-aaba-14a73b0d8fda"
#define CHARACTERISTIC_ECO_UUID "ab17aace-c0b9-4bd3-bb93-7715d9afaeea"
#define CHARACTERISTIC_VOC_UUID "6a8bf86a-9d40-457c-9f7f-f13a3d6803f1"
// Makes the chracteristic globlal
static BLECharacteristic *pCharacteristicTEM;
static BLECharacteristic *pCharacteristicHUM;
static BLECharacteristic *pCharacteristicBAR;
static BLECharacteristic *pCharacteristicALT;
static BLECharacteristic *pCharacteristicECO;
static BLECharacteristic *pCharacteristicVOC;

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

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

// Software Version Information
String sver = "26-26";

void loop() {

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

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

  // Delay 1 sec
  delay(1000);

}

getBME280.ino

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

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

  // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string
  pCharacteristicTEM->setValue(BMEtempC);
  pCharacteristicHUM->setValue(BMEhumid);
  pCharacteristicBAR->setValue(BMEpressure);
  pCharacteristicALT->setValue(BMEaltitudeM);

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

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();

  // setValue takes uint8_t, uint16_t, uint32_t, int, float, double and string
  pCharacteristicECO->setValue(CCS811CO2);
  pCharacteristicVOC->setValue(CCS811TVOC);

  // FullStringA
  FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = "
  + String(CCS811CO2,2) + "\r\n";

  // FullStringA Bluetooth Serial + Serial
  for(int i = 0; i < FullStringA.length(); i++)
  {

    // Serial
    Serial.write(FullStringA.c_str()[i]);
    
  }


}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

  // BLE Device Init
  BLEDevice::init("Don Luc Electronics Server");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );

  pCharacteristicTEM = pService->createCharacteristic(
                                         CHARACTERISTIC_TEM_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
                                       
  pCharacteristicHUM = pService->createCharacteristic(
                                         CHARACTERISTIC_HUM_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicBAR = pService->createCharacteristic(
                                         CHARACTERISTIC_BAR_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicALT = pService->createCharacteristic(
                                         CHARACTERISTIC_ALT_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicVOC = pService->createCharacteristic(
                                         CHARACTERISTIC_VOC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristicECO = pService->createCharacteristic(
                                         CHARACTERISTIC_ECO_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  
  pCharacteristic->setValue("Luc Paquin");
  pService->start();

  // This still is working for backward compatibility
  // BLEAdvertising *pAdvertising = pServer->getAdvertising();
  // BLE Advertising
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(true);
  // Functions that help with iPhone connections issue
  pAdvertising->setMinPreferred(0x06);
  pAdvertising->setMinPreferred(0x12);
  BLEDevice::startAdvertising();

}

——

SparkFun Thing Plus – ESP32 WROOM (Client)

LED – Digital 21
SCK – Digital 13
MOSI – Digital 12
SS – Digital 27
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk07pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth Server and Client - Mk26
26-26
DL2307Mk07pr.ino
2 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Adafruit SHARP Memory Display Breakout
2 x Lithium Ion Battery - 850mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth BLE Device
#include "BLEDevice.h"
// SHARP Memory Display
#include <Adafruit_SharpMem.h>
// Adafruit GFX Library
#include <Adafruit_GFX.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
// 1/2 of lesser of display width or height
int minorHalfSize;

// The remote service we wish to connect to.
static BLEUUID serviceUUID("7c394dc4-49a8-4c22-8a5b-b1612d8c13c1");
// The characteristic of the remote service we are interested in.
static BLEUUID    charUUID("a4c4cec2-f394-4f7a-b9de-89047feca74b");
// Use the same UUID as on the server
static BLEUUID    charTEMUUID("74bd92c6-89d0-4387-823e-97e7e0fb7a2b");
static BLEUUID    charHUMUUID("1b63f246-b97f-4d2e-b8eb-f69e20a23a34");
static BLEUUID    charBARUUID("43788175-37a7-4280-93c6-c690324d088e");
static BLEUUID    charALTUUID("609deed9-a72d-45c3-aaba-14a73b0d8fda");
static BLEUUID    charECOUUID("ab17aace-c0b9-4bd3-bb93-7715d9afaeea");
static BLEUUID    charVOCUUID("6a8bf86a-9d40-457c-9f7f-f13a3d6803f1");
static boolean doConnect = false;
static boolean connected = false;
static boolean doScan = false;
static BLERemoteCharacteristic* pRemoteCharacteristic;
static BLERemoteCharacteristic* pRemoteCharacteristicTEM;
static BLERemoteCharacteristic* pRemoteCharacteristicHUM;
static BLERemoteCharacteristic* pRemoteCharacteristicBAR;
static BLERemoteCharacteristic* pRemoteCharacteristicALT;
static BLERemoteCharacteristic* pRemoteCharacteristicECO;
static BLERemoteCharacteristic* pRemoteCharacteristicVOC;

static BLEAdvertisedDevice* myDevice;
float TEMValue;
float HUMValue;
float BARValue;
float ALTValue;
float ECOValue;
float VOCValue;

int iLED = 21;

// Software Version Information
String sver = "26-26";

void loop() {

  isBluetoothBLE();

  isDisplayEnvironmental();
 
}

getBluetoothBLE.ino

// Bluetooth BLE
void isBluetoothBLE(){

  // If the flag "doConnect" is true then we have scanned for 
  // and found the desired
  // BLE Server with which we wish to connect.  Now we connect to it.
  // Once we are connected we set the connected flag to be true.
  if (doConnect == true) {
    if (connectToServer()) {
      Serial.println("We are now connected to the BLE Server.");
    } else {
      Serial.println("We have failed to connect to the server; there is nothin more we will do.");
    }
    doConnect = false;
  }

  // If we are connected to a peer BLE Server, update the characteristic each time we are reached
  // with the current time since boot.
  if (connected) {
    String newValue = "Time since boot: " + String(millis()/1000);
    //Serial.println("Setting new characteristic value to \"" + newValue + "\"");

    // Set the characteristic's value to be the array of bytes that is actually a string.
   // pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());//***********JKO
  }else if(doScan){
    BLEDevice::getScan()->start(0);  // this is just example to start scan after disconnect, most likely there is better way to do it in arduino
  }

  // read the Characteristics and store them in a variable
  // This also makes the print command do float handling
  TEMValue = pRemoteCharacteristicTEM->readFloat();
  HUMValue = pRemoteCharacteristicHUM->readFloat();
  BARValue = pRemoteCharacteristicBAR->readFloat();
  ALTValue = pRemoteCharacteristicALT->readFloat();
  ECOValue = pRemoteCharacteristicECO->readFloat();
  VOCValue = pRemoteCharacteristicVOC->readFloat();
  
}
// Notify Callback
static void notifyCallback(
  BLERemoteCharacteristic* pBLERemoteCharacteristic,
  uint8_t* pData,
  size_t length,
  bool isNotify) {
    Serial.print("Notify callback for characteristic ");
    Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str());
    Serial.print(" of data length ");
    Serial.println(length);
    Serial.print("data: ");
    Serial.println((char*)pData);
}
// My Client Callback
class MyClientCallback : public BLEClientCallbacks {
  void onConnect(BLEClient* pclient) {
  }

  void onDisconnect(BLEClient* pclient) {
    connected = false;
    Serial.println("onDisconnect");
  }
};
// Connect To Server
bool connectToServer() {
    Serial.print("Forming a connection to ");
    Serial.println(myDevice->getAddress().toString().c_str());

    BLEClient*  pClient  = BLEDevice::createClient();
    Serial.println(" - Created client");

    pClient->setClientCallbacks(new MyClientCallback());

    // Connect to the remove BLE Server.
    // if you pass BLEAdvertisedDevice instead of address,
    //it will be recognized type of peer device address (public or private)
    pClient->connect(myDevice);  
    Serial.println(" - Connected to server");
    //set client to request maximum MTU from server (default is 23 otherwise)
    pClient->setMTU(517); 

    // Obtain a reference to the service we are after in the remote BLE server.
    BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
    if (pRemoteService == nullptr) {
      Serial.print("Failed to find our service UUID: ");
      Serial.println(serviceUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    Serial.println(" - Found our service");

    // Obtain a reference to the characteristic in the service of the remote BLE server.
    pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
    if (pRemoteCharacteristic == nullptr) {
      Serial.print("Failed to find our characteristic UUID: ");
      Serial.println(charUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    Serial.println(" - Found our characteristic");
    // Temperature Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicTEM = pRemoteService->getCharacteristic(charTEMUUID);
    if (pRemoteCharacteristicTEM == nullptr) {
      Serial.print("Failed to find our characteristic UUID Temperature: ");
      Serial.println(charTEMUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    // Humidity Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicHUM = pRemoteService->getCharacteristic(charHUMUUID);
    if (pRemoteCharacteristicHUM == nullptr) {
      Serial.print("Failed to find our characteristic UUID Temperature: ");
      Serial.println(charHUMUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    Serial.println(" - Found our characteristic");

    // Barometric Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicBAR = pRemoteService->getCharacteristic(charBARUUID);
    if (pRemoteCharacteristicBAR == nullptr) {
      Serial.print("Failed to find our characteristic UUID Barometric: ");
      Serial.println(charBARUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    Serial.println(" - Found our characteristic");
    
    // Altitude Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicALT = pRemoteService->getCharacteristic(charALTUUID);
    if (pRemoteCharacteristicALT == nullptr) {
      Serial.print("Failed to find our characteristic UUID Altitude: ");
      Serial.println(charALTUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    // eCO2 Concentration Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicECO = pRemoteService->getCharacteristic(charECOUUID);
    if (pRemoteCharacteristicECO == nullptr) {
      Serial.print("Failed to find our characteristic UUID eCO2 Concentration: ");
      Serial.println(charECOUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    Serial.println(" - Found our characteristic");
    
    // tVOC Concentration Obtain a reference to the characteristic in the service
    // of the remote BLE server.
    pRemoteCharacteristicVOC = pRemoteService->getCharacteristic(charVOCUUID);
    if (pRemoteCharacteristicVOC == nullptr) {
      Serial.print("Failed to find our characteristic UUID tVOC Concentration: ");
      Serial.println(charVOCUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }
    
    
    Serial.println(" - Found our characteristic");
    // Read the value of the characteristic.
    if(pRemoteCharacteristic->canRead()) {
      std::string value = pRemoteCharacteristic->readValue();
      Serial.print("The characteristic value was: ");
      Serial.println(value.c_str());
    }

    if(pRemoteCharacteristic->canNotify())
      pRemoteCharacteristic->registerForNotify(notifyCallback);

    connected = true;
    return true;
    
}
/**
 * Scan for BLE servers and find the first one that advertises the service we are looking for.
 */
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
 /**
   * Called for each advertising BLE server.
   */
  void onResult(BLEAdvertisedDevice advertisedDevice) {
    Serial.print("BLE Advertised Device found: ");
    Serial.println(advertisedDevice.toString().c_str());

    // We have found a device, let us now see if it contains the service we are looking for.
    if (advertisedDevice.haveServiceUUID() && advertisedDevice.isAdvertisingService(serviceUUID)) {

      BLEDevice::getScan()->stop();
      myDevice = new BLEAdvertisedDevice(advertisedDevice);
      doConnect = true;
      doScan = true;

    } // Found our server
  } // onResult
}; // MyAdvertisedDeviceCallbacks

getDisplay.ino

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

    // Text Display 
    // Clear Display
    display.clearDisplay();
    display.setRotation(2);
    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 );
    // Refresh
    display.refresh();
    delay( 5000 );
    
}
// Display Environmental
void isDisplayEnvironmental(){

    // Text Display Environmental
    // Clear Display
    display.clearDisplay();
    display.setRotation(2);
    display.setTextSize(2);
    display.setTextColor(BLACK);
    // Temperature Celsius
    display.setCursor(0,5);
    display.print( "T: " );
    display.print( TEMValue );    
    display.println( "C" );
    // Humidity
    display.setCursor(0,25);
    display.print( "H: " );
    display.print( HUMValue );
    display.println( "%" );
    // Pressure
    display.setCursor(0,45);
    display.print( "B: " );
    display.print( BARValue );
    display.println( "" );
    // Altitude Meters
    display.setCursor(0,65);
    display.print( "A: " );   
    display.print( ALTValue );
    display.println( "M" );
    // eCO2 Concentration
    display.setCursor(0,85);
    display.print( "C: " );
    display.print( ECOValue );
    display.println( "ppm" );
    // tVOC Concentration
    display.setCursor(0,105);
    display.print( "V: " );
    display.print( VOCValue );
    display.println( "ppb" );
    // Refresh
    display.refresh();
    delay( 100 );

}

setup.ino

// Setup
void setup()
{
  
  // Serial
  Serial.begin(115200);
  Serial.println("Starting Arduino BLE Client application...");

  // Initialize digital pin iLED as an output
  pinMode(iLED, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(iLED, HIGH);

  // SHARP Display start & clear the display
  display.begin();
  display.clearDisplay();

  // Display UID
  isDisplayUID();

  // Bluetooth BLE
  BLEDevice::init("");
  
  // Give display time to power on
  delay(100);
  
  BLEScan* pBLEScan = BLEDevice::getScan();
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setInterval(1349);
  pBLEScan->setWindow(449);
  pBLEScan->setActiveScan(true);
  pBLEScan->start(5, false);

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth Serial Terminal for Windows 10 – Mk25

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #GPS #SparkFun #BME280 #CCS811 #IMU #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth Serial Terminal for Windows 10

——

Bluetooth Serial Terminal for Windows 10

——

Bluetooth Serial Terminal for Windows 10

——

Bluetooth Serial Terminal for Windows 10

You can use this App to communicate with Serial Bluetooth devices like the RN-42, ESP32, that are used for arduino projects and other custom projects. Make sure to pair the device first in PC Settings.

  • Use the rfcomm protocol to communicate with serial bluetooth devices.
  • You can send and recieve data in either hex or string format.
  • UI more responsive while updating terminal.
  • Bytes that do not have proper ascii mapping are converted to space characters.
  • Transmit data is displayed on terminal if it is successfully sent.
  • Communicate with Serial Bluetooth devices.

DL2307Mk06

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Bluetooth Serial Terminal for Windows 10
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Pololu AltIMU-10 v5
1 x GPS Receiver – GP-20U7
1 x Lithium Ion Battery – 850mAh
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
GPR – Digital 16
GPT – Digital 17
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk06ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth Serial Terminal for Windows 10 - Mk25
26-25
DL2307Mk06p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x Bluetooth Serial Terminal for Windows 10
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Pololu AltIMU-10 v5
1 x GPS Receiver - GP-20U7
1 x Lithium Ion Battery - 85mAh
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// Includes and variables for IMU integration
// STMicroelectronics LSM6DS33 gyroscope and accelerometer
#include <LSM6.h>
// STMicroelectronics LIS3MDL magnetometer
#include <LIS3MDL.h>
// STMicroelectronics LPS25H digital barometer
#include <LPS.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>

// Bluetooth Serial
BluetoothSerial SerialBT;

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

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

// 9DoF IMU
// STMicroelectronics LSM6DS33 gyroscope and accelerometer
LSM6 imu;
// Accelerometer and Gyroscopes
// Accelerometer
int imuAX;
int imuAY;
int imuAZ;
String FullStringB = "";
// Gyroscopes 
int imuGX;
int imuGY;
int imuGZ;
String FullStringC = "";
// STMicroelectronics LIS3MDL magnetometer
LIS3MDL mag;
// Magnetometer
int magX;
int magY;
int magZ;
String FullStringD = "";
// STMicroelectronics LPS25H digital barometer
LPS ps;
// Digital Barometer
float pressure;
float altitude;
float temperature;
String FullStringF = "";

// 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;
String FullStringG = "";
// 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 = "";
String FullStringH = "";

// Software Version Information
String sver = "26-25";

void loop() {

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

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

  // Accelerometer and Gyroscopes
  isIMU();

  // Magnetometer
  isMag();

  // Barometer
  isBarometer();

  // isGPS
  isGPS();

  // Delay 1 sec
  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;

  // FullString B
  FullStringB = "Accelerometer X = " + String(imuAX) + " Accelerometer Y = "
  + String(imuAY) + " Accelerometer Z = " + String(imuAZ) 
  + "\r\n";

  // FullStringB Bluetooth Serial + Serial
  for(int i = 0; i < FullStringB.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringB.c_str()[i]);
    // Serial
    Serial.write(FullStringB.c_str()[i]);
    
  }

  // FullString C
  FullStringC = "Gyroscopes X = " + String(imuGX) + " Gyroscopes Y = "
  + String(imuGY) + " Gyroscopes Z = " + String(imuGZ) 
  + "\r\n";

  // FullStringC Bluetooth Serial + Serial
  for(int i = 0; i < FullStringC.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringC.c_str()[i]);
    // Serial
    Serial.write(FullStringC.c_str()[i]);
    
  }

}

getBME280.ino

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

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

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

getBarometer.ino

// STMicroelectronics LPS25H digital barometer
// Setup Barometer
void isSetupBarometer(){

  // Setup Barometer
  ps.init();
  // Default
  ps.enableDefault();
  
}
// Barometer
void isBarometer(){

  // Barometer
  pressure = ps.readPressureMillibars();
  // Altitude Meters
  altitude = ps.pressureToAltitudeMeters(pressure);
  // Temperature Celsius
  temperature = ps.readTemperatureC();

  // FullStringF
  FullStringF = "Barometer = " + String(pressure,2) + " Altitude Meters = "
  + String(altitude,2) + " Temperature Celsius = "
  + String(temperature,2) + "\r\n";

  // FullStringF Bluetooth Serial + Serial
  for(int i = 0; i < FullStringF.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringF.c_str()[i]);
    // Serial
    Serial.write(FullStringF.c_str()[i]);
    
  }
  
}

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();

  // FullStringA
  FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = "
  + String(CCS811CO2,2) + "\r\n";

  // FullStringA Bluetooth Serial + Serial
  for(int i = 0; i < FullStringA.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringA.c_str()[i]);
    // Serial
    Serial.write(FullStringA.c_str()[i]);
    
  }

}

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";

     // FullStringG
     FullStringG = "Latitude = " + String(TargetLat) + " Longitude = "
     + String(TargetLon) + "\r\n";

     // FullStringG Bluetooth Serial + Serial
     for(int i = 0; i < FullStringG.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringG.c_str()[i]);
       // Serial
       Serial.write(FullStringG.c_str()[i]);
    
     }
    
  }
  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);

     // FullStringH
     FullStringH = "Date = " + String(TargetDat) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }
    
  }

  // 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);

     // FullStringH
     FullStringH = "Time = " + String(TargetTim) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }
    
  }

  // 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);

     // FullStringH
     FullStringH = "Speed = " + String(TargetSMS) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }

  }

  // Altitude
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

     // FullStringH
     FullStringH = "Altitude = " + String(TargetALT) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }

  }
 
}

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;

  // FullString D
  FullStringD = "Magnetometer X = " + String(magX) + " Magnetometer Y = "
  + String(magY) + " Magnetometer Z = " + String(magZ) 
  + "\r\n";

  // FullStringD Bluetooth Serial + Serial
  for(int i = 0; i < FullStringD.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringD.c_str()[i]);
    // Serial
    Serial.write(FullStringD.c_str()[i]);
    
  }
  
}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("Don Luc Electronics");
  Serial.println("Bluetooth Started! Ready to pair...");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Setup IMU
  setupIMU();

  // Setup Magnetometer
  setupMag();

  // Setup Barometer
  isSetupBarometer();

  // GPS Receiver
  // Setup GPS
  setupGPS();
  
  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth GPS Receiver GP-20U7 – Mk24

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #GPS #SparkFun #BME280 #CCS811 #IMU #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth GPS Receiver GP-20U7

——

Bluetooth GPS Receiver GP-20U7

——

Bluetooth GPS Receiver GP-20U7

——

GPS Receiver – GP-20U7 (56 Channel)

The GP-20U7 is a compact GPS receiver with a built-in high performances all-in-one GPS chipset. The GP-20U7 accurately provides position, velocity, and time readings as well possessing high sensitivity and tracking capabilities. Thanks to the low power consumption this receiver requires, the GP-20U7 is ideal for portable applications such as tablet PCs, smart phones, and other devices requiring positioning capability. With 56 channels in search mode and 22 channels “All-In-View” tracking, the GP-20U7 is quite the work horse for its size.

DL2307Mk05

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Arduino Uno
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Pololu AltIMU-10 v5
1 x GPS Receiver – GP-20U7
1 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
GPR – Digital 16
GPT – Digital 17
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk05ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth GPS Receiver GP-20U7 - Mk24
26-24
DL2307Mk05pr.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x Arduino Uno
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Pololu AltIMU-10 v5
1 x GPS Receiver - GP-20U7
1 x Lithium Ion Battery - 85mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// Includes and variables for IMU integration
// STMicroelectronics LSM6DS33 gyroscope and accelerometer
#include <LSM6.h>
// STMicroelectronics LIS3MDL magnetometer
#include <LIS3MDL.h>
// STMicroelectronics LPS25H digital barometer
#include <LPS.h>
// GPS Receiver
#include <TinyGPS++.h>
// ESP32 Hardware Serial
#include <HardwareSerial.h>

// Bluetooth Serial
BluetoothSerial SerialBT;

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

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

// 9DoF IMU
// STMicroelectronics LSM6DS33 gyroscope and accelerometer
LSM6 imu;
// Accelerometer and Gyroscopes
// Accelerometer
int imuAX;
int imuAY;
int imuAZ;
String FullStringB = "";
// Gyroscopes 
int imuGX;
int imuGY;
int imuGZ;
String FullStringC = "";
// STMicroelectronics LIS3MDL magnetometer
LIS3MDL mag;
// Magnetometer
int magX;
int magY;
int magZ;
String FullStringD = "";
// STMicroelectronics LPS25H digital barometer
LPS ps;
// Digital Barometer
float pressure;
float altitude;
float temperature;
String FullStringF = "";

// 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;
String FullStringG = "";
// 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 = "";
String FullStringH = "";

// Software Version Information
String sver = "26-24";

void loop() {

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

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

  // Accelerometer and Gyroscopes
  isIMU();

  // Magnetometer
  isMag();

  // Barometer
  isBarometer();

  // isGPS
  isGPS();

  // Delay 1 sec
  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;

  // FullString B
  FullStringB = "Accelerometer X = " + String(imuAX) + " Accelerometer Y = "
  + String(imuAY) + " Accelerometer Z = " + String(imuAZ) 
  + "\r\n";

  // FullStringB Bluetooth Serial + Serial
  for(int i = 0; i < FullStringB.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringB.c_str()[i]);
    // Serial
    Serial.write(FullStringB.c_str()[i]);
    
  }

  // FullString C
  FullStringC = "Gyroscopes X = " + String(imuGX) + " Gyroscopes Y = "
  + String(imuGY) + " Gyroscopes Z = " + String(imuGZ) 
  + "\r\n";

  // FullStringC Bluetooth Serial + Serial
  for(int i = 0; i < FullStringC.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringC.c_str()[i]);
    // Serial
    Serial.write(FullStringC.c_str()[i]);
    
  }

}

getBME280.ino

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

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

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

getBarometer.ino

// STMicroelectronics LPS25H digital barometer
// Setup Barometer
void isSetupBarometer(){

  // Setup Barometer
  ps.init();
  // Default
  ps.enableDefault();
  
}
// Barometer
void isBarometer(){

  // Barometer
  pressure = ps.readPressureMillibars();
  // Altitude Meters
  altitude = ps.pressureToAltitudeMeters(pressure);
  // Temperature Celsius
  temperature = ps.readTemperatureC();

  // FullStringF
  FullStringF = "Barometer = " + String(pressure,2) + " Altitude Meters = "
  + String(altitude,2) + " Temperature Celsius = "
  + String(temperature,2) + "\r\n";

  // FullStringF Bluetooth Serial + Serial
  for(int i = 0; i < FullStringF.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringF.c_str()[i]);
    // Serial
    Serial.write(FullStringF.c_str()[i]);
    
  }
  
}

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();

  // FullStringA
  FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = "
  + String(CCS811CO2,2) + "\r\n";

  // FullStringA Bluetooth Serial + Serial
  for(int i = 0; i < FullStringA.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringA.c_str()[i]);
    // Serial
    Serial.write(FullStringA.c_str()[i]);
    
  }

}

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";

     // FullStringG
     FullStringG = "Latitude = " + String(TargetLat) + " Longitude = "
     + String(TargetLon) + "\r\n";

     // FullStringG Bluetooth Serial + Serial
     for(int i = 0; i < FullStringG.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringG.c_str()[i]);
       // Serial
       Serial.write(FullStringG.c_str()[i]);
    
     }
    
  }
  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);

     // FullStringH
     FullStringH = "Date = " + String(TargetDat) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }
    
  }

  // 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);

     // FullStringH
     FullStringH = "Time = " + String(TargetTim) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }
    
  }

  // 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);

     // FullStringH
     FullStringH = "Speed = " + String(TargetSMS) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }

  }

  // Altitude
  TargetALT = "";
  if (gps.altitude.isValid())
  {
    
     // Altitude
     // Meters
     int z = gps.altitude.meters();
     TargetALT = String( z, DEC);

     // FullStringH
     FullStringH = "Altitude = " + String(TargetALT) + "\r\n";

     // FullStringH Bluetooth Serial + Serial
     for(int i = 0; i < FullStringH.length(); i++)
     {

       // Bluetooth Serial
       SerialBT.write(FullStringH.c_str()[i]);
       // Serial
       Serial.write(FullStringH.c_str()[i]);
    
     }

  }
 
}

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;

  // FullString D
  FullStringD = "Magnetometer X = " + String(magX) + " Magnetometer Y = "
  + String(magY) + " Magnetometer Z = " + String(magZ) 
  + "\r\n";

  // FullStringD Bluetooth Serial + Serial
  for(int i = 0; i < FullStringD.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringD.c_str()[i]);
    // Serial
    Serial.write(FullStringD.c_str()[i]);
    
  }
  
}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(9600);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("Don Luc Electronics");
  Serial.println("Bluetooth Started! Ready to pair...");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Setup IMU
  setupIMU();

  // Setup Magnetometer
  setupMag();

  // Setup Barometer
  isSetupBarometer();

  // GPS Receiver
  // Setup GPS
  setupGPS();
  
  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

}

——

Arduino Uno

RX – Digital 3
TX – Digital 2
VIN – +3.3V
GND – GND

——

DL2307Mk05pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth GPS Receiver GP-20U7 - Mk24
26-24
DL2307Mk05pr.ino
1 x Arduino Uno
1 x SparkFun RedBoard Qwiic
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Pololu AltIMU-10 v5
1 x GPS Receiver - GP-20U7
1 x Lithium Ion Battery - 85mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Software Serial
#include <SoftwareSerial.h>

// Software Serial
// TX-O pin of bluetooth mate, Arduino D2
int bluetoothTx = 2;
// RX-I pin of bluetooth mate, Arduino D3
int bluetoothRx = 3;
// Bluetooth
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
// BTA
//String BTA = "0006664FDC9E"; 

// Software Version Information
String sver = "26-24";

void loop() {

  // isBluetooth
  isBluetooth();
 
}

getBluetooth.ino

// Bluetooth
// Setup Bluetooth
void isSetupBluetooth(){

  // Setup Bluetooth
  // Begin the serial monitor at 9600bps
  Serial.begin(9600);
  // Bluetooth
  // The Bluetooth Mate defaults to 115200bps
  bluetooth.begin(115200);
  // Print three times individually
  bluetooth.print("$");
  bluetooth.print("$");
  bluetooth.print("$");
  // Enter command mode
  // Short delay, wait for the Mate to send back CMD
  delay(100);
  // Temporarily Change the baudrate to 9600, no parity
  bluetooth.println("U,9600,N");
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  // Start bluetooth serial at 9600
  bluetooth.begin(9600);
  
}
// isBluetooth
void isBluetooth() {

  // If the bluetooth sent any characters
  if(bluetooth.available())
  {
    
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());
    
  }
  // If stuff was typed in the serial monitor
  if(Serial.available())
  {
    
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
    
  }

}

setup.ino

// Setup
void setup()
{
  
  // Setup Bluetooth
  isSetupBluetooth();

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth Pololu AltIMU-10 – Mk23

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFun #BME280 #CCS811 #IMU #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth Pololu AltIMU-10

——

Bluetooth Pololu AltIMU-10

——

Bluetooth Pololu AltIMU-10

——

AltIMU-10 v5 Gyro, Accelerometer, Compass, and Altimeter

The Pololu AltIMU-10 v5 is an inertial measurement unit (IMU) and altimeter that features the same LSM6DS33 gyro and accelerometer and LIS3MDL magnetometer as the MinIMU-9 v5, and adds an LPS25H digital barometer. An I²C interface accesses ten independent pressure, rotation, acceleration, and magnetic measurements that can be used to calculate the sensor’s altitude and absolute orientation. The Pololu AltIMU-10 v5 is a compact board that combines ST’s LSM6DS33 3-axis gyroscope and 3-axis accelerometer, LIS3MDL 3-axis magnetometer, and LPS25H digital barometer to form an inertial measurement unit (IMU) and altimeter.

DL2307Mk04

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Arduino Uno
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Pololu AltIMU-10 v5
1 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk04ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth Pololu AltIMU-10 - Mk23
26-23
DL2307Mk04pr.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x Arduino Uno
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Pololu AltIMU-10 v5
1 x Lithium Ion Battery - 85mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>
// Includes and variables for IMU integration
// STMicroelectronics LSM6DS33 gyroscope and accelerometer
#include <LSM6.h>
// STMicroelectronics LIS3MDL magnetometer
#include <LIS3MDL.h>
// STMicroelectronics LPS25H digital barometer
#include <LPS.h>

// Bluetooth Serial
BluetoothSerial SerialBT;

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

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

// 9DoF IMU
// STMicroelectronics LSM6DS33 gyroscope and accelerometer
LSM6 imu;
// Accelerometer and Gyroscopes
// Accelerometer
int imuAX;
int imuAY;
int imuAZ;
String FullStringB = "";
// Gyroscopes 
int imuGX;
int imuGY;
int imuGZ;
String FullStringC = "";
// STMicroelectronics LIS3MDL magnetometer
LIS3MDL mag;
// Magnetometer
int magX;
int magY;
int magZ;
String FullStringD = "";
// STMicroelectronics LPS25H digital barometer
LPS ps;
// Digital Barometer
float pressure;
float altitude;
float temperature;
String FullStringF = "";

// Software Version Information
String sver = "26-23";

void loop() {

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

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

  // Accelerometer and Gyroscopes
  isIMU();

  // Magnetometer
  isMag();

  // Barometer
  isBarometer();

  // Delay 1 sec
  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;

  // FullString B
  FullStringB = "Accelerometer X = " + String(imuAX) + " Accelerometer Y = "
  + String(imuAY) + " Accelerometer Z = " + String(imuAZ) 
  + "\r\n";

  // FullStringB Bluetooth Serial + Serial
  for(int i = 0; i < FullStringB.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringB.c_str()[i]);
    // Serial
    Serial.write(FullStringB.c_str()[i]);
    
  }

  // FullString C
  FullStringC = "Gyroscopes X = " + String(imuGX) + " Gyroscopes Y = "
  + String(imuGY) + " Gyroscopes Z = " + String(imuGZ) 
  + "\r\n";

  // FullStringC Bluetooth Serial + Serial
  for(int i = 0; i < FullStringC.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringC.c_str()[i]);
    // Serial
    Serial.write(FullStringC.c_str()[i]);
    
  }

}

getBME280.ino

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

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

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

getBarometer.ino

// STMicroelectronics LPS25H digital barometer
// Setup Barometer
void isSetupBarometer(){

  // Setup Barometer
  ps.init();
  // Default
  ps.enableDefault();
  
}
// Barometer
void isBarometer(){

  // Barometer
  pressure = ps.readPressureMillibars();
  // Altitude Meters
  altitude = ps.pressureToAltitudeMeters(pressure);
  // Temperature Celsius
  temperature = ps.readTemperatureC();

  // FullStringF
  FullStringF = "Barometer = " + String(pressure,2) + " Altitude Meters = "
  + String(altitude,2) + " Temperature Celsius = "
  + String(temperature,2) + "\r\n";

  // FullStringF Bluetooth Serial + Serial
  for(int i = 0; i < FullStringF.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringF.c_str()[i]);
    // Serial
    Serial.write(FullStringF.c_str()[i]);
    
  }
  
}

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();

  // FullStringA
  FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = "
  + String(CCS811CO2,2) + "\r\n";

  // FullStringA Bluetooth Serial + Serial
  for(int i = 0; i < FullStringA.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringA.c_str()[i]);
    // Serial
    Serial.write(FullStringA.c_str()[i]);
    
  }

}

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;

  // FullString D
  FullStringD = "Magnetometer X = " + String(magX) + " Magnetometer Y = "
  + String(magY) + " Magnetometer Z = " + String(magZ) 
  + "\r\n";

  // FullStringD Bluetooth Serial + Serial
  for(int i = 0; i < FullStringD.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringD.c_str()[i]);
    // Serial
    Serial.write(FullStringD.c_str()[i]);
    
  }
  
}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(9600);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("Don Luc Electronics");
  Serial.println("Bluetooth Started! Ready to pair...");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Setup IMU
  setupIMU();

  // Setup Magnetometer
  setupMag();

  // Setup Barometer
  isSetupBarometer();
  
  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

}

——

Arduino Uno

RX – Digital 3
TX – Digital 2
VIN – +3.3V
GND – GND

——

DL2307Mk04pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth Pololu AltIMU-10 - Mk23
26-23
DL2307Mk04pr.ino
1 x Arduino Uno
1 x SparkFun RedBoard Qwiic
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Pololu AltIMU-10 v5
1 x Lithium Ion Battery - 85mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Software Serial
#include <SoftwareSerial.h>

// Software Serial
// TX-O pin of bluetooth mate, Arduino D2
int bluetoothTx = 2;
// RX-I pin of bluetooth mate, Arduino D3
int bluetoothRx = 3;
// Bluetooth
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
// BTA
//String BTA = "0006664FDC9E"; 

// Software Version Information
String sver = "26-23";

void loop() {

  // isBluetooth
  isBluetooth();
 
}

getBluetooth.ino

// Bluetooth
// Setup Bluetooth
void isSetupBluetooth(){

  // Setup Bluetooth
  // Begin the serial monitor at 9600bps
  Serial.begin(9600);
  // Bluetooth
  // The Bluetooth Mate defaults to 115200bps
  bluetooth.begin(115200);
  // Print three times individually
  bluetooth.print("$");
  bluetooth.print("$");
  bluetooth.print("$");
  // Enter command mode
  // Short delay, wait for the Mate to send back CMD
  delay(100);
  // Temporarily Change the baudrate to 9600, no parity
  bluetooth.println("U,9600,N");
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  // Start bluetooth serial at 9600
  bluetooth.begin(9600);
  
}
// isBluetooth
void isBluetooth() {

  // If the bluetooth sent any characters
  if(bluetooth.available())
  {
    
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());
    
  }
  // If stuff was typed in the serial monitor
  if(Serial.available())
  {
    
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
    
  }

}

setup.ino

// Setup
void setup()
{
  
  // Setup Bluetooth
  isSetupBluetooth();

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth CCS811 – Mk22

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFun #BME280 #CCS811 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth CCS811

——

Bluetooth CCS811

——

Bluetooth CCS811

——

SparkFun Air Quality Breakout – CCS811

The CCS811 Air Quality Breakout is a digital gas sensor solution that senses a wide range of Total Volatile Organic Compounds (TVOCs), including equivalent carbon dioxide (eCO2) and metal oxide (MOX) levels. VOCs are often categorized as pollutants and or sensory irritants and can come from a variety of sources like construction materials, machines and even people. This breakout is intended for indoor air quality monitoring in personal devices such as watches and phone.

DL2307Mk03

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Arduino Uno
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout – CCS811
1 x Lithium Ion Battery – 850mAh
2 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk03ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - SparkFun CCS811 - Mk22
26-22
DL2307Mk03pr.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x Arduino Uno
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Lithium Ion Battery - 850mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>
// SparkFun CCS811 - eCO2 & tVOC
#include <SparkFunCCS811.h>

// Bluetooth Serial
BluetoothSerial SerialBT;

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

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

// Software Version Information
String sver = "26-22";

void loop() {

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

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

  // Delay 1 sec
  delay(1000);

}

getBME280.ino

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

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

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

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();

  // FullStringA
  FullStringA = "TVOCs = " + String(CCS811TVOC,2) + " eCO2 = "
  + String(CCS811CO2,2) + "\r\n";

  // FullStringA Bluetooth Serial + Serial
  for(int i = 0; i < FullStringA.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullStringA.c_str()[i]);
    // Serial
    Serial.write(FullStringA.c_str()[i]);
    
  }

}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(9600);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("Don Luc Electronics");
  Serial.println("Bluetooth Started! Ready to pair...");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // CCS811 - eCO2 & tVOC
  myCCS811.begin();

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

}

——

Arduino Uno

RX – Digital 3
TX – Digital 2
VIN – +3.3V
GND – GND

DL2307Mk03pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth CCS811 - Mk22
26-22
DL2307Mk03pr.ino
1 x Arduino Uno
1 x SparkFun RedBoard Qwiic
1 x SparkFun Bluetooth Mate Silver
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x SparkFun Air Quality Breakout - CCS811
1 x Lithium Ion Battery - 850mAh
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Software Serial
#include <SoftwareSerial.h>

// Software Serial
// TX-O pin of bluetooth mate, Arduino D2
int bluetoothTx = 2;
// RX-I pin of bluetooth mate, Arduino D3
int bluetoothRx = 3;
// Bluetooth
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
// BTA
//String BTA = "0006664FDC9E"; 

// Software Version Information
String sver = "26-22";

void loop() {

  // isBluetooth
  isBluetooth();
 
}

getBluetooth.ino

// Bluetooth
// Setup Bluetooth
void isSetupBluetooth(){

  // Setup Bluetooth
  // Begin the serial monitor at 9600bps
  Serial.begin(9600);
  // Bluetooth
  // The Bluetooth Mate defaults to 115200bps
  bluetooth.begin(115200);
  // Print three times individually
  bluetooth.print("$");
  bluetooth.print("$");
  bluetooth.print("$");
  // Enter command mode
  // Short delay, wait for the Mate to send back CMD
  delay(100);
  // Temporarily Change the baudrate to 9600, no parity
  bluetooth.println("U,9600,N");
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  // Start bluetooth serial at 9600
  bluetooth.begin(9600);
  
}
// isBluetooth
void isBluetooth() {

  // If the bluetooth sent any characters
  if(bluetooth.available())
  {
    
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());
    
  }
  // If stuff was typed in the serial monitor
  if(Serial.available())
  {
    
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
    
  }

}

setup.ino

// Setup
void setup()
{
  
  // Setup Bluetooth
  isSetupBluetooth();

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth SparkFun BME280 – Mk21

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFun #BME280 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Bluetooth SparkFun BME280

——

Bluetooth SparkFun BME280

——

Bluetooth SparkFun BME280

——

SparkFun Atmospheric Sensor Breakout – BME280

The SparkFun BME280 Atmospheric Sensor Breakout is the easy way to measure barometric pressure, humidity, and temperature readings all without taking up too much space. Basically, anything you need to know about atmospheric conditions you can find out from this tiny breakout. The BME280 Breakout has been design to be used in indoor/outdoor navigation, weather forecasting, home automation, and even personal health and wellness monitoring.

DL2307Mk02

1 x SparkFun Thing Plus – ESP32 WROOM
1 x Android NextBook
1 x SparkFun BME280 – Temperature, Humidity, Barometric Pressure, and Altitude
1 x Lithium Ion Battery – 850mAh
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LED – LED_BUILTIN
SDA – Digital 23
SCL – Digital 22
RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk02p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - SparkFun BME280 - Mk21
26-21
DL2307Mk02pr.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x Android NextBook
1 x SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
1 x Lithium Ion Battery - 850mAh
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
// Two Wire Interface (TWI/I2C)
#include <Wire.h>
// SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude
#include <SparkFunBME280.h>

// Bluetooth Serial
BluetoothSerial SerialBT;

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

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

void loop() {

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

  // Delay 1 sec
  delay(1000);

}

getBME280.ino

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

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

  // FullString
  FullString = "Temperature = " + String(BMEtempC,2) + " Humidity = "
  + String(BMEhumid,2) + " Barometric = " + String(BMEpressure,2) 
  + " Altitude Meters = " + String(BMEaltitudeM,2) + "\r\n";

  // FullString Bluetooth Serial + Serial
  for(int i = 0; i < FullString.length(); i++)
  {

    // Bluetooth Serial
    SerialBT.write(FullString.c_str()[i]);
    // Serial
    Serial.write(FullString.c_str()[i]);
    
  }

}

setup.ino

// Setup
void setup()
{
  
  // Serial Begin
  Serial.begin(115200);
  Serial.println("Starting BLE work!");

  // Bluetooth Serial
  SerialBT.begin("Don Luc Electronics");
  Serial.println("Bluetooth Started! Ready to pair...");

  // Give display time to power on
  delay(100);
  
  // Wire - Inialize I2C Hardware
  Wire.begin();

  // Give display time to power on
  delay(100);

  // SparkFun BME280 - Temperature, Humidity, Barometric Pressure, and Altitude 
  myBME280.begin();

  // Initialize digital pin LED_BUILTIN as an output
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH
  digitalWrite(LED_BUILTIN, HIGH);

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Bluetooth SparkFun Thing Plus – ESP32 WROOM – Mk20

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #SparkFun #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

SparkFun Thing Plus - ESP32 WROOM

——

SparkFun Thing Plus - ESP32 WROOM

——

SparkFun Thing Plus - ESP32 WROOM

——

SparkFun Thing Plus – ESP32 WROOM

The SparkFun ESP32 Thing Plus is the next step to get started with Espressif IoT ideations while still enjoying all the amenities of the original ESP32 Thing. Espressif’s ESP32 WROOM is a powerful WiFi and Bluetooth MCU module that targets a wide variety of applications. At the core of this module is the ESP32-D0WDQ6 chip which is designed to be both scalable and adaptive. To make the Thing Plus even easier to use, we’ve moved a few pins around to make the board Feather compatible and it utilizes our handy Qwiic Connect System which means no soldering or shields are required to connect it to the rest of your system.

The ESP32 Thing plus integrates a rich set of peripherals, ranging from capacitive touch sensors, SD card interface, Ethernet, high-speed SPI, UART, I2S and I2C. Thanks to the onboard ESP32 WROOM module, the SparkFun Thing Plus features 16MB of flash memory, 520kB of internal SRAM, an integrated 802.11 BGN WiFi transceiver and dual-mode Bluetooth capabilities, and a JST connector to plug in a LiPo battery.

DL2307Mk01

1 x Arduino Uno
1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Bluetooth Mate Silver
2 x SparkFun Cerberus USB Cable

Arduino Uno

RX – Digital 3
TX – Digital 2
VIN – +3.3V
GND – GND

——

DL2307Mk01pr.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth SparkFun Thing Plus - ESP32 WROOM - Mk20
26-20
DL2307Mk01pr.ino
1 x Arduino Uno
1 x SparkFun Thing Plus - ESP32 WROOM
2 x SparkFun Bluetooth Mate Silver
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Software Serial
#include <SoftwareSerial.h>

// Software Serial
// TX-O pin of bluetooth mate, Arduino D2
int bluetoothTx = 2;
// RX-I pin of bluetooth mate, Arduino D3
int bluetoothRx = 3;
// Bluetooth
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

// Software Version Information
String sver = "26-20";

void loop() {

  // isBluetooth
  isBluetooth();
 
}

getBluetooth.ino

// Bluetooth
// Setup Bluetooth
void isSetupBluetooth(){

  // Setup Bluetooth
  // Begin the serial monitor at 9600bps
  Serial.begin(9600);
  // Bluetooth
  // The Bluetooth Mate defaults to 115200bps
  bluetooth.begin(115200);
  
  // Print three times individually
  bluetooth.print("$");
  bluetooth.print("$");
  bluetooth.print("$");
  // Enter command mode
  // Short delay, wait for the Mate to send back CMD
  delay(100);
  // Temporarily Change the baudrate to 9600, no parity
  bluetooth.println("U,9600,N");
  // 115200 can be too fast at times for NewSoftSerial to relay the data reliably
  // Start bluetooth serial at 9600
  bluetooth.begin(9600);
  
}
// isBluetooth
void isBluetooth() {

  // If the bluetooth sent any characters
  if(bluetooth.available())
  {
    
    // Send any characters the bluetooth prints to the serial monitor
    Serial.print((char)bluetooth.read());
    
  }
  // If stuff was typed in the serial monitor
  if(Serial.available())
  {
    
    // Send any characters the Serial monitor prints to the bluetooth
    bluetooth.print((char)Serial.read());
    
  }

}

setup.ino

// Setup
void setup()
{
  
  // Setup Bluetooth
  isSetupBluetooth();

}

——

SparkFun Thing Plus – ESP32 WROOM

RX2 – Bluetooth
TX2 – Bluetooth
VIN – +3.3V
GND – GND

——

DL2307Mk01ps.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - Bluetooth SparkFun Thing Plus - ESP32 WROOM  - Mk20
26-20
DL2307Mk01pr.ino
1 x Arduino Uno
1 x SparkFun Thing Plus - ESP32 WROOM
2 x SparkFun Bluetooth Mate Silver
2 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Bluetooth Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

// Bluetooth Serial
BluetoothSerial SerialBT;

// Software Version Information
String sver = "26-20";

void loop() {

  // isBluetooth
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// Setup Bluetooth
void isSetupBluetooth(){

  // Serial Begin
  Serial.begin(9600);
  
  // Bluetooth device name
  SerialBT.begin("DL2307Mk01ps");
  
  // Serial
  Serial.println("The device started, now you can pair it with bluetooth!");
  
}
// isBluetooth
void isBluetooth() {

  // If stuff was typed in the serial monitor
  if (Serial.available()) {
    
    // Send any characters the Serial monitor prints to the bluetooth
    SerialBT.write(Serial.read());
    
  }
  // If the bluetooth sent any characters
  if (SerialBT.available()) {
    
    // Send any characters the bluetooth prints to the serial monitor
    Serial.write(SerialBT.read());
    
  }
  // Delay
  delay(20);

}

setup.ino

// Setup
void setup()
{
  
  // Setup Bluetooth
  isSetupBluetooth();

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – 4×4 Offroad Race – Mk15

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #Games #Gamepad #ESP32 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

4x4 Offroad Race

——

4x4 Offroad Race

——

4x4 Offroad Race

——

4×4 Offroad Race

3D off-road racing game. Powerful off-road vehicles, trails and routes running on dirt roads, extreme weather conditions and violent opponents, all that we call 4×4 Offroad Race. You will be able to experience the most powerful four-wheel drive vehicles. You have to overcome terrible roads, do jumps over bumps and potholes and knock opponents off the track to win all the races.

DL2304Mk03

1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Terminal Block Breakout FeatherWing
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LJH – Analog A3
LJV – Analog A2
LJS – Digital 12
RJH – Analog A1
RJV – Analog A0
RJS – Digital 21
LD1 – Digital 16
LD2 – Digital 18
LD3 – Digital 19
LD4 – Digital 17
LT – Digital 5
LED – LED_BUILTIN
VIN – +3.3V
GND – GND

——

DL2304Mk03p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency - 4x4 Offroad Race - Mk15
26-15
DL2304Mk03p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Terminal Block Breakout FeatherWing
1 x Lithium Ion Battery - 1 Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Arduino
#include <Arduino.h>
// ESP32 BLE Gamepad
#include <BleGamepad.h>

// ESP32 BLE Gamepad
BleGamepad bleGamepad;

// Left Joystick
#define LJH A3
#define LJV A2
#define LJS 12

// Right Joystick
#define RJH A0
#define RJV A1
#define RJS 21

// D-pad
#define LD1 19
#define LD2 17
#define LD3 18
#define LD4 16

// LT 
#define LT 5

// Previous Button State
int previousButton1State = HIGH;
int previousButton2State = HIGH;
int previousButton3State = HIGH;
int previousButton4State = HIGH;
int previousButton5State = HIGH;
int previousButton6State = HIGH;
int previousButton7State = HIGH;

// Number of pot samples to take (to smooth the values)
const int numberOfPotSamples = 5;
// Delay in milliseconds between pot samples
const int delayBetweenSamples = 2;
// Additional delay in milliseconds between HID reports
const int delayBetweenHIDReports = 5;
// Delay in milliseconds between button press
const int debounceDelay = 10;

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

void loop() {
  
  // Bluetooth Serial (ESP32SPP)
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// isBluetooth
void isBluetooth() {

  // ESP32 BLE Gamepad
  if(bleGamepad.isConnected()) 
  {

    // Button
    isButton();

    // Joystick
    isThumbJoystick();

  }

}

getGames.ino

// Games
// Set Inputs
void setInputs() {
  
  // Make the button line an input
  pinMode(LJS, INPUT_PULLUP);
  pinMode(RJS, INPUT_PULLUP);
  pinMode(LD1, INPUT_PULLUP);
  pinMode(LD2, INPUT_PULLUP);
  pinMode(LD3, INPUT_PULLUP);
  pinMode(LD4, INPUT_PULLUP);
  pinMode(LT, INPUT_PULLUP);
  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH 
  digitalWrite(LED_BUILTIN, HIGH);

}

// Button
void isButton(){
  
  // Button1 State LD1
  int currentButton1State = digitalRead(LD1);
  if (currentButton1State != previousButton1State)
  {
    if (currentButton1State == LOW)
    {
      bleGamepad.press(BUTTON_1);
    }
    else
    {
      bleGamepad.release(BUTTON_1);
    }
  }
  previousButton1State = currentButton1State;
  // Button2 State LD2
  int currentButton2State = digitalRead(LD2);

  if (currentButton2State != previousButton2State)
  {
    if (currentButton2State == LOW)
    {
      bleGamepad.press(BUTTON_2);
    }
    else
    {
      bleGamepad.release(BUTTON_2);
    }
  }
  previousButton2State = currentButton2State;

  // Button3 State LD3
  int currentButton3State = digitalRead(LD3);
  if (currentButton3State != previousButton3State)
  {
    if (currentButton3State == LOW)
    {
      bleGamepad.press(BUTTON_3);
    }
    else
    {
      bleGamepad.release(BUTTON_3);
    }
  }
  previousButton3State = currentButton3State;

  // Button4 State LD4
  int currentButton4State = digitalRead(LD4);
  if (currentButton4State != previousButton4State)
  {
    if (currentButton4State == LOW)
    {
      bleGamepad.press(BUTTON_4);
    }
    else
    {
      bleGamepad.release(BUTTON_4);
    }
  }
  previousButton4State = currentButton4State;

  // Button5 State LJS
  int currentButton5State = digitalRead(LJS);
  if (currentButton5State != previousButton5State)
  {
    if (currentButton5State == LOW)
    {
      bleGamepad.press(BUTTON_5);
    }
    else
    {
      bleGamepad.release(BUTTON_5);
    }
  }
  previousButton5State = currentButton5State;

  // Button6 State RJS
  int currentButton6State = digitalRead(RJS);
  if (currentButton6State != previousButton6State)
  {
    if (currentButton6State == LOW)
    {
      bleGamepad.press(BUTTON_6);
    }
    else
    {
      bleGamepad.release(BUTTON_6);
    }
  }
  previousButton6State = currentButton6State;

  // Button7 State LT
  int currentButton7State = digitalRead(LT);
  if (currentButton7State != previousButton7State)
  {
    if (currentButton7State == LOW)
    {
      bleGamepad.press(BUTTON_7);
    }
    else
    {
      bleGamepad.release(BUTTON_7);
    }
  }
  previousButton7State = currentButton7State;

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Joystick LJH
  // Joystick Pot Values LJH
  int potValues[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues[i] = analogRead(LJH);
    delay(delayBetweenSamples);
    
  }
  int potValue = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValue += potValues[i];
    
  }
  // Value / Pot Samples
  potValue = potValue / numberOfPotSamples;
  // Adjusted Value
  int adjustedValue = map(potValue, 0, 4095, 32737, 0);

  // Joystick LJV
  // Joystick Pot Values LJV
  int potValues2[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues2[i] = analogRead(LJV);
    delay(delayBetweenSamples);
    
  }
  int potValue2 = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
    
    potValue2 += potValues2[i];
    
  }
  // Value2 / Pot Samples
  potValue2 = potValue2 / numberOfPotSamples;
  // Adjusted Value2
  int adjustedValue2 = map(potValue2, 0, 4095, 32737, 0);

  // Joystick RJH
  // Joystick Pot Values RJH
  int potValues3[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues3[i] = analogRead(RJH);
    delay(delayBetweenSamples);
    
  }
  int potValue3 = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
      potValue3 += potValues3[i];
      
  }
  // Value3 / Pot Samples
  potValue3 = potValue3 / numberOfPotSamples;
  // Adjusted Value3
  int adjustedValue3 = map(potValue3, 0, 4095, 32737, 0);

  // Joystick RJV
  // Joystick Pot Values RJV
  int potValues4[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues4[i] = analogRead(RJV);
    delay(delayBetweenSamples);
    
  }
  int potValue4 = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
      potValue4 += potValues4[i];
  
  }
  // Value4 / Pot Samples
  potValue4 = potValue4 / numberOfPotSamples;
  // Adjusted Value4
  int adjustedValue4 = map(potValue4, 0, 4095, 0, 32737);

  //bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_CENTERED);
  bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_CENTERED);
  delay(delayBetweenHIDReports);

  // D-pad
  // LD1
  if (digitalRead(LD1) == LOW){
      
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_UP);

  }
  // LD2
  if (digitalRead(LD2) == LOW){
    
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_LEFT);
  
  }
  // LD3
  if (digitalRead(LD3) == LOW){
      
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_DOWN);
  
  }
  // LD4
  if (digitalRead(LD4) == LOW){
      
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_RIGHT);

  }

}

setup.ino

// Setup
void setup()
{

  // Set Inputs
  setInputs();

  // ESP32 BLE Gamepad
  bleGamepad.begin();

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Project #26 – Radio Frequency – Gamepad Tester – Mk14

——

#DonLucElectronics #DonLuc #RadioFrequency #Bluetooth #JoystickTest #Gamepad #ESP32 #Arduino #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Gamepad Tester

——

Gamepad Tester

——

Gamepad Tester

——

Controller & Gamepad Tester

Controller Tester

You can begin testing your controller or gamepad by pressing a button or moving one of the analog sticks on your gamepad. When you press a button or move an analog stick, the illustration above should light up or display the movement of your analog stick. When we detect movement or button presses, the “Controller Detected” message will show up with your controller’s name in it. If you have multiple controllers or gamepads connected, then please try them one by one. Even though the illustration represents an Xbox controller, the test also works with other similar controllers.

DL2304Mk02

1 x SparkFun Thing Plus – ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Terminal Block Breakout FeatherWing
1 x Lithium Ion Battery – 1 Ah
1 x SparkFun Cerberus USB Cable

SparkFun Thing Plus – ESP32 WROOM

LJH – Analog A3
LJV – Analog A2
LJS – Digital 12
RJH – Analog A1
RJV – Analog A0
RJS – Digital 21
LD1 – Digital 16
LD2 – Digital 18
LD3 – Digital 19
LD4 – Digital 17
LT – Digital 5
LED – LED_BUILTIN
VIN – +3.3V
GND – GND

——

DL2304Mk02p.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #26 - Radio Frequency -  - Mk14
26-14
DL2304Mk02p.ino
1 x SparkFun Thing Plus - ESP32 WROOM
1 x SparkFun Joystick Shield Kit
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Terminal Block Breakout FeatherWing
1 x Lithium Ion Battery - 1 Ah
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// Arduino
#include <Arduino.h>
// ESP32 BLE Gamepad
#include <BleGamepad.h>

// ESP32 BLE Gamepad
BleGamepad bleGamepad;

// Left Joystick
#define LJH A3
#define LJV A2
#define LJS 12

// Right Joystick
#define RJH A0
#define RJV A1
#define RJS 21

// D-pad
#define LD1 19
#define LD2 17
#define LD3 18
#define LD4 16

// LT 
#define LT 5

// Previous Button State
int previousButton1State = HIGH;
int previousButton2State = HIGH;
int previousButton3State = HIGH;
int previousButton4State = HIGH;
int previousButton5State = HIGH;
int previousButton6State = HIGH;
int previousButton7State = HIGH;

// Number of pot samples to take (to smooth the values)
const int numberOfPotSamples = 5;
// Delay in milliseconds between pot samples
const int delayBetweenSamples = 2;
// Additional delay in milliseconds between HID reports
const int delayBetweenHIDReports = 5;
// Delay in milliseconds between button press
const int debounceDelay = 10;

// Software Version Information
String sver = "26-14";

void loop() {
  
  // Bluetooth Serial (ESP32SPP)
  isBluetooth();

}

getBluetooth.ino

// Bluetooth
// isBluetooth
void isBluetooth() {

  // ESP32 BLE Gamepad
  if(bleGamepad.isConnected()) 
  {

    // Button
    isButton();

    // Joystick
    isThumbJoystick();

  }

}

getGames.ino

// Games
// Set Inputs
void setInputs() {
  
  // Make the button line an input
  pinMode(LJS, INPUT_PULLUP);
  pinMode(RJS, INPUT_PULLUP);
  pinMode(LD1, INPUT_PULLUP);
  pinMode(LD2, INPUT_PULLUP);
  pinMode(LD3, INPUT_PULLUP);
  pinMode(LD4, INPUT_PULLUP);
  pinMode(LT, INPUT_PULLUP);
  // Initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  // Turn the LED on HIGH 
  digitalWrite(LED_BUILTIN, HIGH);

}

// Button
void isButton(){
  
  // Button1 State LD1
  int currentButton1State = digitalRead(LD1);
  if (currentButton1State != previousButton1State)
  {
    if (currentButton1State == LOW)
    {
      bleGamepad.press(BUTTON_1);
    }
    else
    {
      bleGamepad.release(BUTTON_1);
    }
  }
  previousButton1State = currentButton1State;
  // Button2 State LD2
  int currentButton2State = digitalRead(LD2);

  if (currentButton2State != previousButton2State)
  {
    if (currentButton2State == LOW)
    {
      bleGamepad.press(BUTTON_2);
    }
    else
    {
      bleGamepad.release(BUTTON_2);
    }
  }
  previousButton2State = currentButton2State;

  // Button3 State LD3
  int currentButton3State = digitalRead(LD3);
  if (currentButton3State != previousButton3State)
  {
    if (currentButton3State == LOW)
    {
      bleGamepad.press(BUTTON_3);
    }
    else
    {
      bleGamepad.release(BUTTON_3);
    }
  }
  previousButton3State = currentButton3State;

  // Button4 State LD4
  int currentButton4State = digitalRead(LD4);
  if (currentButton4State != previousButton4State)
  {
    if (currentButton4State == LOW)
    {
      bleGamepad.press(BUTTON_4);
    }
    else
    {
      bleGamepad.release(BUTTON_4);
    }
  }
  previousButton4State = currentButton4State;

  // Button5 State LJS
  int currentButton5State = digitalRead(LJS);
  if (currentButton5State != previousButton5State)
  {
    if (currentButton5State == LOW)
    {
      bleGamepad.press(BUTTON_5);
    }
    else
    {
      bleGamepad.release(BUTTON_5);
    }
  }
  previousButton5State = currentButton5State;

  // Button6 State RJS
  int currentButton6State = digitalRead(RJS);
  if (currentButton6State != previousButton6State)
  {
    if (currentButton6State == LOW)
    {
      bleGamepad.press(BUTTON_6);
    }
    else
    {
      bleGamepad.release(BUTTON_6);
    }
  }
  previousButton6State = currentButton6State;

  // Button7 State LT
  int currentButton7State = digitalRead(LT);
  if (currentButton7State != previousButton7State)
  {
    if (currentButton7State == LOW)
    {
      bleGamepad.press(BUTTON_7);
    }
    else
    {
      bleGamepad.release(BUTTON_7);
    }
  }
  previousButton7State = currentButton7State;

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Joystick LJH
  // Joystick Pot Values LJH
  int potValues[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues[i] = analogRead(LJH);
    delay(delayBetweenSamples);
    
  }
  int potValue = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValue += potValues[i];
    
  }
  // Value / Pot Samples
  potValue = potValue / numberOfPotSamples;
  // Adjusted Value
  int adjustedValue = map(potValue, 0, 4095, 32737, 0);

  // Joystick LJV
  // Joystick Pot Values LJV
  int potValues2[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues2[i] = analogRead(LJV);
    delay(delayBetweenSamples);
    
  }
  int potValue2 = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
    
    potValue2 += potValues2[i];
    
  }
  // Value2 / Pot Samples
  potValue2 = potValue2 / numberOfPotSamples;
  // Adjusted Value2
  int adjustedValue2 = map(potValue2, 0, 4095, 32737, 0);

  // Joystick RJH
  // Joystick Pot Values RJH
  int potValues3[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues3[i] = analogRead(RJH);
    delay(delayBetweenSamples);
    
  }
  int potValue3 = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
      potValue3 += potValues3[i];
      
  }
  // Value3 / Pot Samples
  potValue3 = potValue3 / numberOfPotSamples;
  // Adjusted Value3
  int adjustedValue3 = map(potValue3, 0, 4095, 32737, 0);
  Serial.print(" RJH: ");
  Serial.println(potValue3);

  // Joystick RJV
  // Joystick Pot Values RJV
  int potValues4[numberOfPotSamples];
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
    potValues4[i] = analogRead(RJV);
    delay(delayBetweenSamples);
    
  }
  int potValue4 = 0;
  for (int i = 0 ; i < numberOfPotSamples ; i++) {
      
      potValue4 += potValues4[i];
  
  }
  // Value4 / Pot Samples
  potValue4 = potValue4 / numberOfPotSamples;
  // Adjusted Value4
  int adjustedValue4 = map(potValue4, 0, 4095, 0, 32737);
  Serial.print(" RJV: ");
  Serial.println(potValue4);

  //bleGamepad.setAxes(adjustedValue, adjustedValue2, 0, 0, adjustedValue3, adjustedValue4, DPAD_CENTERED);
  bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_CENTERED);
  delay(delayBetweenHIDReports);

  // D-pad
  // LD1
  if (digitalRead(LD1) == LOW){
      
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_UP);

  }
  // LD2
  if (digitalRead(LD2) == LOW){
    
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_LEFT);
  
  }
  // LD3
  if (digitalRead(LD3) == LOW){
      
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_DOWN);
  
  }
  // LD4
  if (digitalRead(LD4) == LOW){
      
    bleGamepad.setAxes(adjustedValue, adjustedValue2, adjustedValue4, 0, adjustedValue3, 0, DPAD_RIGHT);

  }

}

setup.ino

// Setup
void setup()
{
 
  // Serial
  Serial.begin(115200);
  
  // Set Inputs
  setInputs();

  // ESP32 BLE Gamepad
  bleGamepad.begin();

}

——

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

Technology Experience

  • Programming Language
  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Wireless (Radio Frequency, Bluetooth, WiFi, Etc…)
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Machine Learning
  • RTOS
  • Research & Development (R & D)

Instructor, E-Mentor, STEAM, and Arts-Based Training

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

Follow Us

Luc Paquin – Curriculum Vitae – 2023
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

Categories
Archives