Avatar for Anton


Member since Jan 2018 • Last active Jan 2018
  • 2 conversations

Most recent activity

  • in Electronics
    Avatar for Anton

    Hi hi hi. I decided to make an electric skateboard.
    I need to connect the receiver to Espruino.
    I have such a transmitter and receiver:

    How to connect? How to receive a signal? Where can I connect pins? There are a lot of them here =)

  • in Tutorials
    Avatar for Anton

    In general, going on the path 1 with yours help, I wrote such code, but there are some strange mistakes = (such as 45 km / h at rest). I tested it in my car. Visually it coincides with the speedometer in my smartphone =)

    Serial3.setup (115200, {rx: P0, tx: P1});
    var R = 6371e3; //
    var Led= require('@amperka/led').connect(A1);
    var lastData; // 
    var lastData2; //
    var lastLon;  //  
    var lastLat; //  
    var LastTime;
    var toRad=Math.PI/180;
    var i=0;
    var gps = require ("GPS"). connect (Serial3, function (data) {
      if (lastData,i<50) {
       // do stuff here - eg. the difference between the two readings
      //****** distance calc  
        var Lon=data.lon*toRad; // lon в  t1
        var Lat=data.lat*toRad; //lat в  t1
        var diffLon=Math.abs(Lon-lastLon*toRad);
        var diffLat= Math.abs(Lat-lastLat*toRad);
            var a= Math.sin(diffLat/2) * Math.sin(diffLat/2) +
            Math.cos(Lat) * Math.cos(lastLat*toRad) *
            Math.sin(diffLon/2) * Math.sin(diffLon/2);
        var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    var distansP = R * c;
    //****** time diff
    var tTime= data.time.split(':'); // time array
    var diffTime=tTime-LastTime;
        //****** speed
        var speed1= distansP/diffTime; // m/s
        var speed2= speed1*3.6; // km/h 
     //console.log ('1',Math.sin(diffLat/2),diffLat/2,'2',M­ath.cos(Lat),  '3',Math.cos(lastLat*toRad),lastLat*toRa­d,'4',Math.sin(diffLon/2),'5',Math.sin(d­iffLon/2),'6',Math.sqrt(a),a,'7',Math.sq­rt(1-a),'8',diffTime ); Debugging
    lastLon=data.lon; // in degrees
    lastLat=data.lat; //in degrees
    LastTime=  data.time.split(':');
    LastTime= LastTime[2];  
    //  lastData = data.time.split(':');
    //lastData2 = lastData[2];
    //  lastLon= data.lon;
  • in Tutorials
    Avatar for Anton

    Wow great. it works!!!

    Serial3.setup (115200, {rx: P0, tx: P1});
    var lastData;
    var gps = require ("GPS"). connect (Serial3, function (data) {
      if (lastData) {
       // do stuff here - eg. the difference between the two readings
        var dlat =data.time;
     //   var dlon = data.lon - lastData.lon;   
      console.log (dlat);
     console.log ('*->',lastData);
      lastData = data.time;
     // return lastData;
  • in Tutorials
    Avatar for Anton

    Hi guys!
    I want to get the speed and, depending on it do an actions, for example, to light the LED.
    I see 2 ways of solving this problem.
    the first one
    Use the standard Esprino library, taken from the link below.

    Serial3.setup (115200, {rx: P0, tx: P1});
    var gps = require ("GPS"). connect (Serial3, function (data) {
      console.log (data);

    The following data is displayed:

    {"time": "16:35:29", "lat": 53.068403, "lon": - 4.076282, "fix": 1, "satellites": 7, "altitude": 1085.0}

    There is no speed but I can get it if i know Time1 and Time0 and latitude, longitude at Time1, Time0.
    I can colculat the distance pased using formulas from there http://www.movable-type.co.uk/scripts/la­tlong.html.

    , then devide it on diff betvin T1 and T0

    The problem is

    How get latitude, longitude at T1, T0 from this code?
    Serial3.setup (115200, {rx: P0, tx: P1});
    var gps = require ("GPS"). connect (Serial3, function (data) {
      console.log (data);
    if i try somth like this

    Serial3.setup(115200, {rx: P0, tx: P1});
    var gps = require("GPS").connect(Serial3, function(data) {
    return T1;
    console.log(gps)enter code here

    i get empty valus in console.

    the second way is to communicate with serial
    I use such cod

    Serial3.setup (115200, {rx: P0, tx: P1});
    var bufer = '';
    Serial3.on ('data', function (data) {
    bufer + = data;
    var lines = bufer.split ('$');
    bufer = lines [lines.length-1];
    if (lines.length> 1) {
    for (l = 0; l <lines.length-1; l ++) {print (lines [l]);}}});

    As a result, it get all data from GPS controller but here http://www.gpsinformation.org/dale/nmea.­htm
    I have not found any messages with such codes, and accordingly I do not understand what position, what it means, and how it's to pars it to get the speed. How to pars the
    NMEA sentent ?