Avatar for countxerox

countxerox

Member since Feb 2016 • Last active Apr 2017
  • 6 conversations
  • 42 comments

I'm an Aerospace Engineer from Cambridge and I'm learning JavaScript as a hobby.

Most recent activity

  • in Pico / Wifi / Original Espruino
    Avatar for countxerox

    Yes, two typos there. I do mean CH_PD and it's hardwired to VCC with a 10k resistor (not 1k). GPIO0 and GPIO2 are disconnected. GPIO15 is hardwired to GND with a 10k resistor.

    It does seem to me like it should work since when I pull CH_PD to GND or VCC manually with a wire everything works as expected i.e. when CH_PD is connected to GND the ESP8266 powers down and when connected to VCC it powers up.

  • in Pico / Wifi / Original Espruino
    Avatar for countxerox

    Here's a picture of it

  • in Pico / Wifi / Original Espruino
    Avatar for countxerox

    Hi, I want to turn my ESP8266 off to save power.

    When I try to pulling the CH_PIN pin high with digitalWrite(B9,1) it doesn't power up and I see Uncaught No 'ready' after AT+RST.

    I tried using a timeout to give it some time to boot up and also tried pulsing the reset pin.

    Also it seems my ESP8266 board has the CH_PD pin hardwired to Vcc via a 1k resistor. If I connect the CH_PD pin to GND, it powers down and if I connect it to the Picos 3.3v pin or leave it dangling it powers up.

    • 12 comments
    • 208 views
  • in JavaScript
    Avatar for countxerox

    Thanks for that advice @oesterle. I've had a go and I think it's improved but I can't close the wifi connection. wifi.disconnect() isn't recognised.

    Serial1.setup(115200, { rx: B7, tx : B6 });
    
    I2C3.setup({sda:B4,scl:A8});
    var bh=require("BH1750").connect(I2C3);
    
    var dht = require("DHT11").connect(B5);
    
    function read_sensors(callback) {
      var n=0,i=100;
      while (i--) n+=analogRead(A7);
      bh.start(3);
      light_intensity = Math.round(bh.read()).toString();
      soil_moisture = (100-Math.round(n)).toString();
      dht.read(function (a) { 
        temp = a.temp.toString();
        humidity = a.rh.toString();
        callback (light_intensity, soil_moisture, temp, humidity);
      });
    }
    
    function send(l,m,t,h) {
      wifi = require("ESP8266WiFi_0v25").connect(Seri­al1, function(err) {  
        if (err) throw err;
        wifi.connect("Xxx", "xxx", function(err) {
          if (err) throw err;
          LED2.set();
          sendForm(l,m,t,h);
        });
      });
    }
    
    function onInit() {
      USB.setConsole(1);
      clearInterval();
      setInterval(function() {
        read_sensors(send);
      },30000);
    }
    
  • in JavaScript
    Avatar for countxerox

    Hi, I let the program run for 25 hrs, sending to google every 2 minutes but when I look at google for the responses only 417 responses have been logged. It didn't crash but after the first few successful sends it either has the memory error, handshake failed or it works.

    >Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    Verifying peer X.509 certificate...
    it works
    >Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    ERROR: Failed! mbedtls_ssl_setup: Not enough memory
    ERROR: Unable to create socket
    Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    ERROR: Failed! mbedtls_ssl_setup: Not enough memory
    ERROR: Unable to create socket
    >Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    ERROR: Failed! mbedtls_ssl_handshake returned -0x4290
    >Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    ERROR: Failed! mbedtls_ssl_handshake returned -0x4290
    >process.memory();
    ={ "free": 3920, "usage": 1180, "total": 5100, "history": 1,
      "stackEndAddress": 536958120, "flash_start": 134217728, "flash_binary_end": 377416, "flash_code_start": 134234112, "flash_length": 393216 }
    >Connecting with TLS...
    Loading the CA root certificate...
    Loading the Client certificate...
    Loading the Client Key...
    Performing the SSL/TLS handshake...
    Verifying peer X.509 certificate...
    it works
    

    Is there something wrong with my code again?

    function onInit() {
      USB.setConsole(1);
      var lastTemp = "";
      var lastHumidity = "";
      var lastLight = "";
      var lastmeasure ="";
      
      I2C3.setup({sda:B4,scl:A8});
      var bh=require("BH1750").connect(I2C3);
    
      var dht = require("DHT11").connect(B5);
      
      clearInterval();
      
      setTimeout(function() {   
        Serial1.setup(115200, { rx: B7, tx : B6 });
        wifi = require("ESP8266WiFi_0v25").connect(Seri­al1, function(err) {  
          if (err) throw err;
          wifi.connect("xxx", "xxx", function(err) {
            if (err) throw err;
              LED2.set();
              setInterval(function() {
                dht.read(function (a) {
                  lastTemp = a.temp.toString();
                  lastHumidity = a.rh.toString();
                });
                bh.start(3,1);
                lastLight = Math.round(bh.read()).toString();
      
                var n=0,i=100;
                while (i--) n+=analogRead(A7);
                lastmeasure = (100-Math.round(n)).toString();
      
                setTimeout(function() {
                  sendForm(lastTemp, lastHumidity, lastLight, lastmeasure);
                }, 5000);
              }, 120000); // once every 2min
          });
        });
      }, 2000); 
    }
    
  • Avatar for countxerox

    OK, found an answer in this post

    The Web IBE reverts to Serial1 when USB is not connected, that must have been conflicting with the ESP8266 (which was also trying to use Serial1) adding USB.setConsole(1) forces the console to stay on USB.

  • Avatar for countxerox

    Hi,

    I want to connect my Pico to the internet with an ESP8266-12f.

    When I send and save() the code using the Web IDE it's fine but then if I disconnect it and power it up with a usb power supply, it doesn't work.

    function onInit() {
      Serial1.setup(115200, { rx: B7, tx : B6 });
      var wifi = require("ESP8266WiFi_0v25").connect(Seri­al1, function(err) {
        if (err) throw err;
        wifi.reset(function(err) {
          if (err) throw err;
          wifi.connect("xxx","xxx", function(err) {
            if (err) throw err;
            require("http").get("http://www.pur3.co.­uk/hello.txt", function(res) {
              console.log("Response: ",res);
              res.on('data', function(d) {
                console.log("--->"+d);
                if (res.statusMessage == "OK") {LED2.set();}
              });
            });
          });
        });
      });
    }
    

    The Pico's green light should switch on if the http response is OK.

    I tried this way aswell but still no joy.

    E.on('init', function() {
      Serial1.setup(115200, { rx: B7, tx : B6 });
      var wifi = require("ESP8266WiFi_0v25").connect(Seri­al1, function(err) {
        if (err) throw err;
        wifi.reset(function(err) {
          if (err) throw err;
          wifi.connect("xxx","xxx", function(err) {
            if (err) throw err;
            require("http").get("http://www.pur3.co.­uk/hello.txt", function(res) {
              console.log("Response: ",res);
              res.on('data', function(d) {
                console.log("--->"+d);
                if (res.statusMessage == "OK") {LED2.set();}
              });
            });
          });
        });
      });
    });
    
Actions