Sensebender Micro


  • Hero Member

    @ServiceXp Good point. Maybe for the low values it's transmitting the temp/humidity when it's calculating the battery level. I'll take a look at the sketch to see if that could be the case.

    Cheers
    Al



  • Hello

    I found an error in the sensebender micro sketch in the latest release.

    The calculation of the temperature change is wrong.

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100);
    

    needs to be replaced with

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0);
    

    The division with 100 needs to be 100.0 otherwise the result will be an integer instead of a float value and the difference will be the decimal places of the last temperature.


  • Contest Winner

    This should work as well and might be more clear:

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100f);
    

    But I guess it is a matter of taste πŸ™‚



  • Hi guys,
    amazing board! But i have a question: The Arduino IDE offerst two options as destination - 8MHz and 1MHz. Which one should i chose? My board seems to work in general, but not very realiable...


  • Hero Member

    @Stephan-Noller Out of the box, I had to use the 8MHz option to upload the sketch to it.

    Cheers
    Al


  • Admin

    The sensebender is set up to run at 8Mhz. There is an option to build it for 1Mhz, but you have to switch the prescaler yourself in your sketch.

    However I think the current consumption saved by running on 1Mhz vs 8Mhz is very limited on the sensebender, as the oscillator is shut down the majority of time (when we are sleeping the MCU).
    . I have not made any measurements on this yet (busy with a 1000 of other projects)


  • Hero Member

    @ServiceXp Your hunch was correct. I built another Sensebender that only transmitted battery levels, and it's battery levels did not vary at all:

    sb1.PNG

    I then modified the sketch to put a short wait after the temp & humidity are sent to allow the voltage level to recover and the battery levels do not fluctuate so far. However, I'm thinking it would be better to always measure right after a transmit, but not sure if that's easy to do.

    Cheers
    Al


  • Hero Member

    @Sparkman Thanks for the follow up.


  • Hero Member

    @hek can anyone help me, no unit is functionnal so far...

    @epierre said:

    @hek

    I started it plugged to a vinduino like schema, so I had this :

    Sensebender Micro FW 1.2 - TestMode
    Testing peripherals!
    -> SI7021 : ok!
    -> Flash : failed!
    -> SHA204 : Ok (serial : 01232F36E159E8ADEE)
    Test finished
    ----> Selftest failed!
    

    I read your posts, replaces 1.4.1 libs by 1.5, reflashed it with the demo code and here is what I have:

    Sensebender Micro FW 1.2radio init fail
    

    is that because I don't have a 1.5 serial gateway ?

    I have the socket and the FTDI on the same side so I may avoid the above ?


  • Admin

    @epierre said:

    is that because I don't have a 1.5 serial gateway ?

    Gateway version shouldn't matter if you get this message at startup of node.

    I have the socket and the FTDI on the same side so I may avoid the above ?

    I don't understand what you mean.


  • Hero Member

    @hek said:

    @epierre said:

    is that because I don't have a 1.5 serial gateway ?

    Gateway version shouldn't matter if you get this message at startup of node.

    what should I do from there ?

    I have the socket and the FTDI on the same side so I may avoid the above ?

    I don't understand what you mean.

    this was related to the electric perturbation with headers close to the radio


  • Hero Member

    @epierre Can you confirm the settings you used in the IDE to program it? Are you sure there are no solder bridges where you soldered the radio or socket for the radio? Have you tried powering it with a couple of AA batteries after you uploaded the sketch?

    Cheers
    Al


  • Hero Member

    Today I integrated my first 2 sensebender micros into my homeautomation and they almost worked out of the box. I like this board really much! Good work, I will order more!

    Pitfall:
    When updating the mysensors lib from 1.4.x to 1.5 the sensor failed to get an id from the controller which btw was still running on 1.4.x.
    After having done all the things like "clearing eeprom", "soldering a capacitor to the radio" and so on... I noticed that I changed the RF_CHANNEL from the default 76 to some other value in MyConfig.h some months ago (probably for some paranoia reason).
    When updating to lib 1.5 the sensor sketch got the 76 while the gateway still used the other one and so the communication between both failed. After changing the radio channel to the one the controller uses, everything worked very quickly!

    Probably this post helps someother guy who fell into the same trap.



  • Hi,

    My sense bender works perfect when sending directly data directly to serial gateway (vera 5), however when I move it out of range to the serial gateway and want it to connect to my repeater node it does not want to discover the repeater node. Anyone else had this problem?


  • Admin

    Remember that it takes a few ( ~5) failed transmits until it searches for a new parent node.



  • @johnr

    Is your repeater node still on MySensors 1.4? I had a similar problem and upgrading to 1.5 solved it.



  • You are probably right. I did not realise sense bender was pre loaded with 1.5

    I think easiest for me would be to downgrade sense bender to 1.4 is it possible?


  • Admin

    Sensebender is still on 1.4, as we haven't prepared new firmware for it yet.

    Mysensors 1.4 and 1.5 should be compatible with each other, right @hek ?


  • Admin

    Yes, it should.

    But as @Dewalt says, there was a bug in repeater functionality. So upgrading the repeater is a good tip.



  • Upgrading repeater to 1.5 solved this issue. Thanks for the quick help. 1.4 sensors communicate OK with the 1.5 repeater as far as I can see right now.



  • I try to make a 3D box for SenseBender Micro with CR123 battery.
    Screenchot :
    Boitier.png



  • first print test : IMG_20150921_230740.jpg
    IMG_20150921_230820.jpg


  • Admin

    @Fabien

    Nice work, what is the dimensions of the enclosure?



  • @mvader said:
    question about the default sketch for this board.
    if i read correctly

    
    // How many milli seconds between each measurement
    #define MEASURE_INTERVAL 60000
    
    // How many milli seconds should we wait for OTA?
    #define OTA_WAIT_PERIOD 300
    
    // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller
    #define FORCE_TRANSMIT_INTERVAL 30 
    
    // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
    // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement
    
    // HUMI_TRANSMIT_THRESHOLD tells how much the humidity should have changed since last time it was transmitted. Likewise with
    // TEMP_TRANSMIT_THRESHOLD for temperature threshold.
    #define HUMI_TRANSMIT_THRESHOLD 0.5
    #define TEMP_TRANSMIT_THRESHOLD 0.5
    

    if temps don't change more than .5 i shouldn't see a transmit but once every 30 minutes
    i have 2 running right now
    and both send temp and humidity every 1-2 minutes and the numbers are the same or in some cases only different by .1
    i have it set to .5 so the question is

    1. why does it transmit every minutes when the temp and humidity are the same
    2. why is it transmitting even with as little as .1 change
      1 board is running 1.2 and the other is running the 1.3 sketch from git
      Battery however does transmit every 60 minutes as it's supposed to.,
      thx

  • Admin

    @mvader

    Have you tried to hook up a serial connection to your sensebender? It writes the difference from the last transmitted measurement, everytime a new measurement is taken (every minute).



  • @tbowmo 47x37 height : 27
    I will make some improvment (can not test, my printer is in maintenance mode !) and post files for others.



  • @tbowmo said:

    @mvader

    Have you tried to hook up a serial connection to your sensebender? It writes the difference from the last transmitted measurement, everytime a new measurement is taken (every minute).

    so if i want it to transmit less frequently (save battery?) i would increase the measure interval. correct?
    I have some situations where i want frequent measuring (1 minute), and some where 15 minutes or 30 minutes would do fine.


  • Admin

    @mvader

    Yes, you could save battery, by changing to 10/15 minute check interval..

    But still, the interesting thing is why it transmits every minute.. That's why I would suggest to check the serial output..


  • Hero Member

    There is an explanation to the problem further up in the thread:

    @gloob said:

    Hello

    I found an error in the sensebender micro sketch in the latest release.

    The calculation of the temperature change is wrong.

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100);
    

    needs to be replaced with

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths) / 100.0);
    

    The division with 100 needs to be 100.0 otherwise the result will be an integer instead of a float value and the difference will be the decimal places of the last temperature.


  • Admin

    @korttoma

    thanks for helping my memory πŸ™‚



  • @korttoma i did see that. but your saying that is what is causing it to transmit every 1 minute?


  • Hero Member

    @mvader yes, it is rounding the temperature difference to the nearest degree so the difference is almost always more then the 0.5.


  • Admin

    Just a hint, itead studio is starting a sale with 10% off on all imall items.. So maybe it's time to buy some Christmas presents for the inner geek πŸ™‚



  • Oh no! Lousy timing, I just bought some...
    ... in fact, they arrived today.

    Speaking of which, whilst I got them to run the default sketch, do I actually need a programmer to do anything different, or can this be done OTA (from a Mac) ?


  • Admin

    @akbooer

    The default sketch doesn't support OTA, as it wasn't available in the stable branch at the time of launch



  • @tbowmo Good sales but did not see the Sensebender too bad .


  • Admin


  • Hero Member

    @hek I've soldered a second unit to compare, same error, I flashed back the sensebender version from the examples and on both I am stuck here: "Sensebender Micro FW 1.2radio init fail"

    Gateway is 1.5 BTW, one radio is from itead the other not.


  • Hero Member

    @Sparkman said:

    @epierre Can you confirm the settings you used in the IDE to program it?

    1.6.5 version

    Are you sure there are no solder bridges where you soldered the radio or socket for the radio?

    same behavior on two units

    Have you tried powering it with a couple of AA batteries after you uploaded the sketch?

    not yet but why should that change anything ?



  • This post is deleted!


  • Just tried out my first Sensebender...
    soldered pins and battery power...
    turn on...
    led flashes once...
    start inclusion...
    3 devices...
    Vera restarts (actually, it's openLuup running on an Arduino YΓΊn)...
    there they are...
    and updating every minute!

    Thanks so much to all who made this level of sophistication so easy!! (Z-wave was never this simple!)

    Whilst I need a couple of temp/humidity sensors, I also need to reflash one as a 4-switch sensor. Can I do this with an Arduino Uno configured with the ArduinoISP sketch as described here ?
    https://www.arduino.cc/en/Tutorial/ArduinoISP

    Any advice or useful pointers? Thanks.


  • Admin

    @epierre

    What do you use as supply voltage for the thing? What is the output from testmode?

    Did you add a capacitor on the radio module? How did you mount them together? (picture?)


  • Admin

    @akbooer

    Should be doable with an arduino as isp. Another option is to use the serial upload.



  • I am a noob in coding so I need some advice for tuning the sensebender.ino
    current observed problems:

    1. sensor values transmitted every minutes
    2. battery level info seems wrong

    I am running the default senseblender.ino.

    on 1) What I understood in this forum, it should transmit the temp. values only every 30min (or direct when change is >.05). However, I see them arriving in my controller (Domoticz) every minute. What should I change to have it send every 30min?

    on 2) I observe in Domoticz that the battery levels reported (in the Devices section) are inaccurate. For example: one sensebender with 3.2v measured power reports 80, where I would expect round 100 (this one has new batteries). Other sensebenders with still 2.63v report 53. How to calibrate the battery measurement?

    I have been searching this forum, but was unable to find the answer.
    Alternatively, a pointer to a wiki on sensebender.ino that has this explained would work as well.


  • Admin

    @jovo

    The firmware that the sensebender is shipped with is pretty old, compared to the one that's available in the current master branch of mysensors library. A lot have been done to do better transmit control (like, limiting number of transmits etc.)

    About the battery voltage, the sensebender is measuring against an internal vref, which isn't that accurate. I can't remember the specifics at the moment, but it's hidden somewhere in the datasheet. The measurement method has a lot of inaccuracy, but on the other hand it saves external components and power.

    I didn't focus on it, but one could perhaps make some kind of calibration routine, use a known supply voltage and do some internal calculations and store an offset in eeprom.



  • @jovo for battery mesurement it's correct 100% is for 3.3V and 0% for 1.9 V (BOD fuse setting). so for 2.63 you have 52,14 %


  • Plugin Developer

    @jovo As @Fabien wrote, the default code puts 3.3 V as 100%. Look for the percentage calculation. You will see that it's basically (vcc - 1900)/14. This makes sense if using a step-up converter where you get 3.3 V. But if connecting directly to two AAs, 100% should be around 3 V. So just replace 14 with 11 in the calculation.



  • Thanks for the comments and suggestion.
    Now I have installed the master branch code from the mys. library.
    Unfortunately no change. Still very frequent updates (under the same circumstances).
    I sense it has something to do with :
    bool tx = force;
    but I am not quite sure where to change it in.
    I will continue my search.....


  • Admin

    @jovo

    There is a small error in the sketch, that falsely converts floats to ints. Look at line 243, it's dividing by 100:

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100);
    float diffHum = abs(lastHumidity - raHum.getAverage());
    

    This should be changed to 100.0 instead. This way the calculation is returning as a float.

    float diffTemp = abs(lastTemperature - (isMetric ? data.celsiusHundredths : data.fahrenheitHundredths)/100.0);
    float diffHum = abs(lastHumidity - raHum.getAverage());
    


  • @fabian how is the box working out were there any mods and are the stl files ready yet?



  • ok, it seems the aggregated upload is solved with the change from Thomas.
    Now I modify the "14" in "11" as suggested by martin. I have 105% now, but that could be right because I measure 3.1V from my 2 fresh AA's

    The only 'new issue' I discovered is that one sensor actually stops being received updates from due low power. The measured voltage on the batteries is still 2.1V and the battery indicator was at 23%.
    Could it be that I have bad fake radios that don't operate lower then 2.1V? (since there is no other external components added to my setup, I suspect only the radios).



  • @5546dug said:

    @fabian how is the box working out were there any mods and are the stl files ready yet?

    Sorry, my 3D printer is out of service, I'm waiting for chinese parts ... I will post correct STL files in 1 or 2 weeks.



  • I'm having trouble with the transmission times.

    // How many milli seconds between each measurement 900000 is 15 minutes
    #define MEASURE_INTERVAL 900000
    
    // How many milli seconds should we wait for OTA? 3000 is 3 seconds
    #define OTA_WAIT_PERIOD 3000
    
    // FORCE_TRANSMIT_INTERVAL, this number of times of wakeup, the sensor is forced to report all values to the controller
    #define FORCE_TRANSMIT_INTERVAL 30 
    
    // When MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
    // Between the forced transmissions a tranmission will only occur if the measured value differs from the previous measurement
    

    I would expect a wake up and measure every 15 minutes. transmit if greater than .5 and go back to sleep
    also i would expect a forced transmission every 30 minutes.
    but that doesn't seem to be happening.
    here are my last few transmit times
    4:07pm
    5:59pm
    6:15pm
    6:47pm
    7:50pm
    8:34pm
    9:10pm

    I don't see a static 30 minute transmit.
    (from 4pm to 6pm?) i'm sure the temp and/or hum changed in 2 hours

    any suggestions on what may be wrong?
    default sketch (1.3 from git) but changed the measure intervals
    sensor lib 1.5
    thanks



  • @mvader If your interval between readings is 15 minutes and the force transmit interval is 30, your actual interval is 15minutes * 30 = 7.5hours. Also, see this thread for sleep time accuracy. 15 minutes of sleep can last 16-17 minutes...



  • @Dwalt said:

    @mvader If your interval between readings is 15 minutes and the force transmit interval is 30, your actual interval is 15minutes * 30 = 7.5hours. Also, see this thread for sleep time accuracy. 15 minutes of sleep can last 16-17 minutes...

    really.. hmm
    so if you look at the default comment
    when MEASURE_INTERVAL is 60000 and FORCE_TRANSMIT_INTERVAL is 30, we force a transmission every 30 minutes.
    That says measure for temp/hum every 1 minute - send if greater than .5 (defined later in the sketch)
    regardless of what goes on send stats every 30 minutes

    can you help me understand why those 2 number would be multiplied together? one shouldn't have anything to do with the other.
    i read that as they are definitions for 2 different process.
    but i may be totally misunderstanding.

    I do buy the sleep accuracy part of it though πŸ™‚



  • @mvader No, it is not 30 minutes, the FORCE_TRANSMIT_INTERVAL counts the number of 'wakeup and take a reading' events, which in the original sketch is every 60 seconds. After 30 wakeup-and-read without a transmit, force a transmit. If you change your FORCE_TRANSMIT_INTERVAL to 2, it will transmit every 30 minutes if the readings do not change more than 0.5.

    The MEASURE_INTERVAL is based upon time (millis) and the FORCE_TRANSMIT_INTERVAL is based upon counting events (wakeup cycles).



  • @Dwalt said:

    @mvader No, it is not 30 minutes, the FORCE_TRANSMIT_INTERVAL counts the number of 'wakeup and take a reading' events, which in the original sketch is every 60 seconds. After 30 wakeup-and-read without a transmit, force a transmit. If you change your FORCE_TRANSMIT_INTERVAL to 2, it will transmit every 30 minutes if the readings do not change more than 0.5.

    thanks for the clarification! πŸ‘



  • @hek said:

    @gbfromhb

    D3 is available on the side-pins. D2 is routed to the radio but can be used with some hacking.

    I need 2 interrupts and would prefer using the external interrupts even though it might work with pin change interrupts. When looking through the forum I saw this answer from @hek but have not found any further reference to how this should be done in order not to disturb any radio functions. Anyone knows?


  • Admin

    I don't know if the radio actually drives the interrupt "output" pin on it's pinheader as default, or if you have to set it up when initializing the radio (@hek might have some input on this part :))

    If it drives the interrupt pin by default, then you need to either cut a trace on the sensebender, or cut / remove the pin in the pinheader on the radio module.


  • Admin

    @tbowmo said:

    I don't know if the radio actually drives the interrupt "output" pin on it's pinheader as default,

    I think it does actually.



  • @hek Is it needed for the radio to work or can I just cut it (seems odd to attach the radio to D2 if it is not really needed for anything).


  • Admin

    No, it isn't currently used by the MySensors library. It could be used to wake up the board when detecting radio transmissions...
    But keeping MCU sleeping and the radio listening still uses up batteries far too quickly so I guess it's still not an option.



  • @hek @tbowmo Thanks! Cut the radio IRQ pin and soldered a connection to D2. Tested to attach both interrupts and it works using a modified SenseBenderMicro sketch. "The Thing" will when ready be placed in my mailbox (which has mail-in and mail-out doors) and as a bonus report the outside temp, humidity and battery status. Does not solve any of this worlds biggest problems but it is fun πŸ™‚



  • Hello,

    one simple quick question, does this board can be used to create door sensors ? I do not need the temp/hum sensors, but I'm interested with the small footprint and the battery optimized board to make smallest door sensors (and some buttons).

    regards,


  • Admin

    @petoulachi

    Yes, it could be made into a door / window sensor.. (I'm planning on doing that myself).

    However, you need to build your own, if you don't want the temperature/humidity sensor on it.



  • @tbowmo
    Well can't I use this board without using the temp/hum sensor ?

    This board is quite small and allows to stack the radio module with minimum place. Also it works at 1Mhz, I guess it's a bit better than an Arduino Pro @ 3.3V ?


  • Admin

    Yes, you can use it without using the temp/hum sensor....

    I just assumed, that as you wouldn't make use of it, you would like to have it removed from the board as well..



  • Well I do, but I think that using a Arduino Pro 3.3V will be less effecient, but maybe I'm wrong ?

    I'm currently using temp/hum/motion sensors with Arduino Pro 5V, but they are not battery powered. Now I need to make very small sensor with battery, and I thought that maybe this sensebender board is my solution ?


  • Contest Winner

    @petoulachi to make the pro mini as efficient as the SenseBender, you need to cut some traces on the board. There are forum topics for battery optimizing a pro mini. The SenseBender has these optimizations built in.



  • That's why I think i'm going to go with this senseboard.
    But I want to be sure that some connectors (D3 ?) support interrupts ? The goal is to have the sensor always in sleep mode, and wake up on interrupts only.

    Regards,



  • @petoulachi D3 can be used for interrupt, just tested it and it works.



  • I vote for one cheap Sensebender version without the temp/hum sensor on it. It will be the perfect door/window sensor.


  • Admin

    @nikos1671

    It has been up before, but back then it was decided that we don't save that much (2-3 $ or something like that). It might also be lower production quantities, which also keeps the price up..



  • @tbowmo just curious do you guys know how many of these you've sold?
    I've bought about 15+ πŸ™‚


  • Admin

    @mvader
    Then you've bought almost 2% of them πŸ™‚

    We're deeply grateful for yours and others support of the MySensors project.



  • Ordered 6 board too ! I'm glad to support MySensors project !



  • I've got 3 coming, can't wait to figure out what I'm going to use them for πŸ™‚



  • @timropp said:

    I've got 3 coming, can't wait to figure out what I'm going to use them for πŸ™‚

    I'm deploying mine all over the house.
    in my attics, garage, shed. bedrooms. etc
    I've attached motion and lux sensors to several of them already.
    I tested / proof of concept adding IR transmitters. but these will likely need to be 5v nano's or something as battery power probably won't work with the IR and staying away waiting for messages from the controller.



  • Got 3 up just using the built in temp/humidity, making sure all looks ok. Will slowly add motion.

    Any suggested motion sensor for these guys?



  • @NotYetRated said:

    Got 3 up just using the built in temp/humidity, making sure all looks ok. Will slowly add motion.

    Any suggested motion sensor for these guys?

    I'm using that HC501 PIR
    you can connect to the side pin and use 3v instead of the 5v


  • Hardware Contributor

    @mvader Can you elaborate how you use 3V on the HC501 ? Which side pin ? Can you post an image ?



  • @GertSanders
    if you look at this image
    on the left side where it says "H" by the 3 pins with the jumper.
    i take off the jumper and connect 3v to the H pin
    works great.
    http://www.bdspeedytek.com/wp-content/uploads/1.1.jpg


  • Hardware Contributor

    @mvader Thanks !


  • Admin

    My Sensebender node started June 10 is still going strong.

    Screen Shot 2015-11-12 at 20.04.18.png


  • Contest Winner

    @hek nice, what tool do you use for logging/graphing? Or is it exported and post-processed?


  • Admin

    @Anticimex

    Datamine for Vera. The actual data is stored to my NAS (mounted from vera).


  • Contest Winner

    @hek cool. Can Vera do that now? Vera lite as well? Though the data miner plugin only could use USB mounts.


  • Admin

    @Anticimex said:

    Can Vera do that now? Vera lite as well? Though the data miner plugin only could use USB mounts.

    Na, a little hack
    http://forum.micasaverde.com/index.php/topic,14910.0.html



  • Hello,
    I've just received my sensebender boards and start playing with it.

    My first goal is to make a door sensor running on battery. I will not use the integrated temp/hum sensor for battery purpose, and use interrupt to have the sensor on sleep the majority of time.

    Looking at the sketch given with temp/hum, I have one question;

    on the loop function, we have

    if ((measureCount == 5) && highfreq) 
      {
        clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power.
        highfreq = false;
      } 
    

    But I don't really understand this ; highfreq is initialized to true in the declaration, and never again. So, does this clock_prescale_set is call only once, meangin that the sensor will run at 1Mhz all the time ?
    It is the 5 first mesure that are running at normal speed, and then the sensor goes into a "battery efficient" mode ?
    Why waiting for 5 mesure to do so, and not doing it at startup ?

    Thanks for your explanation !


  • Admin

    @petoulachi said:

    But I don't really understand this ; highfreq is initialized to true in the declaration, and never again. So, does this clock_prescale_set is call only once, meangin that the sensor will run at 1Mhz all the time ?
    It is the 5 first mesure that are running at normal speed, and then the sensor goes into a "battery efficient" mode ?
    Why waiting for 5 mesure to do so, and not doing it at startup ?

    Thanks for your explanation !

    It's waiting with switching to lower frequency, because it is dumping debug information to the serial port. And when you switch to 1Mhz, the baudrate is "screwed".

    When that's said, my opinion is that there is not much power to save, with switching to 1Mhz. This is because the MCU is sleeping most of the time, with the RC oscillator switched off. I am thinking that the freq. scaling should be removed in the comming releases



  • Oooh so I guess that also explain why I have strange output on the serial using the default sketch ?

    Well, I'll start without touching frequency and see how it behave in the next month. This is the sketch I use (not tested yet !). Sleeping all the time, awake but interrupt. When awake, send the Battery % if different from last mesure.

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * REVISION HISTORY
     * Version 1.0 - Henrik Ekblad
     * 
     * DESCRIPTION
     * Default sensor sketch for Sensebender Micro module
     * Act as a temperature / humidity sensor by default.
     *
     * If A0 is held low while powering on, it will enter testmode, which verifies all on-board peripherals
     *  
     * Battery voltage is as battery percentage (Internal message), and optionally as a sensor value (See defines below)
     *
     */
    
    
    #include <MySensor.h>
    #include <Wire.h>
    #include <SPI.h>
    #include "utility/SPIFlash.h"
    #include <EEPROM.h>  
    #include <avr/power.h>
    
    
    #define RELEASE "1.0"
    
    // Child sensor ID's
    
    #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
    #define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
    #define CHILD_ID_DOOR 1   // Id of the sensor child
    
    
    MySensor gw;
    
    // Sensor messages
    MyMessage msgDoor(CHILD_ID_DOOR, V_TRIPPED);
    
    // Global settings
    int measureCount = 0;
    int sendBattery = 0;
    boolean highfreq = true;
    
    // Storage of old measurements
    long lastBattery = -100;
    boolean oldDoorValue;
    
    /****************************************************
     *
     * Setup code 
     *
     ****************************************************/
    void setup() {
      Serial.begin(115200);
      Serial.print(F("Sensebender Micro FW "));
      Serial.print(RELEASE);
      Serial.flush();
      
      gw.begin();
    
      Serial.flush();
      Serial.println(F(" - Online!"));
      gw.sendSketchInfo("Battery Door", RELEASE);
    
      // sets the motion sensor digital pin as input
      pinMode(DIGITAL_INPUT_SENSOR, INPUT);     
      // Activate internal pull-ups
      digitalWrite(DIGITAL_INPUT_SENSOR, HIGH);
      
       // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_DOOR, S_DOOR);
    }
    
    
    /***********************************************
     *
     *  Main loop function
     *
     ***********************************************/
    void loop() {
      gw.process();
    
      sendBattLevel(false); 
      door(false);
      
      gw.sleep(INTERRUPT, CHANGE, 0);
    }
    
    //  Check if digital input has changed and send in new value
    void door(bool force) 
    {
      // Short delay to allow buttons to properly settle
      sensor_node.sleep(5);
      
      bool tx = force;
      
      boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH; 
      
      if (tripped != oldDoorValue) 
      {
        tx = true;
        oldDoorValue = tripped;
      }
      if (tx)
      {
         // Send in the new value
         gw.send(msgDoor.set(tripped ?  1 : 0));  // Send tripped value to gw 
      }
    } 
    
    
    
    /********************************************
     *
     * Sends battery information (battery percentage)
     *
     * Parameters
     * - force : Forces transmission of a value
     *
     *******************************************/
    void sendBattLevel(bool force)
    {
      if (force) lastBattery = -1;
      
      long vcc = readVcc();
      
      if (vcc != lastBattery) 
      {
        lastBattery = vcc;
    
        // Calculate percentage
        vcc = vcc - 1900; // subtract 1.9V from vcc, as this is the lowest voltage we will operate at
        long percent = vcc / 14.0;
        gw.sendBatteryLevel(percent);
      }
    }
    
    /*******************************************
     *
     * Internal battery ADC measuring 
     *
     *******************************************/
    long readVcc() {
      // Read 1.1V reference against AVcc
      // set the reference to Vcc and the measurement to the internal 1.1V reference
      #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
        ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
        ADMUX = _BV(MUX5) | _BV(MUX0);
      #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
        ADcdMUX = _BV(MUX3) | _BV(MUX2);
      #else
        ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      #endif  
     
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Start conversion
      while (bit_is_set(ADCSRA,ADSC)); // measuring
     
      uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
      uint8_t high = ADCH; // unlocks both
     
      long result = (high<<8) | low;
     
      result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
      return result; // Vcc in millivolts
    }
    
    

    BTW, what is the F() function ? instead of Serial.print("Sensebender Micro FW "); why using Serial.print(F("Sensebender Micro FW ")); ?

    Thanks !



  • Started to solder my 6 sensebender. I've noticed that if I set it to 1Mhz directly, the sensor cannot register itself on the gateway (but unfortunately I dont know why because there's no serial). Putting it at 8Mhz, being detected by the GW with an ID, and I can set it back to 1mhz. Weird.



  • Oh and BTW, which boxes are you using with your Sensebender ? I guess it's maybe the most difficult part of the entire project, finding the perfect box πŸ˜„



  • No, finding a box is the easiest part. This is the "box" for my outdoor temperature. πŸ˜†
    sensebender.jpg


  • Admin

    Wonder how well the hum-sensors work in that enclosure πŸ™‚



  • Hmm, would Gore-Tex work? I will try find a Gore-Tex bag for the next version πŸ™‚



  • @Fabien said:

    @5546dug said:

    @fabian how is the box working out were there any mods and are the stl files ready yet?

    Sorry, my 3D printer is out of service, I'm waiting for chinese parts ... I will post correct STL files in 1 or 2 weeks.

    @Fabien @5546dug
    Hi, any news on this please? I would be good to get a box by Christmas.


  • Admin

    @petoulachi

    The sketch have improved a lot since we released the sensebender, mostly on determining when to power up the radio and transmit. This should save more power. I've got one running with latest development, without hiccups for the last couple of months (it also have Ota fw upgrade enabled by default now).

    So if you are "adventurous" I would recommend to put that into your sensebenders



  • I am adventurous !

    Were can I find the beta version of the sketch ?


  • Hero Member


Log in to reply
 

Suggested Topics

  • 3
  • 5
  • 164
  • 10
  • 109
  • 110

70
Online

11.4k
Users

11.1k
Topics

112.7k
Posts