1

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.

7
  • Can you try them on two different computers? It's vaguely possible that some fault trigger by unplugging a device is forcing a re-start of the whole USB bus. And it's also possible that a random power adapter may be too noisy to use for a radio receiver. Mar 28, 2018 at 5:17
  • you use 5V power adapters connected to barel jack?
    – Juraj
    Mar 28, 2018 at 5:21
  • Its a 2A USB power adapter, cheap :p though not from china, i think. About a second PC, il have to do that when i get home, though it will be an old eee901 netbook, for proximity, those radio modules aren't exactly great ;)
    – grable
    Mar 28, 2018 at 9:15
  • Yep, powering the receiver from another computer works! Ive tried 3 different USB power adapters now, none of them is able to handle wireless. Even the charger for my brand new Huawei P10 with super charging doesnt work.
    – grable
    Mar 28, 2018 at 14:15
  • Perhaps there's something about your sketch that requires a computer. You should probably include the receive code with an edit to your question. Mar 28, 2018 at 16:29

1 Answer 1

0

Turns out I forgot I had put a voltage divider on the data-line from the receiver since I originally build the board for transmission.

This in turn, somehow, caused the signal from the radio receiver to fall short of the TTL signals when powered by anything other than USB.

I bypassed the divider and everything works as it should again :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.