text:
Send data from arduino to server using GSM, TCP
My actual connection is like:
Arduino -> GPRS(http)-> my server(php script)-> firebase <-android plotting app
But it only allows to send some data once every 2 - 3 seconds (depending of ping to my server).
I need to send some data (18 bytes) but every 0.5 - 1 seconds
It is possible to send directly over tcp to firebase?
And also i thinked about this schema:
Arduino(client) -> GPRS(tcp) -> my server(tcp socket) -> my database <- android plotter
but I don't know how to go about it, what server software i need to redirect recieved tcp packages to mysql.

you use AT commands on the unknown GSM module?

allows to send some data once every 2 - 3 seconds .... this indicates that there may be a bug in the PHP script

https://en.wikipedia.org/wiki/HTTP_persistent_connection

@jsotola Or it takes a couple of seconds to establish a new connection.

this is m590e module, and i use simple AT commands. It uses http GET connection and script read data from url parameters. I close connection every GET request. 'void loop() {
value++;
String dpa  = "/test.php?arduino_data="+(String)value;
strncpy(resource, dpa.c_str(), sizeof(resource)); //string to char
http.get(resource); //starting get request
Serial.println(err);
http.stop();} //closing connection' using tinyGSM library, how to make from it persistent connection, removing "http.stop()" not working :C


text:
RGB LED circuit problem
I have written the following code for RGB LED:-
const int RED =11;
const int GREEN = 10;
const int BLUE= 9;
void setup() {
  pinMode(RED,OUTPUT);
  pinMode(GREEN,OUTPUT);
  pinMode(BLUE,OUTPUT);
}

void loop() {
  analogWrite(RED,0);
  analogWrite(GREEN,255);
  analogWrite(BLUE,0);
  delay(1000);
}

Now according to my understanding if I run the above code then only  pin named GREEN i.e. 10th pin will give me current not 9, 11th pin. But when I upload the code and run it I see that 9 and 11 pin are giving me current not 10th pin as it is supposed to. Is there a problem in my code? I have checked my circuits are correct. To check current I took jumper wire that was connected to one of my colour and tried inserting it's other end at pins(9, 10 or 11) of Arduino board. If there is current bulb will glow. For above code the bulb was glowing when I inserted the wire at 9 and 11th pin.

Can we check that your circuit is correct too?

How do you know, that the other pins output a voltage? And what type of RGB LED do you have? Common anode or common cathode?

What do you mean by “give me current”. You are controlling voltage, not current.

@chrisl I took jumper wire that was connected to one of my colour and tried inserting it's other end at pins. If there is current bulb will glow. It's common anode

A common anode RGB LED can be sketched in a schematic like this:

simulate this circuit – Schematic created using CircuitLab
The positive voltage has to be applied to the top, for all the LEDs together. To light the LEDs up, you have to sink the current on the other end, meaning providing ground level at the bottom of that schematic at the corresponding pins. The current will then flow from your 5V pin, through the LEDs into the Arduinos pin.
That means, that analogWrite(pin, 0) will turn the LED on that pin ON and analogWrite(pin, 255) will turn the LED OFF. The logic is inverted here, because the Arduinos output pin is on the other side of the LED.
So your circuit and code work perfectly, you just didn't expect the inverted logic.

Note: The pins of the Arduino can only source/draw a certain amount of current (20mA continuously, 40mA at maximum) without getting damaged. A single, not too strong RGB LED should be OK, but as soon, as you want to drive more LEDs, you should consider using a driver circuit (for example simple transistors). That way the output pins don't have to provide the LEDs current, but only the current to control the transistor.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Is there a digital/ultrasonic Anemometer for Arduino?
I use Arduino DUE and I noticed that many forum users use the TX-23U Wind Sensor.
https://www.amazon.com/Crosse-Technology-TX-23U-Weather-Stations/dp/B0016MYA7U
Also, many people tried to create a DIY ultrasonic anemometer like this;
https://soldernerd.com/category/arduino-ultrasonic-anemometer/
Instead of using the DIY ultrasonic anemometer, I wanted to purchase one but I couldn't find one.
Is there an ultrasonic anemometer which I can purchase and connect it with my Arduino DUE?
3.3V power, non-mechanical rotation, I2C/SPI/UART support are the requirements. Thanks.

When I googled "ultrasonic anemometer" I found various suppliers, though I don't know, if these comply to your specifications or how expensive they are. Have you looked through the google results? I would think, that an ultrasonic anemometer is somewhat niche and this site is not meant for product recommendation, so you might not get a good answer here.

Frame challenge: pick a sensor that complies with your needs and specification - especially the performance characteristics you're interested in, e.g. range of wind speed to measure, required accuracy and resolution, response time and data acquisition rate, to name just a few. Don't look for something specific to Arduinos to not unnecessarily narrowing down your options. Then design or adapt an appropriate interface to make them both work together.
Common interfaces of "industrial grade" ultrasonic anemometers (e.g. 1 and 2) are RS232/RS422/485, so technically UART, though in need of level shifters or a RS-485/RS-422 transceiver, e.g. Maxim. Some also offer analogue output that might be feed into an Arduino's analogue in after matching voltage levels.
I would assume that I2C/SPI are rather uncommon as these are for short-distance, intra-board communication not for connecting a separate sensor module.
The same thought applies to the power supply, I recommend to drop the requirement of powering the sensor with 3V3 put rather select a power supply for a sensor available and affordable. The anemometers available at the linked vendors typically list a supply voltage of 5-30VDC or 6-24VDC.

You can see this one: SONIC-ANEMO-MICRO
https://lcjcapteurs.com/en/girouette-anemometres-capteur-vent/sa-micro-2/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Driving a stepper motor using ESP8266
I have a stepper motor, and a Uln2003a stepper driver, which is connected to an ESP8266.
The ESP8266 is powered via USB, and the stepper motor is powered via the driver, which is then powered by an external power source, providing it a bit more than 12 volt. When powered on the LED D1 and D2 lights red.
Pins D0, D1, D2, D3 are used for input signal for the drive, the stepper board.
Everything should be connected correctly, but for some reason I am not able to make my stepper motor move. It doesn't react on any of my commands - why?
I suspect that the logic level might have to be 5v instead of 3v. But I've seen stepper motors being driven by an ESP before. So why does this not work? Any suggestions?
Any ways to debug?
Code:
esphome:
  name: steppermotor
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: "ssid"
  password: "password"

# Enable logging
logger:

# ESPHome configuration
api:
  services:
    - service: control_stepper
      variables:
        target: int
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return target;'

# Example configuration entry
stepper:
  - platform: uln2003
    id: my_stepper
    pin_a: D0
    pin_b: D1
    pin_c: D2
    pin_d: D3
    max_speed: 250 steps/s

    acceleration: inf
    deceleration: inf

Do the pins, that you use for controlling the driver, are set correctly? The datasheet says, that it can work with 3.3V logic input voltage. I'm not familiar with that kind of code. Where are the functions defined, that actually control the output pins?

the code is part of the https://esphome.io/components/stepper/index.html

I am pretty sure about the pins...  I don't know whether picture would help or?

Mhh, I don't think I can help with the code. Haven't seen that before. The pins are just connected straight to the 4 input pins of the driver. Not much to fail there. The LEDs on the driver will light depending on wether there is a HIGH voltage level on that pin. If nothing happens I would think, that either the pins are not set by the code, or your driver is dead. You can test the latter by connecting the 4 phases one by one to 3.3V. If the LEDs light up correctly, the error must be in your code.

From your code I guess, that you try to control the stepper via an API. How do you call to this API? Do you construct your own call string, or do you have some kind of UI on that site of the project (ESPHome)?

I hope there must be an inbuilt pull-up resistance for each GPIO registers of ESP. Test like this and post your observation: 1. Don't connect anything(ULN2003 jumper wires) to your ESP and check the GPIOs you selected whether they are floating or not. If no float in reading then it's fine. 2. Connect the load and test the GPIOs are floating or not.

use a multimeter to see if the pins do what you expect (without connecting a driver).  once you have that, add the driver (but no stepper motor) and see what the pins for stepper coils are doing.  If it passes that, measure which coils are actually connected on the stepper and check that those match the driver.


text:
Error compiling for any board arduino ide 1.8.9
my arduino ide Until yesterday it worked properly . but today All previous projects   dont compiling and all of them have one error : Error compiling for  board
and It's no different that Which board I choose in all of board i have this error .
please help me .
image link : http://uupload.ir/files/6hjr_capture1.jpg
error : * Error while detecting libraries included by C:\Users\ali_m\AppData\Local\Temp\arduino_build_706504\sketch\timer.ino.cpp

xtensa-lx106-elf-g++: error: CreateProcess: No such file or directory
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

is it just ESP based boards that you can't compile for?

No for all of the boards this is hapen

Can you show the error for an arduino board

image link : http://uupload.ir/files/9aht_capture33.jpg

I hope this link helps you or please try a fresh install.


