Need to reset on external plug vs computer usb

Hi all,

I have a arduino micro pro 3.3v and use it for temperature and humidity measurements (dht11) and transfer data via a nrf24 to my raspberry pi (I use mysensors for that). Right now everything is breadboard mounted with a reset button to be able to upload sketches. And it works fine
The idea for the production version of this is that I'd plug an ac adapter to mini USB 5v directly to the nano. When I do that now, all three LEDs on the nano are and stay on and the board basically doesn't seem to boot, unless I hit my reset button, which I wouldn't want to mount on my production version. When I hit the reset button the board does what it is meant to do.when plugged to the computer USB the board boots fine.
I already got rid of all serial communication in the code. Anybody can hint me to a solution on how to avoid the need of the reset button when not plugged to a computer USB?

Thanks in advance for your help

Peter

Post a diagram showing all the connections. A photo of a pencil and paper drawing will be fine. Please DO NOT use Fritzing.

...R

Hi,

ok I tried to find another service for sketching then. Find attached the sketch. It is a arduino micro pro finally (always mix these small ones up). The whole is powered by the usb plug either via PC (working) or AC adapter (working only when resetting). I didn't sketch the reset button here, but basically it's a switch between GND and RST of the board. Why fritzing is not OK for sketching?
Below also my code :

#define MY_RADIO_NRF24
 
#include <SPI.h>
#include <MySensors.h>  
#include <DHT.h>



// Set this offset if the sensor has a permanent small offset to the real temperatures
#define SENSOR_TEMP_OFFSET 0
#define DHT_DATA_PIN 8 //define the pin where the DHT11 is mounted


// Sleep time between sensor updates (in milliseconds)
// Must be >1000ms for DHT22 and >2000ms for DHT11
static const uint64_t UPDATE_INTERVAL = 60000;

// Force sending an update of the temperature after n sensor reads, so a controller showing the
// timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
// the value didn't change since;
// i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
static const uint8_t FORCE_UPDATE_N_READS = 10;

#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1

float lastTemp;
float lastHum;
uint8_t nNoUpdatesTemp;
uint8_t nNoUpdatesHum;
bool metric = true;

MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgHum(CHILD_ID_HUM, V_HUM);

DHT dht;


void presentation()  
{ 
  // Send the sketch version information to the gateway
  sendSketchInfo("Temperature/Humidity", "1.1");
  
  // Register all sensors to gw (they will be created as child devices)
  present(CHILD_ID_TEMP, S_TEMP);
  present(CHILD_ID_HUM, S_HUM);
  
  metric = getControllerConfig().isMetric;
}

void setup()
{
  dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
  if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
   
  }
   delay(1000) ;
  // Sleep for the time of the minimum sampling period to give the sensor time to power up
  // (otherwise, timeout errors might occure for the first reading)
  //sleep(dht.getMinimumSamplingPeriod());
}

void loop(){  
  dht.readSensor(true);
  float temperature = dht.getTemperature(); // Gets the values of the temperature
  float humidity = dht.getHumidity(); // Gets the values of the humidity
  if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
    // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
    lastTemp = temperature;
 
    // Reset no updates counter
    nNoUpdatesTemp = 0;
    send(msgTemp.set(temperature, 1));


  } else {
    // Increase no update counter if the temperature stayed the same
    nNoUpdatesTemp++;
  }
  
  if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
    lastHum = humidity;
 
    // Reset no updates counter
    nNoUpdatesHum = 0;
    send(msgHum.set(humidity, 1));

  } else {
    // Increase no update counter if the temperature stayed the same
    nNoUpdatesTemp++;
  }

    sleep(UPDATE_INTERVAL);  
}

Screen Shot 2017-12-16 at 16.51.42.png

Hi,
Does that NRF24 have 3.3V reg on board?
Ops circuit.
c82999b6c48970cdecda1c0af21d4ae5656a0b22.png
I assume the dot on U2 shorting the data and Vcc leads is a drawing error.
Tom... :slight_smile:

