Avatar for Kajsat

Kajsat

Member since Mar 2022 • Last active May 2022
  • 0 conversations
  • 10 comments

//I am studying Iskra JS and Espruino ide =)

Most recent activity

  • in Interfacing
    Avatar for Kajsat

    Please tell me how to use the correct code from the instructions for the nrf24l01 module, I do not understand what exactly needs to be prescribed for the slave and master so that they communicate. How should the code look completely?

  • in Interfacing
    Avatar for Kajsat

    Hello, I have two IskraJS boards(http://wiki.amperka.ru/js:iskra_js – ISKRAJS on the Amperka website) and IskraJSmini(http://wiki.amperka.ru/продукты:iskra-js­-mini – ISKGAJSMIN on the amperka website) and two NRF24l01+ wireless communication modules. I connected the modules to the boards directly using an auxiliary pinout scheme from the sites above and to the module itself to the available SPI interfaces (without IRQ contact):
    MISO – MISO;

    MOSI – MOSI;

    SCK – SCK;

    CSN – CSN;

    CE- CE;

    Vcc – 3.3V;

    GND – GND.

    I used the instructions from the website(http://www.espruino.com/NRF24L01P - description of the connection NRF24l01+ to work via EspruinoIDE), as I understood there was no IRQ connection required, well, I did not connect it…

    In the code for the Iskra JS board, which became the emitter (Master), I prescribed again as from the example (only for the necessary contacts):
    SPI2.setup({sck:B13, miso:B14, mosi:B15});

    var nrf = require("NRF24L01P").connect( SPI2, B0, B1 ); //B0(P6),B1(P5) на схеме

    function onInit() {

    nrf.init([0,0,0,0,2], [0,0,0,0,1]);

    }

    onInit();

    setInterval(function() {

    nrf.masterHandler();

    }, 50);
    And I didn't do anything else – but it is filled into memory every other time (the console falls out when filling the firmware).

    In the code for the Iskra JS mini board, which I have become a receiver (Slave), I prescribed and filled in (the console worked fine in the Espruino ide):
    SPI1.setup({sck:A5, miso:A6, mosi:A7});

    var nrf = require("NRF24L01P").connect( SPI1, B0, B1 );

    function onInit() {

    nrf.init([0,0,0,0,1], [0,0,0,0,2]);

    }

    onInit();

    setInterval(function() {

    nrf.slaveHandler();

    }, 50);
    Here I subtracted everything to SPI1 and, as an example, the names of the pins coincided. But then I don't understand what to do, I tried to output the command to the console from the spark of the LC mini, and on the spark of the LC connected to the power supply from the outlet, I planned to send a message from the example through the button:
    nrf.sendCommand("1+2", function(r) { print("=="+r); });
    the result should be =3
    But this did not happen ... I tried the options from the example and also in the empty.
    The code on Master was like this:
    var knopa = require('@amperka/button').connect(P3);

    SPI2.setup({sck:B13, miso:B14, mosi:B15});

    var nrf = require("NRF24L01P").connect( SPI2, B0, B1 ); //B0(P6),B1(P5) насхемеискры

    function onInit() {

    nrf.init([0,0,0,0,2], [0,0,0,0,1]);}

    onInit();

    setInterval(function() {

    nrf.masterHandler();

    }, 50);

    knopa.on('press', function() {

    nrf.sendCommand("1+2", function(r) { print("=="+r);

    });

    });
    Please tell me what and where I did wrong? And then I got confused and I can't figure out where the error is myself. If it is possible with a detailed description, I am not strong in JS yet, while I am mastering.
    Thank you in advance and apologize for the bedsheet.

  • in JavaScript
    Avatar for Kajsat

    Hello, the sensor works when you press the RAM key, but when you enter save() in the left window, and disconnect the device from the power supply and reconnect (com), it gives an error:

    in function called from system
    Uncaught Error: I2C device not responding
    at line 1 col 24
    this.i2c.writeTo(41,179);var a=this.i2c.readFrom(41,9);if(a[...
    ^
    in function "getValue" called from line 12 col 34
    var color = colorSensor.getValue();

                                               ^
    

    What to do, how to continue reading data to the console again after restarting the power supply?
    The code I used is as follows:

    PrimaryI2C.setup({sda: SDA, scl: SCL, bitrate: 100000});

    var colorSensor = require("TCS3472x").connect(PrimaryI2C, 1, 1);

    var PIN_BACKLIGHT = P5;

    digitalWrite(PIN_BACKLIGHT, true);

    setInterval(function() {
    var color = colorSensor.getValue();
    var r = Math.floor(color.red / color.clear * 255);
    var g = Math.floor(color.green / color.clear * 255);
    var b = Math.floor(color.blue / color.clear * 255);

    if ((r > g) && (r > b))

    print("RED");
    

    else if ((g > r) && (g > b))

    print("GREEN");
    

    else if ((b > g) && (b > r))

    print("BLUE");
    

    }, 100);
    // d-sda, c-scl, g-gnd, v-vin, l-P5

  • in JavaScript
    Avatar for Kajsat

    Got it, thanks! Kind man =)

    Just confused by the designation "TCS3472x" in "var tcs=require("TCS3472x").connect(I2C1, 1 /integration cycles/, 1 /gain/);", and I did not understand how I could access a library that I did not find in the libraries connected in espruino/modules, and did not understand how it works inside the program.

    Now, at least I know that I don't need to install anything extra, thanks to you.
    I will continue to study JS and Espruino.)

  • in JavaScript
    Avatar for Kajsat

    Thank you for the answer.)
    But I didn't understand how to use this library? ((
    I assume that:
    a) I need to download this library and put it in a folder with libraries on my computer.
    b) I just need to copy the code from this page and add it to my firmware code.
    Which of the options is correct, "a" or "b"?

    Thank you in advance.

  • in JavaScript
    Avatar for Kajsat

    Hello, tell a beginner: TCS3472x I2C Color Sensor Library https://www.espruino.com/TCS3472x

    How does it work?
    Is it already installed in the Espruino ide or do I need to create a library as a separate file? Or do I need to download it(where)?

    Thank you in advance.

  • in JavaScript
    Avatar for Kajsat

    Hello, tell a beginner: TCS3472x I2C Color Sensor Library https://www.espruino.com/TCS3472x

    How does it work?
    Is it already installed in the Espruino ide or do I need to create a library as a separate file? Or do I need to download it(where)?

    Thank you in advance.

  • in JavaScript
    Avatar for Kajsat

    Hello, tell a beginner: TCS3472x I2C Color Sensor Library https://www.espruino.com/TCS3472x

    How does it work?
    Is it already installed in the Espruino ide or do I need to create a library as a separate file? Or do I need to download it(where)?

    Thank you in advance.

Actions