text:
Trouble uploading code to ESP12 with CH340g
I have a programming circuit for the esp12(see attached) enter image description here
I have produced a pcb using this circuit. Upon plugging the pcb into my pc via the micro usb, the pc immediately recognizes the device.
The problem comes when I hit the upload button in the Arduino IDE. I get the following error:
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, Flash, Disabled, 4M (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Sketch uses 265572 bytes (25%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26984 bytes (32%) of dynamic memory, leaving 54936 bytes for local variables. Maximum is 81920 bytes.
C:\Users\XXXX\Documents\ArduinoData\packages\esp8266\tools\esptool\2.5.0-3-20ed2b9/esptool.exe -vv -cd nodemcu -cb 115200 -cp COM3 -ca 0x00000 -cf C:\Users\XXXX\AppData\Local\Temp\arduino_build_988997/WiFiScan.ino.bin
esptool v0.4.13-1-gf80ae31 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to nodemcu
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM3
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
An error occurred while uploading the sketch
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Where is the error in my design that is preventing the successful upload in the Arduino IDE.
Edit: So I changed the CH340G to a CH340C and removed the 12MHz Crystal and the two 22pf caps connected the the 12MHz. It works perfectly now. I uploaded the code even at 921600 baud.
I guess the issue might have been which crystal I used or maybe the caps. Didn't think it would matter as long as the crystal is 12MHz, but maybe there is something else to account for.
Anyway...the new design will include the CH340C instead of the CH340G, but to be honest I will probably redesign it to use the CP2102.
Thank you for the quick responses. I really do appreciate it.

Well, the schematic seems OK and correct - have you tried putting the ESP into programming mode manually (tie GPIO0 to ground)

iirc, nodemcu 0.9 was a little funky. i would try other board profiles, including the generic.

Jaramanda X I did try to manually boot the ESP into flashing mode. I desoldered the auto-reset/auto-program components and just hooked it up to a breadboard with some push buttons. No success until I replaced the CH340G with a CH340C and removed the 12MHz and both 22pf caps. Programmed perfectly on the first try after that. Thank you for the quick response. Now I am going to go get drunk

So, I guess that means there's a difference in functionality between the CH340G and CH340C such that the former doesn't work with the nodemcu style reset circuit


text:
Atmega328p and cp2102 with error avrdude: stk500_getsync(): not in sync: resp=0x00
I recently bought a usb/ttl cp2102 converter for testing with a standalone Atmega328p, I made the DTR connection with the pin 1 in the Atmega  using a ceramic capacitor of 0.10uf (104) so that when I send my code to my Atmega standalone it save the code without having to worry about the reset. However, when trying to send it the first time it worked and the other attempts failed, it seems that whenever I restart the computer and turn it on again it sends the code to the Atmega and in the other attempts it fails.
To try to solve I tested with IDE Arduino 1.8.5 and 1.8.9 in Linux Mint and Windows 10 and gave the same problem, I recorded the bootloader again and did not solve.
The error that appears in the output of the IDE is this:
avrdude: stk500_getsync(): not in sync: resp=0x00

From what I read, this error is generic and hardly helps to solve the error.

What qualifies as "it works" and "it fails"?  It is hard to understand the meaning of your question.

Possible duplicate of "avrdude: stk500_getsync(): not in sync: resp=0x00," aka Some Dude Named Avr Won't Let Me Upload My Program

Researching a little and found the solution! In addition to capacitor 104, its necessari need to add a 10k resistor by connecting the 5 volts to pin 1.
This is the link of the GitHub project where I found the solution with the assembly scheme, I hope this helps somebody else!
https://github.com/leonvandenbeukel/Arduino-on-a-breadboard/blob/master/README.md

Your problem was that you left the reset floating.


text:
Red LED not turning off on Adafruit Circuit Playground Classic
When using the traditional Blink example program, the light blinks as expected. Even when writing from scratch digitalWriteing pin 13 to high and low repeatedly works fine. The problem is when I try to use CircuitPlayground.redLED(false). That has no effect, and the Circuit Playground specific Hello_Blink example doesn't work at all. The LED is just constantly on no matter what I do.
I've looked through the source code for the CircuitPlayground library and it's also using pin 13, and doing essentially the same thing as the traditional blink program.
Not sure what else could be causing this.
This is the Blink sketch that's working:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

And this is the Hello_Blink sketch that is not working (LED remains on permanently):
#include <Adafruit_CircuitPlayground.h>

void setup() {
  CircuitPlayground.begin();
}

void loop() {
  CircuitPlayground.redLED(HIGH);
  delay(500);
  CircuitPlayground.redLED(LOW);
  delay(500);
}

Changing HIGH and LOW to true and false does nothing.
I also have noticed two other strange things. The speaker does an audible click when the board resets when using the Hello_Blink sketch (or any other sketch that uses the CircuitPlayground library), as if pin #5 is being held high as well. Also, I added these two lines
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);

to the setup() of both programs and then probed #6 with a multimeter. Pin #6 is not connected to anything. The traditional blink program allows the pin to go high as expected. The CircuitPlayground sketch, however, the pin stays low.
I am using this library with a atmega32u4.

This appears to be a bug in the Circuit Playground library. An issue was opened here.
https://github.com/adafruit/Adafruit_CircuitPlayground/issues/40
Edit: This indeed was a bug, it is now fixed in the library version 1.8.4.


text:
Septic tank project
We are to make a project.We have to connect MQ7, buzzers and lights to Arduino. And one buzzer will make sound when gas reaches high level and another buzzer will beep when gas level is very low.. High gas amount will lead to red light glow and very low gas will lit green light.. HOW TO EXECUTE ??

Your question is too broad. This site works best with specific, rather narrow questions. What exactly is preventing you from making the project? Have you googled, how to control the components with an Arduino? There are plenty tutorials out there.

It's a good idea to plan your code by first ignoring any details about the Arduino or the sensors and make a rough list of steps you would need the Arduino to take. When you have done that, then look at each step and do the same thing again - plan that broad step into finer detail. Try doing that first, then if you feel stuck at some point, then say what you did or tried, and what part you don't understand or failed to work the way you expected it to. We're much better able to help with that kind of a question.

I suggest you take a 1 or 2 liter tupperware (i used an empty ice cream container) to test.  leave a little cup of poop and you will get all the gas you need real soon.  For your final project, though, I would have 2 sensorsper nbnoard and at least 2 boards.  PEOPLE DIE IN SEPTIC TANKS.  be safe.  UPVOTED

Easy, this is one of the simple projects used as an introduction to Arduino programming.  You will find many versions of free code out there.  below is an example and a total newbie step-by-step.

Download Arduino IDE.  Buy an MQ7, an Arduino or NodeMCU, a breadboard, a LED and some jumper wires and you are in business.  Use the sketch below or google "MQ7 arduino sketch".
/* MQ-7 Carbon Monoxide Sensor Circuit with Arduino */

const int AOUTpin=0;//the AOUT pin of the CO sensor goes into analog pin A0 of the arduino
const int DOUTpin=8;//the DOUT pin of the CO sensor goes into digital pin D8 of the arduino
const int ledPin=13;//the anode of the LED connects to digital pin D13 of the arduino

int limit;
int value;

void setup() {
  Serial.begin(115200);//sets the baud rate
  pinMode(DOUTpin, INPUT);//sets the pin as an input to the arduino
  pinMode(ledPin, OUTPUT);//sets the pin as an output of the arduino
}

void loop() {
  value= analogRead(AOUTpin);//reads the analaog value from the CO sensor's AOUT pin
  limit= digitalRead(DOUTpin);//reads the digital value from the CO sensor's DOUT pin
  Serial.print("CO value: ");
  Serial.println(value);//prints the CO value
  Serial.print("Limit: ");
  Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath)
  delay(100);
  if (limit == HIGH){
    digitalWrite(ledPin, HIGH);//if limit has been reached, LED turns on as status indicator
  } else {
    digitalWrite(ledPin, LOW);//if threshold not reached, LED remains off
  }
}

original sketch published by Learning About Electronics

Answers should be complete and do not link important data (like the scetch) but contain it. In some time the website you linked will be dead any your answer useless.

i uploadded the file as directed by stackexchange.  i did not link it to an external site.  SE linked it to imgur

I meant the "Use this sketch" link. If the target site goes down then the whole answer is missing most important part. https://stackoverflow.com/help/how-to-answer "Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline."

that is precisely why i wrote or google "MQ7 arduino sketch" @FilipFranik  ;)


text:
NaN for reading from AM2302 from Arduino Uno
I want to read sensor values from 4x AM2302 to an Arduino UNO, and then pass those values for data logging to Raspberry Pi via Serial communication over USB cable.  The sensors are installed at 4x locations in an indoor plant growing system at difficult to access locations.  In the same script is a program that runs HVAC fans and a water pump using timers and relays.  The problem I encounter is that after working for several readings, eventually the AM2302 fails to read and continuously sends NaN value.  If I intervene and power down/repower up, and also reupload the script, then the AM2302 begin reading again, but only for a few readings then fail again.
In the sample read-out table below, the 4x AM2302 sensor read-outs are sensor 1 : (HA01 - humidity, TA01 - temp) sensor 2 : (HA02, TA02) etc..
There is another read-out CT01 which is a DS18B20, which also fails after some-time and reports a value "no more address" which is reported as -127C by the Dallas Library.
I setup a breadboard and ran the same script with 2x AM2302 and no DS18B20 attached and was unable to replicate the problem.
I have chosen to use json string as a way to pass the readings from Arduino to Raspberry Pi, and notice that sometimes the string gets corrupted - in particular the date timestamp.
I would appreciate any help / tips on diagnostics ideas to pinpoint the issue.
Code for Arduino and Raspberry Pi is available on GitHub.
https://github.com/footprintzero/plantlab

Updated info 2019/05/21 18:42
  I re-ran the program with a modified script and so far the sensors are continuously sending a reading (AM2302).This modified script version has the HVAC control timers with the relays commented out in HVAC.ino at line 97. So its only reading the sensors and not controlling the relays.
// timer_mainloop();

I guess that HVAC.ino is the sketch you are talking about. Without having read all the code (since it is a lot of code): You very often use the String class to construct the json data string. This will cause heap fragmentation and may be the reason for your problem (Though I'm not sure). You should avoid using String, especially in a project, that should run for a long time continuesly. Use char buffers with a constant length instead.

Thanks for having a look! The String class is one of the suspicions I have.


text:
Arduino IDE - debugging Exception 29
I installed the ESP EXCEPTION DECODER along with my Arduino IDE.  When my sketch crashes with Exception 29, I take the stack trace and input it, but I can't understand its line references (they dont seem to point to my code).

Exception (29):
  epc1=0x4020ec84 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: sys
  sp: 3ffffcd0 end: 3fffffb0 offset: 01a0
3ffffe70:  3fffb558 00000000 3fff197c fffffffb
  3ffffe80:  3fff0ea0 3fff0ea0 00000000 4020fb20
  3ffffe90:  00000000 00000000 0000001f fffffffb
  3ffffea0:  3fff0ea0 00000000 3fff0e9c 4020ed35
  3ffffeb0:  40000f68 3ffe93b4 3fff0e9c 402120ec
  3ffffec0:  00000000 00000007 3fff197c 402137fa
  3ffffed0:  3ffe93b4 3ffe93b4 3fff0e9c 4021211a
  3ffffee0:  ffffffff 3fff0e9c 3fff197c 4021463c
  3ffffef0:  0100a8c0 3fffdcb0 3ffee960 00000030
  3fffff00:  00000000 3fff0e9c 3fff197c 4021468f
  3fffff10:  4020ffa8 3fff0afc 3fff0fc4 40100690
  3fffff20:  40229e46 00000000 00000012 3fff0af8
  3fffff30:  4020ffa8 3fff0afc 3ffe9348 4020ffb6
  3fffff40:  40104d7e 948e6801 00000018 40210074
  3fffff50:  3ffe9348 3ffed9fc 948e6801 00000000
  3fffff60:  4022e654 3ffee928 3ffee950 60000600
  3fffff70:  0fc612e0 3ffee950 3ffee928 4022e661
  3fffff80:  4022e6a6 3fffdab0 00000000 3fffdcb0
  3fffff90:  3ffee968 40000f65 3fffdab0 00000000
  3fffffa0:  40000f49 3ffe96e8 3fffdab0 40000f49
  <<

  0x4020fb20: tcp_abort at core/tcp.c line 544
0x4020ed35: netif_sta_status_callback at glue-lwip/lwip-git.c line 303
0x402120ec: netif_set_ipaddr at core/netif.c line 545
0x402137fa: dhcp_create_msg at core/ipv4/dhcp.c line 1825
0x4021211a: netif_set_addr_LWIP2 at core/netif.c line 584
0x4021463c: dhcp_release_LWIP2 at core/ipv4/dhcp.c line 1314
0x4021468f: dhcp_coarse_tmr at core/ipv4/dhcp.c line 423
0x4020ffa8: cyclic_timer at core/timeouts.c line 165
0x40100690: free at /home/tony/.arduino15/packages/esp8266/hardware/esp8266/2.4.1/cores/esp8266/umm_malloc/umm_malloc.c line 1739
0x4020ffa8: cyclic_timer at core/timeouts.c line 165
0x4020ffb6: cyclic_timer at core/timeouts.c line 171
0x40210074: sys_check_timeouts at core/timeouts.c line 351

How can I find ou what happens at address 0x4020ec84 and what line it points to?

use the latest esp8266 arduino core 2.5.2.

done.  went in BOARDS MANAGER and upgraded core from 2.4.1 to 2.5.2 -  what next?

upgraded, must wait for problem to occur (historically it has taken 16+ hours to manifest itself - memory might be an issue)

do you use String class to build strings and convert numbers?

yes i do.  could that be the culprit?

https://majenko.co.uk/blog/evils-arduino-strings

@Juraj, apparently, your comment re Strings has pointed me in a valid direction, though it is not quite the answer to the question.  IMportantly, it solves my underlying issue.  I therefore awarded you the 50 bonus points in the other question.  well done, m8 !  ;)


