OscarF10
Published

IOT. Intelligent waste management

IOT. Smart trash cans that remotely warn if they're full, if they smell bad, or if they're being set on fire. Values are sent to ThingSpeak

IntermediateFull instructions provided5 hours748
IOT. Intelligent waste management

Things used in this project

Hardware components

Beduino kit
This is a educational kit. It was created in spain with pieces of My Robot Time Company. The board is an arduino Leonardo board with motor drivers. Use the main board and pieces
×1
ESP8266 ESP-01
Espressif ESP8266 ESP-01
×1
ESP-01S Wifi to Serial Shield
×1
Flame sensor
×1
Air quality sensor
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
dupont cables
×1

Software apps and online services

Blocklyduino
Arduino IDE
Arduino IDE

Story

Read more

Code

WasteProject.ino

Arduino
/*******************************************
***    ARDUINO CODE -- MRTDUINO BOARD    ***
***       Logix5 -- www.logix5.com       ***
********************************************/
#include <IOT_ts.h>

#include "DHT.h"

Iot_device iot;

unsigned int  Estado;
long  Detectado;
DHT dht_5(5,DHT11);

long ultrason_15() {
   long duration, distance;
   digitalWrite(15,LOW);
   delayMicroseconds(2);
   digitalWrite(15, HIGH);
   delayMicroseconds(10);
   digitalWrite(15, LOW);
   duration = pulseIn(16, HIGH);
   distance = duration/58;
   return distance;
}

long temps15 = 0 ;

void setup()
{
  Serial1.begin(9600);

  Serial.begin(115200);

  Estado = 0;

  Detectado = 0;

  dht_5.begin();

  pinMode(15, OUTPUT);
  pinMode(16, INPUT);
  pinMode(18,INPUT);
    iot.Iot_thinkspeak("sadasdasdasdas");
  iot.Mode_ESP8266(1,3000,true);
  iot.Credentials_ESP8266("xxxxxxxxxxxxxx","xxxxxxxxxxxxxxxxxxx",5000,true);

}


void loop()
{
    if ((millis()-temps15)>=15*1000) {
      temps15=millis();
      switch (Estado) {
      case 0:
        iot.thingSpeakWrite(1,dht_5.readTemperature(),true);
        Estado = 1;
        break;
       case 1:
        iot.thingSpeakWrite(2,dht_5.readHumidity(),true);
        Estado = 2;
        break;
       case 2:
        iot.thingSpeakWrite(3,ultrason_15(),true);
        Estado = 3;
        break;
       case 3:
        iot.thingSpeakWrite(4,map(analogRead(A9),0,1023,0,100),true);
        Estado = 4;
        break;
       case 4:
        iot.thingSpeakWrite(5,Detectado,true);
        Estado = 0;
        break;
      }
    }
    if (Detectado == 0 && !digitalRead(18)) {
      Serial.println("Llama detectada");
      Estado = 4;
      Detectado = 1;
      delay(100);

    }
    if (Detectado == 1 && digitalRead(18)) {
      Serial.println("No hay llama");
      Detectado = 0;
      delay(100);

    }

}

WasteProject

