Connecting Pico to the internet without Web IDE

Posted on
  • 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();}
              });
            });
          });
        });
      });
    });
    
  • 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.

  • Yes, that's the one! It's unfortunate when you hit it, but can be a useful feature.

    For the shims I try and use the 2nd UART that doesn't have the problem, but it can be a pain to solder to manually.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Connecting Pico to the internet without Web IDE

Posted by Avatar for countxerox @countxerox

Actions