Collecting data from the physical world.

Discussion created by KylePutzier on Jun 16, 2015
Latest reply on Jun 16, 2015 by coherentkris

No questions. Just thought I would share what I've learned recently.


I want to gather production information from my companies machines. Some of this data is a count of how much raw material go through the machines. In the past I have had the operator manually enter the counter information into FileMaker. Then I found a counter device that had a built-in telnet server, so I was able to write a shell script to communicate with the telnet server. I got close to full automation, but there were issues with the way the device operated and then the company quit making them. Killed that idea. Found quite a few other devices, but all were either cost prohibitive or to difficult for my brain to understand.

I have now found an easy way to gather that info programmably by using a simple little microprocessor called Arduino.

An Arduino is a very small device that has quite a few I/O connections that can be connected to many different types of sensors. I learned enough Arduino programming to build exactly what I need.


Basically I just had to couple it with a ethernet board, add an inductive proximity sensor, add a counter and a web server program and read the values via FileMakers Insert URL script step. Total cost $50, or so, for each machine. Well within my budget.

I can see a future where I can program an Arduino to control the machines from data obtained programmably from FileMaker.

Arduino's have been around for quite awhile. I don't think they will become obsolete anytime soon.


Below is the program I cobbled together from snippets I found. It's basically a very simple C++ program. The program waits for an incoming signal, debounces it, increments the counter variable, saves that number to permanent memory and checks/processes web requests . It can do all that in .012th of a second (12,000 microseconds). It idles (waits for an incoming signal) at 136 microseconds.


#include <SPI.h>

#include <Ethernet.h>

#include <avr/eeprom.h>


const int buttonPin = 2;

const int PulsePin = 7;

const int ReadyPin = 6;

int buttonState;

int lastButtonState = LOW;

unsigned long CurrentCount = 0;

long lastDebounceTime = 0;

long debounceDelay = 10;

EEMEM unsigned long Location;


byte mac[] = {

  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED  // The MAC address can be anything as long as it is unique


IPAddress ip(192, 168, 1, 177);

EthernetServer server(80);


void setup() {

  CurrentCount = eeprom_read_dword( &Location );

  pinMode(buttonPin, INPUT);

  pinMode(PulsePin, OUTPUT);

  pinMode(ReadyPin, OUTPUT);

  digitalWrite(PulsePin, LOW);  // set initial LED state


  Ethernet.begin(mac, ip);


  digitalWrite(ReadyPin, HIGH);  // Program is running indicator



void loop() {


  //  // Program run time seconds.

  //  unsigned int time = 0;

  //  time = micros();

  //  //


  int reading = digitalRead(buttonPin);  // read the state of the switch into a local variable:

  if (reading != lastButtonState) {

    lastDebounceTime = millis();     // reset the debouncing timer



  if ((millis() - lastDebounceTime) > debounceDelay) {

    if (reading != buttonState) {

      buttonState = reading;

      if (buttonState == HIGH) {

        digitalWrite(PulsePin, HIGH); // Blink the LED to show a pulse has arrived

        delay (1);

        digitalWrite(PulsePin, LOW);

        CurrentCount = ++CurrentCount; // Increment the counter

//        Serial.println(CurrentCount);

        eeprom_write_dword( &Location, CurrentCount );




  lastButtonState = reading;


  Web(); // Check for a web request


  //  // Program run time seconds

  //  time = micros() - time;

  //  Serial.println(time, DEC);

  //  delay(100);

  //  //



void Web() {

  // listen for incoming web request (clients)

  EthernetClient client = server.available();

  if (client) {

    boolean currentLineIsBlank = true;

    while (client.connected()) {

      if (client.available()) {

        char c =;

        // send a standard http response header

        client.println("HTTP/1.1 200 OK");

        client.println("Content-Type: text/html");

        client.println("Connection: close");

//        client.println("Refresh: 1");  // Refresh used for debugging purposes. Comment out when not needed.


        client.println("<!DOCTYPE HTML>");


        client.print("The count is ");


        client.println("<br />");





    delay(1);    // give the web browser time to receive the data