The transmitter is an Arduino Mega 2560 (China) that is connected to a computer over Serial, from which it only reads data and sends it using a SYN115 433mhz transmitter.
The receiver is an Arduino Nano (China) that drives an 8x8 * 5 led matrix and it reads data using a SYN480R 433mhz receiver.
Everything works as it should, when both devices are connected to my computer over USB.
If I unplug the receiver, the transmitter now stops responding to Serial data and I have to upload a sketch to make it work again, no resetting or power cycling works. But even after "fixing" the transmitter, if the receiver is not to connected to my computer but an external USB power supply (2A) it never receives any data.
I can then plug the receiver back into the computer and things work again. Also, if I unplug the transmitter while the receiver is still plugged into the computer, the receiver crashes and resets itself.
Obviously there's some power issue when unplugging USB devices causing feedback, but the real issue is the wireless stops working on external power supply.
Both devices are running, it's easy to confirm since the receiver has some scrolling text, and the transmitter blinks an LED when it receives and sends data.
I read at Serial communication not working between two Arduinos unless connected to computer that both systems need to share ground if connected by wires. Could this affect the wireless signal somehow?
UPDATE: Connecting the receiver to a second computer works! (thanks Chris!! I know it was simple, but one can get stuck in one's own thought process ;))
So this is probably power related... Or can the Nano I have require more than just power over USB? I don't touch the serial device on the receiver side at all btw, all it does is read from PIN 2 and pushes data over HW-SPI to the LED matrix.
UPDATE-2: Added reciever code as suggested, though I doubt it's the problem here as it's very simple.
#include <MD_MAX72xx.h>
#include <RadioHead.h>
#include <RH_ASK.h>
#define RADIO_RX 2
#define RADIO_TX 3 // not used in this scetch but still needed by RH_ASK
#define RADIO_EN 4 // -||-
RH_ASK radio( 1200, RADIO_RX, RADIO_TX, RADIO_EN, true);
MD_MAX72XX mx( SS, 5);
void setup() {
radio.init();
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, 0);
mx.control(MD_MAX72XX::TEST, 0);
mx.clear();
}
uint8_t sc_text[128] = "-- No Data -- ";
uint8_t sc_pos;
uint8_t sc_charWidth;
uint8_t sc_charPos;
uint8_t sc_buf[8];
int scrollText() {
mx.update(MD_MAX72XX::OFF);
if(sc_text[sc_pos] == '\0') {
sc_pos = 0;
return 1;
}
if(sc_charPos == 0) sc_charWidth = mx.getChar(sc_text[sc_pos++], sizeof(sc_buf)/sizeof(sc_buf[0]), sc_buf);
if( sc_charPos < sc_charWidth + 1) {
mx.transform(MD_MAX72XX::TSL);
if(sc_charPos < sc_charWidth) mx.setColumn(0, sc_buf[sc_charPos++]);
else sc_charPos = 0;
}
mx.update(MD_MAX72XX::ON);
delay(100);
return 0;
}
char desc[64];
int temp1, temp2;
int wind1, wind2;
uint8_t radio_preamble[] = { 0x7d, 0x6f, 0xe4, 0x26, 0xb5 };
struct wttr_packet {
uint8_t preamble[sizeof(radio_preamble)];
int8_t temp1, temp2;
uint8_t wind1, wind2;
uint8_t desclen;
char desc[32];
};
bool get_wttr_data() {
struct wttr_packet packet;
uint8_t len = sizeof(packet);
int hasdata = radio.recv( (uint8_t*)&packet, &len);
if(hasdata && len == sizeof(packet)) {
if(memcmp( packet.preamble, radio_preamble, sizeof(radio_preamble))) return false
temp1 = packet.temp1;
temp2 = packet.temp2;
wind1 = packet.wind1;
wind2 = packet.wind2;
memcpy( desc, packet.desc, packet.desclen);
desc[packet.desclen] = '\0';
return true;
}
return false;
}
bool hasnewdata = false;
void loop() {
if(get_wttr_data()) hasnewdata = true;
if(scrollText() && hasnewdata) {
if(temp1 == temp2 && wind1 == wind2) sprintf( sc_text, "%s %d %cC %d km/h ", desc, temp1, 0xF7, wind1); // 0xF7 == '°'
else if(temp1 != temp2) sprintf( sc_text, "%s %d/%d %cC %d km/h ", desc, temp1, temp2, 0xF7, wind1); // 0xF7 == '°'
else if(wind1 != wind2) sprintf( sc_text, "%s %d %cC %d/%d km/h ", desc, temp1, 0xF7, wind1, wind2); // 0xF7 == '°'
else sprintf( sc_text, "%s %d/%d %cC %d/%d km/h ", desc, temp1, temp2, 0xF7, wind1, wind2); // 0xF7 == '°'
hasnewdata = false;
}
}
UPDATE-3: Turns out this wasn't a power issue after all. I had forgotten about a voltage divider I put on the board for using it as a transmitter! The radio module has 3.3V TTL so this is needed for the transmitter but NOT the receiver!
Why this made it work plugged in to USB and not any other power brick I have no idea.