RFM69HCW, Radio Head, APA102C, FastLED,

Status
Not open for further replies.

looper89

Member
I am working on a project to control a remote string of LEDs.

APA102C - LED string
Teensy 3.2
RFM69HCW - radio

The radio is using SPI0 and the LED string is utilizing SPI1. I have verified that they both parts work on the given SPI ports individually by using the given examples that come with the libraries.

The data pin for the LEDs is pin 7 and the clock is pin 14. The RFM69 is using pins 10(cs), 11(dout), 12(din) 13(sck) and 4(IRQ). Again both systems work independently.

I am not familiar with the SPI systems in the Teensy3.2 and how the libraries interact with them.

Is there some obvious reason that I haven't been able to find that the two SPI ports or these two libraries won't work together?

The following code is a mash-up of a couple examples. The program runs, the lights cycle through once, the messages is sent to the server (and is received by the server) then the program hangs. Nothing more is sento to the Serial.

Thanks for your time.

Code:
#include "FastLED.h"

#define NUM_LEDS 15
#define DATA_PIN 7
#define CLOCK_PIN 14
CRGB leds[NUM_LEDS];

#include <RHReliableDatagram.h>
#include <RH_RF69.h>
#include <SPI.h>

#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Singleton instance of the radio driver
RH_RF69 driver(10, 4);

// Class to manage message delivery and receipt, using the driver declared above
RHReliableDatagram manager(driver, CLIENT_ADDRESS);

void setup() {
   // sanity check delay - allows reprogramming if accidently blowing power w/leds
   delay(1000);
   FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

   Serial.begin(9600);
   //while (!Serial) ;

   if (!manager.init())
    Serial.println("init failed");
  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM (for low power module)

  if (!driver.setFrequency(868))
    Serial.println("setFrequency failed");

  // If you are using a high power RF69 eg RFM69HW, you *must* set a Tx power with the
  // ishighpowermodule flag set like this:
  driver.setTxPower(10, true);

  Serial.println("Client Setup Complete");


}

//uint8_t data[] = "Hello World!";
uint8_t data[20]; 
// Dont put this on the stack:
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t x = 0;


void loop() {
   // Move a single white led 
   for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
      leds[whiteLed] = CRGB::White;
      FastLED.show();
      delay(50);
      leds[whiteLed] = CRGB::Black;
   }

   sprintf((char*)data, "%3d Hello World!" ,x++);
   if(x==999) x=0;

   Serial.println("Sending to rf69_reliable_datagram_server");

// Send a message to manager_server
  
  if (manager.sendtoWait(data, sizeof(data), SERVER_ADDRESS))
  {
    // Now wait for a reply from the server
    uint8_t len = sizeof(buf);
    uint8_t from;   
    if (manager.recvfromAckTimeout(buf, &len, 2000, &from))
    {
      Serial.print("got reply from : 0x");
      Serial.print(from, HEX);
      Serial.print(": ");
      Serial.println((char*)buf);
    }
    else
    {
      Serial.println("No reply, is rf69_reliable_datagram_server running?");
    }
  }
  else
    Serial.println("sendtoWait failed");
  //delay(500);

}
 
Status
Not open for further replies.
Back
Top