I have set up a (TX and RX)RF on 2 of my arduino nanos and they work fine.
They successfully transmits and receives unsigned bytes without any issues.
But if I add a seven segment display module the the arduino with the RX module stops receiving signal.
I tried changing pin order and stuff but still doesn't work, also tried swapping the arduinos.
So i think the code is fualty since if I remove the lines of code for the display and re-uploads the script, then the arduino starts receiving signal.
I can't figure out whats wrong, any help would be appreciated.
here is the code
#include <Arduino.h> // Arduino library
#include <TM1637Display.h> // Seven segment module library
#include <VirtualWire.h>
const int led_pin = 13;
const int receive_pin = 12;
const byte CLK = 4; // Clock pin on D2
const byte DIO = 7; // Digital pin on D3
TM1637Display display(CLK, DIO);
void setup()
{
delay(1000);
Serial.begin(9600); // Serial communication at 115200 bauds
Serial.println("setup");
vw_set_rx_pin(receive_pin);
vw_setup(2000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
pinMode(led_pin, OUTPUT);
display.setBrightness(0xff); // Seven segment module brightness level
}
void loop()
{
display.showNumberDec(55,false); // display number 55
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
digitalWrite(led_pin, HIGH); // Flash a light to show received good message
// Message with a good checksum received, dump it.
Serial.print("Got: ");
Serial.print(buf[0]); // Print result on serial monitor
Serial.println();
digitalWrite(led_pin, LOW);
}
}
robtillaart:
If you remove the virtual wire code, does the display works as it should?
(verify display is not broken)
The display works as it should even with the VirtualWire or not, also on the hardware level the display works without any problems. It successfully turns on and displays any number that I have programmed it to display.
However its the RX module that stops receiving signal when the display modules code is uploaded.
I have checked for reception by removing any 1 of these lines [display.setBrightness(0xff);] or [display.showNumberDec(55,false);]of code for the display module and the RX functions without any errors.
Also if I remove the jumpers for CLK and DIO for the display module, the RX works fine even without removing those display lines of code.
sterretje:
Quite sure. Your whole circuit is powered by the voltage regulator on your board. And I guess that that can't handle the required power.
With the given code you can switch individual segments on the display on and off; so you can play with that to see with how many segments it fails.
You can use the following setup to try to solve the issue.
Remove the 5V connection between the Arduino and the display board; keep the ground in place.
Use the 5V/2A powerbank to feed the display (connect both 5V and GND).
Use the computer to feed the Arduino via USB.
Hope that this is clear.
I turned on just 1 segment to test according to your suggestion by changing. Uint8_t data[] = {0x0, 0x0, 0x0, 0x0};
to Uint8_t data[] = {0xff, 0x0, 0x0, 0x0};
and the result is that even if only 1 segment is turned on the receiver will fail to work.
Next I pulled out the 5v jumper for the display module while Arduino was running just like you suggested and the receiver started working immediately.
I couldn't try the separate power option which you suggested since I currently dont have a spare usb cable which has exposed wires for connecting the module. But however I will try to power the arduino with a 9v battery or wall adpater through VIN and let you know the results.
HI,
Can you post a picture of your project please, so we can see your layout?
Also a circuit diagram rather than a frtzy would be better, in the fritzy you have the display connected to 3.3V, shouldn't it be 5V?
@sterretje
I connected the Arduino nano to a 9v battery and the setup now works flawlessly. Was it MAGIC ???
But I can't quite figure out why? I mean I tried supplying it USB 5V 2A and it doesn't work, isn't 2 amps more than enough?
Anyways Thanks for your support, much appreciated, you're a life saver.
@TomGeorge
The TM1637 display module will work with both 3.3v and 5v input as the module has voltage regulator built-in.Initially I connected the module to 3.3v just to check whether the problem was caused by voltage input or not, but it seems the problem persists regardless of voltage input of the display.
Hi,
The 9V battery, if it is a smoke detector type, will not last long.
Providing 9V to the DC plug shows that the 5V 2A supply you were trying is not up to scratch.
Have you measured the 5V with a DMM when the fault is present.
Your whole circuit is powered by the voltage regulator on your board.
No its isn't if the supply is 5V either external or USB, it is used when supply is applied though the Vin pin as the OP has done with the 9V battery.
Have you tried putting a 10uF capacitor across the 5V and gnd at the arduino when you power it from the PC USB or USB supply?
The battery is a 9v box type one with both terminals on top of it, and I only used it to test whether the setup works or not. When the project will be implemented I might use a wall adapter instead since I have to power it 24x365.
No I haven't tested the 5v with a multimeter. Which part should I test? the battery input or the arduino 5v pins or the modules VIN pins?
Also the 5V 2A was from a reliable power bank manufactured by Huawei, so I don't think there will be any voltage issues from that.
Whats with the capacitor?, I have zero knowledge about that what you mentioned. I'm kind of a noob.