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
martinhjelmareM

martinhjelmare

@martinhjelmare
Plugin Developer
About
Posts
632
Topics
5
Shares
0
Groups
1
Followers
5
Following
0

Posts

Recent Best Controversial

  • Box for in wall pcb
    martinhjelmareM martinhjelmare

    I'd like to have a box for in wall PCBs with exposed AC circuitry, due to safety concerns. Since space is very restricted I've started on a custom box design for 3d printing. If you have seen commercial samples that fit the criteria, feel free to add links/images here. Also if you want to add your own custom designs, please contribute.

    My design goals:
    Should fit inside a Swedish standard wall box behind the (lamp) switch. Diameter < 65 mm, depth < 30 mm.
    Should hold pcb project by @sundberg84 : http://forum.mysensors.org/topic/2488/in-wall-pcb

    Other in-wall-pcb box projects:

    • UK slimline wall box, depth < 25 mm.
      http://forum.mysensors.org/topic/2511/in-wall-light-switch-node-custom-pcb

    My first WIP design attempt (I'm new to CAD design):

    pcb_wall_box.stl

    pcb_wall_box_cropped.png

    Hardware box pcb inwall

  • OTA firmware updating is too slow..
    martinhjelmareM martinhjelmare

    I implemented a check for firmware update message in my modified SenseBenderMicro sketch, and alternative behavior in the loop if FW update is ongoing. This doesn't solve the problem of dropped messages, but could be good to speed up the update and don't waste time on sensor updates.

    void loop() {
      if (fwUpdateOngoing) {
        fwUpdateOngoing = false;
        fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
      } else {
        normalFlow();
      }
    }
    
    void normalFlow() {
      // Short delay to allow buttons to properly settle
      sleep(5);
    
      int buttonValue = digitalRead(BUTTON_PIN);
    
      measureCount ++;
      sendBattery ++;
      bool forceTransmit = false;
      transmission_occured = false;
    #ifndef MY_OTA_FIRMWARE_FEATURE
      if ((measureCount == 5) && highfreq)
      {
        clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
        highfreq = false;
      }
    #endif
    
      if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
        forceTransmit = true;
        measureCount = 0;
      }
    
      sendTempHumidityMeasurements(forceTransmit);
      if (buttonValue != oldValue) {
         // Send in the new buttonValue
         send(msg.set(buttonValue==HIGH ? 0 : 1));
         oldValue = buttonValue;
         transmission_occured = true;
      }
    
    #ifdef MY_OTA_FIRMWARE_FEATURE
      if (transmission_occured) {
        fwUpdateOngoing = wait(OTA_WAIT_PERIOD, C_STREAM, ST_FIRMWARE_RESPONSE);
      }
    #endif
    
      sleep(digitalPinToInterrupt(BUTTON_PIN), CHANGE, MEASURE_INTERVAL);
    }
    
    Bug Reports

  • 💬 Sensebender Micro
    martinhjelmareM martinhjelmare

    I've tested to upload a sketch to the Sensebender Micro using platformio.

    Put the following JSON into a json file in a folder named boards either in the MySensors library folder (your project in platformio), or somewhere else on the search path. Use the name of the json file in platformio.ini in the board setting. See for more info:
    http://docs.platformio.org/en/latest/platforms/creating_board.html

    • Create a folder named boards in MySensors project folder.
    • Create a file in boards named sensebendermicro8MHz.json.
    {
      "build": {
        "core": "arduino",
        "extra_flags": "-DARDUINO_ARCH_AVR -DARDUINO_AVR_PRO",
        "f_cpu": "8000000L",
        "mcu": "atmega328p",
        "variant": "standard"
      },
      "frameworks": [
        "arduino"
      ],
      "fuses": {
        "efuse": "0x06",
        "hfuse": "0xD2",
        "lfuse": "0xE2",
        "lock": "0x3F"
      },
      "name": "Sensebender Micro (3.3V, 8 MHz)",
      "upload": {
        "maximum_ram_size": 2048,
        "maximum_size": 30720,
        "protocol": "arduino",
        "require_upload_port": true,
        "speed": 57600
      },
      "url": "https://github.com/mysensors/SensebenderMicro",
      "vendor": "MySensors"
    }
    
    • Add an env in platformio.ini.
    [env:sensebendermicro8MHz]
    platform = atmelavr
    framework = arduino
    board = sensebendermicro8MHz
    lib_deps = MySensors
    
    • Compile sketch.
    • Upload sketch.

    I think I've got the settings correct, but it was the first time I did this. But it's tested and works as far as I can see.

    Should we add a JSON file to one of the mysensors repos on github?

    OpenHardware.io temperature atmega328 atsha204a humidity flash mysensors

  • Method to OTA a sleeping node
    martinhjelmareM martinhjelmare

    Home assistant also supports smartsleep.

    Development

  • Home Assistant v 0.12
    martinhjelmareM martinhjelmare

    Version 0.12 of home assistant is now released. The mysensors component has seen three bugfixes and two refactors. This includes:

    • Fix error in unit_of_measurement, by adding version check. Both version 1.4 and 1.5 should now work.
    • Fix adding devices on the fly, without restart and without persistence enabled.

    I've also added information to the documentation at https://home-assistant.io/components/mysensors/. There's now a step by step instruction how to present your sensors and actuators to home assistant. You can also see exactly which S_TYPES and V_TYPES are supported by the sensor and switch platforms.

    All feedback, problem reports and suggestions are very welcome and appreciated. For example, the two mentioned bugs above were found by the community.

    Looking ahead, I'm working on making the serial connection more stable, an ethernet gateway, a light platform, and adding feedback state to the actuator platforms. I'm also planning to add support for value requests and acknowledgements.

    Home Assistant switch serial gateway home assistant sensor

  • Pooling battery relay
    martinhjelmareM martinhjelmare

    Yes, smartsleep is supported. I explained how that is implemented in this post:
    https://forum.mysensors.org/topic/5440/heartbeats/3

    Home Assistant

  • Pooling battery relay
    martinhjelmareM martinhjelmare

    @abmantis

    I didn't make the initial mysensors implementation in home assistant that only supported sensors, but I made the refactor that laid the groundwork for multiple mysensors platforms in home assistant. About 5-10 people has been contributing to the mysensors component in home assistant over time.

    There's also the pymysensors package (not my creation either) that interfaces mysensors and home assistant. It's actually this package that holds most of the mysensors specific logic, like smartSleep. Here there's also about 5-10 people that has contributed.

    All help and feedback is welcome!

    Home Assistant

  • Request for contribution - controller selection matrix
    martinhjelmareM martinhjelmare

    @AWI

    I've added Home Assistant in google drive sheet.

    Controllers

  • Interrupt, Perform a specific function, not the loop
    martinhjelmareM martinhjelmare

    @vickey

    The sleep function with single interrupt returns true if woken by the interrupt and false if woken by the timer. Sleeping with two interrupts returns the number of the interrupt pin that wakes it or negative if timer wakes. See the API.

    I would check the return value of the sleep function and divide the loop into at least two functions. One is run if interrupt wakes it, the other is run after timer wake up.

    edit

    Note that it's the interrupt number and not the pin number of the interrupt, that is returned for the two pin interrupt sleep function, according to the API.
    http://www.mysensors.org/download/sensor_api_15#the-full-api

    General Discussion

  • Home Assistant v 0.11.1 with switch support
    martinhjelmareM martinhjelmare

    Hi!

    Version 0.11 of home assisstant is now released with included mysensors switch support for serial gateway. Right now switches will change state optimistically, without waiting for reply from actuator. I'll add support for feedback state soon. Let me know of any problems.

    I've also refactored the component so it will be easy to add new platforms, light, binary sensor, lock etc. I'm hoping to have time to do so soon. Another new feature is multiple serial gateways connected at the same time.

    Edit:

    You have to update your config if already using mysensors in home assistant. It should now look like this, for two gateways:

    mysensors:
      gateways:
        - port: '/dev/ttyUSB0'
          persistence_file: 'path/mysensors.json'
        - port: '/dev/ttyACM1'
          persistence_file: 'path/mysensors2.json'
      debug: true
      persistence: true
      version: '1.5'
    

    You can see that it's not a sensor platform config anymore. The available platforms will be setup automatically from the component.

    Update: Bugfix release 0.11.1 is now released. Version 0.11 was missing the binary sensors. That has now been fixed in 0.11.1.

    Home Assistant switch serial gateway home assistant

  • Node with Interrupt, sleep and batteries
    martinhjelmareM martinhjelmare

    I think the problem might be that you try to combine the attachInterrupt function that should call an ISR and the mysensors sleep function. The mysensors sleep function handles alot of the required interrupt function logic for you. If you use the attachInterrupt function you have to do that yourself. I might be wrong though, I haven't tried this myself. Maybe @hek can comment?

    For example the following link says that you have to detach the interrupt inside the ISR to not have it trigger again.
    http://playground.arduino.cc/Learning/ArduinoSleepCode

    According to this page, all external interrupt types wake the processor. That's also one of the main points with an interrupt; to be able to wake the processor from sleep.
    http://gammon.com.au/interrupts

    Troubleshooting interrupt sleep

  • Correct presentation of Sensebender temperature and humidity?
    martinhjelmareM martinhjelmare

    @Madhias

    Just call sendTempHumidityMeasurements, with force argument set to true, from inside the if block in the loop. Then you don't need to duplicate code so much.

    You also need to change the last argument in the call to wait inside the if block in the loop. V_STATUS is not the correct type for temperature and humidity that you are waiting for. I think you can leave the last argument out in the call to wait. Let me double check that.

    Edit:
    No, you either have to call wait with all three arguments or only call it with one argument for time to wait. I guess you can put either V_HUM or V_TEMP as the last argument and just make sure you request that value last. BTW, you're missing a call to request as well. Put it after you send in the values ie after the call to sendTempHumidityMeasurements.

    Home Assistant

  • About Serial API 1.5
    martinhjelmareM martinhjelmare

    @emre-ünsal

    Hi!

    From the source code in the dev branch: link

    s = sensor id
    c = message type 0-4: presentation, set, req, internal or stream
    t = value type: S_VALUE during presentation or V_VALUE during set/req
    pt = payload type: string, byte int, etc see link
    l = message length
    sg = signed or unsigned message: 0 or 1 for false or true

    0;0;3;0;9 means node 0 , sensor 0, internal message (3), not an ack message (0), log message (9). This means that it's the gateway that prints this info as a log after already having received the message from a node.

    At the end you have the payload: 27

    Similarly for a sent message: link

    Troubleshooting

  • New nodes, new problems :/ Motion sensor [Solved]
    martinhjelmareM martinhjelmare

    @xydix

    I also think it's the radio transmissions that causes the sensor to trigger. One thing that happens every 20 min by default is the gateway sends a discover request broadcast. This will force all repeaters to resend that broadcast. You can test to change the interval of this broadcast at the gateway and see if the false triggers timing follows.

    The setting is called MY_TRANSPORT_DISCOVERY_INTERVAL_MS. You can define this in the gateway sketch to override the default setting.

    Home Assistant

  • How to build raspberry gw 2.0.0
    martinhjelmareM martinhjelmare

    @pansen

    This is more a guess, but I think the real one (GPIO) is only for the interface between radio and serial gateway program. The virtual is for the interface between serial gateway program and controller. Serial interfaces are exclusive to one program at a time. Someone should verify what I just said though.

    Troubleshooting

  • Multiple sensors home assistant
    martinhjelmareM martinhjelmare

    @sjofel

    In the temperature class, when you send in the new temperature, you set the sensor to 1. That means you connect the message with child 1, which is the door child. Remove that part of that line, and you should be good.

    Home Assistant

  • Cannot connect mysensors to Home Assistant
    martinhjelmareM martinhjelmare

    @SquareKinematics

    Your mysensors home assistant config is missing the value for the device key. In your case it should be mqtt.

    Home Assistant

  • Invalid Message, Sensor not being added
    martinhjelmareM martinhjelmare

    What version of mysensors are you using? Your sketch is using a pre 2.0 library api. I suggest you use the latest mysensors library version and update your sketch to use the current api.

    Read the api documentation on the mysensors site for more info.

    Home Assistant

  • Sensor naming problem
    martinhjelmareM martinhjelmare

    This is on my todo list. I hope to get to it soon.

    Home Assistant

  • Interrupt, Perform a specific function, not the loop
    martinhjelmareM martinhjelmare

    @n3ro

    It's untested, but here you go. It's a modified version of the sketch by @Anticimex for a binary switch with two interrupts.

    https://codebender.cc/sketch:171302

    General Discussion
  • Login

  • Don't have an account? Register

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