You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Sorry it's been such a pain to get started. Out of interest, did you go through­ ? It seems modules and require aren't mentioned there, so I should definitely add a bit on them to help clear this up.

    If data is getting lost, something is definitely going wrong (that's not normal at all!). I think it's possible that you may have got a FIFO_FULL error message at some point during your uploads, but maybe didn't notice it. That basically says "Espruino was doing something that kept it busy during the upload, and the PC kept pushing data in and eventually some data got lost".

    As @allObjects says, the issue is likely that the code example isn't expecting to be executed at upload time, and some part of it takes a while to execute.

    It'd explain why everything is feeling so flaky - whitespace shouldn't cause any issues at all, but by reducing it you're reducing the amount of code that is sent after the require("DS18B20").connect, which might pause for a while.

    Maybe try this - the difference is that require("DS18B20").connect will be called after everything has been uploaded.

    var ow, sensor;
    function onInit() {
      ow = new OneWire(D13);
      sensor = require("DS18B20").connect(ow);
      setInterval(function() {
        sensor.getTemp(function (temp) {
          console.log("Temp is "+temp+"°C"); 
      }, 1000);

    or your other option is to just use the Save on Send option in the Web IDE's settings (which saves you code verbatim and then executes, rather than executing it line by line on upload). The only gotcha with that is that you can't then make changes on the left-hand side of the IDE and change them - at power-on it'd just execute exactly the same code you uploaded.

    If you're uploading code in future, please could you just highlight it and click the 'code' button in the editor? It makes it way easier for us to read :)

  • Hi Gordon

    Nice to meet you .. I (potentially) love what you are doing and have high hopes for my Pixl.

    I did indeed see that FIFO buffer error at least once .. but definitely not every time.

    I will try both of your suggestions - I'm not sure of the rationale for executing each line as it uploads - I can see that any setInterval could fire for a function not yet defined - or for that matter simple function calls could fail. Maybe I misunderstand (entirely).

    I could see I was getting syntax error on code I hadn't written - some sort of corruption.

    Apologies for my bad manners in code formatting.

    My laptop is an HP Spectre 360 - it has Bluetooth but I don't know if it's 'LE' - could that have anything to do with it ?

    BTW I'm using the native IDE not the web one .. I will see if it has a save on send option.


Avatar for Gordon @Gordon started