wire.begin; and serial.begin(xxx); ..what sequence?

In a setup where the following sequence is used, the baud rate is set at 115200:

Serial.begin(1200); Wire.begin(); RTC.begin();

When this sequence is used, the baud rate is 1200:

Wire.begin(); RTC.begin(); Serial.begin(1200);

What is the reason?

Seriously?

Proof?

Code?

  1. The Serial has nothing with the Wire so the order of Serial.begin and Wire.begin is not important.
  2. The RTC uses the Wire so no Wire.begin is needed after or before RTC.begin. In addition in case of calling both your code is bigger and uselessly waste flash memory.
  3. At any moment in the program you can change serial baud rate by Serial.begin call, if it is needed. Serial.begin(1200) will set it to 1200baud, not to 115200, no way.

In addition in case of calling both your code is bigger and uselessly waste flash memory.

Calling a function once, or 14000000 times, has NO impact on the code size or the amount of flash memory used.

What Arduino board are you using and What type of serial output are seeing? The reason I ask is that when esp8266 modules crash they can spit out messages at 115200.

--- bill

Exctly which of the many RTC libraries are you using? Perhaps one that sets the baud rate.

Budvar10: 1. The Serial has nothing with the Wire so the order of Serial.begin and Wire.begin is not important. 2. The RTC uses the Wire so no Wire.begin is needed after or before RTC.begin. In addition in case of calling both your code is bigger and uselessly waste flash memory. 3. At any moment in the program you can change serial baud rate by Serial.begin call, if it is needed. Serial.begin(1200) will set it to 1200baud, not to 115200, no way.

Indeed, I tried to replicate this but unable to.. Sorry guys for wasting your time, indeed this something else in the code that must have affected this.

Budvar10, thanks for that info, I will delete wire.begin();

johnwasser: Exctly which of the many RTC libraries are you using? Perhaps one that sets the baud rate.

I use the RTClibExtended.h

bperrybap: What Arduino board are you using and What type of serial output are seeing? The reason I ask is that when esp8266 modules crash they can spit out messages at 115200.

--- bill

This is on the Pro Mini, used as transmitter. An ESP8266 with an HC-12 is used as the receiver. Both HC-12 modules are set at 1200 baud and communicate at that rate.

brice3010: Budvar10, thanks for that info, I will delete wire.begin();

No so fast. It depends on the specific library. Some RTC libraries call Wire.begin() and some don't and need the sketch to call it. And THAT is why people are asking you which library you are using.

--- bill

Budvar10: (...) 2. The RTC uses the Wire so no Wire.begin is needed after or before RTC.begin. In addition in case of calling both your code is bigger and uselessly waste flash memory. (...)

I use the RTClibExtended.h, so I can omit Wire.h?

bperrybap: No so fast. It depends on the specific library. Some RTC libraries call Wire.begin() and some don't and need the sketch to call it. And THAT is why people are asking you which library you are using.

--- bill

Oeps, thank you!!!

RTClibExtended.h is used.

brice3010:
This is on the Pro Mini, used as transmitter. An ESP8266 with an HC-12 is used as the receiver. Both HC-12 modules are set at 1200 baud and communicate at that rate.

Can you elaborate a bit more on your full setup since now you seem to be implying that more than one Arduino is being used.

— bill

TolpuddleSartre:
Seriously?

Proof?

Code?

Code attached (too long to include in message).

Arduino_duty_cycle_measurement_v12.txt (11.9 KB)

brice3010: Oeps, thank you!!!

RTClibExtended.h is used.

Ok, that is a header file name. We need to know which specific library. Provide a link to the library so we can look at it.

Also, it would be useful to see the code that demonstrating the issue you are having.

It is all the specific little details that matter, and so far they are only slowly dribbling in.

--- bill

bperrybap:
Can you elaborate a bit more on your full setup since now you seem to be implying that more than one Arduino is being used.

— bill

An Arduino Pro Mini is used to hardware serial transmit with HC12 radio to another HC12 at receiving end connected to ESP8266.
It is on the transmitting part that the issue occured.

bperrybap: (...) Also, it would be useful to see the code that demonstrating the issue you are having.

It is all the specific little details that matter, and so far they are only slowly dribbling in.

--- bill

Posted; sorry for not posting the code earlier, the file is so big I thought it would more of a bore

bperrybap: Ok, that is a header file name. We need to know which specific library. Provide a link to the library so we can look at it.

(...) --- bill

This is the RTC library used: https://github.com/FabioCuomo/FabioCuomo-DS3231/blob/master/RTClibExtended.h

PaulS: Calling a function once, or 14000000 times, has NO impact on the code size or the amount of flash memory used.

void setup() {
  RTC.begin();
  Wire.begin();
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly: 
}

1922 bytes vs.

void setup() {
  RTC.begin();
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly: 
}

1914bytes Wire is usable in both.

brice3010: This is the RTC library used: https://github.com/FabioCuomo/FabioCuomo-DS3231/blob/master/RTClibExtended.h

That library https://github.com/FabioCuomo/FabioCuomo-DS3231 does appear to call Wire.begin() in the library begin() method which means you can leave out the Wire.begin() call in your sketch; however, don't expect much code reduction (it should save a few bytes) as the only thing you are saving is an additional call to Wire.begin() in your setup() code.