Omega2+ & Arduino Dock 2 & NeoPixels



  • Hello,

    See here for a basic test of Omega2+ and Arduino Dock 2 with NeoPixels using python.

    ...

    From the beginning...

    1. Setup WiFi
      ... You really need the onion on your local WiFi network so you can SSH/SCP to the Omega2+ to run/edit your python easily.
      ... You can either do this with terminal via a standard Dock, or connect to the Omega2+ AP and SSH to it.
    wifisetup
    

    (Omega2+ with ArduinoDock2 via WiFi)

    1. Update/Reinstall onion firmware. (This example: v0.1.10 b160)
      ... Once you have your Omega2+ on an internet enabled WiFi connection, make sure you have the latest build, because all the things.
      ... This will wipe your Omega2+ back to factory, but the WiFi settings should persist. If not, connect directly to the Omega AP, ssh to it (192.168.3.1), and run wifisetup again.
    oupgrade -f
    
    1. Install Arduino Dock 2 package
      ... This will allow you to write to the ArduinoDock2, with the Arduino IDE via WiFi
    opkg update
    opkg install arduino-dock-2
    
    1. Put the OnionLibrary on the ArduinoDock2 (Arduino IDE 1.8.3 / Windows Store Version 1.8.6.0)

    .
    *** This is missing from the online documentation ***

    You need to add "Onion Arduino Library" to your IDE, include it in some Arduino script and write it to the ArduinoDock2. Technically, you could do this without WiFi using the basic Dock and COM3.

    Add "Onion Arduino Library" in Arduino IDE

    Menu: Sketch > Include Library > Library Manager.

    .ino code to write to Dock.

    #include <OnionLibrary.h>
    Onion* onionSetup;
    
    void setup() {
       // put your setup code here, to run once:
       onionSetup = new Onion();
    }
    
    void loop() {
       // put your mum here, to run repeatedly:
    
    }
    
    1. Install python and the pyNeopixel library
    opkg update
    opkg install pyNeopixel python-light
    

    This page refers to the Arduino Dock 1 ... (?)
    https://wiki.onion.io/Documentation/Libraries/Arduino-Dock-Neopixel-Library
    (The Example Code at the bottom of page - link is dead)

    1. Write up some python...
    from OmegaArduinoDock import neopixel
    import time
    import math
    
    npixel = neopixel.OnionNeopixel(6, 255, 0x08)
    status = npixel.setBrightness(32)
    count = 0
    
    while True:
      print "Pixel #" + str(count)
      status = npixel.setPixel(count, 0x80, 0x00, 0x00)
      status = npixel.setPixel(count+1, 0xff, 0xff, 0xff)
      status = npixel.showPixels()
      count = count +1
      time.sleep(0.03)
    

    Returns...

    Setting pin to 6
    Setting strip length to 255
    Setting brightness to 32
    Pixel #0
    Pixel #1
    Pixel #2
    Pixel #3
    ...
    

    alt text

    Success.



  • ^^ OP updated.

    So, issues encountered while figuring all this out were...

    1. The neopixel-tool package is not available on the Omega2+ repo, as suggested by the documentation ??

    2. Often, you have to press the MCU RESET switch on the ArduinoDock2 to ensure the Arduino Library is running on the Arduino side, before you execute your python on the Omega2+ side.

    Which unfortunately is not a reliable solution. Is there a way in Python to force the Arduino side to re-initialise ??

    1. The python neopixel library seems to have a limit of 255 pixels (pybuf) ??

    e.g.

    npixel = neopixel.OnionNeopixel(6, 256)

    Fails quite spectacularly.

    alt text



  • @Paul-Wright If you just want to drive neopixels from the Omega2, you can also do that without Arduino dock using my PWM based kernel driver for WS28xx type LEDs. It just provides a linux device /dev/ledchainx, where you write a string of bytes representing the RGB (or RGBW, for SK6812 LEDs) values of the LEDs.



  • @luz thanks! Seems to work ok so far :)

    Here's a summary for those playing at home...

    wget http://plan44.ch/downloads/experimental/kmod-p44-ledchain_4.4.61%2B0.9-2_mipsel_24kc.ipk
    opkg install --force-depends kmod-p44-ledchain*
    omega2-ctrl gpiomux set pwm0 pwm
    insmod /lib/modules/4.4.61/p44-ledchain.ko ledchain0=0,300,2
    echo -en '\xFF\x00\x00\x00\xFF\x00\x00\x00\xFF\xFF\xFF\xFF' >/dev/ledchain0
    

    Neopixels DI, GND connected to Omega2+ Pin 18 and GND (on dock).

    For 300 x WS2812B pixels .. "ledchain0=0,300,2" .. ledtype 2 seems to work better than ledtype 1



  • Hooray for CPU! ...driving from Omega2+ direct is so much better than going via the Arduino.

    https://www.youtube.com/watch?v=xnJjrcrQ3rs



Looks like your connection to Onion Community was lost, please wait while we try to reconnect.