Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Alex Merchen
Created March 1, 2020 © GPL3+

Smart IoT Tray

Make a smart IoT tray that keeps your food hot, can be turned on and off using a Kemet Proximity Sensor and can be remotely controlled.

IntermediateFull instructions provided10 hours75

Things used in this project

Hardware components

Adafruit Feather HUZZAH with ESP8266 WiFi
Adafruit Feather HUZZAH with ESP8266 WiFi
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 330 ohm
Resistor 330 ohm
×3
SparkFun Heating Pad
×1
Breadboard (generic)
Breadboard (generic)
×1
Power MOSFET N-Channel
Power MOSFET N-Channel
×1
Dadamachines Power Supply
×1
SparkFun SHR Connector
×1

Software apps and online services

Arduino IDE
Arduino IDE
Adafruit IO

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Shapeoko CNC

Story

Read more

Custom parts and enclosures

Smart Tray Cad File

Schematics

Circuit Design

Code

Main Program

Arduino
Arduino Code to upload to the Feather Huzzah
#include "config.h"

#define LED_PIN 4

int Pyro = A0;
int heatpad = 14;
unsigned long PyroRead = 0;
unsigned long IR_threshold = 198000;
int anaValue = 0;
int pulses = 0;

// set up the 'digital' feed
AdafruitIO_Feed *digital = io.feed("digital");

// IR_threshold is in microsec (usec), therefore 198msec threshold
int LED = 7;
int Detected = LOW;
int IR_sensed = 0;

void setup() {
  
  pinMode (Pyro,INPUT); // IR Sensor connected to A1
  pinMode(heatpad, OUTPUT);
  pinMode(LED_PIN, OUTPUT);
  
  // start the serial connection
  Serial.begin(115200);

  // wait for serial monitor to open
  while(! Serial);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");
  io.connect();

  // set up a message handler for the 'digital' feed.
  // the handleMessage function (defined below)
  // will be called whenever a message is
  // received from adafruit io.
  digital->onMessage(handleMessage);

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  // we are connected
  Serial.println();
  Serial.println(io.statusText());
  digital->get();

}

void loop() {

  // io.run(); is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  // io.adafruit.com, and processes any incoming data.
  

  while ((IR_sensed < 2)){ //Break after 2 good triggers PyroRead = pulseIn(A1, HIGH); //Measure trigger point if(PyroRead > IR_threshold){ //Make sure trigger is over 198msec)
    while (pulses < 5) {
      io.run();
      anaValue = analogRead(Pyro);
      Serial.println(anaValue);
      if (anaValue == 1024) {
        pulses++;
      }
      else {
        pulses = 0;
      }
      delay(100);
    }

    IR_sensed++;
    pulses = 0;
    delay(100);
  }
  
  if (Detected == HIGH)
    {
      digitalWrite(heatpad, LOW);
      Detected = LOW;
      digitalWrite(4, LOW);
   }
  else {
    digitalWrite(heatpad, HIGH);
    Detected = HIGH;
    digitalWrite(4, HIGH);
  }

  digital->save(Detected);

  PyroRead = 0; // Reset readings
  IR_sensed = 0;
  delay(1000); // Accept triggers after a second
  
  

}

// this function is called whenever an 'digital' feed message
// is received from Adafruit IO. it was attached to
// the 'digital' feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {

  Serial.print("received <- ");

  if(data->toPinLevel() == HIGH)
  {
    Serial.println("MANUAL HIGH");
    digitalWrite(heatpad, HIGH);
    Detected = HIGH;
    digitalWrite(4, HIGH);
    
  }
  else {
    Serial.println("MANUAL LOW");
    digitalWrite(heatpad, LOW);
    Detected = LOW;
    digitalWrite(4, LOW);
  }

  PyroRead = 0; // Reset readings
  IR_sensed = 0;

}

Credits

Alex Merchen

Alex Merchen

24 projects • 39 followers
I'm an EE with a Masters in ECE. I like building things.

Comments