Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Prateek Chachra
    @prateekchachra
    Its hard to do with a file that's already in byte form
    I'm using a MCP3204 IC to get the digital input signal
    Bryan Hughes
    @nebrius
    @prateekchachra This project is JavaScript only and it doesn't interface with audio either. You'd be better off asking in some Python forums
    Travis Martin
    @marti2221
    @nebrius im having trouble connecting buttons to the raspi-io plugin. When i instantiate a new button instance in the raspi board's "ready" event, I get an error saying I cannot set property 'mode' of undefined. console.log confirms event callback is running.
    Bryan Hughes
    @nebrius
    @marti2221 can you post your code here?
    Bryan Hughes
    @nebrius
    @marti2221 oh also, can you paste the full stack trace here?
    Travis Martin
    @marti2221
    (node:12999) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'mode' of undefined
    at Firmata.pinMode (/home/pi/node_modules/firmata-io/lib/firmata.js:936:25)
    at Button.value (/home/pi/node_modules/johnny-five/lib/button.js:30:17)
    at new Button (/home/pi/node_modules/johnny-five/lib/button.js:296:10)
    at Board.<anonymous> (/home/pi/Documents/Projects/smartGarden/index.js:18:14)
    at Board.emit (events.js:215:7)
    at Board.EventEmitter.emit (domain.js:476:20)
    at Board.finalizeAndBroadcast (/home/pi/node_modules/johnny-five/lib/board.js:475:12)
    at Board.<anonymous> (/home/pi/node_modules/johnny-five/lib/board.js:145:18)
    at Firmata.ready (/home/pi/node_modules/firmata-io/lib/firmata.js:736:9)
    at Object.onceWrapper (events.js:299:28)
    @nebrius
    const Raspi = require("raspi-io").RaspiIO;
    const five = require("johnny-five");
    console.log("Program is running");
    
    const ports = [
            { id: "A", port: "/dev/ttyACM0" },
            { id: "rpi", io: new Raspi() }
    ]
    
    const boards = new five.Boards(ports);
    
    const raspi = boards[0];
    const arduino = boards[1];
    
    raspi.on("ready", () => {
            console.log("heyey");
            const btn = new five.Button("GPIO27");  
            console.log("hello");
    });
    Travis Martin
    @marti2221
    @nebrius i should also mention that i soldered the wires to the bottom of the header pins as a last resort hack, since i ordered the wrong gender wires.
    Bryan Hughes
    @nebrius
    @marti2221 Ah, so what's happening here is the new five.Button() call doesn't specify a board, so it's defaulting to the Arduino. The Arduino doesn't know what GPIO17 is, so that's why it's crashing
    Instead, you'll need to instantiate your button as such:
    const btn = new five.Button({ pin: 'GPIO27', board: raspi });
    Travis Martin
    @marti2221
    man. im pretty sure i had tried that before i switched to that setup. What i had before was:
    
    var five = require("johnny-five");
    var Raspi = require("raspi-io").RaspiIO;
    
    var ports = [
        { id: "A", port: "/dev/ttyACM0" },
        { id: "rpi", io: new Raspi() }
    ];
    
    var boards = new five.Boards(ports).on("ready", function(){
        A = boards[0];
        rpi = boards[1];
    
    var btn = new five.Button({
            pin: "GPIO",
    })
    Bryan Hughes
    @nebrius
    @marti2221 The board: raspi is the magic sauce you need, which is still missing in this example
    Travis Martin
    @marti2221
    yes sorry accidentally hit enter, heres the rest
    @nebrius
    var btn = new five.Button({
            pin: "GPIO27",
            board: rpi
    })
    btn.on("up", ()  => {
            console.log("button pressed");
    })
    i believe that was giving me the same error, but im not home right now so im unable to recreate the issue
    @nebrius ill let you know how it goes when i get home either sun/mon
    @nebrius i was able to connect the button to the board. but when i ran the .on("ready") listener, i was getting that error. Like i said ill have to try it again when im back home to be sure.
    Travis Martin
    @marti2221
    @nebrius hey i found out i was using the wrong model pin diagram so my GPIO pins were off. I've got it all working now tho. Mux expander (via nano backpack) that reads analog sensors, a 74hc595 shift register used to expand digital outputs that will connect to relay boards. The relay boards will control solenoid valves and a water pump. The raspi reads digital inputs from buttons to turn on those relays. Then i plan to connect to a blynk app for mobile control. Thanks for your help, ill continue to keep you posted on my progress.
    Bryan Hughes
    @nebrius
    @marti2221 Thats awesome, I'm glad you figured that out!
    Travis Martin
    @marti2221
    @nebrius now with i2c, if i want to use 2 of the same sensors (BH1750 Light), i need two different addresses. from what ive read, ill need a pull up resistor (or can i just connect the address pin to HIGH voltage?). how will i know what to set the address properties to on the sensors?
    i guess that should prob go in the other convo, sorry.
    Cory Fail
    @fyroc
    @nebrius I'm trying to connect a Adafruit Ultimate GPS with USB to my Raspberry Pi Zero W and be able to use it with Johnny-Five. How would I do this since it's USB? It has built-in USB to Serial, so would I just need to enable serial in rasp-io and it'll find the GPS module automatically?
    Bryan Hughes
    @nebrius

    @nebrius I'm trying to connect a Adafruit Ultimate GPS with USB to my Raspberry Pi Zero W and be able to use it with Johnny-Five. How would I do this since it's USB? It has built-in USB to Serial, so would I just need to enable serial in rasp-io and it'll find the GPS module automatically?

    @fyroc In theory that should be the case, but a quick glance at the code seems to indicate that Raspi IO only supports the default, built in serial-port I'm afraid.

    Cory Fail
    @fyroc
    @nebrius so does that mean it will not work at all?
    Bryan Hughes
    @nebrius
    @fyroc I’m afraid so
    Cory Fail
    @fyroc

    @nebrius now I'm curious to whether I can just use another GPS NPM package. For example, https://www.npmjs.com/package/gps.

    Then just use it with Johnny-Five.

    Bryan Hughes
    @nebrius
    @fyroc yep, you can totally do that
    The5thGhost
    @The5thGhost_gitlab
    Hi everyone, I need to use serial communication between rpi and stm32 but i also want to use console over serial when i needed. can i change this by gpio based operation like using some push button.
    Bryan Hughes
    @nebrius
    @The5thGhost_gitlab I'm not completely certain, but I don't think you can do that.
    Which RPi are you using? If it's an RPi 4, you have three extra serial serial ports built in, and you can use one of the others for your console
    Otherwise, I'd get two FTDI USB to serial converters and connect them together so you have USB->UART->USB
    The5thGhost
    @The5thGhost_gitlab
    @nebrius Sorry I didn't mention this before,I am using raspberry pi zero w. My plan is to write two config file in which one with console over serial and one without that. and then change that with some gpio event. but I am not certain how to archive this safely.
    Bryan Hughes
    @nebrius
    @The5thGhost_gitlab I could be mistaken, but I seem to recall that you have to reboot your RPi to switch UART mode
    I’d start by testing to see if you can switch modes using the two config files from the command line. If that works and you confirm you don’t need to reboot, then you’d use the fs module to write the contents of the desired config file, then use the child_process to call whatever Linux command you need to reload the UART command
    Bryan Hughes
    @nebrius
    All this said, I’d still recommend adding a second serial port to the device instead (RPi zeros still have USB)
    The5thGhost
    @The5thGhost_gitlab
    @nebrius Thanks, I will wait for your next response. also, I am keeping USB for another purpose and it will be used frequently and in my use case, I have no problem in rebooting.
    Bryan Hughes
    @nebrius
    If you don't mind rebooting, then it should work no problem. Regarding USB, you can always use a USB hub to expand the number of ports so you can use it for serial and your other purpose.
    The5thGhost
    @The5thGhost_gitlab
    @nebrius ok. so how to catch console over usb
    Bryan Hughes
    @nebrius
    @The5thGhost_gitlab TBH I don’t ever use TTY over Serial, but there should be a lot of online resources on how to configure it to use a different port
    After plugging in your adapter, you can run dmesg to find out which /dev/ device it was connected to
    The5thGhost
    @The5thGhost_gitlab
    @nebrius Hi dude, thanks for the advice. Now I am able to do ssh using ethernet over USB and it is a more useful way to access shell in comparison to using console over serial.
    Bryan Hughes
    @nebrius
    Nice, I’m glad you got it working!
    ZackM032488
    @ZackM032488
    Hello, I'm trying to send serial messages from a RPi 4 to a Teensy LC over UART, but the Teensy doesn't seem to be receiving any of the messages. I wrote a simple js program with Raspi-Serial that just writes '0' then '1' a handful of times at a half second interval and an Arduino sketch for the Teensy that reads incoming serial data and turns on and off the on-board LED when it receives 1s and 0s. This my first time ever using a RPi and I'm pretty new to node.js too, so I'm sure I'm missing something. Is there anything specific that I should be considering to make the communication work?
    Bryan Hughes
    @nebrius
    Hi @ZackM032488. Did you go through the steps to enable serial as discussed here https://github.com/nebrius/raspi-io/blob/master/README.md#serial-notes?
    ZackM032488
    @ZackM032488
    @nebrius, I believe those are the same steps found here https://github.com/nebrius/raspi-serial, correct? That's what I followed when I set it up. I installed Raspi first and then Raspi-serial. Do I need to have Raspi-IO and Johnny-Five installed too?
    Bryan Hughes
    @nebrius
    @ZackM032488 they should be the same instructions, and no you don’t need Johnny-Five and Raspi IO. You do need to enable serial and reconfigure it though, cause it’s disabled by default on all WiFi enabled RPi models
    ZackM032488
    @ZackM032488
    @nebrius Looks like the issue was just the port path. I was using /dev/ttyAMA0, but I needed to use/dev/serial0. It seems to be working perfectly now.
    Bryan Hughes
    @nebrius
    Glad you got it working
    Joonas Jokinen
    @jnsjknn
    Hi, I noticed your wiki doesn't have pin information on R-Pi Model 4. I'd be happy to add it.
    Bryan Hughes
    @nebrius
    Hi @jnsjknn. I just updated the wiki to indicate that the pinout for the 2/3/Zero also applies to the 4. Thanks for pointing it out!