text:
HM-10 BLE controller is not responding to some AT commands
I have HM-10 BLE controller and it is not responding to some AT commands which I need to use.
AT commands which don't work:

AT+TYPE2 returns +TYPE=0
AT+VERR? not responding
AT+VERS? not responding
AT+RESTART not responding
AT not responding but AT+responds with OK
AT+VERSION responding with MLT-BT05-V4.1

The most important command for me is AT+TYPE2 because even if I set pin with command AT+PIN112233, in my Android App, AlertDialog with password field is not activated during connection with bleGatt = bleDevice.connectGatt(this, true, bleGattCallback) function.
I even tried to call createBond() function on this device, but it is not returning anything. I need to activate pairing with password with AT+TYPE2 but its always returning 0 which is default connection without password and pairing method.
I'm not sure if I have some bugged HM-10 controller but I cant even reset it to default settings.
It is working fine with transfering data by characteristics but other stuff is not working.
I've used some weird iterating function to print out AT+HELP commands for this controller and AT+TYPE is not listed there as a command. That means I cant set pairing method? What kind of BLE device has pairing disabled and there is not option to set up at least password?
Here are my commands
21:01:19.739 ->  Command             Description
21:01:19.880 ->  ----------------------------------------------------------------
21:01:19.949 ->  AT                  Check if the command terminal work normally
21:01:20.054 ->  AT+RESET            Software reboot
21:01:20.159 ->  AT+VERSION          Get firmware, bluetooth, HCI and LMP version
21:01:20.271 ->  AT+HELP             List all the commands
21:01:20.365 ->  AT+NAME             Get/Set local device name
21:01:20.459 ->  AT+PIN              Get/Set pin code for pairing
21:01:20.552 ->  AT+PASS             Get/Set pin code for pairing
21:01:20.646 ->  AT+BAUD             Get/Set baud rate
21:01:20.740 ->  AT+LADDR            Get local bluetooth address
21:01:20.880 ->  AT+ADDR             Get local bluetooth address
21:01:20.950 ->  AT+DEFAULT          Restore factory default
21:01:21.054 ->  AT+RENEW            Restore factory default
21:01:21.157 ->  AT+STATE            Get current state
21:01:21.271 ->  AT+PWRM             Get/Set power on mode(low power)
21:01:21.365 ->  AT+POWE             Get/Set RF transmit power
21:01:21.459 ->  AT+SLEEP            Sleep mode
21:01:21.553 ->  AT+ROLE             Get/Set current role.
21:01:21.693 ->  AT+PARI             Get/Set UART parity bit.
21:01:21.787 ->  AT+STOP             Get/Set UART stop bit.
21:01:21.834 ->  AT+START            System start working.
21:01:21.952 ->  AT+IMME             System wait for command when power on.
21:01:22.056 ->  AT+IBEA             Switch iBeacon mode.
21:01:22.161 ->  AT+IBE0             Set iBeacon UUID 0.
21:01:22.264 ->  AT+IBE1             Set iBeacon UUID 1.
21:01:22.381 ->  AT+IBE2             Set iBeacon UUID 2.
21:01:22.475 ->  AT+IBE3             Set iBeacon UUID 3.
21:01:22.569 ->  AT+MARJ             Set iBeacon MARJ .
21:01:22.663 ->  AT+MINO             Set iBeacon MINO .
21:01:22.756 ->  AT+MEA              Set iBeacon MEA .
21:01:22.850 ->  AT+NOTI             Notify connection event .
21:01:22.967 ->  AT+UUID             Get/Set system SERVER_UUID .
21:01:23.071 ->  AT+CHAR             Get/Set system CHAR_UUID .
21:01:23.174 ->  -----------------------------------------------------------------
21:01:23.257 ->  Note: (M) = The command support slave mode only.

use AT+HELP to list the available commands

where did you buy the module?

https://www.banggood.com/KEYES-HM-10-6-Pin-Transparent-BLE-Bluetooth-V4_0-Serial-Port-Module-With-Logic-Level-Translator-p-1023524.html?cur_warehouse=CN

Its weird that it has functional PASS and PIN commands but no way to activate pairing :D

it has some minimal firmware

Probably but I dont know how to update it because I dont know what is firmware version and what kind of firmware will work with this.

same as me... clone of a hm10.
not very much info on this board.
at command doesn't works when they are in caps ..
no need ? or = after command.
you can paired with at+connX (x is the device number, the first founded is 1. the second is 2, etc etc).
it cannot auto connect even if you paired them before.
not much range (7 meter).

As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.


text:
It is possible an Arduino generate 3d graphics on tft or vga
It is possible to an Arduino render 3d graphics like very low polygonal 3d models or generating lighting efects non realtime shadows or realtime shadows and reflections. Rendering like first 3d video game consoles.
Someone can ask why you don't use an Rasberry Pi. Beacuse Linux can be more complex. Also Rasberry Pi is a computer runs Linux .Linux is hard and some people can say you can install Windows but it doesn't give freedom as Arduino on Arduino you have more control on system.It doesn't run operating system but Rasberry pi runs and you needed write programs for it. You can't do much  anything ( at least i know) than Linux or Windows will allow.
My goal was running very basic 3d graphics on a Vga.
Theres no rule it can be like old dos games.Fake 3d effect like distorting sprites to look like 3d and rotate them move change coordinates change camera position like a 3d but it's actually generating fake depth.
Must camera position controllable . Like a video game.
Sprites,effects are completely pre rendered. Only realtime rendered thing was distorting sprites by camera position. Changing room (Square area will reset view that will make after another room it would show another room).
Is there a library can done that?
Your solution can be for another Arduinos.
Your solution can be Arduino dependent. Like only works for due,mega etc.
Theres a vga library for Due supports 256 colors your solution can use this library problary called DueVGA

Completely possible, and it had already been done. http://crawlingrobotfortress.blogspot.com/2015/12/better-3d-graphics-engine-on-arduino.html And there are even sources (check "examples" folder) https://github.com/michaelerule/Uno9341TFT

While there is no VGA library for Arduinos with AVR, there is one for ESP32: ESP32 VGA Library.
It makes heavy use of the Hardware capabilities like I2S that are not present in in Arduino.

