Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Coal or water level sensor

Coal or water level sensor

Scheduled Pinned Locked Moved My Project
2 Posts 2 Posters 2.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    romeok01
    wrote on last edited by
    #1

    Coal or water level sensor
    http://projektpimalina.blogspot.com/2016/05/czujnik-poziomu-wegla-na-nadajniku.html

    https://www.youtube.com/embed/3ShomcZfV-w

    #include <MySensor.h>
    #include <SPI.h>          //import biblioteki MySenors
    
    #define trigPin 3
    #define echoPin 4
    int max = 60; //maksymalna odleglosc w cm gdy zbiornik bedzie pusty
    int procent; //odleglosc w procentach
    int ilosc; //ilosc w procentach napelnienia zbiornika
    
    #define child_id_ilosc 1   //definicja identyfikacji ilosci wegla w kontenerze
    
    MySensor gw;
    MyMessage msgilosc(child_id_ilosc, V_IMPEDANCE); //utworzenie konteneru do przechowywania danych
     
    void setup() {
      
      pinMode(trigPin, OUTPUT); //Pin, do którego podłączymy trig jako wyjście
      pinMode(echoPin, INPUT); //a echo, jako wejście
     
      gw.begin();   //uruchomienie biblioteki MySensors
      gw.sendSketchInfo("Czujunik ilosci wegla", "1.0");
      
      gw.present(child_id_ilosc, S_WEIGHT); //prezentacja danych do kontrolera
    }
     
    void loop() {
      
      long czas, dystans;
     
      digitalWrite(trigPin, LOW);
      delayMicroseconds(2);
      digitalWrite(trigPin, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigPin, LOW);
     
      czas = pulseIn(echoPin, HIGH);
      dystans = czas / 58;
      
      procent = ((dystans * 100) / max);
      ilosc = 100 - procent;
      
      gw.send(msgilosc.set(ilosc)); //przeslanie ilosci wegla do domoticz
      
      delay(1000);    // opóźnienie
    }
    1 Reply Last reply
    0
    • malukoM Offline
      malukoM Offline
      maluko
      wrote on last edited by maluko
      #2

      thanks romeak01

      i have update with my sample, i think that will run ok.

      #include <MySensor.h>
      #include <SPI.h>          //import  MySensors library
      
      #define trigPin 6
      #define echoPin 5
      int max = 91; //distance (cm) from min water level to sensor 
      int min = 6;  // distance (cm) from max water level to sensor
      int procent; //distance percentage
      int ilosc; //amount of the tank as a percentage
      
      #define child_id_ilosc 1   //setting to identify the amount of water in the tank
      
      MySensor gw;
      MyMessage msgilosc(child_id_ilosc, V_IMPEDANCE); 
       
      void setup() {
        
        pinMode(trigPin, OUTPUT); //Pin, that its connet to trig
        pinMode(echoPin, INPUT); //a echo, input
       
        gw.begin();   //launch MySensors library  
        gw.sendSketchInfo("Water tank meter", "1.0");
        
        gw.present(child_id_ilosc, S_WEIGHT); //present data to controller
      }
       
      void loop() {
        
        long czas, dystans, diferenca;
       
        digitalWrite(trigPin, LOW);
        delayMicroseconds(2);
        digitalWrite(trigPin, HIGH);
        delayMicroseconds(10);
        digitalWrite(trigPin, LOW);
       
        czas = pulseIn(echoPin, HIGH);
        dystans = czas / 58;
        diferenca = max -min;
        
        procent = (((dystans - min)  * 100) / diferenca);
        ilosc = 100 - procent;
        
        gw.send(msgilosc.set(ilosc)); // send to controller
        delay(1000);    // delay
      }```
      1 Reply Last reply
      0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      15

      Online

      12.0k

      Users

      11.2k

      Topics

      113.4k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular