Home > Projects > Seat Monitor

Seat Monitor

Summary of Seat Monitor


This project uses ARTIK Cloud to monitor vehicle seat occupancy via vibration sensors. It detects if a seat is empty or occupied by reading piezo sensor data, processing it through an Arduino MKR1000 and Realtek Ameba board, and updating the status on the cloud. An onboard LED indicates seat availability: green for empty, off when occupied. The system works for trains, buses, and boats but not planes due to RF restrictions.

Parts used in Seat Monitor:

  • Arduino MKR1000
  • Realtek Ameba RTL8195 Board
  • ControlEverything.com Piezo Sensor
  • Seeed Grove - Piezo Vibration Sensor
  • Samsung ARTIK Cloud for IoT

Using ARTIK cloud to monitor cabin seat state.

Things used in this project

Hardware components

Arduino MKR1000
Arduino MKR1000
× 1
Realtek Ameba RTL8195 Board
× 1
Piezo Sensor
ControlEverything.com Piezo Sensor
× 1
Seeed Grove – Piezo Vibration Sensor
× 1

Software apps and online services

ARTIK Cloud for IoT
Samsung ARTIK Cloud for IoT

Story

seat sensor

Arduino

Ameba RTL8195 Board
/*
 Thanks Ameba Basic MQTT example
 I mark some point I stuck
*/

#include <WiFi.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.

char ssid[] = "ssid";     // your network SSID (name)
char pass[] = "pass";  // your network password
int status  = WL_IDLE_STATUS;    // the Wifi radio's status
//******************************************************************************
//must double check when you copy the code
//******************************************************************************
// MQTT - Artik Cloud Server params
char mqttServer[]     = "api.artik.cloud";
int  mqttPort         = 8883;
char clientId[]       = "seat";
char Device_ID[]   = "Device_ID"; // DEVICE ID
char Device_TOKEN[]   = "Device_TOKEN"; //  DEVICE TOKEN
char publishTopic[]   = "/v1.1/messages/Device_ID";
char subscribeTopic[] = "/v1.1/actions/Device_ID";
char publishPayload[128];

int sensorValue;
int sensorValuetemp;
//******************************************************************************
//must use SSL when MQTT protocol
//******************************************************************************
WiFiSSLClient wifiClient;
PubSubClient client(mqttServer, mqttPort,wifiClient);

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect(clientId, Device_ID, Device_TOKEN)) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish(publishTopic, publishPayload);
      // ... and resubscribe
      client.subscribe(subscribeTopic);
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}
void publish(void) //publish seat sensor value to cloud
{
  /*
   * smaple field
   * {"seatvalue":1}
   */
   //creat field data make it short or ARTIK cloud not work
  memset(publishPayload, 0, sizeof(publishPayload));
  sprintf(publishPayload, "{\"seatvalue\":%d}",sensorValue);
  printf("\t%s\r\n", publishPayload);
  client.publish(publishTopic, publishPayload);
}
void setup()
{
  Serial.begin(38400);

  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);
    // wait 5 seconds for connection:
    delay(5000);
  }
  reconnect();
  Serial.println("initial sensorValue");
  Serial.println(sensorValue);
  // Allow the hardware to sort itself out
  delay(1500);
}

void loop()
{
  
  if (!client.connected()) { //check connect state and reconnect
    reconnect();
  }
  for (int i =0; i<10;i++)
  { // delay 1 Mnts
   client.loop();
   sensorValue = analogRead(A0); //read sensor value
   Serial.println(sensorValue);
   if(sensorValue!=sensorValuetemp) //publish when sensorValue change
   {
      publish();
      sensorValuetemp = sensorValue; //save current sensor value
   }
    Serial.println(publishPayload);
    delay(6000);
  }  
}

 

Source : Seat Monitor

Quick Solutions to Questions related to Seat Monitor:

  • How does the system indicate an empty seat?
    The controller shows a green light when the seat is empty.
  • Can this project be used on airplanes?
    No, it cannot be used on planes because of RF restrictions.
  • What happens when someone sits on the seat?
    The sensor sends data to the cloud and the controller LED automatically turns off.
  • Which hardware components act as the vehicle controller?
    The Arduino MKR1000 serves as the vehicle controller.
  • What role does the Realtek Ameba board play?
    The Realtek Ameba RTL8195 Board acts as a Wifi buffer to send data to the cloud.
  • Does the system update old vehicles easily?
    Yes, it can directly update old vehicles to make finding seats easier.
  • What type of sensor monitors the seat state?
    A Piezo sensor is used to monitor the seat state.
  • How often does the code check the sensor value?
    The loop runs with a delay of 6 seconds between checks, totaling about 1 minute per cycle.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top