text:
How to send and receive unsigned int from one arduino to another arduino
I'm trying to send some big numbers ranging from 0-62000 from one arduino to another via serial communication. I'm using unsigned int to hold values from 0 to 65535. And I'm using serial.print() and serial.write () to send numbers and serial.read()-'0' ; to receive numbers, but I'm unable to send and receive numbers above 9. Please help me.
Here is my code -
(For master)
const int Button_1 = 2;
unsigned int s =0;
void setup ()
{
   Serial.begin(115200) ;
   pinMode(Button_1,INPUT);
}
void loop()
{
  if (digitalRead(Button_1))
  {
     s = 61805;
     Serial.write(highByte(s)) ;
     Serial.write(lowByte(s));
     delay (5);
     s=0;
  }
  else
  {
     s = 60005;
     Serial.write(highByte(s)) ;
     Serial.write(lowByte(s));
     delay (5);
     s=0;
  }
}

(code for slave)
unsigned int upperByte, lowerByte, r=0,p=0;
void setup()
{
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT) ;
}
void loop ()
{
  If (Serial.available()>1)
  {
     upperByte = Serial.read();
     lowerByte = Serial.read();
  }
    r = (upperByte << 8) + lowerByte ;

   while (r==61805)
    {
        digitalWrite(LED_BUILTIN, HIGH) ;
    }
    while (r==60005)
    {
        digitalWrite(LED_BUILTIN, LOW) ;
    }
}

hint: with serial.write(b) you get to 256. with two serial.write(b) you get to 256*256 (65536)

If you want to do this in ASCII (opposing to byte values like Juraj suggested), you should use a message delimiter - a special character that marks the end of a number. You can use the newline character \n for this. Then you can read the digits one by one, adding them together to the big number. For further help, we need to see your code.

Using two serial.write (b)  is nice idea, but I can't get many numbers which lies between 0-65536 with that logic. And my code is very basic, I'm just using serial.write ()  to send and serial. read() to receive.. I don't think if it will help you.

What do you mean "I can't get many numbers which lies between 0-65536 with that logic"? You can send as many ints as you want. You would send each int as a pair of bytes, as shown in CrossRoads' answer. Each unsigned int can hold a value from 0-65535.

i can move up to 32 bytes from one arduino to another using master/slave architecture.  if that helps, i can post an answer

There are 2 ways to transmit data over serial: As byte data or in ASCII codes

Byte data: Everything, that is digitally stored or processed, is a series of 0s and 1s (bits) (electrically HIGH and LOW level), which are grouped into bytes (8 bits). So all data is just numbers at low level. The different datatypes (like numbers, Strings, executable code) are only reached by different interpretation of the byte data. You can take the number value of a byte directly. A byte like 0b00000101 for example is equivalent to the decimal value 5. So every byte can hold numbers between 0 and 255. (Google the binary system for more information). To hold bigger numbers, more bytes are put together. For example an integer consists of 2 bytes (16 bits) and can hold numbers between 0 and 65535. Note: These are the unsigned types. There are also signed types, that also can hold negative values. To understand this, google binary two's complement. To transmit such a bigger type over serial (which is byte based), you need to seperate the bytes of the type, send them consecutively and put them back together at the receiving side. You can do this with the following code:
unsigned int number = 54321;
Serial.write(number & 0xFF); //getting the lower byte of the number by using bitwise AND
Serial.write(number >> 8); // getting the high byte of the number by shifting the bits of the value 8 bits to the right

There are macros defined for Arduino, that can do this for you:
Serial.write(lowByte(number));
Serial.write(highByte(number));

In long term, you should learn, how the bitwise operators work. They are often needed. To put the data back together, you can look at CrossRoads answer.
Note: Serial.write() will send the byte data unchanged, while Serial.print() will convert the data to ASCII before sending. They are not equal.
ASCII Data: One interpretation of byte data is the ASCII standard (which is really old). Every byte value between 0 and 127 get's a corresponding ASCII value, meaning characters of the alphabet, digits, some special characters and some control characters. Numbers, that are transmitted as ASCII data, consist of multiple bytes, one for each digit. Thats, what you tried. Since the receiver has to seperate the different numbers to process them correctly, you have to mark the end of each number. This is commonly done with the newline character \n (optionally preceeded by the carriage return character \r, windows style). You add this at the end of every number. Serial has an extra function for that: Serial.println() will print the parameter as ASCII and will add a carriage return and newline character. On the receiving side you read the bytes into a buffer, until you see this delimiter sequence. After that, you process the whole buffer. If you want to know, how this Serial communication is done in code, look at the SerialEvent example, that comes with the Arduino IDE.

What way you use for transmitting data, is up to you and depends on your needs. If you only want to transmit number data, nothing else, you can use byte data. For complex or diverse data types, you can use the ASCII representation.

EDIT: I have described above, that - when using ASCII data - you can use one or more special characters to delimit one message/number. The receiver can then distinguish between the numbers in that row of digits. This is just some kind of protocol, that you impose on the data. You state, that every message is ended with this special character, much like very sentence in the english language is ended with a dot.
An important requirement is, that the special character does not occure inside of a message/number. So cannot use the character '1' as delimiter, since it will also occur inside of your numbers and you would chop the numbers in the wrong way.
The same principle can be imposed as protocol onto a byte stream. For example: You define, that every message/number will be ended with a special byte sequence, so that the receiver always can say: "This is the whole data of a number and not just a part of it." As above, the special byte sequence must not occur inside of the valid data. You wrote, that your numbers are always in the range of 0 to 62000. This means, that the value 65535 will never occur as valid data, thus you can use it as delimiter. In hex 65535 is written als 0xFFFF, which means, that you send two bytes with every bit set to 1 (each byte having a decimal value of 255). In your code everytime, that you are receiving something, you can check, if you have got 2 consecutive bytes with the value 255 (or written as 0xFF). If not, write the data into a buffer. If yes, that means, that you can process the data inside the buffer to a number.
For sending that would look like this:
Serial.write(lowByte(number));
Serial.write(highByte(number));
Serial.write(0xFF);
Serial.write(0xFF);

Note: This protocol will make sure, that sender and receiver cannot get out of sync. But still the first reading after a transmission problem (for example that a byte got send before the receiver was ready) will be garbage. That will happen very very rarely, so for most people it's not a problem. There are more principles, that you can use in your protocol to mitigate those problems, if you want to. For example you can define another special byte sequence as the start of a message/number. Or you can calculate a checksum of the number and only use messages/numbers, that fit to that checksum.

