NeoPixel on CowTracker v2

Hi,

I am writing a sketch for the CowTracker v2 board (https://shop.sodaq.com/sodaq-cowtracker-v2.html) and I want to turn on the NeoPixel LED. On what pin can I access it?

Hi omegasupreme,

Which board files are you using?

If you are using the Explorer board files, you can use the following pins:

  • With ‘LED_BLUE’ (PA13) you can enable power to the NeoPixel LED (by setting the pin to HIGH)

  • With ‘LED_RED’ (PA12) you can control the DI-pin of the NeoPixel

Hope this helps you!

Thank you for your reply. I am using the SODAQ Cow Tracker Gateway board files. In an earlier attempt I tried using the AdaFruit_NeoPixel library to control the Neopixel, but that didn’t work out (I guess since I didn’t know what pin is occupied by the pixel). I tried your suggestion as well, but unless I am doing something wrong it doesn’t work.

When using the actual SODAQ Cow Tracker Gateway board files, you will need to use the following pins:

  • With ‘RGB_EN’ (PA13) you can enable power to the NeoPixel LED (by setting the pin to HIGH)
  • With ‘DI_WS’ (PA12) you can control the DI-pin of the NeoPixel

Let me know if this works for you!

Thank you for your quick reply! I am not really sure if I have the latest board files since the defines you specify do not exist in the one I have here …

Additionally: would it be possible to use Adafruit_Neopixel to control the pixel or not?

How did you obtain your current board files? It could be that the version you have is for rev1 (but that should still include the DI_WS pin).

Using Adafruit_Neopixel shouldn’t be an issue, I’ve used that myself for testing purposes. See a quick’n’dirty example below:

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            DI_WS //9

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      8

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 100; // delay for half a second

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.


  //Needed from Cow Tracker revision 2 (switch for enabling RGB LED)
  pinMode(RGB_EN, OUTPUT);
  digitalWrite(RGB_EN, HIGH);


    //stand 1
  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,80,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }

}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  //pixels.Color(0,255,0);
  //delay(2000);
  //pixels.Color(0,150,0);
  //delay(2000);


  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,0,255)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }

  delay(5000);

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(255,0,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }

  delay(5000);

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,255,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }

  delay(5000);

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(255,255,255)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(50); // Delay for a period of time (in milliseconds).

  }

  delay(5000);
}

Thank you for your elaborate answer. I got the board files previously when we bought revision 2. I already had something setup like you did with AdaFruit and it seems correct comparing to your example.

By the way DI_WS is defined in my board files(#define DI_WS (24u)), but RGB_EN is not so I don’t know what to specify here. What value does it have in your environment?

RGB_EN is needed to enable power to the LED. These smart RGB LEDs will still use quite a bit of current, even when they are not on (due to the internal driver), therefor we incorporated a switch to the LED.

Could you send me an email: gregory@sodaq.com ? I’ll share the latest board files with you to see if that fixes the problem.

Thank you for your effort, I will send you an E-mail.

Just to close this topic: I already said to in the mail, but again thank you very much for the updated board files I received. Now the neopixel can be controlled.

1 Like