Wen-Liang Lin
Published © MIT

Blow Strength Beacon

By blowing through DC fan as a sensor to measure blow strength. Then use BLE to beacon value.

BeginnerFull instructions provided1 hour492
Blow Strength Beacon

Things used in this project

Hardware components

nRF52 Development Kit
Nordic Semiconductor nRF52 Development Kit
PCA10056
×1
Capacitor 10 µF
Capacitor 10 µF
×1
Resistor 100k ohm
Resistor 100k ohm
×1
Bridge Rectifier Diode, Single Phase
Bridge Rectifier Diode, Single Phase
×1
Axial Fan, 12 VDC
Axial Fan, 12 VDC
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×2
Breadboard (generic)
Breadboard (generic)
×1
Male-Header 36 Position 1 Row- Long (0.1")
Male-Header 36 Position 1 Row- Long (0.1")
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE
beacon scanner

Story

Read more

Schematics

sensor sch

Code

Nrf52840 blow

Arduino
/*********************************************************************
 This is an example for our nRF52 based Bluefruit LE modules

 Pick one up today in the adafruit shop!

 Adafruit invests time and resources providing this open source code,
 please support Adafruit and open-source hardware by purchasing
 products from Adafruit!

 MIT license, check LICENSE for more information
 All text above, and the splash screen below must be included in
 any redistribution
*********************************************************************/
#include <bluefruit.h>

// Beacon uses the Manufacturer Specific Data field in the advertising
// packet, which means you must provide a valid Manufacturer ID. Update
// the field below to an appropriate value. For a list of valid IDs see:
// https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers
// 0x004C is Apple (for example)
#define MANUFACTURER_ID   0x004C 

// AirLocate UUID: E2C56DB5-DFFB-48D2-B060-D0F5A71096E0
uint8_t beaconUuid[16] = 
{ 
  0xE2, 0xC5, 0x6D, 0xB5, 0xDF, 0xFB, 0x48, 0xD2, 
  0xB0, 0x60, 0xD0, 0xF5, 0xA7, 0x10, 0x96, 0xE0, 
};

// A valid Beacon packet consists of the following information:
// UUID, Major, Minor, RSSI @ 1M
BLEBeacon beacon(beaconUuid, 0x0000, 0x0000, -80);

int adcin    = A5;
int adcvalue = 0;
//float mv_per_lsb = 3600.0F/1024.0F; // 10-bit ADC with 3.6V input range
uint16_t ADsum,ADavg;
int ADread,read_cnt;
int Blow_Flag;
uint16_t Major, Minor;
void setup() 
{
  Serial.begin(115200);
  while ( !Serial ) delay(10);   // for nrf52840 with native usb

  Serial.println("Blow strength recorder");
  Serial.println("--------------------------\n");

  Bluefruit.begin();

  // off Blue LED for lowest power consumption
  Bluefruit.autoConnLed(false);
  Bluefruit.setTxPower(0);    // Check bluefruit.h for supported values
  Bluefruit.setName("Blow");

  // Manufacturer ID is required for Manufacturer Specific Data
  beacon.setManufacturer(MANUFACTURER_ID);

  // Setup the advertising packet


  Serial.println("Broadcasting beacon, open your beacon app to test");

}

void startAdv(void)
{  
  // Advertising packet
  // Set the beacon payload using the BLEBeacon class populated
  // earlier in this example
  Bluefruit.Advertising.setBeacon(beacon);

  // Secondary Scan Response packet (optional)
  // Since there is no room for 'Name' in Advertising packet
  Bluefruit.ScanResponse.addName();
  
  /* Start Advertising
   * - Enable auto advertising if disconnected
   * - Timeout for fast mode is 30 seconds
   * - Start(timeout) with timeout = 0 will advertise forever (until connected)
   * 
   * Apple Beacon specs
   * - Type: Non connectable, undirected
   * - Fixed interval: 100 ms -> fast = slow = 100 ms
   */
  //Bluefruit.Advertising.setType(BLE_GAP_ADV_TYPE_ADV_NONCONN_IND);
  Bluefruit.Advertising.restartOnDisconnect(true);
  Bluefruit.Advertising.setInterval(160, 160);    // in unit of 0.625 ms
  Bluefruit.Advertising.setFastTimeout(30);      // number of seconds in fast mode
  Bluefruit.Advertising.start(30);                // 0 = Don't stop advertising after n seconds  
}



void loop() {
  delay(50);
  ADread = analogRead(adcin);

  if(ADread>=5)
  {
    Blow_Flag = 1;
    ADsum += ADread;
    read_cnt++;
    Serial.print(ADread);
    Serial.print(",");
    Serial.print(ADsum);
    Serial.print(",");
    Serial.print(ADavg);
    Serial.print(",");
    Serial.println(read_cnt);
  }
  else if( ADread <= 5 && Blow_Flag == 1 && read_cnt>10)
  {
    ADavg = ADsum / read_cnt;
    Major=ADsum/256+(ADsum%256)*256;
    Minor=ADavg/256+(ADavg%256)*256;
    beacon.setMajorMinor(Major, Minor); //Big Endian
    startAdv();
    
    Blow_Flag = 0;
    read_cnt = 0;
    ADsum = 0;
  }
  else if( ADread < 5 )
  {
    Blow_Flag = 0;
    read_cnt = 0;
    ADsum = 0;
  }
}

Credits

Wen-Liang Lin

Wen-Liang Lin

28 projects • 34 followers
Hi, I am momososo

Comments