Skip to content
  • 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
M

Mike Cayouette

@Mike Cayouette
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store
About
Posts
41
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Node-Red as Controller
    M Mike Cayouette

    I also use node-red with a serial gateway attached. I created a flow that converts the serial payload to a mqtt type payload and it is picked up by openHAB. This also works the other way around. openHAB sents everything out via mqtt and node-red picks it up and parses it back into a serial formated payload which is picked up by the serial gateway. I also use node-red's Owntracks node to monitor my proximity and send updates to openHAB as an mqtt message and I also have a flow that monitors my phone and my wifes phone, if we are both home the outside lights get turned off at 22:00. node-red also sends twitter messages to me when my doors and windows are opened and no one is home.

    I only use mqtt with with a combiniation if nfr radios via the serial gateway, like I mentioned above, and I also use ESP8266 modules running lua. So as not to send the wrong payload to the serial gateway, all topics that come from openHAB that are destined for the serial gateway start with RF24SN/out/... and on node-red I subscribe the RF24SN/out/#. This will capture all those message and they will get parsed to the serial format (Nodeid;clientid;message;...etc).

    Everything that happens in node-red is passed to openHAB. I have a couple of relays and leds I control from openHAB. The leds use the MySensor LEDDimmer. Basically node-red acts as the middle man between the serial gateway and openHAB/mqtt.

    Mike

    Node-RED node-red

  • Install your own controller on cheap android tvbox
    M Mike Cayouette

    The TV box you are talking about is pretty much like the Cubieboard2, which is also an A20 processor, except the cubieboard2 has 1GB of DDR3 memory. I use a Cubieboard3, also known as a Cubietruck, which is an A20 dual core 1Ghz with 2GB of DDR3 memory. The Cubietruck runs Cubuntu server, on this I run openHAB, Node,js, Node-RED and Mosquitto server. I have the MySensor serial Gateway connected to the USB port of my Cubietruck and node-red handles all the incoming serial messages and parses them to an MQTT format, and the other way around it takes MQTT message and parses them to a MySensor serial format and sends it the serial gateway. I also have a 128GB SSD attached to it and use it as a NAS for my 3 OpenELEC media center servers running on Raspberry Pi's and I also have some Raspberry Pi's with PiCams that stream mjpeg videos to the NAS. It works like a charm all in one little package.

    I have been documenting my installation and configuration progress, one day when I have more time I will put it up somewhere.

    Regards,

    Mike

    Controllers

  • Why is my ESP8266 MQTT Client Gateway an Access Point?
    M Mike Cayouette

    Forget that last message. I reliazed you mentioned to change the MyGatewayTransportEthernet.cpp, which I did, but I'm running the MQTT Gateway. I found the same location in the MyGatewayTransportMQTTClient.cpp file (line 157) and added the entry there. That disabled the AP advertisement.

    Thank you,

    Mike

    Troubleshooting

  • Node-Red as Controller
    M Mike Cayouette

    @Fredrik-Carlsson said:

    The only thing is that you must point the topic of the mqtt node directly to a child. Its not possible to just subscribe to topics higher in the hierarchy.

    For example in MyMQTT app on Android i can just subscribe to topic MyMQTT and then i get messages from all nodes connected to the Gateway. This is not possible with the mqtt node in NodeRED. You must specifically point it.

    You can capture all higher level topics by using the # symbal. As I mention above, my openHAB sents RF24SN/out/.... and on node-red I have an mqtt node that listens for RF24SN/out/#.

    Mike

    Node-RED node-red

  • [SOLVED] Timers and Interrupts not being triggered
    M Mike Cayouette

    @Yveaux I solved the problem.

    The issue was not my sketch, but rather my ESP8266 MQTT Gateway. I was using an older development version. After upgrading to version 2.0 everything started working. Thankfully my older nodes, using the older development version, are still working, I will upgrade them over time.

    This is my final sketch:

    #define MY_DEBUG 
    
    #define MY_RADIO_NRF24
    
    #define MY_NODE_ID 300
    
    #define SN "ACDimmer"
    #define SV "1.0"
    #define AC1_ID 1
    #define FADE_DELAY 18      // Delay in ms for each percentage fade up/down (10ms = 1s full-range dim)
    
    #include <TimerOne.h>
    #include <SPI.h>
    #include <MySensors.h>
    
    MyMessage dimmerMsg(AC1_ID, V_DIMMER);
    
    volatile int i=0;               // Variable to use as a counter volatile as it is in an interrupt
    volatile boolean zero_cross=0;  // Boolean to store a "switch" to tell us if we have crossed zero
    int AC_pin = 4;                // Output to Opto Triac
    int intPin = 3;
    int dim = 0;                    // Dimming level (0-128)  0 = on, 128 = 0ff
    int inc=1;                      // counting up or down, 1=up, -1=down
    int freqStep = 65;    // This is the delay-per-brightness step in microseconds.
    unsigned long previousMillis = 0;        // will store last time LED was updated
    unsigned long currentMillis = 0;
    int currentLevel =  0;
    int requestedLevel = 0;
    
    void before() {
      #ifdef MY_DEBUG
      Serial.println("Dimmer Node Starting");
      #endif
    
      pinMode(AC_pin, OUTPUT);                          // Set the Triac pin as output
      attachInterrupt(digitalPinToInterrupt(intPin), zero_cross_detect, RISING);    // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
      Timer1.initialize(freqStep);                      // Initialize TimerOne library for the freq we need
      Timer1.attachInterrupt(dim_check, freqStep);      
    }
    
    void setup() {                                      // Begin setup
    }
    
    void presentation() {
      present( AC1_ID, S_DIMMER );
      
      sendSketchInfo(SN, SV);
    }
    
    void zero_cross_detect() {    
      zero_cross = true;               // set the boolean to true to tell our dimming function that a zero cross has occured
      i=0;
      digitalWrite(AC_pin, LOW);       // turn off TRIAC (and AC)
    }                                 
    
    // Turn on the TRIAC at the appropriate time
    void dim_check() {                   
      if(zero_cross == true) {              
        if(i>=currentLevel) {                     
          digitalWrite(AC_pin, HIGH); // turn on light       
          i=0;  // reset time step counter                         
          zero_cross = false; //reset zero cross detection
        } 
        else {
          i++; // increment time step counter                     
        }                                
      }                                  
    }                                   
    
    void loop() {
                             
    }
    
    
    void receive(const MyMessage &message) {
    
      #ifdef MY_DEBUG
      Serial.print("Message: ");
      Serial.println(message.type);
      Serial.print("Message Data: ");
      Serial.println(message.data);
      #endif
    
      if (message.type == 3) {
        int requestedLevel = map(atoi( message.data ), 0, 100, 128, 0); //128 = off | 0 = ON
    
        while (currentLevel != requestedLevel) {
      
          if(currentLevel<=requestedLevel) inc=1;
          if(currentLevel>=requestedLevel) inc=-1;
    
          currentLevel+=inc;
    
          #ifdef MY_DEBUG
          Serial.print("Current Level:");
          Serial.println(String(currentLevel));
          #endif
    
          //delay
          currentMillis = previousMillis = millis();
          while (currentMillis - previousMillis < FADE_DELAY) {
            currentMillis = millis();
          }
    
        }
    
      }
    }
    

    There is still one error though. When I try to set my own node id using #define MY_NODE_ID 300, I get the following error:

    In file included from /home/sketchbook/libraries/MySensors/MySensors.h:253:0,
                     from /home/sketchbook/ACDimmer_Test/ACDimmer_Test.ino:11:
    /home/sketchbook/libraries/MySensors/core/MyTransport.cpp: In function 'void stInitTransition()':
    /home/sketchbook/libraries/MySensors/core/MyTransport.cpp:74:16: warning: large integer implicitly truncated to unsigned type [-Woverflow]
         _nc.nodeId = MY_NODE_ID;
                    ^
    In file included from /home/sketchbook/libraries/MySensors/core/MyHwATMega328.cpp:22:0,
                     from /home/sketchbook/libraries/MySensors/MySensors.h:69,
                     from /home/sketchbook/ACDimmer_Test/ACDimmer_Test.ino:11:
    /home/sketchbook/libraries/MySensors/core/MyHwATMega328.h:69:88: warning: large integer implicitly truncated to unsigned type [-Woverflow]
      #define hwWriteConfig(__pos, __value) (eeprom_update_byte((uint8_t*)(__pos), (__value)))
                                                                                            ^
    /home/sketchbook/libraries/MySensors/core/MyTransport.cpp:76:5: note: in expansion of macro 'hwWriteConfig'
         hwWriteConfig(EEPROM_NODE_ID_ADDRESS, MY_NODE_ID);
    

    I was able to set my own node id's in the older development version but it does not seem to work now.

    Thank you for all your help.

    Mike

    Troubleshooting

  • [SOLVED] Timers and Interrupts not being triggered
    M Mike Cayouette

    @mfalkvidd Node id's work now.

    Thank you everyone for your help.

    Mike

    Troubleshooting
  • Login

  • Don't have an account? Register

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