George Foroglou
Created October 12, 2017

EMBIoTS - End-to-End IoT Systems for Power Tools

A system, embedded on power tools, that can prevent damages on the tool and warn the user when a service is needed.

92

Things used in this project

Hardware components

ST Sensortile
×1
NFC sensor
×1
Flexiforce Sensor
×1
Non-Invasive Current Sensor
×1
Hall Effect Sensor US1881
×1

Software apps and online services

Windows 10 IoT Core
Microsoft Windows 10 IoT Core

Story

Read more

Schematics

Schematic

Code

Diagnostics

R
library(neuralnet)
nnet_drilltrain <-drilltrain
drilltrain$Materials <- c("wood","cement","brick","concrete")
drilltrain <- data.frame(Pressure=numeric(0),Bit=character(0),IPM=numeric(0),Consumption=(0),Material=character(0))
drilltrain <- edit(drilltrain)
drilltest$Materials <- c("wood","cement","brick","concrete")
drilltest <- data.frame(Pressure=numeric(0),Bit=character(0),IPM=numeric(0),Consumption=(0),Material=character(0))
drilltest <- edit(drilltest)
#Binarize the categorical output
nnet_drilltrain <- cbind(nnet_drilltrain, drilltrain$Material == ‘wood’)
nnet_drilltrain <- cbind(nnet_drilltrain, drilltrain$Material == ‘cement’)
nnet_drilltrain <- cbind(nnet_drilltrain, drilltrain$Material == ‘brick’)
nnet_drilltrain <- cbind(nnet_drilltrain, drilltrain$Material == ‘concrete’)
names(nnet_drilltrain)[6] <- ‘wood’
names(nnet_drilltrain)[7] <- ‘cement’
names(nnet_drilltrain)[8] <- ‘brick’
names(nnet_drilltrain)[9] <- ‘concrete’
nn <- neuralnet(wood+cement+brick+concrete ~ Pressure + Bit +
IPM + Consumption, data=nnet_drilltrain, hidden=c(4))
plot(nn)
mypredict <- compute(nn, drilltest[-5])$net.result
# Consolidate multiple binary output back to categorical output
maxidx <- function(arr) {
+ return(which(arr == max(arr)))
+ }
idx <- apply(mypredict, c(1), maxidx)
prediction <- c(‘wood’, ‘cement’, ‘brick’,‘concrete’)[idx]
table(prediction, drilltest$Materials)

NFC

C/C++
/* used the generic code for the MFRC522 breakout board 
added small parts for our project. In this project
we used our one and only drill so we have only one
written tag
*/

#include <MFRC522.h>
#include <SPI.h>

#define SAD 10
#define RST 5

MFRC522 nfc(SAD, RST);

void setup() {
  SPI.begin();
  // Read a fast as possible. There is a limit for how long we are
  // allowed to read from the tags.
  Serial.begin(115200);

  Serial.println("Looking for MFRC522.");
  nfc.begin();

  // Get the firmware version of the RFID chip
  byte version = nfc.getFirmwareVersion();
  if (! version) {
    Serial.print("Didn't find MFRC522 board.");
    while(1); //halt
  }

  Serial.print("Found chip MFRC522 ");
  Serial.print("Firmware ver. 0x");
  Serial.print(version, HEX);
  Serial.println(".");
}

/* keyA and keyB used for different tags
with sample values that we can change according
to the drill bits we have */

byte keyA[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };
byte keyB[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, };

void loop() {
  byte status;
  byte data[MAX_LEN];
  byte serial[5];
  int i, j, pos;

  // Send a general request out into the aether. If there is a tag in
  // the area it will respond and the status will be MI_OK.
  status = nfc.requestTag(MF1_REQIDL, data);

  if (status == MI_OK) {
    Serial.println("Tag detected.");
    Serial.print("Type: ");
    Serial.print(data[0], HEX);
    Serial.print(", ");
    Serial.println(data[1], HEX);

    // calculate the anti-collision value for the currently detected
    // tag and write the serial into the data array.
    status = nfc.antiCollision(data);
    memcpy(serial, data, 5);

    Serial.println("The serial nb of the tag is:");
    for (i = 0; i < 3; i++) {
      Serial.print(serial[i], HEX);
      Serial.print(", ");
    }
    Serial.println(serial[3], HEX);
    
    /* Select the tag we want to communicate with*/
    nfc.selectTag(serial);

    // Assuming that there are only 64 blocks of memory in this chip.
    for (i = 0; i < 64; i++) {
      // Try to authenticate each block first with the A key.
      status = nfc.authenticate(MF1_AUTHENT1A, i, keyA, serial);
      if (status == MI_OK) {
        Serial.print("Authenticated block nb. 0x");
        Serial.print(i, HEX);
        Serial.println(" with key A.");
        // Reading block i from the tag into data.
        status = nfc.readFromTag(i, data);
        if (status == MI_OK) {
          // If there was no error when reading; print all the hex
          // values in the data.
          for (j = 0; j < 15; j++) {
            Serial.print(data[j], HEX);
            Serial.print(", ");
          }
          Serial.println(data[15], HEX);
        } else {
          Serial.println("Read failed.");
        }
      } else {
        // If we could not authenticate with the A key, we will try
        // the B key.
        status = nfc.authenticate(MF1_AUTHENT1B, i, keyB, serial);
        if (status == MI_OK) {
          Serial.print("Authenticated block nb. 0x");
          Serial.print(i, HEX);
          Serial.println(" with key B.");
          status = nfc.readFromTag(i, data);
          if (status == MI_OK) {
            for (j = 0; j < 15; j++) {
              Serial.print(data[j], HEX);
              Serial.print(", ");
            }
            Serial.println(data[15], HEX);
          } else {
            Serial.println("Read failed.");
          }
        } else {
          Serial.print("Access denied at block nb. 0x");
          Serial.println(i, HEX);
        }
      }
    }

    // Stop the tag and get ready for reading a new tag.
    nfc.haltTag();
  }
  delay(2000);
}

Credits

George Foroglou

George Foroglou

3 projects • 0 followers
Thanks to Adalakis Lefteris and Kyriazidis George.

Comments