Avatar for ert4

ert4

Member since Feb 2016 • Last active Apr 2016
  • 3 conversations
  • 6 comments

Most recent activity

    • 35 comments
    • 8,933 views
    • 9 comments
    • 3,028 views
  • in JavaScript
    Avatar for ert4

    Im collecting the data, and using the pico as a sever.
    ---------------------Code
    // ESP8266 WiFi v25
    var WIFI_NAME = "Temp-Student";
    var WIFI_PASS = "TempStu1";
    Serial2.setup(115200, { rx: A3, tx : A2 });
    var wifi = require("ESP8266WiFi_0v25").connect(Seri­al2, function(err) {
    if (err) throw err;
    wifi.reset(function(err) {

    if (err) throw err;
    console.log("Connecting to WiFi");
    wifi.connect(WIFI_NAME, WIFI_PASS, function(err) {
      if (err) throw err;
      console.log("Connected");
      // print IP address
      wifi.getIP(console.log);
      // Create a server
      require("http").createServer(pageHandler­).listen(80);
    });
    

    });
    });
    --------------------end of code
    I want to have the light go on a graph.

  • in JavaScript
    Avatar for ert4

    Hello i was wondering if their is a way to send info to the web server. What im trying to do is have the pico somewhere else and be collecting the how bright the light is, but how to you send the info to the webpage.

    I know how to get info from the webpage though this code

    ------------Code---------------
    function pageHandler(req, res) {
      if (req.method=="POST") {
        // If it POST(Web side does this), save the data
        var info = url.parse(req.url,true);
        console.log("POST ",info);
        //Looks though HTML "pos" and collect the value
        if (info.query && "pos" in info.query)
          //Activats setPos
          setPos(parseFloat(info.query.pos));
        res.writeHead(200);
        res.end("Ok.");
      } else {
        // otherwise write the page out
        console.log("GET "+req.url);
        if (req.url=="/") {
          res.writeHead(200);
          res.end(page);
        } else {
          res.writeHead(404);
          res.end("404: Not found");
        }
      }
    }
    --------------------------------------en­d of code----------
    
  • in JavaScript
    Avatar for ert4

    Hello i was wonder if there any why to make the pico a server to host a local webpage. I want to host a webpage to control the light on the pico itself but i don't know how to set it up on the pico or where to start.
    ------------------------------------HTML­

    <meta charset="UTF-8">
    <title>Untitled Document</title>
    


    <script>
        var light = function() {
            var p = document.getElementById("lightnumber").v­alue;
            var q = document.getElementById("number");
            q.innerHTML = "Light: " + p + "%";
        }
    </script>
    <p>light intensity?<input  name="lightsorce" id="lightnumber" type="text"/>Percent<input type="submit" onclick="light()"/></p>
    <p id="number">Light:</p>
    

    • 8 comments
    • 5,293 views
  • in Interfacing
    Avatar for ert4

    Fix it just needed more power.

  • in Interfacing
    Avatar for ert4

    @Gordon I have put in the code, but i'm not getting any a weird message code in console when i type in wifi.connect().
    --------------------------------Console


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    || || |_|||_|_|

          |_| http://espruino.com
    

    1v83 Copyright 2015 G.Williams

    echo(0);
    =undefined
    wifi.connect()
    =undefined
    Uncaught No 'ready' after AT+RST
    at line 1 col 16
    if (err) throw err;

               ^
    

    in function "a" called from line 1 col 112
    ...a("No 'ready' after AT+RST");else return b

                              ^
    

    in function "b" called from line 1 col 15
    d=void 0;b&&b()

              ^
    

    in function called from system

  • in Interfacing
    Avatar for ert4

    Hello, the javascript code i have keeps giving me the error "module wifi not found", The picture is what my pico looks like.
    ----------------------------------------­ Java Script
    var wifi = require("wifi");
    var ssid = "Temp-Student";
    var pw = "TempStu1";
    wifi.connect(ssid, {password:pw}, function(err){
    console.log("connected? err=", err, "info=", wifi.getIP());
    });
    wifi.stopAP();
    ----------------------------------------­ Console


    | |_ ___ ___ _ ||___ ___
    | |_ -| . | _| | | | | . |
    |
    || || |_|||_|_|

          |_| http://espruino.com
    

    1v83 Copyright 2015 G.Williams

    echo(0);
    ERROR: SD card must be setup with E.connectSDCard first
    WARNING: Module "Wifi" not found
    Uncaught Error: Field or method "connect" does not already exist, and can't create it on undefined
    at line 1 col 5
    wifi.connect(ssid, {password:pw}, function(err){

    ^
    

    Uncaught Error: Field or method "stopAP" does not already exist, and can't create it on undefined
    at line 1 col 5
    wifi.stopAP();

    ^
    

    =undefined

Actions