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
rollercontainerR

rollercontainer

@rollercontainer
About
Posts
96
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • [ProMini] Blue LED on Pin 13 wont turn off
    rollercontainerR rollercontainer

    How about an I2C Display? Two wires on A4 &A5...

    Troubleshooting

  • MyController - 0.0.3-Alpha2 pre-release - volunteers required to test
    rollercontainerR rollercontainer

    me too, i you need more tester.

    MyController.org alpha pre-release mycontroller.org

  • Uno as serial gateway? Can it also be a sensor node?
    rollercontainerR rollercontainer

    I've got a MQTTClientGateway using an Uno with DHT22 sensor attached. It's working for weeks without problems.

    General Discussion

  • How to deal with a request for information from controller?
    rollercontainerR rollercontainer

    I would like to share my sketch for 2.0.0-beta. Its a node with two relays and the ability to read the status from mqtt.

    // Relais Node for MySensors 2.0.0-beta
    
    // I am using the filename and compile date for sktech announcements:
    #include <string.h>
    // Strip the path info from __FILE__ 
    // For Windows use '\\' instead of '/'.
    #define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
     
    // #define MY_DEBUG
    #define MY_RADIO_NRF24
    #define SKETCH_NAME __FILENAME__
    #define SKETCH_DATE __DATE__
    #define MY_NODE_ID 2
    #define MY_PARENT_NODE_ID 0
    #define MY_REPEATER_FEATURE false
    
    #include <SPI.h>
    #include <MySensor.h>
    
    #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 2 // Total number of attached relays
    #define RELAY_ON 0  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 1 // GPIO value to write to turn off attached relay
    
    void before() { 
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);   
        // Set relay to last known state (using eeprom storage) 
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    void setup() {
      
    }
    
    void presentation()  
    {   
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo(SKETCH_NAME, SKETCH_DATE);
    
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_LIGHT);
      }
    }
    
    void loop() 
    {
      
    }
    
    void receive(const MyMessage &message) {
    int msgcmd = mGetCommand(message);
      
      // Verify its a switch command (V_LIGHT)
      if (message.type==V_LIGHT) {
        // Command type 1 is a set command 
         if (msgcmd==1){
           // Change relay state
           digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
           // Store state in eeprom
           saveState(message.sensor, message.getBool());
         }
       // Command type 2 is a request for the sensor state
       if (msgcmd==2){
           // construct message body with requested sensor-id and type V_LIGHT (= switch) 
           MyMessage msg(message.sensor,V_LIGHT);
           // Example: requested sensor is 2 (message.sensor). 
           // The programm reads the digital pin 4, calculated by 2 (sensor) - 1 (static) + 3 (first relay pin)
           // after that, the reading is compared to the RELAY_ON value (might be invers logic, regarding to your relais schematic)
           // if it is matching, the payload is set to 1, otherwise its set to 0
           send(msg.set(digitalRead(message.sensor-1+RELAY_1) == RELAY_ON ? 1 : 0));
        }
      }
    }
    

    and here are the lines in my openhab2 items.item:

    Switch node2_sw1   "N2SW1"    (all,node2)    { mqtt=">[mosquitto:mysensors-in/2/1/1/0/2:command:ON:1],>[mosquitto:mysensors-in/2/1/1/0/2:command:OFF:0],<[mosquitto:mysensors-out/2/1/2/0/2:state:default]" }
    Switch node2_sw2   "N2SW2"    (all,node2)    { mqtt=">[mosquitto:mysensors-in/2/2/1/0/2:command:ON:1],>[mosquitto:mysensors-in/2/2/1/0/2:command:OFF:0],<[mosquitto:mysensors-out/2/2/2/0/2:state:default]" }
    

    I would like to repeat: Its for the last versions of mysensors and openhab2. Notice the absence of any "gw." and the different structure in the mqtt strings !

    Can someone tell me, if it is a problem to redefine the "MyMessage msg(message.sensor,V_LIGHT); " every time a request is done? I am not sure.

    Greetings

    Troubleshooting

  • Arduino and NRF24 Mesh Code
    rollercontainerR rollercontainer

    The gateway is always Node 0 and that "target" is coded as default. If you want to go from Node 2 (S) to Node 1 (R) and then to the Gateway (GW) as stated on your painting above, you have to init Node 2 with "target" Node 1 insted of 0 and tell Node 1, that it is a repeater. This is done by create repeating node.

    Development

  • Slim Node Si7021 sensor example
    rollercontainerR rollercontainer

    The most SI7021 coming from ebay are with voltage regulator and level shifter. I searched for a raw version and there are only very few... If you are not sure, post a link or a foto.

    My Project

  • Arduino and NRF24 Mesh Code
    rollercontainerR rollercontainer

    There is always only one gateway. This has to be NodeID 0. NodeID of the for all other nodes are free of choice or assigned automaticly.
    ChildIDs are for the children of the nodes: the sensors themself. They are presented to the gateway.

    Development

  • Slim Node Si7021 sensor example
    rollercontainerR rollercontainer

    According to the datasheet the absolute maximum time to get ready is 80ms.

    My Project

  • My Slim 2AA Battery Node
    rollercontainerR rollercontainer

    I ordered a proto pack on 15th of April and received it on 30th of April. Pretty fast, I think. :-)

    My Project

  • Multisensor PIR based on IKEA Molgan
    rollercontainerR rollercontainer

    @Cliff-Karlsson
    Excellent summarized! Perfect HowTo!

    Voted Cliff-Karlson for Documentation Team :-D

    My Project

  • My Slim 2AA Battery Node
    rollercontainerR rollercontainer

    @AWI one step forward, two steps back... Thanks for the hint.

    I guess, I should send battery percentage every 10 interrupts or so. Even if the contact doesn't trigger for a while, I can force it by showing my neighbours my ocd on doors ^^ (knock, knock, knock - Penny!)

    What do you think?

    My Project

  • My Slim 2AA Battery Node
    rollercontainerR rollercontainer

    Did you considered a tiny solar cell like enocean does?
    https://www.enocean.com/en/enocean_modules/stm-320/
    That would be perfect...

    My Project

  • RGB LED strip controller with FastLED
    rollercontainerR rollercontainer

    Hi,

    I built a 1m x 1,5m accoustic absorber with Basotect for the ceiling in my living room. To generate ambient lighting, I installed a non-smart analog 5m LED strip on the top side. My first attempt was to use PWM from arduino which resultet in visual steps when do slow fading. Next approcach was a 12bit PWM motor shield, resulting in 4096 steps which were smooth but I couldn't use the real good FastLED library. So I ended up with a P9813 RGB MosFET Board from ebay which represents a single pixel. (But can easily chained for several strips in the room.) FastLED is dithering between the 256 steps of the arduino and produces very smooth transitions.

    Hardware:

    • Arduino Nano (~5€)
    • NRF24L01 (~2€)
    • P9813 RGB MosFet Board from ebay (Full Color RGB LED Strip Driver Sensor v1.1 for Arduino STM32 AVR P9813) (4,29€)
    • LM2596S DC-DC Step-Down Converter for 12V->5V (~1€)
    • 5m RGB LED Strip ( < 10€)
    • old 12V laptop power supply

    Software:

    My setup is a mqttClientGateway and a raspi with node-red.
    To change color, you can send a RRGGBB string to mysensors-in/node-id/0/1/0/40
    To change the fade time you can send a integer from 0 to 255 to mysensors-in/node-id/1/1/0/24
    To persist the current settings to eeprom you can send a "1" (meaning bool "true") to mysensors-in/node-id/2/1/0/2
    To set the brightness you can send 0 to 100 (V_PERCENTAGE) to mysensors-in/node-id/3/1/0/3

    https://github.com/rollercontainer/nanoP9813FastLEDMySensors/blob/master/main.cpp

    This code is working. Nevertheless it could be a lot better. It is posted, to help people take code lines or inspirations out of it. I think, I change the setup to esp8266 because of the OTA flash ability.

    Greetings

    My Project
  • Login

  • Don't have an account? Register

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