How to control servo, motor and sensors with nodejs?

Discussion in 'UDOO NEO' started by FadiBunni, Apr 8, 2017.

  1. FadiBunni

    FadiBunni New Member

    Joined:
    Mar 9, 2017
    Messages:
    16
    Likes Received:
    1
    Hallo guys i am really trying to make my own robot by using Udoo Neo and nodejs I am (trying to) follow this guide: http://node-ardx.org/ where I need to use Johnny-five lib which uses the StandardFirmata example. I try to run the standardFirmata, but it prints out bunch of errors, now I know the M4 is not exactly like a another arduino board, meaning some code(probably a lot) has to bee changed to make it understandable for M4. But do you guys know how I can make it work, or at least control some servo and motors trough nodejs - getting access to GPIO's and being able to send data? Another thing the Neo-baraometer package Is working wonderfully fine, but lacks the control of the accelerometer and magnometer - have an idea of how to add it.

    The reason i am using nodejs is because I am building a much bigger project where nodejs servers are a core thing for the system, so being able to access sensors and controlling motors and servo, is a key thing for my system.

    Thanks a lot!

    Fadi
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Unfortunately the Firmata library is not supported on the Neo. You have to make your own communication protocol or get Firmata running somehow.
     
  3. FadiBunni

    FadiBunni New Member

    Joined:
    Mar 9, 2017
    Messages:
    16
    Likes Received:
    1
    wow, soo many opportunities. How do you do that, the communication protocol, is their really no other way to control f.eks a servo through nodejs, or anything else beside the neo-barometer package?
     
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    There is a node serial https://github.com/EmergingTechnologyAdvisors/node-serialport

    You could use that to communicate with the serial port. In my how to's in my signature I have a very basic protocol setup. You could extend that with more.

    Ideally the Firmata protocol should work but I looked into that once and it was way over my head.
     
  5. FadiBunni

    FadiBunni New Member

    Joined:
    Mar 9, 2017
    Messages:
    16
    Likes Received:
    1
    Yes I can now read from the serial port but how the heck do i write to it? so that i can move a servo?
     
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    You have to write an Arduino sketch that is reading the serial port and converts the command to for example a servo control. For examples for serial communication between A9 and M4 see http://www.udoo.org/docs-neo/Serial_Libraries/index.html
    They are very basic so have to be expanded (writing your own protocol). So writing S1 90 could mean set servo 1 in position 90 degrees. O6 1 could mean set output 6 high.

    Verstuurd vanaf mijn XT1039 met Tapatalk
     

Share This Page