You are reading a single comment by @chrigu and its replies. Click here to read the full conversation.
  • Hi
    I'm running a Pico on 1v80 and I was wondering if this problem still exists.

    I have the following code:

    var ssid, password, url, timeout, apiString, ledInterval, wifiReady, http, wifi, testUrl;
    
    //network & http stuff
    ssid = "myssid";
    password = "mypassword";
    url = "http://www.myserver.com";
    wifiReady = false;
    
    //timestuff
    timeout = 60*1000;
    
    //setup
    apiString = "";
    
    function clearLed() {
        //clear RGB Pixel
    }
    
    function handleData(data) {
        //dosomething
    }
    
    function getForecast() {
        if (wifiReady) {
            http.get(url, function (res) {
                apiString = "";
                res.on('data', function (data) {
                    apiString += data;
                    console.log(data);
                });
                res.on('close', function () {
                    handleData(apiString);
                });
            });
        }
    }
    
    function onInit() {
      
        http = require('http');
    
        digitalWrite(B9,1); // enable on Pico Shim V2
    
        //init serial for Wifi
        Serial2.setup(115200, {rx: A3, tx: A2});
    
        //init LED bus
        SPI2.setup({baud: 3200000, mosi: B15});
        SPI2.send4bit([0, 0, 0], 0b0001, 0b0011);
    
        wifi = require("ESP8266WiFi_0v25").connect(Seri­al2, function (err) {
            if (err) {
                clearLed();
            }
            console.log("Connecting to WiFi");
            wifi.connect(ssid, password, function (err) {
                if (err) {
                    clearLed();
                    throw err;
                }
                console.log("Connected");
    
                //add a delay just to make sure an IP address was obtained
                setTimeout(function () {
                    wifi.getIP(function (err, ip) {
                        if (err) {
                            clearLed();
                            throw err;
                        }
                        //console.log(ip);
                        wifiReady = true;
                        getForecast();
                    });
                }, 2000);
            });
        });
        
        setInterval(getForecast, timeout);
    
    }
    

    When I upload the code to the Pico via the IDE and type save() the code works as expected as long as the Pico is connected to the laptop. However, when I use a USB power supply to power the Pico the code does not work (I don't see any requests from the Pico on the server). So I wonder whether I got something wrong with the save() method or whether the problem still exists. Thanks!

About

Avatar for chrigu @chrigu started