Okay, I finally got the digispark to work with the Colorado Micro Devices' RadioBlocks.
I had to make changes to the SoftwareSerial library. In SoftwareSerial.cpp, I made the
following addition. This was the change that Eric @digistump originally suggested, but I
had to tweak the values for 115200 baud, to make it work.
#elif F_CPU == 16500000
static const DELAY_TABLE PROGMEM table[] =
{
// baud rxcenter rxintra rxstop tx
{ 115200, 1, 16, 16, 12, },
{ 57600, 10, 38, 38, 34, },
{ 38400, 26, 59, 59, 56, },
{ 31250, 32, 72, 72, 70, },
{ 28800, 35, 79, 79, 76, },
{ 19200, 56, 121, 121, 118, },
{ 14400, 76, 161, 161, 158, },
{ 9600, 118, 243, 243, 240, },
{ 4800, 240, 489, 489, 486, },
{ 2400, 486, 980, 980, 977, },
{ 1200, 977, 1961, 1961, 1958, },
{ 600, 1961, 3923, 3923, 3919, },
{ 300, 3923, 7855, 7855, 7852, },
};
const int XMIT_START_ADJUSTMENT = 5;
To connect the RadioBlock, I plugged it directly into the DigiSpark, with VCC on pin 3,
GND on pin 2, RX on pin 1, and TX on pin 0. First, I upload the sketch without the RadioBlock connected. After uploading the sketch, I disconnect the Digispark from the computer, plug in the RadioBlock and then plug the Digispark into a USB wall charger.
DCP_4927 by
Jeff Rand, on Flickr
Here's a simple sketch to blink the LED on the connected RadioBlock.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX
void setup(){
pinMode(2, OUTPUT);
digitalWrite(2,LOW); // GND on pin 2
pinMode(3, OUTPUT);
digitalWrite(3,HIGH); // VCC on pin 3
mySerial.begin(115200);
}
void loop(){
delay(500);
mySerial.print(char(0xAB)); // Start byte
mySerial.print(char(0x02)); // Size 2 bytes
mySerial.print(char(0x80)); // Command to set LED status
mySerial.print(char(0x02)); // Toggle LED
mySerial.print(char(0x8F)); // Low byte of CRC
mySerial.print(char(0x4D)); // High byte of CRC
}
Here's another sketch to blink the LED on a remote RadioBlock at adress 0x0001.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX
void setup(){
pinMode(2, OUTPUT);
digitalWrite(2,LOW); // GND on pin 2
pinMode(3, OUTPUT);
digitalWrite(3,HIGH); // VCC on pin 3
mySerial.begin(115200);
}
void loop(){
delay(500);
mySerial.print(char(0xAB)); // Start byte
mySerial.print(char(0x06)); // Size 6 bytes
mySerial.print(char(0x20)); // Command to transmit data
mySerial.print(char(0x01)); // Low byte of remote address
mySerial.print(char(0x00)); // High byte of remote address
mySerial.print(char(0x00)); // no options
mySerial.print(char(0x00)); // no options
mySerial.print("O"); // Payload to toggle LED
mySerial.print(char(0x63)); // Low byte of CRC
mySerial.print(char(0x41)); // High byte of CRC
}
Hope this helps.