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
warmaniacW

warmaniac

@warmaniac
About
Posts
49
Topics
5
Shares
0
Groups
0
Followers
0
Following
2

Posts

Recent Best Controversial

  • Low power battery Door/Window sketch nrf24l01
    warmaniacW warmaniac

    @sundberg84

    I had barometer BMP180 powered on 2xAA 1,5V , in usage from 1.March 2017 , Start battery power was 85% (not new batteries, before used) and now after 14 days of usage is 84 % , Im very satisfied. Using only without LEDs ,with power regulator on arduino.

    1_1489491784079_baro_2.png 0_1489491784079_baro_1.png

    Development

  • SCT-013-030 current monitor sensor
    warmaniacW warmaniac

    updated my sketch with new values for SCT-013-00 result is now

    #define MY_DEBUG
    #define MY_RADIO_NRF24
    // EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3  ***/
    #include <SPI.h>
    #include <MySensors.h>
    #include "EmonLib.h"             // Include Emon Library
    EnergyMonitor emon1;             // Create an instance
    
    #define CHILD_ID_CLAMP1 0
    #define PIN_ANALOG_I1 A1 //pince amperemetrique1
    
    unsigned long lastSend_power = millis();
    unsigned long lastSend_c = millis();
    unsigned long SEND_FREQUENCY = 120000; // Minimum time between send (in milliseconds). We don't wnat to spam the gateway.
    unsigned long SEND_FREQUENCY_C = SEND_FREQUENCY / 30;
    int index = 0;
    double Irms1 = 0;
    boolean pcReceived1 = false;
    float nrj1 = 0, old_nrj1;
    
    MyMessage IrmsMsg1(CHILD_ID_CLAMP1, V_WATT);
    MyMessage kWhMsg1(CHILD_ID_CLAMP1, V_KWH);
    MyMessage pcMsg1(CHILD_ID_CLAMP1, V_VAR1);
    
    void before() {
    
    }
    
    
    void presentation()
    {
      sendSketchInfo("Multisensors_Entree", "2.0");  // Send the sketch version information to the gateway and Controller
      present(CHILD_ID_CLAMP1, S_POWER);   // Register this device as power sensor
      request(CHILD_ID_CLAMP1, V_VAR1);
    }
    
    
    void receive(const MyMessage &message)
    {
      if (message.type == V_VAR1)
      {
        nrj1 = old_nrj1 = message.getFloat();
        Serial.print("Received last nrj count from gw:");
        Serial.println(nrj1);
        pcReceived1 = true;
      }
    }
    
    void setup()
    {
      emon1.current(PIN_ANALOG_I1, 111.1);       // Current: input pin, calibration.
      Serial.println("SETUP completed");
    }
    
    void envoi_donnees(double intrms, int id_clamp)
    {
      Serial.print("Envoi des donnees .... clamp="); Serial.println(id_clamp);
      double energie = (intrms * 240.0 * SEND_FREQUENCY / 1000) / 3.6E6;
      switch (id_clamp) //can be modified ...
      {
        case 1:
          {
            send(IrmsMsg1.set(intrms * 240.0, 1));
            nrj1 += energie;
            send(kWhMsg1.set(nrj1, 5));
            send(pcMsg1.set(nrj1, 5));
            old_nrj1 = nrj1;
          }
          break;
      }
    }
    
    void loop() {
      unsigned long now = millis();
      bool sendTime_c = now - lastSend_c > SEND_FREQUENCY_C;
      // Calcul de Irms1 et Irms2
      if (sendTime_c) //calcul Irms moy clamp1/clamp2
      {
        if (index == 0)
        {
          Irms1 = emon1.calcIrms(1480);
        }
        else  
        {
          Irms1 = (index * Irms1 + emon1.calcIrms(1480)) / (index + 1);
        }
        lastSend_c = now;
        index++;
      }
    
    bool sendTime_power = now - lastSend_power > SEND_FREQUENCY;
    
     if (sendTime_power)
    {
      // Envoi ou request Puissance1
      if (pcReceived1) envoi_donnees(Irms1, 1);
      else     {
        request(CHILD_ID_CLAMP1, V_VAR1);
        Serial.println("Request VAR1");
      }
      //on reinitialise les compteurs
      lastSend_power = now;
      index = 0;
      }
    }
    

    0_1490992284051_upload-583cafbf-bd94-4bad-8fd3-8c510f5cfbfc

    Hardware
  • Login

  • Don't have an account? Register

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