Oh ok ty, I think it will help for sure (:

I have posted my code, sry it is not arranged coz I'm using it on my phone so can't see any option to arrange it.. It is not working, I'm trying a basic program to send and receive those high numbers.. Please check it, ty (:

Logic is not working I don't know what's the problem, please help me to solve it

@Mayank How it is not working? What behaviour do you actually see with that code? Do you use an external pulldown resistor for the button? And the receiver code will only react once, since it will get stuck as soon as one of the two values for r are received, because in the while loops r cannot change. Instead of while use an if statement for testing.

Note that, with binary transfer, if the receiver misses the first byte (maybe it takes longer than the sender to boot), it will get out of sync. It will stick the second byte of the first number together with the first byte of the second number, and get a bogus result. There are ways out of this (checksums, frame delimiters + escape code...), but they are not so simple. ASCII is way easier and should be preferred as long as throughput is not an issue.

Yeahhhhhh, I'm using external pull down resistor for button. I will try internal resistance if you want? Oh ok I will do those changes and see ty (:

Does ASCII way is much better tha Byte? I don't know how to use it, I will be happy to learn (:

Actually servo is stucked at 0° and not moving

Oh, so do I put \n and \r after every number in my previous code?  Does it will work fine?

Yes, after every number. The receiver has to distinguish the numbers, so you need a delimiter. Servo? Your code is not using a servo. Byte transmission is not that capable. It depends on what you want to send. Numbers are still ok. You can mitigate the out of sync due to startup problem by waiting a bit, before sending data. You can also impose some protocol onto the byte stream. For example you can choose a short byte sequence, that will not occur in your data (for example 0xFFFF), which can mark the end of a number. Then you cannot get out of sync.

If you want to use ASCII, look at the SerialEvent example of the Arduino IDE. That shows, how this is often be done.

Ty so much!! ((: after those changes it is working..  Ohh? Where I put that 0×FFFF.. Can you please explain it with a small example code?

Try something like this to send and receive/recombine two bytes:
Send side:
Serial.write (highByte (your unsigned int));
Serial.write (lowByte (your unsigned int));

Receive side:
if (Serial.available() >1){ // two byte received
upperByte = Serial.read();
lowerByte = Serial.read();
}
newInt = (upperByte <<8) + lowerByte;

Does I can get 257 as a output too? With that logic?

257 decimal = 0x0101.  highbyte = 0x01, lowbyte = 0x01.  x01 << 8 + 0x01 = 257 decimal, so sure.

Yes, you can use this method to send any value from 0 to 65535 (2^16 - 1). If you need larger values than that you can send an unsigned long using 4 bytes. That will give you a huge range of values. (0 to 2^32-1, which is over 4 billion.)

Oh cool! Ty ((:

What are upperbyte and lowerByte ? Int type data type?

bytes.  I declare them before setup() so they are global.  I declare all my variables there. Probably an abuse of how scope of variables was intended, but it works ok for the small embedded programs I create.

Oh got it... ty! (:


text:
OSCOKIRQ failed to assert with USB HOST and SD card
I am having an issue using a MAX 3421 EE based Arduino USB Host shield and an SD card shield. From my understanding, they should both function as long as they are using different CS/SS pins and only one is active at a time. I have connected the SD card CS pin to pin 4. I am trying to write a program that reads an ACM terminal and writes that data to a file on the SD card (see code below). When the SD card is not powered the USB host shield reads the ACM and prints it to serial fine. However, immediately when I connect the SD card shield power, it starts printing "ACM not ready." On a reset, it prints "OSCOKIRQ failed to assert."
Troubleshooting steps I have already tried:

External power source.
Removing SD card from the reader.
Commenting out all SD Card code.
Disconnecting USB Device (to see if initialization still works)

None of these steps have helped solve the USB initialization issue.
My code:
//Lots of Code from https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/acm/acm_terminal/acm_terminal.ino
#include <cdcacm.h>
#include <usbhub.h>

#include "pgmstrings.h"

// Satisfy the IDE, which needs to see the include statment in the ino too.
#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif

#include <SPI.h>
//#include <SD.h>

//https://github.com/felis/USB_Host_Shield_2.0.git
class ACMAsyncOper : public CDCAsyncOper{
public:
    uint8_t OnInit(ACM *pacm);
};

uint8_t ACMAsyncOper::OnInit(ACM *pacm){
    uint8_t rcode;
    // Set DTR = 1 RTS=1
    rcode = pacm->SetControlLineState(3);

    if (rcode)
    {
        ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
        return rcode;
    }

    LINE_CODING lc;
    lc.dwDTERate    = 115200;
    lc.bCharFormat  = 0;
    lc.bParityType  = 0;
    lc.bDataBits    = 8;

    rcode = pacm->SetLineCoding(&lc);

    if (rcode)
        ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);

    return rcode;
}

const int USBChipSelect = 10;
USB     Usb;
//USBHub     Hub(&Usb);
ACMAsyncOper  AsyncOper;
ACM           Acm(&Usb, &AsyncOper);

const int SDChipSelect = 4;
/*
const int maxLog = 10000;
volatile int logged = 0;
volatile long name = 0;
*/
void setup()
{
    Serial.begin(115200);
    Serial.println("Start");

    pinMode(USBChipSelect, OUTPUT); // Sets USB CS pin output
    pinMode(SDChipSelect, OUTPUT); //Sets SD CS pin output
    digitalWrite(SDChipSelect,HIGH);
    digitalWrite(USBChipSelect,HIGH);

    USBActive();

    if (Usb.Init() == -1){
    Serial.println("OSCOKIRQ failed to assert");
  }

    delay(500);
}

void loop(){
    String toWrite = "Error";

    toWrite = readACM();
    Serial.println(toWrite);

    if(logged>=maxLog){
        logged = 0;
        name++;
    }
    /*
    SD.begin(SDChipSelect);
    File dataFile = SD.open(String(name), FILE_WRITE);
    if(dataFile){
        dataFile.println(toWrite);
        dataFile.close();
    }*/
    delay(100);
}

//Activates USB and Deactivates SD
void USBActive(){
    digitalWrite(SDChipSelect,HIGH);
    digitalWrite(USBChipSelect,LOW);
}

//Activates SD and Deactiavates USB
void SDActive(){
    digitalWrite(USBChipSelect,true);
    digitalWrite(SDChipSelect,false);
}

String readACM(){
  Usb.Task();

  if( Acm.isReady()) {
       uint8_t rcode;

        /* reading the phone */
        /* buffer size must be greater or equal to max.packet size */
        /* it it set to 64 (largest possible max.packet size) here, can be tuned down
        for particular endpoint */
        uint8_t  buf[64];
        uint16_t rcvd = 64;
        rcode = Acm.RcvData(&rcvd, buf);
         if (rcode && rcode != hrNAK)
            ErrorMessage<uint8_t>(PSTR("Ret"), rcode);

        if( rcvd ) { //more than zero bytes received
            char rcvdData[rcvd];
            for(uint16_t i=0; i < rcvd; i++ ) {
                rcvdData[i] = (char)buf[i]; //printing on the screen
            }
            return String(rcvdData);
        }
    }
    return String("ACM Not Ready");
}

Thanks in Advance.

As I remember SD cards don't behave well on the SPI bus. They are blocking all other devices.

If they block all other SPI devices why do they still have a CS line? Isn't the CS line to select which device on the SPI bus to use.

Found this question, which suggests, that the problem lies with the cheap sd card modules, not with the cards themselves. I guess you use one of these modules, since you have to convert the 5V level of the Arduino to the 3.3V of the SD card.

Ok, I thought the SD card module was a bit too cheap but it worked fine on its own. Any suggestions for an SD card module (preferably MicroSD) that does this properly?

the Adafruit SD adapter is good


text:
Cannot POST to server. HTTP code -1. NodeMCU
I am trying to make a POST request with NodeMCU, but I get a HTTP status code -1.
Code:

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

#ifndef STASSID
#define STASSID "Wifi"
#define STAPSK  "123"
#endif

const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "https://laimonasjanutenas.000webhostapp.com/wifidata.php";

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");
  Serial.println("trying to post ");

  HTTPClient http;

  http.begin(host);
  http.addHeader("Content-Type", "application/x-www-form-urlencoded");

  int httpCode = http.POST("temp=1337");
  Serial.println(httpCode);
  http.end();
}

Serial monitor outputs this:
connecting to Wifi
........
WiFi connected
trying to post
-1

I can confirm that I can actually make a POST to the server. I tested in Postman using this:
https://laimonasjanutenas.000webhostapp.com/wifidata.php?temp=159

I have no clue what I am doing wrong. Feel free to make POST requests to the this server if needed. Thank you.

what status were you expecting? .... why do you say that you are doing something wrong?

Does it work if you use http instead of https? It looks like extra params are required for https: https://github.com/esp8266/Arduino/issues/1941

Yes it works! I changed the link from https to http and it worked :). Thanks

To elaborate on @ChrisCombs comment, you have work to do if you want to talk HTTPS. Please read : https://forum.arduino.cc/index.php?topic=515541.0


text:
Use Arduino to turn fan on / off
I have a simple fan.
When I plug it to GND and Vin it spins.
I'd like to have the ability to turn it on / off with code.
Any example will do, as long as it gets it to spin.
I have a NodeMCU board, if that helps.

Use a MOSFET as digital switch. Fan+ to Vin, Fan- to MOSFET drain, MOSFET source to ground, MOSFET gate to a digital pin of the Arduino. You can google MOSFET as a switch

Related if not dupe: https://arduino.stackexchange.com/q/54018/17196 and https://arduino.stackexchange.com/q/54145/17196

google images "mosfet switch low side"

Depending of the type of fan you are using, two solutions exist.

First one, use a MOSFET to drive the FAN from you nodemcu
Second one, use a relay to drive the FAN from your nodemcu

Things to consider :

The mosfet allow you to drive the fan without mechanical part moving.
The relay require some transistor and feedback diode to be driven by your µc.

What about a motor driver?

Motor driver in the end is just several mosfets connected in a smart way. It's unnecessarly complicated and redundant if fan just spins when you supply power. There is a very good chance that the fan already has a driver inside it (all computer fans do)

So I didn't have a transistor to do a MOSFET, but I did have a motor driver which I ended up using. From there it was just finding example code to use the motor driver, connecting it up and using it.


text:
Arduino programming with multiple loops
I was trying to program my Arduino (along with a connected motor controller) to switch from cycle to cycle with this program.  It doesn't seem to work however.  There's still plenty of storage space and dynamic memory, so those aren't the issue.  This is the program:
int EnablePin1 = 8;
int duty;
int period;
int cycle;

int PWMPinA1 = 11;
int PWMPinB1 = 3;
int PWMPinA3 = 6;
int PWMPinB3 = 5;

const byte CPin1 = A0;

int CRaw1;
void setup() {

    Serial.begin(9600);

    pinMode(EnablePin1, OUTPUT);

    pinMode(PWMPinA1, OUTPUT);
    pinMode(PWMPinB1, OUTPUT);
    pinMode(PWMPinA3, OUTPUT);
    pinMode(PWMPinB3, OUTPUT);

}

void loop() {
    digitalWrite(EnablePin1, HIGH); //enable the board
    for (duty = 0; duty <= 255; duty += 15)
    {

        analogWrite(PWMPinB1, 0); //Set pinB to 0, when speed is written to pinA

        analogWrite(PWMPinA1, 255);
        delay(850);
        if (PWMPinA1 == 11)
        {
            PWMPinA1 = 3;
            PWMPinB1 = 11;
        }
        else
        {
            PWMPinA1 = 11;
            PWMPinB1 = 3;
        }
   }
   analogWrite(PWMPinA1,0);//end at max speed
   analogWrite(PWMPinB1,0);
   CRaw1 = analogRead(CPin1);

   Serial.println("Feedback");

   Serial.print(CRaw1);

   delay(2000);
   //analogWrite(PWMPinB3, 0);
   for (duty = 255; duty >= 0; duty -= 51) // ramp down speed
   {
       //analogWrite(PWMPinA1, duty);
       analogWrite(PWMPinB3, 0);
       analogWrite(PWMPinA3, 255);
       delay(period);
       //delay(cycle);
       if(PWMPinA3 == 6)
       {
           PWMPinA3 = 5;
           PWMPinB3 = 6;
           //period = 850;
       }
       else
       {
           PWMPinA3 = 6;
           PWMPinB3 = 5;
          //period = 2500;
       }
   }
   analogWrite(PWMPinA3, 0); //set to 0 speed
   analogWrite(PWMPinB3, 0);
   delay(2000);

   digitalWrite(EnablePin1, LOW);// Toggle enable to reset the power chips           if we have had an overcurrent or overtemp fault

   for (cycle = 1000; cycle < 9000; cycle += 4000)
   {
       //cycle=period;
       period=cycle;
   }

 /*for (cycle = 2000; cycle <= 3000; cycle += 1000)
   {
       //cycle=period;
       period=10000;
   }*/
   for (cycle = 9000; cycle >= 1000; cycle -= 8000)
   {
       period=0;
   }

   //delay(2000);  // Swap pins to make the motor change direction

}//end main loop

I've also tried having the cycle loops be this:
 for (cycle = 0; cycle < 9000; cycle += 3000)
 {
     //cycle=period;
     period=cycle;
 }
 for (cycle = 9000; cycle >= 0; cycle -= 9000)
 {
     //cycle=period/3;
     period=cycle;
 }

But that didn't do anything (I can see what PWM pins are powered through LEDs, and the first attempt, the LEDs only lit up for 1 second and the 2nd, they didn't light up at all.

doesn't seem to work .... this is a very poor description of observed results .... it contains no information that could be used to solve the problem ............ what do you expect to happen? .... what did happen? ....  and what is your question?

Why are you changing the values of the pin numbers? Doesn't seem good. And what should the for loops actually do? Currently they only set the variable period multiple times without doing something with it. The second loop only runs once. The variable period is not used ever again. This code part does absolutely nothing. You need to explain way more, what you want to achieve and what the problems are with this.

duty should be renamed: it's not a duty cycle, and its name is misleading. period should be initialized before use. The loops over cycle should be removed: they serve no useful purpose (and the compiler will remove them anyway). The biggest issue is that, on reading the program, its purpose is not clear at all. And the description in your question (“switch from cycle to cycle”) makes no sense. If you want to have any hope of receiving a useful answer, you should write a clear and complete description of what the program is supposed to do.

First things, try to use multiple function and call it from the loop()
You can use some code magic for dealing with multitasking on Arduino.
It's a bit tricky to understand but it's working.
Here is an example :

const int BROCHE_LED_1 = 13;
const int BROCHE_LED_2 = 12;
const int BROCHE_LED_3 = 11;

const unsigned long BLINK_INTERVAL_1 = 1000;
const unsigned long BLINK_INTERVAL_2 = 500;
const unsigned long BLINK_INTERVAL_3 = 2000;

void setup() {

  pinMode(BROCHE_LED_1, OUTPUT);
  pinMode(BROCHE_LED_2, OUTPUT);
  pinMode(BROCHE_LED_3, OUTPUT);

  digitalWrite(BROCHE_LED_1, LOW);
  digitalWrite(BROCHE_LED_2, LOW);
  digitalWrite(BROCHE_LED_3, LOW);
}

void loop() {

  task_led1();
  task_led2();
  task_led3();
}

void task_led1() {
  static unsigned long previousMillisLed1 = 0;
  static byte etatBrocheLed1 = LOW;

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillisLed1 >= BLINK_INTERVAL_1) {

    previousMillisLed1 = currentMillis;

    etatBrocheLed1 = !etatBrocheLed1;
    digitalWrite(BROCHE_LED_1, etatBrocheLed1);
  }
}

void task_led2() {
  static unsigned long previousMillisLed2 = 0;
  static byte etatBrocheLed2 = LOW;

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillisLed2 >= BLINK_INTERVAL_2) {

    previousMillisLed2 = currentMillis;

    etatBrocheLed2 = !etatBrocheLed2;
    digitalWrite(BROCHE_LED_2, etatBrocheLed2);
  }
}

void task_led3() {
  static unsigned long previousMillisLed3 = 0;
  static byte etatBrocheLed3 = LOW;

  unsigned long currentMillis = millis();

  if(currentMillis - previousMillisLed3 >= BLINK_INTERVAL_3) {

    previousMillisLed3 = currentMillis;

    etatBrocheLed3 = !etatBrocheLed3;
    digitalWrite(BROCHE_LED_3, etatBrocheLed3);
  }
}

Second things, Try to use Real time operating system
You can try to use FreeRTOS, it's work with most arduino and you got lot of infos on the web.
It make multi tasking way more easy than the previous example.
Here is the Docs i've found


text:
How to read high voltage (40-65v) from a Solar Battery bank
I would like to monitor the battery voltage of a 48v solar battery system. The expected voltage range is 40-65v.
I have tried creating a voltage divider with 2 resistors but with all values I have tried one resistor almost melts as soon as you connect to battery.
Also, using a voltage divider creates a (small) drain which I would like to avoid.
Can anyone suggest a way of reading high DC voltage (40-65v) with and Arduino (really I'm using an ESP8266)?
If Voltage Divider
please suggest resistor types (e.g. 1/4watt or 1-2% etc, I'm new here but know there are many types) and values that I could read with A0 (analog pin, max 5v)
Can I use a MOSFET to connect the voltage divider just before reading the voltage? How?
or another way
like a circuit (from AliExpress) or using some other component that would be greatly appreciated.
So far this article has been helpful, it talks about a voltage divider with a opamp to get more accuracy, but I need a bit more advice from someone that knows more than myself.
https://openenergymonitor.org/forum-archive/node/11011.html
Thanks in advance for any help.

Is this what you are trying to do? https://electronics.stackexchange.com/questions/42710/how-to-read-high-voltages-on-microcontroller

the resistance of your voltage divider (the sum of both resistors) needs to be that high so that the current is rather small, milliamps or less (to prevent the melting of the resistors and the discharge of the battery). Note that the proportions of both resistors define the voltage level for the analog in while the sum of both resistors are relevant for the current. So higher is better but unfortunately you also need 2) that resistance to be low compared to the input impedance of the analog input. This is where the OPAMP might come into play. Both are adressed in the link posted by VE7JRO.

You need a voltage divider with resistors that have large values.

...but with all values I have tried one resistor almost melts as soon as you connect to battery.

This suggests that you have been using values that are too low.
So lets go through the calculations to select good resistor values.
1/4 Watt resistors are common and easily available so I will base my calculations on that. These calculations will also be suitable for 1/2 Watt and 1 Watt resistors.
I am also going to add some margin above the 65V max that the solar panel can output (plus it makes the math easier)
Max Voltage = 100V

The voltage Divider:

Let's simplify. Almost all of the current will be going from your source, through the resistors (R1 & R2) to ground. Let's simplify by initially calculating the resistance required if R1 & R2 were combined into a single resistor:
From V = I x R
And P= V x I
Minimum resistor = V^2 / P
R = 75^2 / 0.25
R = 22500 Ω minimum
I would go further and say double that because I never like operating a resistor right on its maximum power rating. ie  the minimum that R1 + R2 should equal is 50kΩ.
Lets play it safe and say that R1 + R2 is 100kΩ. The ESP8266 ADC pin input voltage range is 0 to 1V. Input is 0-100 V (which covers the required 40-65V range). Now all we have to do is calculate for R1.
Note: Most ESP8266 development boards come with an internal voltage divider. For these boards the input range is 0 to 3.3V.
Edit: The OP tells me that they get a max analog reading at 3.0V not 3.3V. Adjust the below calculations for an input voltage of 3.0V not 1V.
The formula to calculate the output voltage is:

Vout / Vin = R2 / (R1 + R2)
1 / 100 = R2 / 100kΩ
0.01 = R2 / 100k
Therefore R2 = 1k Ω
R1 = 100k - R2 = 99kΩ
I would up R1 to 100kOmega; as it will only result in a 1% error.
So R1 = 100kΩ and R2 = 1kΩ

Values of R1 = 49.5kΩ and R2 = 500Ω would also work.
In this case R1 could be made up of 2-3 resistors in series:
47KΩ
2.2KΩ
300Ω or 330Ω (optional)

The raw ADC input on the ESP8266 chip is 0-1V with a high input impedance (~20M). This means an op-amp buffer is not needed.
However, if you are interested, a op-amp circuit can be built from a 741 IC (among others) and is configured like this:

Thank you very much for putting your time into that answer. I tested a few ESP8266 dev boards I had and to get 1024 on the Analog pin it only requires 3v on all my boards, specs do say 3.3 but all voltages higher than 3 just = 1024 so I will factor this in to my calculations, thank you again!

It sounds as if you have tried using far too small a value resistors. For example, if you used resistors totaling , say, 1,000 ohms across a 50V supply then they would dissipate V^2/R watts = 2.5W. Standard 1/4 watt resistors are going to melt when overloaded 10 times.
So it boils down to picking a pair of resistors that
1) Are working within their wattage rating.
2) Give a convenient scaling factor.
3) Draw an insignificant amount of current relative to the ratings of the solar panels.
The design of any voltage divider also depends on the input impedance or load imposed by the ESP8266. Referring to the ESP8266 Community Forum the analog input imposes a 50nA load, but they also state that the maximum input voltage is only 1V (equivalent to 20 M ohm impedance). The Adafruit forum also suggests that 1V is the maximum. Maybe the board you have has different built in scaling.
For the sake of argument, let us assume the following
Voltage range to be measured = 40 - 65V
Maximum input voltage of pin A0 = 1V
Pin A0 can draw 50nA and this should not effect the measurement by more than 1 in 2048 (half the least significant bit of the ADC).
The current through the voltage divider should therefore be at least 2000 * 50nA = 0.1 mA. This almost certainly meets the requirement of not significantly loading the battery.
So based on the low end of the voltage range the divider chain should total in the region of 45V / 0.1mA = 450K ohms. The two resistors need to be in the ratio 64:1 in order to drop a 65V input to 1V. Referring to standard resistor values, 360K and 5K6 in series will be very close to 64:1 (64.28:1). They will draw a maximum of 65V/(360K + 5K6) = 0.18mA and the 360K resistor will dissipate about 10mW.
So standard quarter watt E24 series 1% resistors should be suitable.

