Avatar for allObjects


Member since Jul 2014 • Last active Feb 2019

Espruino makes IoT as easy as 123!

Most recent activity

  • in Projects
    Avatar for allObjects

    The product you are talking about is like that - http://www.towelrads.com/collections/ele­ctric/mccarthyelectric/ - with brochure at http://www.brittens-bathtime.com/wp-cont­ent/uploads/2017/04/Towelrads-2017-Broch­ure.pdf - w/ pages 101 / 102 show and describe the switch you took a pic of. ...pretty close to what I imagined.

    In your picture I see gray power cored... if this goes to a wall outlet, you consider an alternative to the actual, physical pressing of a button: putting a box w/ Espruino and a 5V relay between the wall outlet and the radiator. You can then even integrate a 5V phone wall outlet power supply and never have to worry about power again. I used a pico to do my tests, but you may find the puck.js the better solution, because it has connectivity... and you need a driver N MOS FET anyway...

    Btw, alternative to servo, a stepper w/ gear - see this post - or micro stepper with a lead screw for linear movement (pic attached) would do as well... and there are even more alternatives, food for future posts.

    Took a look at the idea of driving a 9g micro/nano servo with 5 pins from a PICO. PICO as chip can handle a total of 120ma. Each pin can handle up to 25mA up to the combined total of the chip. With 5 pins I maxed out... Even though the pins could handle easily the 3.4mA standby power consumption of the servo and on move could provide the no-load of roughly 60..70 mA, the servo did not move: the voltage was too low: 2.7V something, which is typical for a loaded pin... and still way in the limit of 1 / HIGH output.

    Resorting to a N MOS FET did the trick... put in the LOW side... When fed by USB through PICO's diode on vBat/USB puts the USB 5V down to 4.3V, still good enough . Connecting directly to rail up to 6V (4x1.5V... or 4x1.2V=4.8V w/ rechargeables) gives it a bit more umph. 1S LiPo may not be enough and 2S directly connected is probably too much, and it could also be an issue with PICO. a 5V bost converter w/ 1S and a bucket converter w/ 2S would do as well

    Holding the servo to get an idea of the blocking current shows quite a draw, briefly over 200ma...

    Attached is a still and a clip.

    In clip it can be servo moves a bit odd: it goes very briefly in the wrong direction to then turn and to in the right direction to the desired position. Also weird is the start up... may be my servo is an out-layer...

    The code was quite interesting to write, since all is timed. I added a command fifo in the logical servo, that handles the times and also manages the power up and power down of the FET... btw, the FET is from @DrAzzy 's shop - any equal will do as well, just make sure the gate-on voltage is low enough so it can be driven by 3...3.3V logic. For details I placed one on the bread board at the bottom right corner. The multi-meters are cheapo's - free on the numerous sales events throughout the year - which I modified: I pushed in - with hot solder iron - two machined pin sockets and wired them internally, in order to use the meters w/ jumper wires. The left one shows 0..200ma and the right one 0..20V.

    The code has a test procedure that indefinitely every 6.5 seconds makes three :button pushes:...

    So far I have only straight horns on the servo axle. For push a switch I would use a cam. Only little stroke is used, so it can be of very small high/low diameter and therefore can produces enough force over a 'leaf spring' onto an actual push button.

    // servoFETPowered.js
    // on demand powered servo w/ FET for moving it.
    var pCP = B3 // power contol pin - control N-FET gate
      , sCP = B4 // servo control pin  (PICO)
      , servoMod = require("servo")
      , servo    = null
    var s = // servo that switches it self on and then off
    { pCP: null // power control pin
    , sCP: null // servo control pin
    , s: null // actual servo
    , i: null // power off timeout id
    , cs: []  // fifo of commands - [p,t], if p falsy, just wait t
    , setup: function(pCP,sCP,range) { // setup w/ power and servo control pins
       this.pCP = pCP;
       this.sCP = sCP;
       this.s = servo = servoMod.connect(this.sCP,{range:range})­;
    , m: function(p,t) { // move command as like move of actual servo
        if (this.i) this.i = clearTimeout(this.i);
        if (this.cs.length===1) {
          this.pCP.set(); LED2.set();
      } }
    , x: null // xu bound
    , xu: function() { // exec command in fifo[0] - unbound
        var c = this.cs[0], p = c[0];
        if (p>=0) this.s.move(p,c[1]);
    , c: null // cu bound
    , cu: function() { // conclude current command and continue or power off - unbound
        if (this.cs.length>0) { this.xu();
        } else { this.i = setTimeout(this.o,100); }
    , o: null // ou bound
    , ou: function() { // switch power off
        this.pCP.reset(); LED2.reset();
    , bs: function() { // do binds
        this.x = this.xu.bind(this);
        this.c = this.cu.bind(this);
        this.o = this.ou.bind(this);
    }; s.bs();
    var st = 500; // stroke time
    var ht = 100; // hold time
    function t() { // toggle switch - press and release 
    var iId = null; // interval Id ( issue 'clearInterval(iId)' to stop)
    var iTm = 6500; // interval Time
    function ts() { // continuously/every iTm seconds 3 toggles
      iId = setInterval(function(){ t();t();t(); },iTm);
    function onInit() {
    setTimeout(onInit,500); // while dev'g / comment for upload for save()
  • in Puck.js, Pixl.js and MDBT42
    Avatar for allObjects

    ...and it payed of...

    The right-handed question was triggered by the position of display and button... to make the remote available thinking about how to us it with the other hand or both and till git from it what have designed is worth a thought - may be too version that at least support both preferences. I'n not a boarder and also do not know now often the display would have to be consulted or would be nice to be easily consulted while racing / cruising. UX things are quite a factor of acceptance.

    --- I guess you have to brand it with saw in elegant letters (and just drop the flattened O as goes with the pouch ;/* )

  • in Projects
    Avatar for allObjects

    Brilliant application for getting into IoT... and very useful!

    Espruino source/sink capabilities are not enough to power a servo directly, but they have plenty of power to drive the control line. You can go for a relay to switch the power of the servo, but a relay is a power hungry too. Simplest is to drive it with a FET - and it may even work to have the N-FET in the low side. Otherwise you need a P-FET. Depending on the battery you use and what protection circuitry is involved if needed at all, I see no reason why not have it 'unattended'. A PICO is fine if you tune the frequency when no clock crystal is on board. You may end up to connect it to a small display that would allow you to show and adjust the time as needed... Going Bluetooth / BLE - with the http://www.espruino.com/MDBT42Q breakout, you have communication and can control it from a phone... and get the temperature back... It all depends how elaborate you want to go... beginning w/ baby steps.

    Do you know the force you need to do your switch? What is the stroke the switch has (if it is a push button switch)? Is the switch directly switching the towel rack heating element or just a control line?

    Can you take and publish a pic of the switch?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for allObjects

    @Shane.au.wade , what circuitry did you use to ensure safety for the MDBT42Q Bluetooth Module (<=3.6V) from the LiPo (up to 4.2V) - in the bottom of the remote?

    Are you right-handed?

    The remote looks really great!

  • in Interfacing
    Avatar for allObjects

    you mean to move cursorX/Y to earlier in the struct, so they are always in the same place?


    In other words: 'all' that is always there comes first, after that the optional 'things'.

    And in deed, the modified extent and font alignment/rotation information do not have to be in teh same #ifndef...

    Btw, I was surprised that this space/byte/variable saving business to fit onto devices w/ low flash is that fine granular... a lot of work... but it makes sense (not the work but the way it is done).

  • in General
    Avatar for allObjects

    What happens when you run your source through the google closure compiler at https://closure-compiler.appspot.com/hom­e w/ simple minification?

  • in General
    Avatar for allObjects

    Usually, the module name is without file extension (.js). What is the exact name of the module in the file system?

    I usually use only no or just simple minification until I'm done w/ development. Then I go to the google closure compiler, paste in the source from my sandbox' modules folder, run the compile and copy-paste the result 'back' into the .min.js file in my sandbox' modules folder.

  • in Interfacing
    Avatar for allObjects

    ...instead of grouped I should have said bundled...

    for reasons of having unconditional structure accessible as one, contiguous block, incl. cursor pos - (https://github.com/espruino/Espruino/blo­b/master/libs/graphics/graphics.h#L69, though may not be of interest.

  • in Interfacing
    Avatar for allObjects

    ...indeed... kind of a cartesian product says hell(o)!...

    To keep complexity limited, I can see multiple, different extensions and only the application has to load only what is needed... it could even be instance based rather than prototypical, even though latter I prefer (for encapsulation reasons and simplicity of use). For starters I will go for support of single neopixel string w/ zig-zag and not-zig-zag.

    A) Is there reason not to group fontAbc and modMmmN, since they are build-time conditioned? - https://github.com/espruino/Espruino/blo­b/master/libs/graphics/graphics.h#L64L68­ and https://github.com/espruino/Espruino/blo­b/master/libs/graphics/graphics.h#L70L72­ , respective
    B) What is STM32F4's alignment in structs? - byte for things <= byte, 2 bytes for things of 2 bytes, 4 bytes of 4 bytes

    I assume SAVE_ON_FLASH flag is at runtime accessible somewhere...