Hi,
I think you may need to pull the RESET pin HIGH, but that should be done on board.
Otherwise you need to make a capacitor and resistor, power ON reset circuit.

Tom.. :slight_smile:

Why fritzing is not OK for sketching?

Because it does not provide a schematic, it generates a device interconnection diagram which is not the same thing.

You've used the terms "Nano Pro" in your description and "Pro Micro" in your schematic, showing the pin out of a Pro Micro. Since there is no Arduino "Nano Pro" but there is a Nano which uses a USB mini connect - I suspect that is what you have physically. A photo to confirm that would be helpful.

Further confusion insues from your description of uploading a sketch. Neither the Nano and the Pro Micro require pushing a reset button to upload a sketch. Only a Pro Mini with an external USB<->serial converter without the DTR pin connected would require the use of a reset to upload a sketch.

Regardless of the Arduino you're using, it should power up and run without a manual reset to get it started. TomG was asking about the NRF24 wiring because as shown in your schematic, you have +5 volts supplying the NRF module which is not correct, it needs a 3.3 volt supply, unless you're not showing a connector module with a step-down regulator. If you are indeed powering a 3.3 volt module with 5 volts could be why your system does not power up and run. The NRF24 I/O is tolerant of 5 volt levels buts the VCC pin is not.

All things considered, your post and questions make little sense. Please clarify with photos and/or correct descriptions. The quality of the answers you get depend upon the quality of the information you provide.

Your Original Post says "nano" but your drawing shows "pro-micro". They are very different. Which are you using?

And it makes things easier if you put the Arduino I/O pin numbers on the drawing.

...R

Hi,

sorry for not being that clear in the first place. Not 100% used to that universe yet and I agree that the quality of repsonse depends on what I describe. Will try to do better now!

I have these arduino boards : https://www.aliexpress.com/item/2pcs-Leonardo-Pro-Micro-ATmega32U4-16MHz-3-3V-Replace-ATmega328-Pro-Mini/32661332411.html?spm=a2g0s.9042311.0.0.IwYhfw
Micro USB Pro Micro.

this NRF module : https://www.aliexpress.com/item/10PCS-NEW-NRF24L01-2-4GHz-Antenna-Wireless-Transceiver-Module/32327366606.html?spm=a2g0s.9042311.0.0.IwYhfw

this DHT : https://www.aliexpress.com/item/Free-shipping-1pcs-lot-DHT-11-DHT11-Digital-Temperature-and-Humidity-Sensor-DHT-11/32659637930.html?spm=a2g0s.9042311.0.0.IwYhfw

this AC 5V plug : https://www.aliexpress.com/item/High-Quality-black-color-5V-2A-Travel-Wall-Charger-MICRO-USB-Cable-EU-Plug/32711811004.html?spm=a2g0s.9042311.0.0.IwYhfw

I have the 3.3v arduino board (sorry, yet another error in the beginning of the post) version. So it should be fine with the NRF24L01+. However, while writing this I notice that my plugs are 5V and my arduino board 3.3V, might this be an issue here?

Yes @TomGeorge, this was a drawing error. I uploaded the correct drawing with correct voltage here. Sorry for that :frowning:

Screen Shot 2017-12-16 at 21.52.57.png

Image from Reply #7 so we don't have to download it. See this Image Guide

a97a284dfa0f57c76f75b68e21ad14e6b8a60c8b.png

...R

Hi,
If you have this NRF and no adapter PCB then it should be operating on 3.3V not 5V.
10PCS-NEW-NRF24L01-2-4GHz-Antenna-Wireless-Transceiver-Module.jpg_640x640.jpg

Tom... :slight_smile:

Hi,
Have you measured Vcc?

Tom.. :slight_smile:

I would expect any microprocessor board to go through its boot process when power is first applied.

How do you know it is not doing so?

Why have you "got rid of all serial communication in the code"? The ProMicro has a separate HardwareSerial port on Serial1 and you could connect that to your PC using a USB-TTL cable so that you can get debug messages even when the ProMicro is not powered from a PC.

...R

