HI All,
I have a project that has attiny85 send a string via a 433MHZ transmitter and at the moment a arduino nano picks up this with the receiver and tests the string like a password, if correct throws relay.
this all works perfect.
Im now wanting to replace the arduino nano with an attiny85 like i did with the transmitter, however there seems to be an issue, the code will no longer compile for board selected attiny85, if i change the board back it compiles fine.... weird
here is the code, I have replaced the string with # for reasons of my own choosing
#include <VirtualWire.h>
void setup(){
digitalWrite(3,HIGH);
vw_set_ptt_inverted(true); // Required for DR3100
vw_setup(2000); // Bits per sec
vw_set_rx_pin(2);
vw_rx_start(); // Start the receiver PLL running
}
void loop(){
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
String abc;
for (i = 0; i < buflen; i++)
{
abc += buf[i];
abc += " ";
}
if (abc == "## ## ## ##"){
digitalWrite(3,LOW);
}
}}
in the original code if had just if (abc = "## ## ## ##") but changed to == as the compiler did not like it when attiny85 was selected, this leads me to think its an issue with this line but i can not find out what.
please help
also the error i get is
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
Hi,
I have tried the code and its not working, i think the issue lies in the secret code part.
this is what i have including the real message as received by my original code
I have tried also removing the space from the secret code as last time i added them in myself and still didnt work, i also tried putting the raw text and that didnt work
seeing as attiny has no serial its impossible for me to see what its getting as data, any ideas?
bensonsearch:
I have tried also removing the space from the secret code as last time i added them in myself and still didnt work, i also tried putting the raw text and that didnt work
Share the code that is sending the message...
seeing as attiny has no serial its impossible for me to see what its getting as data, any ideas?
I'd do two thinks:
Hook up an LED and test the standard "Blink" example. Make sure the LED blinks on/off at the correct interval. The ATTiny85 fuses may be set wrong and your timing might be off.
Leave the LED hooked up and make it blink once for "message received" and blink twice for "passcode correct"
If you google the error message you will find a number of people have had the same problem. This error message means that you have exceeded the program size limit (4 Kbyte). There is a patch for the AVR GCC linker that allows you to use the full 8K byte program size.
Please note that the above helps with your initial error message (only ;-).
If you are interested there is a Cosa version of Virtual Wire that is fully OOP and allows several configurations. It works on all of the boards that Cosa supports. Ranging from Tiny to Mega and Mighty.
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn85.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25\libgcc.a(_exit.o)
That's a bug in the linker. Download the latest version of winavr and copy the binary files (in folder 'bin') into your Arduino installation.
Thank you all for the information, Blinking a message ha, that to me seems hard as i dont know morse code and binary hmmm lol
its still not working and i have no more variations of the password to try so i may need to experiment with some other way
i dont really know much about all this but would the compare between uint8_t and char array have anything to do with it? also the fact its static, i assume when we receive a mesage the static variable changes to the message right?
The way I calculate it, when the password is "Benson14", sizeof(SECRET_CODE) is 9. The actual message is only 8 characters long. if buflen doesn't include the null terminator, 8 won't be >- 9, and the test will fail. Maybe you should use strlen(SECRET_CODE) or hard code an 8 in there and see if that works.
Well, that's just a detail. There are ways to get around any of those issues.
Blink it in binary or Morse Code, take a video, and post it where someone who DOES know them can interpret.
Blink the raw numbers, with pauses in between. First, blink the buflen. Then blink out each of the letters in the msg. So what if it takes 110 blinks to blink an 'n'? At least it's SOMETHING.
Trying to debug a problem by staring at the code is sometimes just not going to work. If you can somehow get the machine to tell you what's actually going on in there, you can figure out what's actually wrong, instead of guessing.