On AVR based Arduinos: No, definitely not. It is possible to create a VGA signal, but only with very limited resolution and few colors (like 4 or so) and also a framerate, that will not be enough. Also they all have too few memory.
It might be possible on the Due (don't have much experience with it), but it is still a bad choice for a platform (also partly because the Due is in general such a bad designed board with no good documentation).

Is there a library can done that?

I don't think, that you will find any library doing all what you want. You might find libraries, that help you draw on the display, but you will do all the hard stuff (creating and loading sprites, distorting them, animating them) yourself. This is, because Arduino is a bad choice for such a project.
Also: In the title you mentioned TFT. I guess you meant one of the TFT display modules, that you can connect to Arduinos. Forget about that. They are connected over rather slow serial data interfaces (not meaning the Arduino Serial here, but serial interfaces like I2C or SPI). You won't get a sufficient frame rate with them.

I would oppose your arguments against the Raspberry Pi. Sure, it has an OS, but that also means, that it can make use of a variety of languages and frameworks. You are not bound to plain C/C++. You can use the language or framework, that best suites your needs. That can be a bit complex at first to find the right one. But thats, because your project is complex. What you are describing is a very complex task, when you cannot rely on others, that have already implemented the hard stuff (which would be the case for the Arduino).
Also a Raspberry Pi has plenty of RAM and plenty of storage space. It runs at high speed and is actually capable of outputting video with a good framerate.
Without wanting to offend you: I think, as you are asking this question here, you are not qualified enough yet to do such a project on an Arduino. There are insanely capable people out there (wouldn't count myself to them), who do incredible things with Arduinos by milking the very last drop of resources out of them. But they are doing it for the grind, not for having a functioning product at the end. I guess you want this to work good at the end, without needing you to work on it for many years. Then you are result-focused and should choose the correct platform for this. A computer (like the Pi) will be easier.

Rasberry Pi had lot of things but some of them are unnecessary.

Yes, but is that really a problem? Is the unused potential really a no-go for the project? You could say the same thing about an Arduino. It has a lot of peripherals build in (depending on type Timers, Comparators, ADCs, DACs, several communication interfaces, power management peripherals, ...). Almost no project uses all of them. But that's simply the difference between general purpose chips/boards (like all Arduinos or Raspberry Pis) and custom made chips for a single purpose. If (!) a fitting chip for your project exists, that really only has what you need, it will most likely be very expensive. Chips for a single very narrow purpose have a very narrow target group, thus are more expensive (simple economy here). Companies have formally nearly everytime designed their own chips for gaming consoles (which is way beyond your current scope), like PS1 or N64. Current gaming consoles rely often on modified standard hardware, also because it is cheaper. The really old gaming consoles used the generic electronical chips, which means, that you didn't have one single programmable chip. Instead lots of the logic was build into the electronic design.
So you will always have some excessive features, that are not used. Why would you want to remove them from the project, just for the fuzzy goal of not wasting features. It will make your project only more complex and expensive. You will gain nearly nothing from minimizing the resources. This is a hobby project, not for selling it.

In rasberry pi you just writing a computer program.You don't have much control like arduino

That depends on what type of control you mean. On a computer you are writing code on a higher level of abstraction. That also makes it easier to do complex things, since you can rely on the low level programming of others. What control do you want to have over the system, that you don't have on a computer like the Pi? Do you think, you can program better display drivers or graphic renderers, than all the other people? Then you can still do that on the Pi. A Pi also gives you control over the GPIO pins, which let's you do many hardware things, that you can also do on an Arduino.
Also Linux is open source. If you think, you need more low level interaction with the hardware (cannot think of a reason for needing it), then you can build your own OS, which gives you the needed freedom. Sure, that is very complex. But when you are able to use the low level programming, then you are also able to change the OS.

You seem to already have chosen the Arduino for your project. I, like others, have advised you to use a Pi instead to make it a lot easier and better. It is up to you, if you want to believe us or not. All in all I'm still not convinced, that you are able to pull that off on the Arduino platform, while still getting good results. You are simply not at that point of knowledge yet. You write confidently about the problems with an OS, while you don't seem to have a concept about the exact structure of these problems and how they impact you. We will not prevent you from doing it the hard way. Please for free to choose your own way.

You are right but Rasberry Pi like overkill . Also i don't want build a computer in my goal. Also on rasberry pi and other linux systems had very complex commands. Running 3D graphics on rasberry pi just making a video game for just a linux computer. Arduino feels more user friendly also i didn't used Linux i used in school on smart boards it's not a Linux Linux-Based os called Pardus can run some exe files if i remember correctly

I don't think, that a Pi is overkill. It is a good way to go for a beginner. You could use the Pi Zero, which is very small (smaller than an Arduino Uno). The commands can be less complex than on Arduino, because you don't need to do the nitty optimization stuff. But sure, I don't prevent you from doing it with Arduino. If you like the very steep learning curve, then it is good. Not just something I would recommend

In rasberry pi you just writing a computer program.You don't have much control like arduino(at least i know). It just a program runs on a rasberry pi. Rasberry Pi had lot of things but some of them are unnecessary. Is there another embeded system had 1 gb ram but doesn't run os like rasberry pi does. You have full control over system. Microcontroller or Microprocessor supports 1 gb of ram and rendering 3d (like ps1).I don't want os even it had os It just like MS-DOS. Linux or Windows. You still depending on os. If you just want special tasks run. Not like explorer.exe running background or etc

A Raspberry pi is not overkill. It's the right tool for the job. An Arduino is woefully under-powered to do ANY kind of graphics. It's too slow, has too little memory, and has too low I/O bandwidth. Most Arduinos don't even have enough RAM to display a single frame of VGA color graphics, never mind the memory needed to manipulate an array of vertexes and render it to full-screen color output. Then there is the fact that they don't have native floating point, and you really need specialized graphics hardware to do 3D graphics with a decent frame-rate. (Software floating point is SLOOOOOOOOOW.)

@IWantJustBasicCollisions I added some explanations to address directly some of your arguments. I don't think, that you are right. Though, as you already seem determined to stay on the Arduino framework, this is the last piece, that I will write for this question. You can choose the easy or the hard way as you like. Please decide yourself on what you want to do.

Actually you are right can i install dos like operating system. Linux or Windows like overkill. I just don't want os running and just a program popup draw 3d graphics etc. Even it was running os i want code it like arduino(arduino actually not an os justa program) i just want direct program and none of another programs don't run like explorer.exe does run on background etc. Even it will running linux only 3d application and critical system apps must run. Wallpaper desktop must invisible. Linux themes etc.  must gone. Like ps1. It just run programs for 3d rendering other programs wil not run

VGA
I suggest you build the famous world's worst video card. It's a great project and you'll definitely learn something when building it.
That graphics card uses only 2 bit per base color, which is 6 bits in total, or 64 colors. The resolution of the graphics card is 100x75 pixels. An image can basically become as good as

That picture is still 100x75 = 7.5 kB in size. That means it does not fit into the 2 kB of RAM of an Arduino Uno.
To clock the graphics card, Ben Eater uses a 10 MHz crystal to get the timing right. That means, your Arduino needs to output one color at a speed of 10 MHz. That's clearly not feasible for an Arduino Uno running at 16 MHz.
However, an Arduino Uno is nothing without some hardware attached. You could try to calculate the 3D graphics on the Arduino and write the results into an EEPROM (just like Ben Eater's graphics card) and let the EEPROM handle the output of the colors. That way, you could certainly generate single images. The frame rate will definitely not be high.
But: your request is not far fetched. My first computer, an Apple IIe was running at 1 MHz speed - but at least it had 64 kB of RAM. It could do all sorts of stuff, although I can't remember a 3D game. Using an Arduino Due with 84 MHz and 96 kB of RAM should be a realistic approach - and probably the reason why DueVGA exists.
TFT
A TFT display already has its own memory, so you needn't worry about that aspect. People already did 3D rendering, although they were going through a lot of problems that I mentioned for VGA before. It requires a lot of optimization. A library is the ATmega328 Tiny 3D Engine.
With shading it seems to render up to 3 frames per second on an Arduino, which is likely not enough to for smooth interaction.
Raspberry Pi

Linux is hard

Some Linuxes are. Especially Kali Linux. But Raspbian is really a good OS for the Raspberry Pi. We are teaching internships Linux + Shell + Python in 1 week (like this project). It's enough to focus on the programming. Not much configuration needed.

You can't do much anything ( at least i know) than Linux or Windows will allow.

That might be true. However, I am developing software that runs on operating systems since 1996 and have never had the feeling that the operating system restricts me from doing something. In the opposite: the OS provides features that would be very hard to implement on my own.

Thanks but i saw some people really rendering 3D on Arduino: https://hackaday.com/2016/01/02/better-3d-graphics-on-the-arduino/ (TFT) Also i remember theres a library for noki a lcd's but i don't know but i can't find code for it. Even i do it. It just be distorting shapes for look like 3d. It  will not render as showed in article.

@IWantJustBasicCollisions the guy in that video is doing VERY advanced optimization and going to great, elaborate lengths to create seemingly impressive, but actually rather crude results. They are not really practical for a game. If you want to write video games, use a platform that has a built in video output with graphics support. Rolling that stuff yourself is really, REALLY hard, and the results are pretty limited.

I disagree with your premise. If you use a high-end Arduino, like one of the ones based on an ARM processor, and you optimize the snot out of it, you might be able to generate crude VGA level graphics, and gin up some 3D looking images. But expect to spend a lot of time on very fussy timing code that requires a LOT of expertise to get right.
(An Arduino does not have any display driver at all.)
You want a device that can output video through hardware. A Raspberry Pi is a much, much better choice. Sure, it runs UNIX. UNIX isn't going to bite you. Roll up your sleeves and

You can definitely render 3D graphics on an Arduino-based MCU & TFT and I have done exactly that with Teensy.
It requires quite a bit of work to implement software rasterizer though and I'm not aware of an off-the-shelf 3D library you could use. I would think that someone has written a 3D graphics iib though, so might be good to scour GitHub if you don't want to write a rasterizer yourself.
There are plenty of different TFT options with both SPI (serial) and 8/16bit parallel interfaces you can use and have decent frame rate. E.g. with Teensy you can update a 320x240x16bpp screen over SPI at ~30fps. You can also pass SPI data transfer to DMA to free spending MCU cycles for it if your MCU supports it. With parallel interface you can bit bang the data to TFT faster and have potentially higher frame rate, but then you have to waste MCU cycles for the data transmission.
Newer Teensy models has plenty of RAM (1MB) for 3D rendering but it can be quite challenging to render 3D graphics on some MCU's with only few kilobytes of RAM. I'm using tiled rendering, which renders a frame in small tiles (e.g. 64x64px) and thus doesn't need to maintain the whole frame & depth buffers in memory. Because of this I was able to get the 3D renderer running on Teensy LC, which has only 8kb of RAM, but it's much slower and simpler 3D model. I also store the 3D assets (geometry, textures) in the MCU flash in format that can be directly used for rendering to save RAM.
You can also implement texture sampling on MCU, which opens possibility to implement various different effects, like sprites you mentioned.

source: Stack Exchange

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

sort: votes


text:
Arduino as USB HID is slowed down when PC doesn't read events
I have an Arduino Micro that is acting as a HID device for a Linux PC.
I use this call to send the HID values:
HID().SendReport(1, _values, sizeof(_values));
This works in principle, but I noticed this issue:
If my Linux PC is not actively reading the events from the Arduino, then the Arduino is slowed down. My rotary encoders are missing signals, is one symptom.
But as soon as I read the events with my Linux PC, the Arduino loop() runs at full speed again.
I suspect that this is due to recv/send time out delays in the USB core code? Because I noticed this in USBCore.cpp:
u8 timeout = 250;               // 250ms timeout on send? TODO
Anyway, I tried to solve this issue in the following manners:
Check for configuration and suspension with:
     if (USBDevice.configured())
      if (!USBDevice.isSuspended())
         ...

Which did not work.
I also tried monitoring the increments of the frame number:
  // See if USB shows activity.
  static uint8_t prev_fr_num = UDFNUML;
  static uint8_t num_times_idle = 0;
  uint8_t fr_num = UDFNUML;
  if (fr_num == prev_fr_num )
  {
    if (num_times_idle < 255)
      num_times_idle++;
  }
  else
  {
    num_times_idle = 0;
    prev_fr_num = fr_num;
  }

And then only send if num_times_idle is smaller than a threshold. Again, this did not help.
The only way to make it fast, is by reading the events with linux, like so:
$ jstest /dev/input/js0
or alternatively:
$ evtest /dev/input/event5
How can I have the USB HID stuff not slow down my loop code when the PC is not paying attention?
Thanks!
Bram

please reduce the code to smallest code that still exhibits the issue and add the code listing to your question

USB is actively polled by the host and a client can not initiate communications. Maybe it's a buffer filling up?

For those that hit the same issue, here is how I solved it:
Expose the USB_SendSpace() information in the HID interface by editing
/usr/local/arduino-1.8.12/hardware/arduino/avr/libraries/HID/src/HID.cpp
u8 HID_::SendSpace(void)
{
        return USB_SendSpace(pluggedEndpoint);
}

And adding the interface to class HID_ in:
/usr/local/arduino-1.8.12/hardware/arduino/avr/libraries/HID/src/HID.h
That way, before calling HID().SendReport() you can check for send buffer space available by calling the HID().SendSpace() method.
If there is no space, just skip the SendReport() calls, and the Arduino loop() will no longer be slowed down by time outs.

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


text:
Interrupt every second on ATTiny84 (and sleep the rest)
I'm building a digital watch just like in this post, except I'm using an ATTiny84. However, the ATTiny84 doesn't have an asynchronous Timer2 like the ATMega328 and does not have a power save mode, so it cannot wake up from the Timer2 interrupt as is suggested in that post.
I need to increment my 'seconds' counter every second, and I need to do it precisely so I don't lose/gain time (so I can't use the watchdog timer which, as I understand, does not use the crystal oscillator but rather its own imprecise clock). I was planning on just keeping the CPU on and using an external crystal, but it seems that that takes a lot of power (~3mA). Even with the SLEEP_MODE_IDLE, I could only get the current draw down to around (~1.2mA).
Like Nick Gammon suggested in that post, I feel like the real solution is to sleep when not changing the counter. Is there any way to wake up after a precise amount of time in the POWER_DOWN or STAND_BY modes?

Is there any way to wake up after a precise amount of time in the
  POWER_DOWN or STAND_BY modes?

I'm afraid not. You will have to use a timer. Since the ATtiny84 does
not have an asynchronous timer, you will have to keep your timer
clocked. This means the clkIO clock domain has to stay
active. Now, take a look at the table “Active Clock Domains and Wake-up
Sources in Different Sleep Modes”, on page 33 of the ATtiny84
datasheet. It shown that “Idle” is the only sleep mode
that keeps this clock domain active.

Even with the SLEEP_MODE_IDLE, I could only get the current draw
  down to around (~1.2mA).

There are ways to bring this down. First, there is a collection of
functions named power_*_disable() in the avr-libc. You can use
these to power down every single peripheral except the one timer that
you will be using.
Most importantly, you can save power by reducing the clock speed. Since
these devices have extremely little leakage current, the current draw is
roughly proportional to the clock frequency. You can then achieve huge
power savings by drastically reducing that frequency. Obviously, your
processing power will also suffer, but this may not be an issue for a
simple binary clock.
I think the best option for you is to clock your ATtiny84 off a
32.768 kHz watch crystal. See the section
6.2.4 – Low-Frequency Crystal Oscillator in the datasheet.
These crystals can be very accurate, as they are specifically designed
for time keeping. And the frequency is so low that the current draw from
the MCU will likely be negligible compared to whatever other components
are in your clock.
Edit: answering the question in the comment.

Wouldn't waking from idle still use the watchdog timer though? Or is
  there a way to wake up based on the 32.768 kHz crystal?

As the watchdog timer is way too inaccurate, it is of no use to you.
Instead, you would use either Timer 0 or Timer 1, and configure it to
deliver an interrupt every 32,768 CPU cycles. This interrupt will
be your 1 Hz wakeup source.
You can do this with either timer, in either CTC or fast PWM mode. You
have to configure the prescaler and the TOP value such that
prescaler_factor × (TOP + 1) = 32,768
Then, enable the relevant interrupt, and define the corresponding ISR
that will advance your clock by one second.

Thanks, it looks like the power used by a 32.768 kHz crystal is low enough for me if running in idle. Wouldn't waking from idle still use the watchdog timer though? Or is there a way to wake up based on the 32.768 kHz crystal?

@AnubhavSrivastava: see expanded answer.


text:
Using the LED pin for input
I have an Arduino-like device with few GPIO pins (DigiSpark clone). It is based on an 8-pin AtTiny85 IC so there are Power, Ground and six other pins, two of those six are being used for USB keyboard simulation which leaves 4 GPIO which I want to connect 4 buttons to with minimal circuitry. The normal way to do this is to enable the internal pullups and have the buttons connect the pin to ground. This works well for most pins.
The problem is the equivalent to Pin 13 (Pin 1 in this case) which is connected via a resistor and LED to ground. The internal pullup is too weak to raise the voltage enough. Consequently that pin always appears to be in a "button pressed" state.
One solution is to cut the tracks connecting the LED, but the board is so tiny and crowded that I doubt I have the eyesight and steadiness of hand to do this.

Problematic resistor + LED are at bottom right of AtTiny85 IC
It occurs to me I could either

Add an external pullup to this input,
Change the button wiring so when pressed, it connects the pin to 5v. Change the code to look for high, not low.

Are there any problems with either of these approaches?

You have forgotten the reset pin. So effectively you only have 3 pins left (8 pins minus Vcc, ground, reset and 2 pins for USB = 3)

@chrisl - I plan to disable the reset fuse using avrdude. I don't have a high voltage  programmer but I don't need to use ICSP or change the bootloader so should be OK. I was considering adding Pin 5 issues as a separate question if I hit problems.

P.S. Fixing P5 on DigiSpark clones

How do you plan to program the digispark, if you cannot reset the chip? The bootloader, which does programming over Serial is only activated, when the chip is reset.

@chrisl - by unplugging from USB, clicking the IDE's upload button and then waiting for the IDE's prompt ("Plug in device now... (will timeout in 60 seconds)") then plugging the DigiSpark back in. This is the normal method for reprogramming a DigisSpark. So far as I know this enables you to reprogram the Digispark without pulling RESET low. Presumably the "micronucleus" bootloader becomes active after initial power-on, waits for USB activity from the IDE (uploader/avrdude) for n seconds and only then jumps to the existing user code ("sketch").

For me it's option 2. I would not expect any problem.

I'd remove the LED. Takes but a moment with a soldering iron.

In the end, stimulated by Majenko's advice to desolder the LED,  I instead carefully studied the PCB layout online, checked that it corresponded to my PCB, checked the location of nearby traces I didn't want to cut and then used multiple magnifying glasses and a fresh blade in my smallest utility knife and carefully cut the track leading from the LED to the IC. All was well.


text:
Bicycle Tail Light project
For my college course we currently have to carry out a project of our own choice.
I chose to make a Tail light system, with strobing indicators, fog-light and brake-light.
The lighting uses Neopixel strips and rings, with the indicator sections consisting of 2 neopixel strip 6 (in parallel); the fog light using a neopixel jewel; and the brake light using a neopixel ring 16.
The indicators need to strobe outward from the centre of the device (in the desired direction, left/right) based on a button input. The fog-light should turn on when the device is activated by switch, and the brake-light will turn on when receiving an input from another button.
I've only ever coded using Python during GCSE and can't wrap my head around Arduino code. Currently using tinkercad for creating this as I don't have any arduino kit, and don't want to spend out the money on unneeded components.
Any help is appreciated, and if a link to the tinkercad circuit would be useful let me know.

https://arduino.stackexchange.com/tour

If you want to program your project in Python you should add the Python tag to your question.

I don't want to code in python, just stating what prior coding knowledge I have. I know python is probably not the best coding tool for this.

Break down your project into steps, both hardware and software, and tackle a step at a time.
First do a block diagram of the system, showing the different components, the layout of the control buttons, etc.
Then map out the desired behavior, perhaps using a flowchart. What should it do when you first turn it on? How will it respond to different button inputs? Will it continue to flash in the current pattern indefinitely until there's another input? Will there be a cancel button?
Then read up on how to power and control NeoPixel LEDs. I believe they use I2C? Are there any NeoPixel libraries you can use?
You might then try using a circuit simulator to create a virtual prototype of your circuit. Figure out how big a battery & voltage regulator you're going to need. (If you're running off of batteries you should use a switching or "buck" type voltage regulator rather than a linear voltage regulator since they are much more efficient. Just make sure you pick a regulator that can provide enough current for all your LEDs plus your Arduino, with a little extra left over.))
Once you get a virtual circuit working, it's time to use real hardware.
For a bike tail-light, you should think about how to make it weather-proof. are there waterproof enclosures you can use? What about waterproof NeoPixels? If there are no waterproof NeoPixels, what about waterproof enclosures with clear covers?
Buy the Arduino you're going to use, and at least a few of your NeoPixels. Work out how to control and flash a single LED. Then gradually add complexity to your project until you get it working.


