Mayank JonejaRahul Singh
Published © GPL3+

Trash Talker Using Bolt IoT

The trashcan in our office isn't smart. No smarter than a 1 year old baby which can shout and cry to make its needs heard anyway.

BeginnerProtip30 minutes12,271
Trash Talker Using Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×7

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Trash Talker Breadboard Circuit

The circuit for the Trash Talker system

Code

Trash Check Distance

Arduino
Modified Ultrasonic Simple example from ErickSimoes/Ultrasonic library to send data from sensor over serial to Bolt.
/*
 * Ultrasonic Simple
 * Prints the distance read by an ultrasonic sensor in
 * centimeters. They are supported to four pins ultrasound
 * sensors (liek HC-SC04) and three pins (like PING)))
 * and Seeed Studio sesores).
 *
 * The circuit:
 * * Module HR-SC04 (four pins) or PING))) (and other with
 *   three pins), attached to digital pins as follows:
 * ---------------------    ---------------------
 * | HC-SC04 | Arduino |    | 3 pins  | Arduino |
 * ---------------------    ---------------------
 * |   Vcc   |   5V    |    |   Vcc   |   5V    |
 * |   Trig  |   12    | OR |   SIG   |   13    |
 * |   Echo  |   13    |    |   Gnd   |   GND   |
 * |   Gnd   |   GND   |    ---------------------
 * ---------------------
 * Note: You need not obligatorily use the pins defined above
 * 
 * By default, the distance returned by the distanceRead()
 * method is in centimeters, to get the distance in inches,
 * pass INC as a parameter.
 * Example: ultrasonic.distanceRead(INC)
 *
 * created 3 Apr 2014
 * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 * modified 23 Jan 2017
 * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 * modified 03 Mar 2017
 * by Erick Simões (github: @ErickSimoes | twitter: @AloErickSimoes)
 *
 * This example code is released into the MIT License.
 */

#include <Ultrasonic.h>

/*
 * Pass as a parameter the trigger and echo pin, respectively,
 * or only the signal pin (for sensors 3 pins), like:
 * Ultrasonic ultrasonic(13);
 */
Ultrasonic ultrasonic(12, 13);

void setup() {
  Serial.begin(9600);
  
  }

void loop() {

  Serial.println(ultrasonic.distanceRead());
  delay(1000);
}

Trash Alert

Python
This is the Python script you run on your PC to check the distance against a threshold and send SMS alerts.
from boltiot import Bolt, Sms #Import Sms and Bolt class from boltiot library
import json, time

garbage_full_limit = 5 # the distance between device and  garbage in dustbin in cm

API_KEY = "your Bolt Cloud api key"
DEVICE_ID  = "your device id"

# Credentials required to send SMS
SID = 'your twilio sid'
AUTH_TOKEN = 'your twilio auth token'
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding country code in the beginning'

mybolt = Bolt(API_KEY, DEVICE_ID) #Create object to fetch data
sms = Sms(SID, AUTH_TOKEN, TO_NUMBER, FROM_NUMBER) #Create object to send SMS
response = mybolt.serialRead('10')
print response

while True:
    response = mybolt.serialRead('10')  #Fetching the value from Arduino
    data = json.loads(response)
    garbage_value = data['value'].rstrip()
    print "Garbage level is", garbage_value
    if int(garbage_value) < garbage_full_limit:
        response = sms.send_sms('Hello DeBae, I am full- Trash Talker')
    time.sleep(200)

Credits

Mayank Joneja

Mayank Joneja

6 projects • 22 followers
Embedded Hardware Development and Robotics. Networked Embedded Systems | IoT | Wireless Sensor Networks | Design Thinking
Rahul Singh

Rahul Singh

7 projects • 44 followers
Software Developer at Bolt IoT
Thanks to Erick Simoes.

Comments