Avatar for PaddeK

PaddeK

Member since Mar 2017 • Last active Dec 2017
  • 2 conversations
  • 68 comments

Most recent activity

  • in Interfacing
    Avatar for PaddeK

    @Wilberforce Thanks for looking into this. I did find those documents too, but they are all for other sensors and in almost every document they come up with some magic device specific constants. Sadly the other sensor are quite different spec-wise so i can't work with those formulars and/or magic constants.

  • in Interfacing
    Avatar for PaddeK

    I could need some help writing a conversion function to lux for this sensor. Contrary to the other light sensors of this manufacturer they do not provide a formular in the datasheet to convert from sensor output in counts to lux. The different conversion functions i could find floating around in the internet are all derived from the adafruit code for this sensor. But according to multiple sources the results are not correct so i left that function out for the time being.

    Since i do not really need a conversion to lux and i can not validate a against a luxmeter i put this work in progress code to the public. I hope someone is proficient in this area and can round off the code with this last missing piece.

    You can find the source, examples and documentation in my github account here.

  • in Other Boards
    Avatar for PaddeK
    function func(_pin)
    {
        if (_pin instanceof Pin)
        {
            /* here some code */
        }
    }
    
  • in Other Boards
    Avatar for PaddeK

    Or.. if the contextObject you need is the outer scope just use a arrow function as setTimeout callback and be done with it.

    Other public choices for the this alter ego are me and self :D

  • in Pico / Wifi / Original Espruino
    Avatar for PaddeK

    Maybe it is a timing issue and using a Promise could help.. dont know the complete code but something like this could work:

    function getPrices() {
      return new Promise((resolve, reject) => {
        h.get(`${proxy}${api}${symbols[++symbolC­tr % (symbols.length + 1)]}-${currency}`, res => {
          let pricesRaw = "";
          res.on('data', d => pricesRaw += d);
          res.on('close', () => (prices[symbol] = JSON.parse(pricesRaw), true) && resolve());
        });
      });
    }
    

    And in your other code just do:

    getPrices().then(showPrices);
    

    Error handling ommited for keeping it simple.. but you should take care of it :)

    • 2 comments
    • 76 views
  • in Projects
    Avatar for PaddeK

    I bought a cheap breakout for a temperature sensor and had no manual or other indication of which I2C address is used. So i wrote code to scan all I2C addresses and because it helped me i pimped it a little and made a ready to use module for everyone who might need it in the future.

    You can grab the code, usage example and options documentation here.

  • in Projects
    Avatar for PaddeK

    @Wilberforce i think using the mac address is a better fit in this scenario and there are multiple ways to get a mac address then a serial. But to be portable i used the callback variation of getIP so we should be fine in this regard.

    @Vasily nice to hear!! And to be clear... there is no bug in UDP its just not know supported for espruino devices.. so the alexa code right now just works for ESP8266 and maybe ESP32 users.

  • in Projects
    Avatar for PaddeK

    @Gordon thanks for the code.. had no time so far to look into it though.
    @Vasily i saw that the getIP call is for getting the mac address and that it is only used to create an identifier.. but i think its a good idea so i left it in.

    Only problem right now.. besides spare time to get into it.. is UDP or more specific multicast UDP.
    In a short research i found inconsistent statements about support of the AT firmware for multicast UDP. I guess next step will be to whip up some dirty test code and see if alexa can find a device.

    By the way there is a chance the rest of the code works as is.. at least for folks with a ESP8266.

Actions