text:
2 SPI devices conflict
I want to connect a W5500 ethernet Module and an SD card module to arduino Uno using SPI (with different CS pins of course). When connected separately they work fine but when connected in the same circuit the ethernet module doesn't get a correct ip address and always gets an address 255.255.255.255. To me the ethernet module is the likely culprit as the SD card module works without problem even when the ethernet module is also connected.
Tried using Ethernet & Ethernet2 libraries but no difference. Tried manually assigning the IP address but it won't work. I have even set the CS pins HIGH in the setup before calling SD.begin & Ethernet.begin() to avoid both components "listening" at the same time but it still doesn't work. How can I fix it?
Here is the sketch I am working with. Although it doesn't use SD module but as mentioned above if SD module is connected in the circuit, ethernet module doesn't get incorrect ip address
#include <SPI.h>
#include <Ethernet2.h>

//IPAddress ip(192, 168, 1, 22);

// MAC address just has to be unique. This should work
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

EthernetServer server(80);

void setup()
{

  pinMode(8, OUTPUT); // SD module CS
  digitalWrite(8, HIGH);
  pinMode(10, OUTPUT); // Ethernet module CS
  digitalWrite(10, HIGH);
  delay(1);

  Serial.begin(9600);
  Ethernet.begin(mac);
  server.begin();
  Serial.print("Server started on: ");
  Serial.println(Ethernet.localIP());
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client)
  {
    while (client.connected())
    {
      // send a standard http response header
      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println();

      // send the body
      client.println("");
      client.println("
Arduino Server
");
      client.print("
A0=");
      client.print(analogRead(0));
      client.println("
");
      client.print("
millis=");
      client.print(millis());
      client.println("
");
      client.println("");
      client.stop();
    }
    delay(1);
  }
}

Another sketch with reference to both SD and Ethernet Libraries
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

byte mac[] = { 0x00, 0xC3, 0xA2, 0xE6, 0x3D, 0x57 };
byte LED = 2;
char wServer[] = "media.wizards.com";
char wFile[] = "/images/magic/tcg/resources/rules/MagicCompRules_20140601.pdf";

EthernetClient myClient;

void setup() {
  //D53 on an Arduino Mega must be an output.
  pinMode(53, OUTPUT);

  pinMode(LED, OUTPUT);

  Serial.begin(9600);
  while (!Serial);

  Serial.print("Establishing network connection... ");

  if (Ethernet.begin(mac) == 0) {
    Serial.println("FAILED!");
    while (true) {
      digitalWrite(LED, HIGH);
      delay(500);
      digitalWrite(LED, LOW);
      delay(500);
    }
  }
  else {
    Serial.println("OK!");
  }
}

void loop() {

  Serial.print("Connecting to ");
  Serial.print(wServer);
  Serial.print("... ");

  if (myClient.connect(wServer, 80) == 1) {
    Serial.println("OK!");

    myClient.print("GET ");
    myClient.print(wFile);
    myClient.println(" HTTP/1.0");
    myClient.print("Host: ");
    myClient.println(wServer);
    myClient.println();

    if (SD.begin(8)) {
      if (SD.exists("MAGIC.PDF"))
        SD.remove("MAGIC.PDF");

      Serial.print("Saving response... ");
      digitalWrite(LED, HIGH);

      File dd = SD.open("MAGIC.PDF", FILE_WRITE);

      char lc;
      while (myClient.connected()) {
        if (myClient.available()) {
          char nc = myClient.read();
          if ((lc == 10) && (nc == 13)) {
            while (myClient.available() == 0);
            myClient.read();
            break;
          }
          else
            lc = nc;
        }
      }

      while (myClient.connected()) {
        if (myClient.available() > 0) {
          dd.write(myClient.read());
        }
      }

      dd.close();
      delay(500);
      Serial.println("OK");
      digitalWrite(LED, LOW);
    }
    else
      Serial.println("No SD card detected!");

    myClient.stop();
  }
  else
    Serial.println("FAILED!");

  delay(3600000);
  asm volatile(" jmp 0");

Where did you tell the SD library  and the Ethernet library which CS they should use?

In additional to @theSealion very valid question. This article should be able to help you to troubleshoot and narrow down the cause.

ethernet2.h is deprecated.

ethernet2 by default using pin 10 as cs (https://github.com/adafruit/Ethernet2/blob/master/src/utility/w5500.h#L133), however, your code has no reference to SD card library or initialisation of SD card.

I have experimented with a few different sketches but it's not working. I have uploaded another sketch which I tried but it doesn't work.

@theSealion the ethernet library by default uses pin 10 as cspin so no need to mention it. As I mention in my original post, by keeping both SD card module and ethernet module in the circuit causes an issue. It doesn't matter if the sketch has reference to SD library or not. Since in my circuit, the sd module has pin 8 as CSpin and that I pulled high to avoid any conflict but it doesn't help.

@Zaffresky than I would recommend to start looking at the hardware. Take a voltage meter and have a look at the CS and SPI lines when the µC is in reset state and when your sketch is running. Even better would be a oscilloscope to watch the signal.

I had the same problem with my SD card module.
I don't have too much knowledge about all details, but it is related that most SD card modules (the simple ones) do not have tri-state functionality, meaning they cannot cope with multiple SPI devices on the same bus.
Sadly, the Arduino has only one SPI connection, but there are solutions:

There exist tri-state buffers which you can use  (somewhere in the CD or 74HC range). See comment of hcheung: use e.g. an 74AHC125  MISO tri-state buffer.
However, another solution is to use e.g. an SD card shield, something like https://boutique.semageek.com/en/1445-sd-storage-shield-with-rtc-clock-for-arduino.html

I think you are referring to 74AHC125 to be used a MISO tri-state buffer.

@hcheung yes, thanks ... I will add it to the answer

The problem with SD cards is that the SD card doesn't strictly adhere to the SPI protocol standards.  The CS pin doesn't cause the SD card to be isolated from the bus as it should, and there are specific operations that you perform on a SD card through the SPI bus while the CS pin is held high.

Also the order of initialization is critical. You must start the SD card before any other SPI device to ensure that every device on the bus is SPI, since the SD card defaults to SDIO mode and that can interfere with the rest of the bus.

@Majenko am I right that a tri-state buffer like 74AHC125 will fix the CS pin problem?

It certainly helps matters, yes. When the SD is isolated from the bus then no matter what it does it can't interfere with the rest of the bus.

Personally I never share the SPI bus with anything else when using an SD card (but then I use PIC32 with multiple SPI busses). If needed you can always bit-bang SPI for other devices that don't need high speed.

@Majenko good to know thanks ... haven't used an SD card for long but found the problem when I started with Arduino, to be honest, never tried the buffer (since I was just trying out lots of stuff).

@Majenko Also one reason for trying to use STM32 is they have indeed more features (like more SPIs, and especially more SRAM).

@MichelKeijzers Meh... if you like ARM, sure... Give me MIPS any day though ;)

@Majenko can you give an example of MIPS microcontrollers? (or am I missing something)

@MichelKeijzers PIC32. It's all I use unless I have to use something else due to a customer requirement.

@Majenko somehow it's not really advertised or so ... I mean I checked Arduino, found it to be too limiting for what I wanted (learning microcontrollers), and the most 'obvious' links where STM32(F1). So I don't know how good/bad PIC32 (probably good as professionals use it). But I'm a bit doubtful to move (again) to a different architecture.

Heh. PIC32 has the advantage that it gets the best hardware/software support from me ;) chipKIT is the Arduino API variant for PIC32, though it is slightly lagging behind on some of the API facilities.

@Majenko I will check into it (because I'm curious).

@MichelKeijzers Thanks for the info but I wonder if the SD card shield also uses the SPI bus? If so then how will it be different than using the SD card module?

@Majenko I don't know anything about that tristate buffer but will read more about it. Also will need to order first the 74AHC125 ic to test it

@Majenko I tried initiating the SD card prior to start the ethernet but still it fails. I guess it more of a hardware issue and the tristate buffer thing will probably fix it. What really surprises me is that even if I pull the CSpin of the SD card high throughout the sketch, the ethernet module isn't able to get the correct ip so keeping it's CS pin high has no effect at all?


text:
Boost an audio signal for analog read - Envelope Detector
I'm working on my first Arduino project and I have a sensitivity issue.
I'm building a module to listen to an audio signal and to start the power source of my speaker with a relay. Everything seems to work fine, but if I drop the volume of my sound, the analog pin doesn't record values (at maximum volume, it peaks at around 50, which is not a lot).
I thought about getting a capacitor but I'm really not sure on what I should get and how the wiring should be done.

An analog input on an Arduino can only tolerate voltages from 0 to 5VDC.  It can't tolerate negative voltages.  Audio signals are AC signals.  Their voltage changes rapidly from positive to negative.  The negative voltages involved could damage your Arduino.  It isn't safe to connect an audio source directly like this.

Hooo, thanks for that, I knew I'd learn something but not that I could have fryed my Arduino ;) Do you have any suggestions on what I could do and that is secure? I suppose that a diode bridge could fix that problem since I really don't care about the content of the signal?

If you only want to detect whether the signal existed or not, you can use a low-pass filter (basically through a diode and  resistor to charge a capacitor) to give you a near-DC output, and bring it down to appropriate level, say 2.5v, and just read it through analogRead().

it sounds like what you are wanting to do is to detect a minimum threshold of sound so that your speaker power source can be turned on when an audio signal is playing.
You need to amplify your signal while also avoiding voltages that exceed the maximum input specification and also don't go negative. One way to accomplish this is with an operational amplifier (op-amp) circuit. A specific type will accomplish all three requirements. An op-amp that is powered by a single-sided supply, for example +5V and ground, will prevent negative voltages and limit the maximum voltage exceeding what the Arduino can take.
For your application, you don't really care about making a high-quality audio amplifier. You care about not distorting the signal (music) that you are monitoring and detecting a threshold level. Op-amps are good because they have high impedance inputs (they don't draw much (or any) current from your music signal) and they work with few external components.
A classic text for learning about electronics is Horowitz and Hill. Alternatively, you can find references for circuit designs on-line with appropriate searches. For any op-amp that you buy, you can get a datasheet that tells you how to use it. The following reference goes into detail (maybe too much) about single supply op-amps.
Circuits (and search terms) that you might find useful are op-amp follower, single supply, bias, and capacitive coupling. You'll need to purchase components. A good supplier is DigiKey. DigiKey has an on-line catalog that allows you to do a parametric search to identify the components that you need. You'll need a breadboard, resistors, capacitors, and the op-amp in a dual-inline package (DIP).
One search filters the list of possibilities from tens of thousands to a reasonable number. The LM833 Datasheet here is a reasonable choice.
Test equipment, like a single generator and oscilloscope can be very helpful when building amplifiers. You might be able to digitize your amplified signal with your Arduino if you don't have access to test equipment.

What you're looking for is called a peak detector, or probably better in your case - an envelope detector. Pass this through an op-amp with adjustable gain to let you tune your sensitivity. R3 - your potentiometer will let you adjust the sensitivity.Your gain will be
.
Set Vdd to 5V and common ground with your Arduino.
It's unlikely your audio source is generating too much voltage given you're saying its not registering - but in the unlikely event you're above 5V put a reverse biased Zener diode in parallel with your capacitor to clamp voltage to 5V

simulate this circuit – Schematic created using CircuitLab
Hit simulate to see what playing with values does!

Sorry, it took sometime, everything was closed here... I just got my hand on all parts required. The problem that I now have is that the TL081 always give me the same reading on the arduino, even when I remove the jack from my board, I remove everything from my Vin but I kept having reading from the analogue IN. Have any idea on waht can cause that?


text:
Convert comma-delimited Arduino String of hex values to array of bytes

My apologies if this is a naive question. How do I convert a String which has hex values to a byte array that has those hex values?
This:
String s = "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff";

Needs to be converted to this:
char test[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };

I used the following procedure. It does convert it, however, each character is saved as a character as opposed to hex value:
unsigned int str_len = s.length() + 1;
char charArray[str_len];
s.toCharArray(charArray, str_len);

Any help will be appreciated. Thank you!

there is no such thing as a hex byte ... it is simply an 8 bit number ... you could use 0xff or 255 because they are the same value

@jsotola This is just an example, I need this to be used for all hex values. How do I convert the string to byte array?

Related: How to convert a hex string to an array of bytes?

You only convert the String object to a char array. It need to further split the char array into substring, and then convert it to number.
To split the char array, you can use strtok() function in c++ to do the job.
There is no str conversion function that can convert "0xff" into uint8_t directly. However, as @rubemnobre mentioned strtol() can be used to convert a c string to a long (in Arduino, it is 4-byte number) and further cast into a uint8_t and store in a byte array.
String s = "0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff";

// Convert String object to char array
unsigned int str_len = s.length()+1;
char charArray[str_len];
s.toCharArray(charArray, str_len);

uint8_t byteArray[7];
int i=0;

// split charArray at each ',' and convert to uint8_t
char *p = strtok(charArray, ",");
while(p != NULL) {
  byteArray[i++] = strtoul(p, NULL, 16);
  p = strtok(NULL, ",");
}

// Print the byteArray
for (i=0; i<sizeof(byteArray)/sizeof(char); i++) {
  Serial.print(byteArray[i]);
  Serial.println(", ");
}
Serial.println();

If you're not strtol's using "endptr" (&ptr in your case) you can just replace it with NULL and the parameter will be ignored. Also if you're casting to uint8_t then strtoul would be a better choice.

@Majenko, thanks and upvoted for your comment, make the code cleaner and simpler. I updated my answer.

There are C functions that can convert text to number. For example, strtol() or atoi(). Here is a little snippet to get you started:
char *str = "FF";
char *ptr;
int result = strtol(str, &ptr, 16); //the 16 is the base the string is in (HEX -> base 16)

result will have 0xFF or 255 by the end. You can use this to achieve what you are trying to do. Take a look at this for functions you can use to manage your String.


text:
Upgrade ESP-01 firmware on MacOS
I recently bought an ESP-01 as well as an FTDI programmer (3.3v-5v) and after typing AT+GMR I noticed it said:

AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04

I have looked and looked on a way to upgrade its firmware (on MacOS) to no avail. How can I upgrade it? I want to be able to change the baud rate to 9600. A lot of examples to do it are in windows requiring another application or something like that but how can I do it in a Macbook? Thanks.

use esptool. the firmware binaries are on Espressifs site. the latest versions don't fit into esp-01's flash memory

"I want to be able to change the baud rate to 9600", what do you mean by that? Is that the reason you want to upgrade firmware? The firmware came as binary file, you won't be able to change that. Default baud rate of esp-01 is 115200 bps. You can change it via AT command, run a bare minimum sketch and type in AT+UART_DEF=9600,8,1,0,0 to make the change, the command _DEF will make the setting persistent.

Sorry im really new to Arduino and ESP in general, I read that you need to have both the Arduino and ESP in the same baud rate and to do that I need to upgrade my firmware (please correct me if im wrong).

Here is the step-by-step on upgrade the ESP-01 AT Command firmware (for running on macOS).
Wiring
For flashing the ESP-01 firmware, you need to have a USB-TTL adaptor as a programmer.
+---------------------+---------+
|                     | RxD Vcc |
|       Top View      | IO2 RST |
|                     | IO0 CPD |
|                     | GND TxD |
+---------------------+---------+

ESP-01          USB-TTL Adaptor
 VCC   ---------- 3V3
 GND   ---------- GND
 TxD   ---------- RxD
 RxD   ---------- TxD
 CH_PD ---------- see note* below
 GPIO0 ---------- Connect to a push switch (Flash button) to GND
 RST   ---------- a push switch (Reset button) to GND

Note: depend on whether you have ESP-01 or ESP-01S, for ESP-01, you will need to connect CH_PD either directly to 3v3 or via a 3k-10k resistor to 3v3. However, you don't need an extra pull-up resistor for ESP-01S as CH_PD already has on-board pull-up resistor. This picture shows the different between ESP-01 and ESP-01S, visually ESP-01 has 2 LEDs on board near the antenna, while ESP-01S have two extra resistor between header pins and ESP8266EX chip, and with only one LED.

Download and install esptool
Download and install esptool from https://github.com/espressif/esptool. esptool is a python application. You need to have python installed as well.
Download firmware 2.1
Download ESP8266 nonOS SDK - Release 2.1.x, noticed that this is not the latest version as the latest version doesn't works for ESP-01 based on my experience.
Upgrade the firmware
You will actually only need 4 files for the upgrade, I would suggest that you copy and paste those files into your esptool directory from the downloaded bin/ directory. cd into your esptool directory and run the following commands to upgrade the firmware.
To put ESP-01 into programming mode:

Press and hold Flash(GPIO0) button;
Press Reset button once, this will put ESP-01 in programming mode;
Press Reset to start the newly uploaded program when upload is completed.

./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x00000 boot_v1.7.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x01000 user1.1024.new.2.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x7c000 esp_init_data_default.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x3e000 blank.bin
./esptool.py --port /dev/cu.SLAB_USBtoUART write_flash 0x7e000 blank.bin

Please noted that /dev/cu.SLAB_USBtoUART is the USB port for my USB-TTL interface, yours might be different, run ls /dev/tty.* to find out your USB port

the AT binaries are published separately from SDK too. https://www.espressif.com/en/support/download/at?keys=&field_type_tid%5B%5D=14

usual is to run esptool as one command started in the at firmware's folder esptool.py write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin (this command is for AT 1.7 and 2 MB or more flash)

@Juraj  You have ESP-01 with 2MB? I never saw any ESP-01 came with 2MB flash unless I buy chip and replace it. Usually I saw  it either come with 512kB or 1MB.

I didn't say that it is for esp-01. I have a command for a 2 MB module so I pasted it as example.

I see. Thanks for the one liner.

I think you might mention that esp-01 need a decent power supply with s good amount of current to prevent any problems while flashing... Definitely I wouldn't suggest connecing Esp's vcc to the USB-TTL but to an external power supply..... If I am wrong please tell me I am a student and I am learning so I can be wrong

@ShamsEl-Deen  Yes, esp-01 could take as much as 170mA during communication, and the short burst of increase of current could cause the drop of voltage down to 3v, and that will cause esp-01 to crash. A good power source of 250mA with a large cap will be sufficient. In my case, my USB-TTL happened to be able to power that while all my Arduino boards (Uno, Leonardo, Nano) failed to power ESP-01.

You use esptool.py available from github.
It's exactly the same usage regardless of which operating system you are using (apart from the serial port device name of course), so instructions for Linux (for example) are the same as instructions for Mac OS X.

The OP doesn't need to upgrade the ESP's firmware, despite that that's what the question said. They apparently want to change its baud rate. That is doable with an AT command in the existing firmware, as described @hcheung described in a comment.
See my answer to a similar question here, noting especially, the last few lines of that post which is essentially a script for manually making the change. Note also, that this is not at all host operating system specific; everything is done with a sketch like the one in that question, and the Arduino IDE Serial Monitor.


text:
ESP8266 not responding after random intervals of time
4th Update:
I bought an ESP32 (the successor to ESP8266) and am getting the same problem. I used the same code except used the Wifi.h library instead, also removed the ESP8266WiFiGratuitous.h code. I added an LED flash at the start of the loop and can confirm the LED stops flashing, so I can confirm the loop() stops running.
This makes me think it must be something to do with my WIFI network.
3rd update:
I've removed all the code and instead uploaded a simple onboard LED blink sketch. The LED has been blinking for over 24 hrs which leads me to think there is something in the wifi code that is making the software crash.
2nd update:
I've even tried resetting the board at the start of the loop() body, every 10 mins, using the millisDelay.h library, calling this method to reset:
void(* resetFunc) (void) = 0;

but that doesn't help either. The loop() method seems to completey stop running.
Update:
I've added experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs(); but am still failing to get a response after 1hr, with about 15 requests made in that hour.
I have this code which works on my ESP8266:
    #include <ESP8266WiFi.h>
    #include <ESP8266WiFiGratuitous.h>

    const size_t input_buffer_length = 256;

    const char* ssid = "iiNetC2DAD7";
    const char* wifiPassword = "aM9PrxcbtkS";
    const char* passwordToOpenDoor = "/87"; //password should begin with a slash

    const int doorPin = 5;
    const int buzzerPin = 4;
    const int toneDuration = 700;

    int numOfRequests = 0;

    WiFiServer server(301); //Pick any port number you like
    WiFiClient client;

    void setup() {
      Serial.begin(115200);
      delay(10);
      Serial.println(WiFi.localIP());

      pinMode(LED_BUILTIN, OUTPUT);
      digitalWrite(LED_BUILTIN, 1);

      pinMode(doorPin, OUTPUT);
      digitalWrite(doorPin, 0);

      pinMode(buzzerPin, OUTPUT);
      digitalWrite(buzzerPin, 0);

      Serial.println();
      Serial.print("Connecting to ");
      Serial.println(ssid);

      WiFi.begin(ssid, wifiPassword);

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

      experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();

      server.begin();
      Serial.println("Server started.");
      Serial.println(WiFi.localIP());
    }

    void loop() {
      client = server.available();
      if (!client) {
        return;
      }

      while(!client.available()){
        delay(1);
      }

      char request[input_buffer_length];
      client.readBytesUntil('\r', request, input_buffer_length);
      Serial.println(request);

      if(strstr(request, passwordToOpenDoor)) {//Is password correct?
        GenerateResponse("Password is correct");
        OpenDoor();
        CorrectPasswordSound();
      }
      //Got a GET request and it wasn't the favicon.ico request, must have been a bad password:
      else if (!strstr(request, "favicon.ico")) {
        GenerateResponse("Password is incorrect.");
      }
    }

    void OpenDoor() {
      digitalWrite(LED_BUILTIN, 0); //flash the onboard LED to help during testing.
      digitalWrite(doorPin, 1);
      delay(500);
      digitalWrite(LED_BUILTIN, 1);
      digitalWrite(doorPin, 0);
    }

    void GenerateResponse(const char *text) {
      Serial.println(text);
      client.print(
          "HTTP/1.1 200 OK\r\n"
          "Content-Type: text/html\r\n"
          "\r\n"
          "<!DOCTYPE HTML>\r\n"
          "\r\n"
          "

"
      );
      client.print(text);
      client.print("

Num of requests: ");
      client.print(++numOfRequests);
      client.print("
\r\n");
      client.flush();
    }

    void CorrectPasswordSound() {
      //Play 1700, 1800, 1900Hz
      for(int i = 17; i < 20; i++){
        int frequency = i * 100;
        tone(buzzerPin, frequency);
        delay(toneDuration);
        noTone(buzzerPin);
      }
    }

However, after a random amount of time, the software crashes and the device won't respond to HTTP requests anymore.

I've tested this by printing to the serial monitor every loop. It seems as though it crashes and the loop() function stops running since it stops printing to the monitor.

I noticed that it'll still reply to pings.

It won't reconnect after restarting the router, I need to press the reset button on the ESP8266 to get it to start working again.

I've tested it by sending an HTTP Get request every 5 mins for many hours (using a C# console app). Sometimes it failed after 45 mins, sometimes 7 hours.

I initially thought it was because I was using String objects, but after getting an answer to this question and testing it out with only C-strings, I still have the same problem.

I've been sending HTTP Get requests using Chrome on my phone and laptop, as well as the .NET Framework class System.Net.Http.HttpClient.

Spec:

Board: AI-Thinker ESP8266MOD
IDE: Arduino 1.8.12
ESP8266 Boards version = 2.6.3
IDE Settings:

I've tried resetting the connection using:
server.stop();
delay(1000);
server.begin();

Then this:
ESP.reset();

Then after those 2 didn't work, this:
ESP.restart();

Resetting it frequently did nothing.
Is there anything in my code that stands out?
If there's nothing wrong withe code, then maybe my only option is to hard reset the board every 30 mins some how.

Your code looks okay. A couple of suggestions. 1) move the WiFiClient client; into the loop() and can combined with server.available(); to form a one liner like this WiFiClient client = server.available();. 2) the only time that the loop() seems to stop running will be the time where if (!client) { return;} which is actually when server is not available. I would suggest instead of simply return, you print something out before the return to see if that's what happening.

@hcheung but then client won't be recognised in the GenerateResponse() function.

Oh, you are right. I guess it has to be at Global then.

make the WiFiClient a local variable. pass it to function as reference. void GenerateResponse(WiFiClient& client, const char *text) {

@Juraj will that provide any benefits?

in past there was a problem with a memory leak if the client object was reused

Have you ruled out any hardware issues, like marginal power supplies, bad connections,  etc? What does enabling the doorPin do?

@StarCat I'm going to try just turning the LED on and off, no wifi or anything and see what happens. The doorPin just turns on a relay.

I don't know if this is your problem, but I'll leave it here because it is certainly a potential bug.
This code in loop:
  while(!client.available()){
    delay(1);
  }

can cause a deadlock if you have a client that drops or doesn't talk.  Turn that around and let the loop keep running.
boolean haveClient = false;

void loop() {
  client = server.available();
  if (client) {
    haveClient = true;
  } else {
    haveClient = false;
  }

  if(haveClient && client.available()){

     // The rest of your loop where you read
     //  from the client goes inside here.

That way if you get a client and then available keeps returning false you can at least keep checking for a client.
This may not be and is not intended to be a code solution. This is probably not the best way to code what I'm trying to say.  I don't know if server.available will keep giving you back the same client or if it is going to cut you off to call that again before the client disconnects.  There may be some method in there to check the connection.  Either way, that's not the point.  The point is to never capture your code into a locked up while loop.  That is always asking for a deadlock.  It's bad practice except for cases like fatal errors where you truly want to lock the thing up.  Let the loop keep looping.  Use if statements to decide which parts get run when.
If you want to check that this is where you are locking up, put some sort of output before and after that while loop.  Print something or turn a light on before and off after.  That way you can tell if this is the spot you're locking up.

After implementing your change, it's worked the longest it ever has, over 7hrs!

Thanks to Delta_G for pointing me in the right direction.
The trick was to not get stuck in the loop() function, ie. no while loops.
The problem was that after you run client = server.available();, the client needs some time before client.available() returns true, which is what the while loop is for, however, for some reason, the client would lose its connection every now and then and client.available() would never return true, in which case you get stuck in the while loop. You need to give it a second chance and let the process start again.
By delaying about 50ms, it seems to be enough time for the client to establish a connection, and if it doesn't, it loops and tries again so quickly that it appears as though the client always gets the connection and the code works fine.
Here's the working code:
void loop() {
  WiFiClient client = server.available();

  if(client){
    delay(50);
    if(client.available()) {
        //rest of code here
    }
}

I'm facing the similar problem especially when the WIFI signal is weak. The connection drop prematurely, end up the software execution is stuck within the while(!client.available()) loop.
A fail-safe timer can be implemented to get out from this loop as follow:
  unsigned int u32FailSafeTimer = 3000;   /*Set 3s timeout*/
  while(!client.available())
  {
    u32FailSafeTimer--;
    delay(1);   /*pause for 1ms*/
    if (0 == u32FailSafeTimer)   /*Fail-safe timer elapsed, get out from unexpected error*/
    {
      Serial.printf("timeout (RSSI: %d dBm)\n\n", WiFi.RSSI());
      client.flush();   /*Kill and prepare for next session*/
      return;
    }
  }

This will be the "server unreachable after a while" problem, which is solved solved by sending gratuitous ARP requests. In the esp8266 Arduino core 2.7 they added functions for this. The main function is experimental::ESP8266WiFiGratuitous::stationKeepAliveSetIntervalMs();. Include <#include "ESP8266WiFiGratuitous.h>
Notes:

You don't know if your loop stops. It doesn't print anything if no client can reach it.
remove the flush() after readBytesUntil(). it doesn't do what you think it does.

You means stationKeepAliveSetIntervalMs? or it is at somewhere else in the source code?

sorry it changed on the way from PR to release. yes stationKeepAliveSetIntervalMs

How do I read the password in the request URL without using readBytesUntil()?

Juraj is suggesting to delete the client.flush(), not the client.readBytesUntil().

Sorry! Misread the answer.

@DavidKlempfner, in setup() after successful connection to AP

Where do I put this line of code?:
WiFi.stationKeepAliveSetIntervalMs(interval).I tried "WiFi.stationKeepAliveSetIntervalMs(1000);" after "WiFi.begin(ssid, wifiPassword);" but got
'class ESP8266WiFiClass' has no member named 'stationKeepAliveSetIntervalMs'

and did you update to 2.7.0?

Yeah I updated the board manager ESP8266 to 2.7. Are there any extra #includes I need to add?

sorry I updated the answer. it is still an experimental function

@Juraj please see my updated question. I added that code but it still failed after 1hr.

@Juraj I tested again, it worked for 5.5hrs and did 82 requests before it timed out.

I will take a SWAG and say it sounds like the watchdog may be getting you. I was getting similar problems but nothing to do with WiFi or anything like that. I determined that when it got stuck in a loop it would sit for a while and then crash. I was able to determine (guess) something was timing out and since the external hardware did not reset and yet it would run setup() again the processor was resetting itself. It would hang with some things appearing to work. After I dug down into it I found that I had to release my code to allow the watchdog to be reset by the internal ESP software. I based this on some information I found about the maximum time allowed for the delay() function. Hopefully this helps.


text:
Arduino Nano, DS3231 RTC clock module and 4 cascaded FC-16 led matrix modules
Like I said in the title, I am using a DS3231 real time clock module and 4 cascaded FC-16 modules(they are basically MAX7219 led matrices based modules). My goal is to display a timetable, a schedule for a classroom on the matrices. The purpose of the DS3231 module is to keep track of time(mainly hours) from 8:00AM to 20:00PM, to display the hour on the matrix and to change the subject when it hits even hours.
Eg: when it's 8:00AM we have subject A, when it's 10:00AM we have subject B etc
And after that I have to use a ESP8266 wifi module to change the schedule from distance.
EDIT1:
I managed to display the hour on the matrix, but now I really can't figure out how to display the text in 4 rows. I have 4 FC-16 modules and I want to put each of them on top of the other so I can have 4 rows of text. I managed to do this by inserting space between words but this is not optimal. I want this to be automated so the person changing the text in the program doesn't have to do the spacing thing by themselves.
#include "RTClib.h"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

const uint16_t WAIT_TIME = 1000;

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 16

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

RTC_DS3231 rtc;

//char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup () {
  P.begin();

  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

 if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
//     If the RTC have lost power it will set the RTC to the date & time this sketch was compiled in the following line
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

  }
}

void loop () {
    DateTime now = rtc.now();

    char buffer[] = "hh:mm";  // hours and minutes
    P.print(now.toString(buffer));  // display

   // Serial.println();
    delay(1000);
}```

Re your edit: you commented-out the rtc.adjust() line. Are you sure your RTC is correctly initialized? If not, the returned DateTime can be invalid, which could result in garbage being printed out. You can also check the value returned by now.isValid().

how do I display the time from the DS3231 clock module on the FC-16
  led matrix modules?

You can use the DateTime::toString() method to convert the
current time to a string in the format of your choice, then P.print()
to display that string on the LED matrix:
void loop() {
    DateTime now = rtc.now();
    char buffer[] = "hh:mm";  // hours and minutes
    P.print(now.toString(buffer));  // display
}

how do I use that hour of the day so that the microcontroller knows
  what text it should display next?

Condition your logic on now.hour().

Thank you very much, I will try and I'll come up with an update


text:
HM-10 controller is not responding to AT commands
I recently purchased new HM-10 module, because old one was clone and it lacks AT+TYPE command. I connected it to my Arduino and I don't know why but I cant see any response in SerialMonitor.
I even tried to use this ble_help() function which worked on my old HM-10 controller but here nothing is returned.
Pins:

TXD --- D2
RXD --- D3

Here is my code:
#include <SoftwareSerial.h>
SoftwareSerial BTserial(2, 3); //Create software serial instance, pins of your choice

char c = ' ';

// Initialization
void setup()
{
  Serial.begin(9600);
  Serial.print("Sketch:   ");   Serial.println(__FILE__);
  Serial.print("Uploaded: ");   Serial.println(__DATE__);
  Serial.println(" ");

  BTserial.begin(9600);
  Serial.println("BTserial started at 9600");
  ble_help();
}

String str_ii = "";
int ii_0 = 0;
void ble_help(){
  BTserial.println("AT+HELP"); // list all AT+ commands
  while (true){ // loop to print all AT+ commands
    char in_char = BTserial.read();
    if (int(in_char)==-1 or int(in_char)==42){continue;}
    str_ii+=in_char;
    if (in_char=='\n'){
      if (str_ii==String('\r')+String('\n')){
        if (ii_0 == 0){
          ii_0 = 1;
          continue;
        }
        break; // break after more than 1 empty carriage return and newline
      }
      Serial.print(str_ii);
      str_ii = "";
    }
  }
}

// Arduino Execution Loop
void loop()
{
  // Read from the Bluetooth module and send to the Arduino Serial Monitor
  if (BTserial.available())
  {
    String hm10msg = "";
    char c;

    while((c = BTserial.read()) != -1) {
      hm10msg += c;
      delay(10);
    }

    Serial.println("Received: " + hm10msg);
  }

  // Read from the Serial Monitor and send to the Bluetooth module
  if (Serial.available())
  {
    c = Serial.read();
    BTserial.write(c);
    //Serial.write(c);
  }
}

Have you tried different baudrates for the HM-10? It might be configured for a different baudrate than 9600

I will try. But 9600 should be default as far as i know

Tried every possibility but it doesnt work

With a new module like this, I just skip the code and connect it straight to my PC with a UART-USB adapter. That way, I can send commands directly from the Serial Monitor and also try out different baud rates easily. Do you have an adapter like this? If you don't, it's possible to use the one on your Nano.

Ok its working now. I have to use BTserial.print(c) instead of BTserial.write(c).


text:
Changes to user included library
I've been putting a small helper library together which I'm just including manually via the libraries sub-directory. I've just made some changes to the library in the filesystem however when trying to compile a previous sketch referencing it (after making the appropriate changes), the compiler is complaining and it appears to still be using the old version of the library. What's going on here and what is the correct way to update such a library?
I have tried completely reloading the Arduino IDE to flush out any caches etc. but that didn't help

rename the library file and see if the compiler complains that it cannot find it

The file path should be included in any error message from the compiler and that should tell you if it's really using the file you think.

Whatever compiler you are using (Arduino IDE?) should have a 'verbose' setting that you can activate.  This will give you a HUGE amount of output, but will also show you exactly what file is being accessed for the library in question.
When I do this, I copy/paste the entire output into Notepad++ and use its search capabilities to sort through all the chaff.
Frank


text:
Trying to do hello world app for Nokia 5110 LCD with arduino yun and johnny five
I have a Nokia 5110 LCD which is using this display PCD8544, I am using a arduino yun and johnny five I have hooked up the following pins. So far with my node app all that happens is the lcd lights up. I am not sure if maybe the lcd is not supported with johnny five, if I have a pin wrong. I followed this site for the pin setup https://lastminuteengineers.com/nokia-5110-lcd-arduino-tutorial/ Any help would be greatly appreciated. This is my first attempt with Johnny five and second attempt at hooking anything up to a bread board. Hope we can get this working. Thanks
Here is my code
const five = require('johnny-five');
const board = new five.Board();

board.on("ready", function() {

    lcd = new five.LCD({
      controller: "PCF8574"
    });

    lcd.print("Hello");
  });

Here is my configuration
blue         =  pin 7          sclk     (serial clock(CLK)) 10 om
white        =  pin 6          DN(MOSI) (Serial data in) 10om
grey         =  pin 5          D/C      (Mode select) 10om
orange       =  pin 4          RST      (Reset) 10om
yellow/red   =  pin 3          SCE      (Chip select) 10om
yellow-short =  power strip +  LED      (backlight supply) 1kom
green/black  =  gnd / strip -
blue/power   =  3.4v power + 330om

Here is are some images of the setup

Update so my configuration looks more like this now
blue         =  pin 7          sclk     (serial clock(CLK)) 10k
white        =  pin 6          DN(MOSI) (Serial data in) 10k
grey         =  pin 5          D/C      (Mode select) 10k
orange       =  pin 4          RST      (Reset) 10k
yellow/red   =  pin 3          SCE      (Chip select) direct
yellow-short =  power strip +  LED      (backlight supply) 330
green/black  =  gnd / strip -
blue/power   =  3.4v power powerstrip direct

does the code compile without errors?

I don't see any errors, I can console log the board, and the repl just starts with johnny five

Follow the instructions on your page: use 10k (not 10 ohms) on the signal lines. Get rid of the 330-ohm connected to the display's VCC, there should no resistance there at all. Use that 330-ohm for the BL pin instead.

that's a mistake on my part I was using 10k, but the 330 I guess was in the wrong spot, so I moved it to the backlight pin, now It doesn't light up. Have to figure this out now.

I added my new config above still no luck

Arduino Yun is a ATMega32U4-based board, like other ATMega32U4-based Arduino boards, such as Arduino Leonardo, Micro, the SPI is only available on the ICSP header:
MOSI - Yun has it on ICSP Pin 4
MISO - Yun has it on ICSP Pin 1
SCK - Yun has it on ICSP pin 3
SS - Yun has no dedicated pin, use any digital data pin

You can find out the ICSP header pin assignment at Arduino SPI reference page. So here is the connection between Arduino Yun and LCD5110
Yun               LCD 5110
ICSP pin3         CLK(SCK)
ICSP pin 4        DN(MOSI)
any GPIO pin      D/C (see note 1)
RST               RST
any GPIO pin      SCE(SS) (see note 1)
any GPIO pin      Backlight (via a 330 ohm resistor) (see note 2)
GND               GND
3v3               VCC

Note 1: Although you could use any GPIO for D/C and SCE, you should consult the library that you are using to see what pin the library used for the data/command line and SS line.
Note 2: Connecting to a GPIO pin allows you to turn on and off the LED backlight, you could ignore the connection if you don't want the backlight, or you could connect it directly to 3v3 via a resistor if you want backlight on permanently

If you still have problem in using the LCD5110, please update your question with complete code and the library that you are using.

Im still working on this, I tried the new arrangment and still no led, or any text to screen. When you say library are you refering to this http://johnny-five.io/api/lcd/ that's the API I am using. The only other thing I can think of is I am using Firmata to connect Johnny Five To the Board. I'll look over my config again and see if I am missing something, but still quite stuck.

I took a look at the library that you are using, I don't think it supports SPI to begin with. The Nokia 5110 is a display with SPI interface and the library seems to be a wrong one.

Oh ok well I will just try and get some leds going, I just wanted to get that libary working period. Down the road want to do some soil testing. Ok I'll select your answer thanks for all the help

Maybe update your answer saying I am using the wrong library, in case someone else needs to know

You can easily find Arduino LCD library for LCD5110 if you are using c++(i.e. Arduino), I wrote my own library a few years ago as part of my learning. Maybe you could port it JS.


text:
Is it possible to overload the digital pins for an Arduino?
I worked on an Arduino project for school that was a self-driving security robot that also acted as a smart home system.
It was essentially a self-driving Roomba-like car that included several LED's(resembling home appliances), three distance sensors, an LCD screen, a motion sensor, an audio amplifier with a speaker, an SD card module to store .wav files, a Bluetooth module to connect with MIT App Inventor, and a motor driver that controlled two electric motors. It's a long list of modules so the Arduino Mega was required. When assembling all of these modules and building the code, I would perform intermittent tests that would isolate the obstacle avoidance and driving, turning on appliances(LED's), and sending and receiving data from the phone app. Every aspect of the project worked in isolation until I combined everything.
When everything was combined, instead of simply driving forward until an obstacle is detected as its programmed, the car would jitter around and not react to walls or obstacles. Also, the LCD screen was heavily dimmed as opposed to when the Arduino was running off of laptop power. Especially when the phone app called for turning on heat or AC, the proper LED's would turn on, but the whole system seemed to respond to the initial load required to read a .wav file and play the corresponding audio and made the jitter worse.
So my question is this, with all these modules plugged into an Arduino, is it possible that the number of modules all needing some input from the digital pins has highlighted a current limitation? All of these issues were exacerbated when the laptop power was replaced with a 9v battery. I was able to confirm that the code was not the issue as I would simply comment out major portions but leaving all the pins initialized. Also, if there is a current output limitation, is there any way to explain why? Thank you for reading my lengthy post and for giving feedback.

what kind of a 9 V battery are you using?

Is the battery one of these 9V block batteries, that are also often used in smoke alarms? You cannot use these batteries, since they are not able to provide enough current. They are for low power applications. And how are all the modules and motors powered? All through the Arduino 5V pin?

It's a 9v block battery, I did some research and found a simple connector that was apparently made for Arduinos. Actually, I thought that maybe it didn't supply enough current initially, so I jumped two of these 9v batteries in parallel with one another hoping to boost the current output. All the modules I listed are powered via the 5v pin I connected to the breadboard and the digital pins do all of the driving and data stuff.

a 9 V block battery consists of six AAAA cells ... try using six AA or six C cells

Hope you're not connecting it all over the onboard 5V voltage regulator. With higher currents from AA/C cells and lots of sensors, motors and so, it'll be quite hot or even shutting down

All the way through this essay I was thinking "It's a 9V battery... it's a 9V battery..."  ... and it was.

As mentioned in the comments, you cannot power your robot from a 9V block battery. These are made for low power projects (like a smoke detector) and cannot provide enough current to drive even only the motors correctly. Using 2 of them does not really help much. You need to change to a different battery type. If you want to stay with alkalines, you could use six AA batteries or C cells, like jsotola suggested. But you might want to upgrade to a fitting LiPo/LiIon battery (in combination with a fitting battery charger module). That would give you enough power for all your needs, while being rechargable.
A different issue: It seems to be, that you provide all the components (sensors and motors) with power through the 5V pin of the Arduino. But especially with motors you can easily reach the current limitation of the voltage regulator on the Arduino. When drawing more current through it, than recommended, the regulator will go in emergency shutdown (with a genuine Arduino; with the cheap clones, the regulator will melt and be destroyed).
Instead you need to be sure, that the drawn current does not exceed the maximum current for the voltage regulator (depends also on the voltage provided). At least the motors should be provided with power parallel to the Arduino, so that the motor current will not flow through the Arduino. It is unclear, how you are controlling the motors. If you are using a motor shield, then look for the terminal for external power supply on it. Most motor shields have them. Depending on the batteries, you will use in future, and on motors and shield, you maybe an directly connect the battery voltage to the shield. Or you need to buy an extra (switching) voltage regulator, which brings the battery voltage down to 5V. In that case be sure, that the regulator can provide the needed current plus some overhead clearance.

Thank you for your input, I included details about the motor driver, not the motors themselves. The motors have their own main power source, an array of 4 AA batteries. It's the Arduino's digital pins that were driving the motor driver.


text:
ATtiny85 - report error "Device reports version as: 2.2"
I've bought ATtiny, from see link.
Trying to upload a basic Blink sketch I get this error: Device reports version as: 2.2.
1) Board manager was updated using http://digistump.com/package_digistump_index.json
2) Board selected as Digispark (Default -16.5MHz )
3) Programmer set to Micronocleus
Tried using some guides on-line, but some were old, some were for windows, while I'm using Ubuntu machine.
Appreciate any help,
Guy

It sounds like you have a newer board than the version of Micronucleus in the Arduino package.
As I discovered here you basically need to upgrade micronucleus in your Ardino installation, which you can download from here

Download the zip file from Github and extract it.  Then in a terminal (if you're not already in one) go to the directory you extracted.
Build the executable by typing "make"
Copy the compiled executable to ~/.arduino15/packages/digistump/tools/micronucleus/<version>/

where <version> is the currently installed version number (e.g., 2.0a4).  There should already be a micronucleus executable in there that you would replace with your newly compiled one.

a `\2.04a' directory was inside that path you noted ( was added after adding digistumb's board manager

@Guy.D Where abouts in the path?

micronucleus after built was move to noted directory. But directory already contains an instance of micronucleus, inside a directory 2.0a4. Should I delete it ? ( didn't help ). Seemed that didn't matter

Replace the existing one with your newly compiled one

guy@desktop:~/.arduino15/packages/digistump/tools/micronucleus$ ls -l total 60 drwxrwxr-x 2 guy guy  4096 May  8 16:06 2.0a4 -rwxr-xr-x 1 guy guy 55616 May  8 17:40 micronucleus

after deleting I get this error msg: "
`java.io.IOException: Cannot run program "REMOVE/launcher": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:11)
at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
at
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 11 more
An error occurred while uploading the sketch'

Did you replace the existing one with the new one, or put the new one up a directory? I have modified my answer

I have deleted entire 2.04 lib, and pasted 1 executable file that was created by make

Make the directory again and move the file into it.

that solved it !!!! thank you !!!


text:
generating signal of 3 phase UPS PWM by SVM
Is there a realization code for 3-phase UPS inverter by Arduino?  I need implementation for SVM by voltage and current feedback.

you can write your own code


text:
FC-16 led matrix module based on MAX7219
EDIT:
const char  *pc[NUM_ZONES] =
{
  "ROOM", //0
  "SUBJECT", //1
  "GRADE",//2
  };

I did this and I can't get them to display every row simultaneously.
void loop(void)
{

 DateTime now = rtc.now();
 char buffer[] = "hh:mm";  // hours and minutes

 for (uint8_t i=0; i<NUM_ZONES; i++){
   P.displayZoneText(0,now.toString(buffer), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   P.displayZoneText(1, pc[1], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   P.displayZoneText(2, pc[2], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);  // display
   P.displayZoneText(3, pc[3], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
 }
}

I can only display one row at a time like this, now it only displays the hour:min.
Tell me what am I doing wrong
EDIT2:
Or like this:
-this is my goal, to change the text based on hour
void loop(void)
{

 DateTime now = rtc.now();
 char buffer[] = "hh:mm";  // hours and minutes

   P.displayZoneText(0,now.toString(buffer), PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);

   if(now.hour()==21){
   P.displayZoneText(1, pc[1], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   P.displayZoneText(2, pc[2], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);  // display
   P.displayZoneText(3, pc[3], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
   }
   P.displayAnimate();
}

And at the moment with this code it only displays the hour and minutes

When you do it by hand like that, how do you figure how many spaces to put between the words?  All you really need to do is to do that same thing in program, but it isn't clear exactly what that process is.

I haven't used this library, but reading through the documentation it seems it operates on the concept of zones.

Create a zone for each row (a zone is a contiguous block of modules forming a kind of sub-display)
Perform operations on the zones with the zone-specific functions.

For example, setting up your zones would be:
P.begin(4); // We will have 4 zones
P.setZone(0, 0, 3); // Modules 0-3 in zone 0
P.setZone(1, 4, 7); // Modules 4-7 in zone 1
P.setZone(2, 8, 11); // Modules 8-11 in zone 2
P.setZone(3, 12, 15); // Modules 12-15 in zone 3

Then you can clear a zone with:
P.displayClear(2); // Clear zone 2

And write text to a zone with:
P.displayZoneText(3, "P03", PA_CENTER, 0, 0, PA_NO_EFFECT, PA_NO_EFFECT);

I'm not certain about what all the parameters mean, but the prototype is:
void displayZoneText(uint8_t z, const char *pText, textPosition_t align, uint16_t speed, uint16_t pause, textEffect_t effectIn, textEffect_t effectOut = PA_NO_EFFECT);

I managed to do that. I created my 4 zones and I can now display text on any of them. Now, I would like to know how to display hour:minutes from the clock module and text simultaneously. Hour and minutes on one row and text on the other 3

You print the time in zone 0 and the other text in the other zones.

Yes, but I don't know the prototype of that. I can't print them. Only separately

I give you an explicit example in my answer.

I gave you an edit


text:
UNIX time in ms to human date time
Been struggling with something for a few days.
Loading data from a website via JSON and it includes an updated date time in milliseconds. This is an EPOCH date and I can get the right value using some of the online convertor sites, epochconvertor.com
That said when I try and parse it in my sketch it’s not retuning the correct date.
JSON
“currentupdatedms”:1588312648603
Convertor Shows as:
1 May 2020 05:57:28.603
My sketch is showing:
1 May 2020 02:33:00
That’s in the JSON and I can’t use a Long as it’s 13 digits. Tried Long Long and it accepts the value but when I later divide by 1000 to get seconds the number changes completely when I try printing it to serial or the OLED.
Plan is to use the Timeh library to display it as a human date time.
Any thoughts be appreciated.
Here is my code and I have tried various methods:
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
#include <TimeLib.h>
#include <time.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define ARDUINOJSON_JSON_LONG_LONG 1 //Not needed???
#define   ONE_HOUR   3600
const size_t capacity = JSON_OBJECT_SIZE(8) + 140;
DynamicJsonDocument doc(capacity);

/*Notes
   Need to look at conversion of Update and Changed times as they are not showing correctly
   Move the conversion of time datetime in ms to a seperate function
   Move the get request and JSON section to seperate function
*/

const char* ssid = "SSID";
const char* password = "PWD";

void setup () {

  Serial.begin(4800);

  Wire.begin(2, 0);           // set I2C pins (SDA = GPIO2, SCL = GPIO0), default clock is 100kHz

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }

  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);

  WiFi.begin(ssid, password);

  display.setCursor(0, 0);
  display.println(F("Connecting to Wifi..."));
  display.display();

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to Wifi...");
  }

  display.setCursor(0, 10);
  display.println(F("Wifi Connected..."));
  display.display();
}

void loop() {

  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status

    display.setCursor(0, 20);
    display.println(F("Requesting Data..."));
    display.display();
    delay(2000); // Pause for 2 seconds

    HTTPClient http;  //Declare an object of class HTTPClient

    http.begin("http://corona.tuply.co.za/DataHandler.ashx?w=s&uq=8f1fp8p5jdxi84481");  //Specify request destination
    int httpCode = http.GET();                                                                  //Send the request

    if (httpCode > 0) { //Check the returning code

      String payload = http.getString();   //Get the request response payload
      Serial.println(payload);                     //Print the response payload

      deserializeJson(doc, payload);

      int TotalCases = doc["TotalCases"];
      int TotalCasesToday = doc["TotalCasesToday"];
      int TotalDeaths = doc["TotalDeaths"];
      int TotalDeathsToday = doc["TotalDeathsToday"];
      int TotalRecovered = doc["TotalRecovered"];
      int TotalTerritories = doc["TotalTerritories"];
      long long CurrentUpdatedMS = doc["CurrentUpdatedMS"];
      long long CurrentChangedMS = doc["CurrentChangedMS"];

      //delay(10000);

      time_t CurrentUpdateMS_t = (CurrentUpdatedMS/1000) + ONE_HOUR; //ONE_HOUR added for BST

      char buffUpdateMS[32];
      sprintf(buffUpdateMS, "%02d/%02d/%02d %02d:%02d:%02d", day(CurrentUpdateMS_t), month(CurrentUpdateMS_t), year(CurrentUpdateMS_t), hour(CurrentUpdateMS_t), minute(CurrentUpdateMS_t), second(CurrentUpdateMS_t));
      Serial.print("U:");
      Serial.println(buffUpdateMS);
      Serial.print("ctime: ");
      Serial.println(ctime(&CurrentUpdateMS_t));

      time_t CurrentChangedMS_t = CurrentChangedMS/1000 + ONE_HOUR; //ONE_HOUR added for BST

      char buffChangedMS[32];
      sprintf(buffChangedMS, "%02d/%02d/%02d %02d:%02d:%02d", day(CurrentChangedMS_t), month(CurrentChangedMS_t), year(CurrentChangedMS_t), hour(CurrentChangedMS_t), minute(CurrentChangedMS_t), second(CurrentChangedMS_t));
      Serial.print("C:");
      Serial.println(buffChangedMS);
      Serial.print("ctime: ");
      Serial.println(ctime(&CurrentChangedMS_t));

      display.clearDisplay();

      display.setCursor(0, 0);
      display.print(F("T Cases: "));
      display.println(TotalCases);

      Serial.print("Total Cases: ");
      Serial.println(TotalCases);

      Serial.print("Total Cases Today: ");
      Serial.println(TotalCasesToday);

      display.setCursor(0, 10);
      display.print(F("T Deaths: "));
      display.println(TotalDeaths);

      Serial.print("Total Deaths: ");
      Serial.println(TotalDeaths);

      Serial.print("Total Deaths Today: ");
      Serial.println(TotalDeathsToday);

      display.setCursor(0, 20);
      display.print(F("T Recov: "));
      display.println(TotalRecovered);

      Serial.print("Total Recovered: ");
      Serial.println(TotalRecovered);

      Serial.print("Total Territories: ");
      Serial.println(TotalTerritories);

      display.setCursor(0, 30);
      display.print(F("U T: "));
      display.println(buffUpdateMS);

      display.setCursor(0, 40);
      display.print(F("C T: "));
      display.println(buffChangedMS);

      display.display();

    }

    http.end();   //Close connection

  }

  delay(60000);    //Send a request every 60 seconds

}

If I run that now I get this JSON string:
{"TotalCases":4036128,"TotalCasesToday":26837,"TotalDeaths":276825,"TotalDeathsToday":849,"TotalRecovered":1400460,"TotalTerritories":214,"CurrentUpdatedMS":1589027095790,"CurrentChangedMS":1589026765665}
CurrentUpdateMS = 1589027095790 which is Sat May 09 2020 13:24:55, granted there may be an hour difference with BST.
Instead I am getting:
Sat May  9 13:23:32 2020
Also appears to stay the same after refreshes which I have set to 60 seconds.
I tried the Time.h library with same results.
Thankful for any input or suggestions.

Do not mix time.h with TimeLib.h: they both define their own version of time_t. 2. This program is too long for a question here. You should break down your problem into small pieces and tackle them one at a time. First, Serial.println(CurrentUpdatedMS) in order to know whether the issue lies in the JSON deserialization or in the interpretation of the number as a time. Then, write a minimal, reproducible example addressing only that issue. See my answer as an example of what a “minimal, reproducible example” may look like.

It's hard to know what is wrong with your code... because you are not
showing it in the question! Here is a basic test I tried on my Uno:
#include <time.h>

const uint64_t ms = 1588312648603;

void setup() {
    time_t t = ms/1000 - UNIX_OFFSET;
    Serial.begin(9600);
    Serial.println(ctime(&t));
}

void loop(){}

It's output is:
Fri May 01 05:57:28 2020

Note that this <time.h> comes from the avr-libc. It uses an epoch
different from the Unix epoch, hence the UNIX_OFFSET correction.
Edit: I tried replacing avr-libc's <time.h> by Adafruit
RTClib (declaring DateTime t(ms/1000);) and Paul
Stoffregen’s Time library (with time_t t = ms/1000;). In all
cases I get the same time displayed.