PS. I assume the ProMicro takes in 5v on its USB connection and converts it to 3.3v for general use. If the nRF24 works fine when the ProMicro is connected by USB to a PC that is almost certainly the case.

Hi,
In DHT11 documentation.

Might be causing problem if not enough time for DHT11 to stablize.

Tom... :slight_smile:

Robin2:
I would expect any microprocessor board to go through its boot process when power is first applied.

How do you know it is not doing so?

Why have you "got rid of all serial communication in the code"? The ProMicro has a separate HardwareSerial port on Serial1 and you could connect that to your PC using a USB-TTL cable so that you can get debug messages even when the ProMicro is not powered from a PC.

When plugged on PC USB the board starts transmitting temperature and humidity like it should. Only the yellow and red LEDs are on.
On ac plug the board switches on all leds so the blue one too and they all stay on. Nothing is transmitted to my raspberry pi. Nothing unless I reset the board via the reset pin.
I read somewhere on another post that the arduino might be waiting for the serial connection to be established, but I guess it is not the case as you said.
Something I didn't try yet is to add a blinking led in the loop to check whether it enters there when plugged to ac. Might be worth a try?

pschmidtke:
Something I didn't try yet is to add a blinking led in the loop to check whether it enters there when plugged to ac. Might be worth a try?

Ok I just tried this. I added a blink in the setup and loop function. When on PC USB it's blinking, when on AC plug all LEDs stay on, no blinking. When I hit the reset button, it's starting to blink and only the red LED stay's on.

TomGeorge:
Hi,
In DHT11 documentation.

Might be causing problem if not enough time for DHT11 to stablize.

Tom... :slight_smile:

I added back the sleep in the setup function for this :
sleep(dht.getMinimumSamplingPeriod());
Doesn't solve the issue either.

pschmidtke:
Ok I just tried this. I added a blink in the setup and loop function. When on PC USB it's blinking, when on AC plug all LEDs stay on, no blinking. When I hit the reset button, it's starting to blink and only the red LED stay's on.

I think you need to monitor the Vcc and Reset pins with an oscilloscope to see what is happening during the start process. I wonder is it hanging in the reset state?

Edit following Reply #19
Have you tried powering the Arduino with a pack of 3 x AA alkaline cells - a very steady 4.5v?
this should have said
Have you tried powering the Arduino with a pack of 2 x AA alkaline cells - a very steady 3v?

Apologies for any confusion

...R

Robin2:
Have you tried powering the Arduino with a pack of 3 x AA alkaline cells - a very steady 4.5v?

...R

Have tried that just now. Same as with the AC plug. Don't have oscilloscope :frowning:

TomGeorge:
Hi,
I think you may need to pull the RESET pin HIGH, but that should be done on board.
Otherwise you need to make a capacitor and resistor, power ON reset circuit.

Tom.. :slight_smile:

you mean a circuit like this? https://www.google.fr/search?q=power+on+reset+circuit+arduino&tbm=isch&source=iu&ictx=1&fir=YEYWb_cM9zF3FM%253A%252CROxdX_-V5WACRM%252C_&usg=__IEokpGBdDsI7sZw2FTUffRqg3F0%3D&sa=X&ved=0ahUKEwiHybXe-5DYAhVQJVAKHU8jCYcQ9QEILTAC#imgrc=YEYWb_cM9zF3FM:

From what I understand this should already be handled by the chip itself, no?

Putting anything above 3.3 volts on VCC is exceeding the the rating of the NRF24 module.

Connecting an external 5 volt supply through the USB port keeps the NRF24 at 3.3 volts since the Pro Micro's 3.3 regulator is in the circuit. Supplying 4.5 volts from a battery pack should go either through the USB cable or be connected to the RAW pin, not the VCC pin.

At this point, you should be posting your code. You're off chasing hardware reset ghosts and we have no idea what you're doing with the processor. For example, if you're using Serial functions, you could be hanging your program at startup since there is no serial connection without the computer attached. Start with the simplest explanations first, they're far more likely to be the source of your troubles.