XML
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="arduino_setup" x="0" y="0"><statement name="MySetup"><block type="iot_init_iot"><field name="PINBAUDIOS">9600</field><next><block type="iot_init_thinkspeak"><value name="APIwrite"><shadow type="text"><field name="TEXT">7MWRTNYIWQ3T3E0X</field></shadow><block type="text"><field name="TEXT">sadasdasdasdas</field></block></value><next><block type="serial_init"><field name="PINBAUDIOS">115200</field><next><block type="iot_configmode_esp8266"><field name="MODE">1</field><field name="LOGIC">TRUE</field><value name="delaytime"><shadow type="math_number"><field name="NUM">3000</field></shadow></value><next><block type="iot_confignetwork_esp8266"><field name="LOGIC">TRUE</field><value name="ssid"><shadow type="text"><field name="TEXT">name net</field></shadow><block type="text"><field name="TEXT">xxxxxxxxxxxxxx</field></block></value><value name="password"><shadow type="text"><field name="TEXT">******</field></shadow><block type="text"><field name="TEXT">xxxxxxxxxxxxxxxxxxx</field></block></value><value name="delaytime"><shadow type="math_number"><field name="NUM">3000</field></shadow><block type="math_number"><field name="NUM">5000</field></block></value><next><block type="variables_declare"><field name="VAR">Estado</field><field name="TYPE">unsigned int</field><value name="VALUE"><block type="math_number"><field name="NUM">0</field></block></value><next><block type="variables_declare"><field name="VAR">Detectado</field><field name="TYPE">long</field><value name="VALUE"><block type="math_number"><field name="NUM">0</field></block></value></block></next></block></next></block></next></block></next></block></next></block></next></block></statement><statement name="MyLoop"><block type="tempo_no_delay"><field name="unit">s</field><value name="DELAY_TIME"><shadow type="math_number"><field name="NUM">5</field></shadow><block type="math_number"><field name="NUM">15</field></block></value><statement name="branch"><block type="controls_switch"><mutation casebreak="4"></mutation><value name="SWVAR"><block type="variables_get"><field name="VAR">Estado</field></block></value><value name="CASE0"><block type="math_number"><field name="NUM">0</field></block></value><statement name="DO0"><block type="iot_sendthinkspeak_esp8266"><field name="LOGIC">TRUE</field><value name="field"><shadow type="math_number"><field name="NUM">1</field></shadow></value><value name="value"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="dht_sensor"><field name="PIN_DHT">5</field><field name="OUTPUT_TYPE">0</field><field name="OUTPUT_VALUE">0</field></block></value><next><block type="variables_set"><field name="VAR">Estado</field><value name="VALUE"><block type="math_number"><field name="NUM">1</field></block></value></block></next></block></statement><value name="CASE1"><block type="math_number"><field name="NUM">1</field></block></value><statement name="DO1"><block type="iot_sendthinkspeak_esp8266"><field name="LOGIC">TRUE</field><value name="field"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="math_number"><field name="NUM">2</field></block></value><value name="value"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="dht_sensor"><field name="PIN_DHT">5</field><field name="OUTPUT_TYPE">0</field><field name="OUTPUT_VALUE">1</field></block></value><next><block type="variables_set"><field name="VAR">Estado</field><value name="VALUE"><block type="math_number"><field name="NUM">2</field></block></value></block></next></block></statement><value name="CASE2"><block type="math_number"><field name="NUM">2</field></block></value><statement name="DO2"><block type="iot_sendthinkspeak_esp8266"><field name="LOGIC">TRUE</field><value name="field"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="math_number"><field name="NUM">3</field></block></value><value name="value"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="ultrasonic_ranger_sensor"><field name="PIN_TRIG">15</field><field name="PIN_ECHO">16</field></block></value><next><block type="variables_set"><field name="VAR">Estado</field><value name="VALUE"><block type="math_number"><field name="NUM">3</field></block></value></block></next></block></statement><value name="CASE3"><block type="math_number"><field name="NUM">3</field></block></value><statement name="DO3"><block type="iot_sendthinkspeak_esp8266"><field name="LOGIC">TRUE</field><value name="field"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="math_number"><field name="NUM">4</field></block></value><value name="value"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="Gas_sensor"><field name="PIN_GAS">A9</field><field name="OUTPUT_VALUE">0</field></block></value><next><block type="variables_set"><field name="VAR">Estado</field><value name="VALUE"><block type="math_number"><field name="NUM">4</field></block></value></block></next></block></statement><value name="CASE4"><block type="math_number"><field name="NUM">4</field></block></value><statement name="DO4"><block type="iot_sendthinkspeak_esp8266"><field name="LOGIC">TRUE</field><value name="field"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="math_number"><field name="NUM">5</field></block></value><value name="value"><shadow type="math_number"><field name="NUM">1</field></shadow><block type="variables_get"><field name="VAR">Detectado</field></block></value><next><block type="variables_set"><field name="VAR">Estado</field><value name="VALUE"><block type="math_number"><field name="NUM">0</field></block></value></block></next></block></statement></block></statement><next><block type="controls_if"><value name="IF0"><block type="logic_operation"><field name="OP">AND</field><value name="A"><block type="logic_compare"><field name="OP">EQ</field><value name="A"><block type="variables_get"><field name="VAR">Detectado</field></block></value><value name="B"><block type="math_number"><field name="NUM">0</field></block></value></block></value><value name="B"><block type="logic_negate"><value name="BOOL"><block type="Flame_status_sensor"><field name="PIN_FLAME">18</field></block></value></block></value></block></value><statement name="DO0"><block type="serial_print"><value name="CONTENT"><shadow type="text"><field name="TEXT">text</field></shadow><block type="text"><field name="TEXT">Llama detectada</field></block></value><next><block type="variables_set"><field name="VAR">Estado</field><value name="VALUE"><block type="math_number"><field name="NUM">4</field></block></value><next><block type="variables_set"><field name="VAR">Detectado</field><value name="VALUE"><block type="math_number"><field name="NUM">1</field></block></value><next><block type="base_delayms"><value name="DELAY_TIME"><shadow type="math_number"><field name="NUM">1000</field></shadow><block type="math_number"><field name="NUM">100</field></block></value></block></next></block></next></block></next></block></statement><next><block type="controls_if"><value name="IF0"><block type="logic_operation"><field name="OP">AND</field><value name="A"><block type="logic_compare"><field name="OP">EQ</field><value name="A"><block type="variables_get"><field name="VAR">Detectado</field></block></value><value name="B"><block type="math_number"><field name="NUM">1</field></block></value></block></value><value name="B"><block type="Flame_status_sensor"><field name="PIN_FLAME">18</field></block></value></block></value><statement name="DO0"><block type="serial_print"><value name="CONTENT"><shadow type="text"><field name="TEXT">text</field></shadow><block type="text"><field name="TEXT">No hay llama</field></block></value><next><block type="variables_set"><field name="VAR">Detectado</field><value name="VALUE"><block type="math_number"><field name="NUM">0</field></block></value><next><block type="base_delayms"><value name="DELAY_TIME"><shadow type="math_number"><field name="NUM">1000</field></shadow><block type="math_number"><field name="NUM">100</field></block></value></block></next></block></next></block></statement></block></next></block></next></block></statement></block></xml>

Blocklyduino

The graphical software used to program this example

Examples with Blocklyduino

Credits

OscarF10

OscarF10

1 project • 0 followers
I am telecommunication engineer.In my free time I am doing things related of robotics,technology for students in our courses in logix5

Comments