JAMES BLACK
Published © MIT

Smart Shop Controller

This smart shop controller is for any shop concerned with safety, security and sanitation. A fully connected device for any shop owner.

BeginnerWork in progressOver 2 days138
Smart Shop Controller

Things used in this project

Hardware components

Argon
Particle Argon
×1
Adafruit Monochrome 1.3" 128x64 OLED graphic display
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
×1
MAX30105 High-Sensitivity Optical Sensor for Smoke Detection Applications
Maxim Integrated MAX30105 High-Sensitivity Optical Sensor for Smoke Detection Applications
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Photodiode, 1 nA
Photodiode, 1 nA
×1
Philips hue
Philips hue
×1

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

CustomLogo/BigButton

you can put on the front of the enclosure or use as a huge encoder button

Schematics

SmartShopSchematic

Code

SmartShopController1

C/C++
I used this code to set off red warning phillips hue lights if smoke is detected , this would serve as a gentle warning to workers that a tee shirt or printing platen may be getting too hot and to address it before there is scorching. Also there is a photodiode that sends a signal to a servo motor that can be hooked up to a locking mechanism when it is dark, basically if the lights are out, the shop should be locked, and this serves as a failsafe if someone forgets to lock the door, an extra layer of security. And last but not least, the Smart Shop Controller even comes equipped with a liquid sensor that controls a pump to clean up any undesireable liquids, like someone urinating in the shop, one of my pet peeves! Basically the liquid sensor senses liquid and activates a smart plug that pumps water out from a water pump, to clean up the mess a bit. (There is a manual button for neo pixel, open sign and encoder controlled phillips hue lights that did not make it into this code!)
/*
 * Project SmartShopSourceCode002
 * Description: SmartShopSourceCode
 * Author:JBlack
 * Date:03-09-2023
 */
#include "IoTClassroom_CNM.h"
#include <math.h>
const int photodiodePin = A1; // reading from photodiode
const int servoPin = D8; //servo pin
int photodiodeValue, brightness;  //int for photodiodevalue , int for brightness
const float OFFSET = 90; 
const float AMP = 90;
float t; // variable for time
float signal; // variable that will be outputted
float freq = 0.2; // frequency for sin-wave. freq = 1/period
const int BULB5= 5;
const int BULB4=4;
const int BULB3=3;
const int BULB2=2;
const int BULB1=1;
int color;
const int button=D5;
bool buttonState;
bool toggleState;

int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 30000;//sampe 30s ;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;
const int waterSens = A3; // define water sensor
int val;
int relay = 17;

Servo myservo; // create servo object to control a servo
SYSTEM_MODE (SEMI_AUTOMATIC);
void setup()
{
  {
  pinMode(waterSens, INPUT); // set water sensor as an input
  Serial.begin(9600); // initialize Serial  
}
pinMode(relay, OUTPUT);      // Initialize pin as an output

  Serial.begin (9600);
  pinMode(photodiodePin, INPUT);
  myservo.attach(servoPin); // attached to pin D6
  pinMode(pin,INPUT);
    starttime = millis();
  waitFor(Serial.isConnected,15000);
  
  WiFi.on();
  WiFi.setCredentials("IoTNetwork");

  WiFi.connect();
  while(WiFi.connecting()) {
    Serial.printf(".");
  }
  delay(1000);
  Serial.printf("\n\n");
  

}
  void loop() {
  duration = pulseIn(pin, LOW);
    lowpulseoccupancy = lowpulseoccupancy+duration;

    if ((millis()-starttime) > sampletime_ms){
    concentration >=3000;
    duration = millis();
   //switchON ();
     setHue(BULB5,true,HueRed,255,255);
     setHue(BULB4,true,HueRed,255,255);
     setHue(BULB3,true,HueRed,255,255);
     setHue(BULB2,true,HueRed,255,255);
     setHue(BULB1,true,HueRed,255,255);
} 
  
   else {
   setHue(BULB5,false,HueRed,255,255);
   setHue(BULB4,false,HueRed,255,255);
   setHue(BULB3,false,HueRed,255,255);
   setHue(BULB2,false,HueRed,255,255);
  setHue(BULB1,false,HueRed,255,255);
    
   }    //switchOFF ();
    Serial.printf ("sensorread");
     photodiodeValue = analogRead(photodiodePin);
  brightness = 255 - (photodiodeValue / 16);
  Serial.printf("\n\n\nphotodiodeValue=%i\n,brightness=%i\n\n\n",photodiodeValue,brightness);
  
 // analogWrite(servoPin, brightness);

// myservo.write(60);
// delay(1000);
// myservo.write(120);
// delay(1100);

  if (photodiodeValue < 600) { // check if it is dark
    signal = AMP * sin(2 * M_PI * freq * t) + OFFSET; //sine wave
    myservo.write(signal); //send via my servo
    t = millis() / 1000.0; //time in milliseconds
  }
  val = analogRead(waterSens);
  if (val > 150){// read the water sensor
  Serial.printf("Water level value = %d\n", val); // print the water level value to Serial
digitalWrite(relay, HIGH);   // Turn the relay on (HIGH is the voltage level = 1)
delay(5000);                 // Stay ON for 5 seconds
digitalWrite(relay, LOW);    // Turn the relay off by making the voltage LOW = 0
delay(3000);                 // Stay OFF for 30 seconds
}
  }

GitHubof SmartShop

Project folders for all code. Use Git Commands

Credits

JAMES BLACK
3 projects • 9 followers
I decorate T-Shirts, I have been developing for 10 weeks. IoT Bootcamp representing Abq Public Art department under Brian Rashap and EJ
Contact
Thanks to Brain Rashap and Edward Ishman.

Comments

Please log in or sign up to comment.