Avatar for ok2chatt

ok2chatt

Member since Jan 2019 • Last active Jan 2019
  • 1 conversations
  • 7 comments

I love learning new things and tinkering. Mostly used to Arduino and Python, but have recently been learning Java and Javascript. Very happy to have come across Espruino and what it has to offer.

Most recent activity

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

    I was able to get this to work with both the power adaptor and also with a 9V battery as a separate test. I had to wrap the code in a setTimeout with a delay of 15 seconds to get the modem to initilize. I had performed this step initially; However, it seems wrapping Bluetooth.setConsole(1) inside of the setTimeout caused me problems.

    So, in the end wrapping the entire code(with the exception of the Bluetooth.setConsole(1) in a setTimeout for 15 seconds, in addition to the 'Direct to flash(Execute at boot)' was the needed fix to resolve this one. I hope others find this post useful should the encounter the same issues I did. Final code is posted below. On a side note and you will see the PIR block of code included below, this is also now stable and works as expected. Seems that the setTimeout is pretty crucial, and maybe in certain other cases could use a longer timeout than 15 seconds, to get this to work.

    Bluetooth.setConsole(1);
    setTimeout(function(){
    Serial1.setup(9600, { rx: D29, tx : D28 });
    var ATSMS = require("ATSMS");
    var sms = new ATSMS(Serial1);
    
    sms.init(function(err) {
      if (err) throw err;
      console.log("Initialised!");
    
      sms.list("ALL", function(err,list) {
        if (err) throw err;
        if (list.length)
          console.log(list);
        else
          console.log("No Messages");
      });
    
      // and to send a message:
      //sms.send('+441234567890','Hello world!', callback)
       setInterval(function readPIR(){
       PIR = digitalRead(D30);
       print(PIR);
         if(PIR == 1){
           digitalWrite(LED3,1);
           sms.send('+15555555555', 'Motion Detected!');
      }  else{
           digitalWrite(LED3,0);
      }
    }, 2500);
    });
    
    sms.on('message', function(msgIndex) {
      console.log("Got message #",msgIndex);
      sms.get(msgIndex, function(err, msg) {
        if (err) throw err;
        print("Read message", msg);
        var txt = msg.text.toLowerCase();
        if (txt=="on") LED1.set();
        if (txt=="off") LED1.reset();
        // delete all messages to stop us overflowing
        sms.delete("ALL");
      });
    });
    },15000);
    

    I would like to thank you again for all of your help and generous inputs! It has certainly helped me towards a resolution.

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

    As an added question, do you know of any solid liPo's that would be compatible with breadboard (future protoboard) with easy ability to charge? Most that I have seen have the tiny j connectors (which are the ones I currently have).

    Thanks again

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

    So, I replaced Bluetooth.setConsole(1); with the code snippet you sent and also ensured that the code is set to 'direct to flash' then reset and waited a bit and did the print(log) and returned the following:

    <- Serial1
    Uncaught ATE0 ERROR undefined
    -> Bluetooth
    =undefined

    As for the LiPo, I do have a few lying around, but do not have a proper jumper to connect to breadboard at the moment. I'll have to see if I can locate something to rig it up. Actually I do have a protoshield with a battery. I will charge it and try later today.

    Thanks again!

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

    Hey Gordon, thanks for the continued follow ups. I have made sure that it is puck.js firmware being uploaded to the board. That said, I upgraded the firmware tonight to v2.01. I immediately noticed that code is substantially faster to load to the board. I also hard reset prior to uploading the firmware to clear anything out beforehand.

    I measured the voltage passed to the puck from the output of the PIR sensor, it logs 3.27V at it's high peak, so everything looks good there.

    I have omitted the PIR sensor for the time being as I really want to focus on getting the code to work after removing and restoring power. If I disconnect from the serial bluetooth connection, but keep power supplied to the board, it will continue to work. However, if I remove power and restore power, I get no response when sending on or off via text message.

    I did notice that if I restore power and connect via web bluetooth and then call the load(); in the REPL, that it initializes and then works. I have a feeling that maybe the code running prior to the modem getting power may be causing problems when the code runs. However, I have also tried applying power to the modem until the modem boots up, then powering up the module and still no luck. I then tried to wrap all of the code in a setTimeout(function(){all of code here},12000); to see if setting a 12 second delay to allow the modem to boot up would help.

    I've commented out Bluetooth.setConsole(1) as well as uncommented it. As mentioned, it all works great, when connected to the web console and even after disconnecting from the console, just as soon as I remove power, it no longer works.

    As for a sketch of what I have wired up, I have attached a schematic with Fritzing(I had to substitute a pico.js board as there were no puck.js boards)

    It's pretty barebones as I have removed the PIR sensor from the equation at this time. Please let me know if you have any other thoughts. I did get the MDBT42Q breakout board today, but aside from soldering the headers to the board, I haven't been able to flash firmware or test on that board yet.

    Thanks again for all of the help and please let me know if you have any questions for me. I have also included the current sketch that I am using (I've omitted all of the other tests that I had mentioned, to confirm that even on a clean sketch using direct to flash execute code on boot and only the SIM800L module with 3.3 V power supply being fed to the puck it is still not working as expected).

    Bluetooth.setConsole(1);
    Serial1.setup(9600, { rx: D29, tx : D28 });
    var ATSMS = require("ATSMS");
    var sms = new ATSMS(Serial1);
    
    sms.init(function(err) {
      if (err) throw err;
      console.log("Initialised!");
    
      sms.list("ALL", function(err,list) {
        if (err) throw err;
        if (list.length)
          console.log(list);
        else
          console.log("No Messages");
      });
    
      // and to send a message:
      //sms.send('+441234567890','Hello world!', callback)
    });
    
    
    sms.on('message', function(msgIndex) {
      console.log("Got message #",msgIndex);
      sms.get(msgIndex, function(err, msg) {
        if (err) throw err;
        print("Read message", msg);
        var txt = msg.text.toLowerCase();
        if (txt=="on") LED1.set();
        if (txt=="off") LED1.reset();
        // delete all messages to stop us overflowing
        sms.delete("ALL");
      });
    });
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for ok2chatt

    Hi Gordon,

    Thank you for your quick follow up. I have actually tried wrapping the entire code in onInit, but then nothing runs at all, it just hangs and nothing is spit out on the console. I had tried several times to update the firmware and there was a long press of the button prior to applying power. Had a green light, then switch to the red light each time. Only after downgrading to v1.99 did it seem to be recognized again.

    As for the PIR and Microwave sensors, I've tried common ground initially, prior to connecting to a separate rail, I typically do a common ground, but have heard that sometimes these sensors need a separate power rail as they can cause noise, hence the reason for the filter cap. In either case, when I have introduced the SMS module code in addition to the sensor, it locks the input pin from the sensor on high and multiple messages are sent.

    I'm wondering what else I can try at this point. Thanks again for all of your help.

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

    I have a few different issues regarding puck.js and SIM 800L module. The first issue is that if I power down the puck (remove the power from the VCC pin, and power it back up, it does not run the initialization code from onInit(). I have tried both onInit() and Save on Send option (w/o) onInit() and neither appear to work. I have to reconnect the puck to the web bluetooth and re-install the code. Please see the SMS.js file attached, which is essentially the same exact code that was provided in the 'Control Bluetooth Lights with SMS' tutorial.

    The second issue that I have is that adding a function in the sms.init section causes the sensor(I've tried both PIR and Microwave sensors) to go crazy and appears to keep the pin on as high level even when motion is not detected, sending me multiple texts. I am sure that I am probably doing something wrong here that needs corrected. I have included the PIR.js file as well for review.

    A few other things to mention, for the PIR and Microwave sensor, I have ensured to place these on a separate power rail and have a filter cap between VCC and Ground rails. I have tried both 3.3 and 5 volts for both of the sensors as well. Additionally, if I just load up a .js file to test the sensor (without the SIM 800L module in the code, but still connected to the puck) then they work and properly log when motion is detected.

    Additionally, I had to revert the firmware from v2.00 to v1.99 as my puck disappeared from the Web bluetooth as a selectable device and refreshing to v2.00 still didn't get it to show. Not sure if I have a defective puck, but there have been a few quirks with it. Overall, very satisfied with it and hope to iron everything out. Thanks for any insight anyone may be able to provide and please let me know if there are any questions for me.

Actions