Wow thank you so much for a great explanation.
I have a few ESP8266 devices, all analog pins can take up to 5v but I think in reality the A0 (ADC) should be max of 3.3v (see Wemos
Any chance you could let me know the values to go from 60V to 3.3v?

Your Vin is 60V and Vout is 3.3V , Assume R1 and R2 have same value, then calculate the values of R1 and R2 using above formula i.e. Vout = (R2/(R1+R2))*Vin;

I have not use your particular ESP8266 board, but it may be that 3.3V is the maximum voltage you can apply to the A0 input without causing damage. The input voltage that will generate the full scale 10 bit encoding (1024) may well be different. You need to do a bit more research, either by finding a more detailed data sheet or testing it on the bench with a low voltage source, a meter and a program that loops reporting the ADC output.

Hi @PeterJennings , I have tested the boards I have, they read max input (1024) at 3v (not 3.3 like the specs say) so I'll adjust accordingly, thanks.


text:
creating HTTP persistent connection, to create 'smooth' data over GSM sending
Project goals

Send data over GSM to firebase
Fast sampling - need to send 16 bytes every half second to firebase
Send data using GET or POST to server with PHP script, that redirect data to firebase

Problems --
Extremely low data rate!

Using standard GET or POST request from client(arduino) side, is impossible to achieve second (2) project goal.
To send data correctly I need to close connection with server, so next data package unfortunately waits(2-6 seconds) for establishing a new connection.
Is this quite nonsense? I'm using ArduinoHttpClient library.

My actual Nonsense Connection and fully useless, but works

while(1){

http.post("/test.php","application/x-www-form-urlencoded","data=0");
http.stop(); //closing connection with server

//next instruction take over 5 second to establish new connection :(

http.post("/test.php","application/x-www-form-urlencoded","data=0");
http.stop(); //closing connection with server, whyyy?
}

Data are send once per 2 - 6 seconds, this is not even funny. NEED to send data every 0.5 seconds!
So I decided to create super solution, which not works :C
while(1){
    http.post("/test.php","application/x-www-form-urlencoded","data=0");
    delay(xxx);
//no connection closing, no wasting time for establishing new one :)
}

Just tell my why this connection is not "Keep-Alive", also used with

http.sendHeader("Connection: Keep-Alive"); or
  http.connectionKeepAlive();

//First run
http.post(blabla);// returns value: 0 & data are logged into firebase
//Second run
http.post(blabla);// returns value: -2 & data are not logged in firebase

my test.php file
<?php
require_once 'firebaseLib.php';
$url = 'https://czujniki-aa5ca.firebaseio.com/';
// --- Use your token from Firebase here
$token = ':-CCCCCCCCCCCCCCCCCCCCCCC';

$arduino_data_post = $_POST['data'];
$firebasePath = '/';

$fb = new fireBase($url, $token);
$response = $fb->push($firebasePath, $arduino_data_post);
sleep(2);

does the 'modem' disconnect from network with no active connection? search for a setting to keep the GPRS connection connected

@Juraj i think modem doesn't turn off networking itself, I will check the code and post back. If it will not work, i will test it on pure AT commands.

try in the library in HttpClient.h make resetState() public (by moving 'protected:') and then in sketch call resetState() before post()

@Juraj [link] (https://ibb.co/7rc2Yt8) look at the screenshot. resetState() is working fine, and now we dont need to use stop(), but essentially it works like .stop(); Look at the timestamp, delay between data uploading is still awful. 0 means 0 error code, so data are send successfully

The ArduinoHttpCliemt library's HttpClient.stop() method does two things. It resets the state of the HttpClient object and stops the underlying Client connection (TCP connection). If HttpClient.stop() is not called, the internal state is not good to call get() or post() again.
The method resetState() is called in HttpClient.stop() to reset the internal state of the HttpClient object. But resetState() is protected. To call it we must modify the library header file.
In HttpClient.h make resetState() public (by moving 'protected:') and then in sketch call resetState() before post(). It will put the HttpClient object into initial state without disconnecting the underlying TCP connection.

Yes that's work, but time between POST's is still huge. [link] (ibb.co/7rc2Yt8) screenshot

add #define LOGGING at the beginning of HttpClient.cpp, to see if it uses the connection or reconnects

[link] (https://ibb.co/k88TXXm) logging returns: connection already open, connected. Look at time, delay increases while new posts are sended. Is it opening new connections, instead of using first one?

no it always prints Connected. so it is reusing the connection. that was your question. the request takes time, not the connection.

try to read the response with int statusCode = client.responseStatusCode();

[link] (https://ibb.co/Q9ZHxJN), with responseStatusCode(); arduino client do nothing

so it doesn't get a response. check the server

[link] (https://ibb.co/gJxQSfw) now i setted it to make reconnect every POST. And it seems to be paradox, because we got smaller delays, if you look at the timestamp. Quite frustrating, keep-alive should lower time between requests, but it's working in the opposite direction

because not the new connection is the problem as you can see on the output times


text:
MKR1010 serial communication
Is communication using tx/rx from an arduino to mkr1010 the same as any other serial communication?
I ask because I can't find any tutorials or info on connecting an arduino to mkr1010, but there are plenty on connecting one arduino to another.

it has Serial1 on RX/TX pins

Though you need level shifting, since the Mega is a 5V device, while the MKR1010 works with 3.3V and cannot tolerate 5V on it's pins. The UART pins are only unidirectional, so it should be sufficient to put a voltage divider between Arduino TX and MKR1010 RX.


text:
Connecting multiple RS485 together
I am trying to build communication across multiple Arduino using RS485. When i am trying to connect 3 Arudino nano together using breadboard my code doesn't reach slave where as if i just if i do direct connection between 2 RS485 without breadboard it works but i use breadboard for 2 it doesn't work. Am i missing any setup here?
Breadboard connection - A & B are connected to + & - of both RS485.
Working connection - A & B of first RS485 connected to A & B of 2nd RS485.

show a picture of the breadboard version

It is possible you have too many resistors on the RS485 bus. From the RS485 wikipedia page there is this quote:

Ideally, the two ends of the cable will have a termination resistor
  connected across the two wires.

This may explain why you can use 2 of your RS485 interfaces but not 3.  Consider removing the resistors from the RS485 board in the middle if possible.

problem is even if i use only 2 with breadboard it doesn't work. It only work when i connect them directly ? Do i have to use any resistor on breadboard ?

Breadboards are not good with high frequencies.  Try slowing down the baud rate.  Also check if you are using the breadboard correctly.  So, 2 connected using wires works?  And 3 connected using wires works?  But 2 connected using the breadboard does not work?  And exactly which TTL to RS485 adapter are you using?  Have you added termination resistors to the ends of your RS485 bus?

The thing with termination resistors is, that it's value should be the wave resistance of the specific cable at that specific frequency. I don't think, that this is critical here, as long as the OP does not use too high baudrates. But the breadboard might be the real problem here.


text:
How to control two 12 V motors with the dual MAX 14870 Motor Drive Shield for Arduino?
How to control two 12 V motors with the dual MAX 14870 Motor Drive Shield for Arduino?
I am a beginner and I need help on how to control two 12 V motors using the Pololu dual MAX 14870 Motor Drive Shield for Arduino Uno.

I had attached the screenshot for this
This picture tells you about the Arduino Connection with the with the SHIELD.

EN (Enable Pin) is used to enable and disable the motor drivers. As it is inverted SET this PIN HIGH will Disable the Motors and vice versa.
DIR pinS is used direction of rotation. It highly depends upon your connection, setting this PIN HIGH LOW will make the motor rotation from CLOCKWISE & ANTI CLOCKWISE or vice versa depends upon your hardware connection.
PWM pins are used to control the rotation speed of the MOTOR. Driving PWM signal on this pin will adjust your rotational speed. MAX PWM frequency suggested is 50Hz.
Fault is the INPUT PIN to Arduino with ACTIVE LOW signal indicating some kind of fault is there.

du i have to download and install a library for that shield.

No you can use simple digitalWrite and analogWrite instructions for handling all the pins.

thank you, you have been most helpful.

i'v been looking all over for help, i'm surprised there are not tutorials on how to use the Dual Max14870 Motor Driver Shield

You can use this l293d with arduino for referral as they have similar properties. They are not exactly same but it will help you understanding with the CODE.


text:
Controlling multiple 12v solenoids with 5v relay modules (Arduino Reset Issue)
I have 4 12V(1A) solenoids running on a 12V(4.16A) power supply.
Each solenoid circuit is controlled by a 5V relay module connected to the Arduino Uno (powered by USB).
The solenoids actuate properly but eventually the Arduino resets, typically when multiple solenoids are turned on/off in fast succession. This is accompanied by random character artifacts on the LCD display (connected to the Uno) during operation but before the reset.
From what I've gathered there are back EMF surges occurring when the solenoids lose their charge. Here are some possible remedies I've found:

Add a flyback diode (IN4004) to each solenoid circuit. (Redirect the surge)
Add a capacitor (4700 - 10,000 uF) to the 5v supply (from the Uno) for the relays. (Filter the surge)
Provide a separate 5v power source to the relay modules instead of using power from the Uno. (Isolate the surge)

Any input on which solution(s) should be applied or other possible causes for the Uno reset and LCD distortion is appreciated.

Those 5V relay modules already have flyback diodes, so I don't see how providing a separate 5V source for these modules will help. A schematic would certainly help here.

Some of those 5V "digital" relays can be wired using a separate power supply for the relays and the Arudino. You have to move a jumper to use separate power supplies.
My guess is that you're powering both your Arudino and your relay coils from the same 5V supply, and when you energize all 4 relays at the same time you draw too much current and the Arduino doesn't get enough voltage and resets.
Read up on your relay modules, and either re-wire them using 2 different 5V supplies, or switch your 5V supply to a higher current supply. (and possibly adding a filtering capacitor to the Arduino to smooth out the power fluctuations as the relays energize and de-engergize)
I used a 4-channel relay unit in a project of mine that has optical isolation of the relay control lines, and can be wired to use separate power supplies for the Arudino and the relay power. When wired with separate power supplies, the relay's control lines just draw CMOS logic levels to control the different relay channels, and get the power for the coils independently from the microcontroller's power.

Here is another path to explore :

Try to use separate rail for the 5v relays
Use a transistor or darligton array (such as ULN2003) for controling your 5v relay.
ALWAYS put a feedback diode when you use an inductive load it can break your Arduino !!

My analyse :

Arduino and many other µc have limited output current on IO, be sure to not overload these value by using transistor or darligton array.
The voltage regulator on the Arduino can provide around 200 mA of power. I you are overloading the value use an external power supply for your circuit.
The solenoid can draw lot of current of the power supply, try to measure if a voltage drop occur on loads. It can cause the arduino to reset due to low voltage.

The relay modules seem to already have to needed circuitry (transistor and flyback diode). What do you think? You are right, that the symptoms suggest a voltage drop. I think that is the way to investigate further.

If you have already put the required circuitry for driving properly each relay. I think you can investigate for voltage drop.

Would adding an additional flyback diode (assuming the relay module already has one) to the circuit cause problems? I'll find a suitable 5v rail for the relays, this seems like the culprit. 4 relays, LCD screen, MIDI In/out, and an IR receiver are likely drawing more than the 200 mA available.

I don't see how are the relays optoisolated. there is no separate VCC and ground input for the "behind the optocoupler" circuit.


text:
Mega <> esp8266 comms sending baffling data
I have Wemos Mega-ESP8266 board. I have uploaded a simple WebSocket server on the ESP...

#include <ESP8266WiFi.h>
#include <WebSocketsServer.h>

const char* ssid     = "SKYNET";
const char* password = "yourdogsfavouriteauntysmaidenname";

WebSocketsServer webSocket = WebSocketsServer(81);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) {

    //Serial.printf("[%u] get Message: %s\r\n", num, payload);

    switch(type) {
        case WStype_DISCONNECTED:
            break;

        case WStype_CONNECTED:
            {
              IPAddress ip = webSocket.remoteIP(num);
              Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\r\n", num, ip[0], ip[1], ip[2], ip[3], payload);
            }
            break;

        case WStype_TEXT:
            {
              String _payload = String((char *) &payload[0]);
              Serial.print(_payload);
            }
            break;

        case WStype_BIN:
            {
              hexdump(payload, lenght);
            }
            // echo data back to browser
            webSocket.sendBIN(num, payload, lenght);
            break;

    }
}

void setup() {

  // Set up serial comms
  Serial.begin(115200);

  // Set up WiFi
  WiFi.begin(ssid, password);
  while(WiFi.status() != WL_CONNECTED) {
     Serial.print(".");
     delay(200);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  delay(500);

  // Set up web socket
  Serial.println("Start Websocket Server");
  webSocket.begin();
  webSocket.onEvent(webSocketEvent);
}

void loop() {
  webSocket.loop();
}

I upload via the Arduino IDE & everything looks fine except the ESP doesnt send any information back through the serial monitor (yes I have the DIP switches correct for serial <> ESP comms).
I tried to see if was sending anything through the Mega via Serial3, the mega code (DIP switches set accordingly & ESP serial switch set to RX3). Mega code...
// Input buffer from ESP8266
String temp;

void setup() {
  // Set up serial comms
  Serial.begin(115200);   // Debug to Serial Monitor
  Serial3.begin(115200);  // From ESP8266
}

void loop() {
  while (Serial3.available()) {
      Serial.println(".......");
      Serial.println("In from ESP8266");
      temp = Serial3.readString();
      Serial.println(temp);
      Serial.println(".......");
  }
}

So now I get 2 one time messages to the serial monitor..
.......
In from ESP8266
[WS-Server] Server Started.

.......
.......
In from ESP8266
pm open,type:2 0

.......

I have no idea where these messages are being generated or why the ESP isnt sending the serial messages on set up eg the IP address for the ESP etc.
Any idea what's going on here?
Edit 1: Addition info asked for in comments (or at leat I think this is what was asked for)

Edit 2:
DIP switch settings for flashing the ESP - OFF, OFF, OFF, OFF, ON, ON, ON
DIP switch settings ESP > serial monitor - OFF, OFF, OFF, OFF, ON, ON, OFF (RX switch to TX0)
DIP switch settings for ESP > Mega > serial monitor - ON, ON, ON, ON, OFF, OFF, OFF (RX switch to TX3)
Edit 3 I have to press the red reset button after flashing the ESP8266 & it works BUT as soon as I unplug & restart nothing again! The client connects, sends the same data but it doesnt get echoed back via the serial comms. The only way to get to work again is to reflash the ESP8266 and hit the reset button.
Edit 4 Swapped out the board & now nothing works again. Uploads look fine but no serial comms at all from the ESP8266.

@Juraj have added (I think) the information you requested to the OP

sorry. I read then the question again and it is not about logging. (but set "Debug port" to None and don't use "Wemos D1 R1". use "Generic esp8266")

@Juraj just reflashed using "Generic esp8266" & no debug port & got a string of gibberish but nothing else. Flash mode set to DOUT (compatible)

ahh right OFF, OFF, OFF, OFF, ON, ON, ON to flash the ESP

@Juraj DIP switch info added to OP

The esptool auto-reset feature by default sets io 0 LOW over the RST line and then makes a reset over the DTR line to put the esp8266 into flashing mode. After the upload the esptool resets the board over the DTR line.
On this board Mega+WiFi, only the DTR line is wired like for AVR MCU. For flashing the io 0 pin is put LOW with the pin 7 of the DIP switch manually. So the reset after upload sets the esp8266 back to flashing mode.
The esp8266 arduino package changed from version 2.5.0 the upload tool to the python version of the esptool which makes this reset after upload. This reset can be turned off by changing the command line of the esptool in platform.txt (--after no_reset in tools.esptool.upload.pattern before write_flash)

if you don't like the DIP switches, you can upload to esp8266 over the ATMega https://forum.arduino.cc/index.php?topic=519181.0


text:
Wifi stopped connecting (Wemos D1 Mini)
I am stumped.  I have a few Wemos D1 Mini boards that were working on the local WiFi yesterday, yet today none of them will connect.  More puzzling is that I can flash Tasmota on them and they all connect to the WiFi, but none with this code that was working yesterday.  Any tips would be appreciated.

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(wifi_ssid);

  //Connect to WiFi network so we can reach the MQTT broker and publish messages to topics.
  WiFi.mode(WIFI_STA);
  WiFi.begin(wifi_ssid, wifi_password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.print(F("WiFi connected, "));
  Serial.print(F("IP address: "));
  Serial.println(WiFi.localIP());
}

did you update the esp8266 boards package?

Thanks for the response.  No updates- I just turned on my PC to continue on my project from the previous day, and none of the Wemos devices will connect to the WiFi.  But I can flash them with Tasmota and they connect to WiFi, so it's not a hardware issue.

I think it problem with your wifi master or with your slaves. But if few slaves can't connect to master wifi it can't be problem with your slaves. That restart your computer.
It can be problem with avrdude or Arduino IDE.

and what version of the arduino esp8266 package you use? does it use the same SDK version as the Tasmota firmware?

It looks like Version 2.2.2 of the WiFiesp library.  But I've changed nothing.  The sketch flashed and worked yesterday, but not today.

2.2.2 is very old. install 2.5.2

I went to a PC that has never seen Arduino- installed the latest IDE, the latest esp8266 boards and the latest esp8266WiFi library.  Same result.  Itis starting to look like a Router problem, but why are esp nodes compiled earlier still connecting with no problem?  Why can Tasmota connect now with no problem?

Fixed.
My router is ancient and does not support WPA.  As of ESP8266WiFi library Version 2.5.0, WPA is is the preferred mode.  The solution is to get a better router, or add WiFi.enableInsecureWEP(); before calling WiFi.begin().
WiFi.enableInsecureWEP();
WiFi.begin(wifi_ssid, wifi_password);

Solved.  (sort of).  This is a working workaround.
I have determined that if I use ESP8266WiFi library Version 2.5.0 or later, all I get from WiFi.status() is WL_NO_SSID_AVAIL.
By reverting to ESP8266WiFi library Version 2.4.2, I can get a connection with the same sketch.
(Juraj's comments pushed me in the direction of trying older library versions.)

Assuming that it's not something silly and accidental like the password or ssid being changed in your code, there are two things you may be running in to:

The WiFi.begin() function is technically not needed more than once. Values written with it are stored in a separate part of flash memory that is not overwritten by any sketch uploads. Since it's stored persistently, it may start connecting before your connection code is called. This causes a race condition that triggers a bug in the library that is, to my knowledge, still present, and can break the WiFi subsystem. If this has happened, the reason that the other firmware might work is if it fixes the error or somehow uses a different method.
You can work around this by waiting a few seconds and then trying to connect if it's not currently connected.
Try this fix: https://github.com/kentaylor/EraseEsp8266Flash to see if that's the problem. Alternatively, you can try some of the options in the first link of my next item to see if those work for this purpose.
Remember how I said that the functions persist data in flash? That has a limited write count, and no, that partition has no wear-leveling. After so many writes (and, since begin() is called in setup, it does so every time the device starts or wakes!) it will fail to hold the correct values. The endurance can be quite poor on some cheaper flash devices (and cheaper boards). But, if you want to keep using begin() to set up the WiFi (rather than set it once the normal way and then make sure begin() isn't called again by your code), delete the stored parameters (Does the ESP8266 somehow remember wifi access data?) and then turn off persistence (esp8266 advertising AP even when flashed with custom firmware). I also suggest running the following code fragment to turn off persistence and then stop turning it off (since THAT change persists too!):
if (WiFi.getPersistent()) {
  WiFi.persistent(false);
}

This latter case is known to break Arduino projects, but NOT nodeMCU Lua ones. If the Tazmota firmware uses a different method, it could also ignore this issue but your code might experience it. To test this, try running the code on a different board (can be the same type, just so long as it's not the same one).

the SDK doesn't write the same configuration value to flash

Did they fix that, or was this always the case? I was under the impression that it did this at least at one point.

Thanks for the useful information.  Is the "Erase Flash: All Flash Contents" in the Arduino IDE different from Kent Taylor's program?  I've tried the same sketch on a few Wemos D1 Minis and a couple of NodeMCU boards.  When using ESP8266WiFi library Version 2.4.2, they all compile, upload to the ESP, and connect to the WiFi.  When using ESP8266WiFi library Version 2.5.0 or later, none of them connect to the WiFi.  I strongly suspect my Router, even though I rebooted and later reset it to the original setup. Time for a new router.

@RDragonrydr, AT firmware reference Appendix 'A' Notice


text:
Arduino components
I’m teaching and learning coding with MicroBit and was wondering if these components are compatible with MicroBit. The specific kits labeled for MicroBit are twice the price but the components look similar. Just trying to save a few bucks. Would this kit work with my MicroBit?

That is a whole collection of components, most of them simple electronic components not specific for Arduino. Some components are more complex, but they also should work with the microbit. This is seen from the first glance, I didn't looked into everything in detail. What can be done simultaneously on the microbit depends more on what you try to build. What components did you see, that where marked compatible with Microbit? It might be easier to point out devices, that are microbit specific instead of the one which are not.

It looks like the MicroBit runs on 3.3V versus 5V for most Arduino boards. You'd need to use 3.3V components.
It looks like the kit you linked to is built for (and includes) a 5V Arduino, so those accessories would not work with your MicroBit.
There are other Arduino boards that run on 3.3V. Look for 3.3v accessories. Those should work.
EDIT:

I assume that the MicroBit is capable of I2C interfacing. If so, you should look at the SparkFun Qwiic system. It's a setup with 3.3V I2C serial interface in a 4-wire ribbon cable with a standard connector. You can easily daisy-chain Qwiic devices by just plugging Qwiic cables between them, and they are reasonably priced. I bought some of them thinking I could use them with my Arduino projects, only to discover that they use 3.3V, so I can't use them without I2C voltage translation interfaces, which makes them much less appealing.

Thanks. For speedy response

See the edit to my answer, talking about SparkFun Qwicc devices.


text:
Code with if multible conditions
My project has 4 float switches, 2 valves and 3 pumps. I created a sketch and uploaded it. But my project keep all "OUTPUT" at "HIGH" all the time. I couldn't find what the problem, can you help?
This is my sketch:

#include <DS3231.h>
#include <Wire.h>
#include <LiquidCrystal.h>
DS3231  rtc(SDA, SCL);

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int x = 45;
int y = 47;
int z = 41;
int w = 43;

int WaterIn =  40;
int WaterOut = 42;

int Pump1 = 25;
int Pump2 = 24;
int Pump3 = 27;

void setup()
{
  rtc.begin();
  lcd.begin(16,2);
  // Start the I2C interface
  Wire.begin();
  // Start the serial interface
  Serial.begin(9600);
  //rtc.setDOW(TUESDAY);     // Set Day-of-Week to SUNDAY
  //rtc.setTime(1, 15, 0);     // Set the time to 12:00:00 (24hr format)
  //rtc.setDate(6, 6, 2017);   // Month, Day, Year

 //Setup FLoat Switch Pins
  pinMode (x, INPUT);
  pinMode (y, INPUT);
  pinMode (z, INPUT);
  pinMode (w, INPUT);

 //Setup Irrigation Valves
  pinMode(WaterIn, OUTPUT);  //irrigation "in" valve
  pinMode(WaterOut, OUTPUT);  //irrigation "out" valve

//Setup Pumps
  pinMode(Pump1, OUTPUT);
  pinMode(Pump2, OUTPUT);
  pinMode(Pump3, OUTPUT);
}  // end of setup

void Calendar(){

 lcd.setCursor(0,0);
 lcd.print("Real Time Clock  ");
 lcd.setCursor(0,1);
 lcd.print("Time: ");
 lcd.print(rtc.getTimeStr());
 delay(1000);
 lcd.setCursor(0,1);
 lcd.print("Date: ");
 lcd.print(rtc.getDateStr());
 delay(1000);
 lcd.setCursor(0,1);
 lcd.print("Day: ");
 lcd.print(rtc.getDOWStr());
 lcd.print("           ");
 delay(1000);
 lcd.setCursor(0,1);
 lcd.print("Temp: ");

 lcd.print(rtc.getTemp());
 lcd.print(" C");
 lcd.print("          ");
 delay(1000);
}  // end of setup

void Valves(){
    int pinToTurnHigh = 24;
    if ((x == HIGH) && (y == HIGH) && (z == HIGH) && (w == LOW))  //Condition 1
    {
        pinToTurnHigh = WaterIn;
        pinToTurnHigh = Pump1;
        pinToTurnHigh = Pump2;
        pinToTurnHigh = Pump3;
    }
    if ((x == LOW) && (y == LOW) && (z == HIGH) && (w == HIGH))  //Condition 2
    {
       pinToTurnHigh = WaterOut;
    }
    resetAllPumpValve();
    digitalWrite(pinToTurnHigh, HIGH);
}  // end of setup

void resetAllPumpValve(){
     digitalWrite(WaterIn, LOW);
     digitalWrite(Pump1, LOW);
     digitalWrite(Pump2, LOW);
     digitalWrite(Pump3, LOW);
     digitalWrite(WaterOut, LOW);
}  // end of setup
void loop()
{
    Calendar();
    Valves();
    resetAllPumpValve();
}  // end of loop

use serial.print() to display debugging information on the serial console .... verify that the program flow is as you expect it to be

I'm new with arduino, can you make it clear? You mean replace lcd.print () to serial.print()?

No, rather, in addition to the lcd.print() commands. This way you can see on the serial monitor where your code is going during execution. delay() may also come in handy.

chrisl made an excellent analysis of your program and the problems
therein. I would just want to add a point about how to handle the
Calendar() function. You have been given the suggestion to look at the
Blink Without Delay Arduino tutorial, and I second that suggestion.
This is indeed the first thing you should do.
However, once you have studied that tutorial and you try to apply it to
your specific problem, you will notice that yours is somewhat harder
than blinking an LED. The reason it is harder is that you have to manage
a more complex system state. The LED has only two states, and it
periodically transitions between them as:

LOW → HIGH → LOW

Your display routine will instead have four states and make the following
transitions:

SHOW_TIME → SHOW_DATE → SHOW_DAY → SHOW_TEMP → SHOW_TIME

The relevant programming concept for dealing with this kind of system is
called a “finite state machine” and I suggest you also study this
finite state machine tutorial. This tutorial proposes a very
generic switch/case control structure for programming an FSM.
However, if there is some behavior common to all states (in your case:
the fact that each one lasts for exactly one second), you can factor that
behavior out of the switch/case construct.
Here is what I would propose as a non-blocking Calendar(). First, put
this near the top of the program, along with the other constants:
const LCD_DISPLAY_TIME = 1000;  // display each item for 1,000 ms

Then, is setup(), right after initializing the LCD:
lcd.setCursor(0, 0);
lcd.print("Real Time Clock ");

As a general rule, setup() is the right place for anything that only
needs to be done once, at the start of the program.
And finally, the Calendar() function to be called from loop():
void Calendar()
{
    // Do nothing unless it's time to refresh the display.
    static uint32_t last_change = -LCD_DISPLAY_TIME;
    if (millis() - last_change < LCD_DISPLAY_TIME) return;
    last_change += LCD_DISPLAY_TIME;

    // Switch to the next item: Time -> Date -> Day -> Temp -> Time
    lcd.setCursor(0, 1);
    static enum { SHOW_TEMP, SHOW_TIME, SHOW_DATE, SHOW_DAY } state;
    switch (state) {
    case SHOW_TEMP:
        lcd.print("Time: ");
        lcd.print(rtc.getTimeStr());
        state = SHOW_TIME;
        break;
    case SHOW_TIME:
        lcd.print("Date: ");
        lcd.print(rtc.getDateStr());
        state = SHOW_DATE;
        break;
    case SHOW_DATE:
        lcd.print("Day: ");
        lcd.print(rtc.getDOWStr());
        state = SHOW_DAY;
        break;
    case SHOW_DAY:
        lcd.print("Temp: ");
        lcd.print(rtc.getTemp());
        lcd.print(" C");
        state = SHOW_TEMP;
        break;
    }
    lcd.print("           ");  // pad
}

It is not clear, what the code actually should do (what behaviour you are trying to achieve), so I will only look into the obvious programming problems.

The following declarations at the global scope seem to be pin numbers:
int x = 45;
int y = 47;
int z = 41;
int w = 43;

int WaterIn =  40;
int WaterOut = 42;

int Pump1 = 25;
int Pump2 = 24;
int Pump3 = 27;

But in the Valves() function yout treat them as they were representing the value of that pins. That is not the case. If you want to read the state of a pin, you cannot do
if ((x == HIGH) && (y == HIGH) && (z == HIGH) && (w == LOW))

You are just comparing the pin number with HIGH, which is defined as 1. That cannot work. You have to actually read the pin using it's pin number, which looks like this:
if( digitalRead(x) == HIGH && digitalRead(y) == HIGH && digitalRead(z) == HIGH && digitalRead(w) == HIGH)

And that can be shortened to:
if( digitalRead(x) && digitalRead(y) && digitalRead(z) && digitalRead(w) )

Inside of the mentioned if statements you set a variable multiple times without doing anything with it. Any consecutive write to this variable will overwrite the previous value. After the code block
pinToTurnHigh = WaterIn;
pinToTurnHigh = Pump1;
pinToTurnHigh = Pump2;
pinToTurnHigh = Pump3;

The variable pinToTurnHigh is 27 (Pump3). The values, that you assigned right before that line, are lost. You actually have to do something with the variable, or the first 3 lines of that block makes no sense.
In most cases it is not a good idea, to use variables with changing values to handle pin numbers, since that will make the code difficult to understand. The circuitry is mostly hardwired, it will not change. So there is no need to assign pin numbers to a changing variable. Instead you can directly do, what you need to do with a constant pin number. (Actually the code optimizer, that comes with the compiler, can optimize the not-changing pin-number variables out, so that you wrote them in your code, but the actually code might not have them.) Here it seems, that you want to write a HIGH value to all the mentioned pins. You can do that directly:
digitalWrite(WaterIn, HIGH);
digitalWrite(Pump1, HIGH);
digitalWrite(Pump2, HIGH);
digitalWrite(Pump3, HIGH);

Here it is important to understand, that digitalWrite() is only working on 1 single pin at a time. If you want to set multiple pins with it, you have to call it multiple times with the according pin numbers.
Now the timing of your code: The Calendar() function will block the rest of the code for about 4s, because you used that much of delay(). During that time the Arduino cannot react to anything. The switches will not do anything either (since the Arduino is busy waiting in the delay() instead of checking the switches). The code, that is called after the Calendar() function, contains no delay()s, so it will run very fast. In the Valves() function you first reset all the pumps and valves to LOW. Then you write HIGH to one pin (as mentioned above I assume, that you wanted to write them all on condition). After that the program will go back to the loop() function and execute the resetAllPumpValve() function again, which will set all the outputs to LOW.
All in all that means, that the Arduino is fiddling thumbs inside the Calendar() function, without doing anything else. Then he will reset, set and reset the pins again. Since there is not timing code in there, this will happen very fast. So the pins have to be LOW most of the time and being turned on about every 4s for a tiny amount of time (a low number of milliseconds, since that is about the time to execute digitalWrite() or it's siblings). The motors or values will hardly have time to move with that.
For solving this you might want to look into the BlinkWithoutDelay example, that comes with the Arduino IDE. It shows a non-blocking coding style, that will only do something, if it is the time to do it. Much like when you bake a pizza. You will not sit in front of the oven and wait patiently, until the pizza is fully baked. You will put it into the oven and regularly (maybe every 5 min) look, if the pizza is ready to eat. In the meantime you would do other things. Thats what is done there by using the millis() function, that will return the number of milliseconds passed since the programs startup. You can look into the example and google about it to learn more. It has been covered numerous times throughout the internet.

That's it for now. To really help you with the logic of the program, you will first have to get these parts right.
Have fun while learning :-)

Outstanding analysis of the problems with that code. (voted) I got part-way through it and threw up my hands. I couldn't make much sense of what it was supposed to do, and saw so many problems that gave up trying to call them all out. You were very thorough and patient, and provided clear explanations. Huzzah!

I would add to Chrisl's answer by saying that, if you wanted to make the code more compact, you could represent the 4 boolean variables by a single byte,
e.g. w HIGH + x HIGH + y LOW + z LOW = 1100.
e.g. w HIGH + x HIGH + y LOW + z HIGH = 1101.
Then it would be easier to implement a switch statement instead of if( digitalRead(x) == HIGH && digitalRead(y) == HIGH && digitalRead(z) == HIGH && digitalRead(w) == HIGH) etc.
For example:
byte state;

void setup(){}

void loop(){
 // insert code to read state
 switch (state)
 {
     case 1:
         // insert code to be run if state = 0b0001;
     break;

     case 13:
         // insert code to be run if state = 0b1101;
     break;

     default: // code to be run if state doesn't match any cases
 }
 // insert other code
}

If you were willing to use the ATmega's digital 30-37 pins then you could use the AVR's port command PINC to read all of the HIGH/LOW states at once, using a single instruction.  I leave this as an exercise for you to try!

This is likely to make the program harder to read and understand. There are situations where your suggestion would make the program more readable, e.g. if all 16 cases have to be dealt with and there is no easy way to factor cases. But if there are only two or three cases to handle, if/else is likely to be both more compact and more readable.

Very true, but I wrote "if you wanted to make the code more compact", not necessarily readable.

I fixed the Calendar(), it works perfect.