You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • Hello!

    We are beginners with javascript and are confused on how to interface the sensors with the Pixl.js.
    It doesn't seem too complicated, but there aren't many examples on how to use them together. We've looked at this, but are confused why certain parts of the code are commented out, or what we would put in the (...) sections.
    http://www.espruino.com/Grove

    Also, specifically for the temp + humidity sensor, we found the DHT11 module and tried using that as well:

    var dht = require("DHT22").connect(D3);
    dht.read(function (a) {console.log(JSON.stringify(a));});
    

    But this doesn't return any raw values.
    temp and humidity = -1

    The sensor should be connected to the right pin and we have also made sure to flash the Pixl.js with the most recent firmware 2v04. What could be the issue with this?

    Also, is there any sample code we could refer to in javascript for the other sensors?
    Thanks!

  • Sat 2019.07.27

    Welcome to the world of Javascript @user98241 as I know you will enjoy many hours of discovery with your purchase of Pixl.

    'We are beginners with javascript'

    Excellent resource with a tryit window option:

    https://www.w3schools.com/js/js_operator­s.asp

    The language itself:

    https://developer.mozilla.org/en-US/docs­/Web/JavaScript/Reference/Statements/var­

     

    'are confused why certain parts of the code are commented out'

    On the 'Grove' page, the code within the commented out sections just indicate an alternate way in which commands could be used. It's there to aid as a hint, and to avoid having to look up each command, which may be done at:

    http://www.espruino.com/Reference#Pin

    It also appears that the commented out sections may be a suggestion on how to set up the declarations section, and the viewable code lines show usage, for the specific section beneath the heading in blue.

     

    ' what we would put in the (...) sections'

    Is there a specific example? It would depend on which command, which sensor etc. A combination of command lookup in the above link, and searching the manufacturer data sheet would be a good idea.

     

    'there aren't many examples on how to use them together'

    On the device specific page, beneath the Tutorials heading there are at least fifty:

    http://www.espruino.com/Pixl.js

     

    'any sample code we could refer to in javascript for the other sensors'

    Has the tutorials and samples page been discovered yet? Tons there also:

    https://www.espruino.com/Tutorials

     
    A good overview of a complete code example with the Pixl:

    https://www.espruino.com/Freezer+Alarm

About

Avatar for Robin @Robin started