text:
Wroom 32 can't be recognized by Arduino 1.8.9 on a ubuntu 19.04 computer
I started by plugging my Wroom 32 into my Kubuntu desktop. I checked my /dev before and after, and found no changes. After opening Arduino IDE, I only found my other Arduino, the Arduino Due, in the port list. I already installed the ESP 32 board. What's wrong?

use lsusb and dmesg to determine what is happening ... i.e. run lsusb, plug the WROOM32 in, run lsusb again - anything new detected? run dmesg - check the output for errors regarding the new device

wroom32 has USB?

@Juraj - not the wroom32 itself. I have a "DOIT" ESP32 dev kit - the ESP32 module on it is a WROOM32 - perhaps the OP has a similar dev kit


text:
PIR motion sensor (HC-SR501) false results with NodeMCU
I have a PIR sensor which I use to detect the motion and turn ON and OFF the lights on the basis of it.
I have PIR connected with NodeMCU (ESP8266) based board. I find that sometimes it trigger false positive value. Even when there is no motion. As per my understanding I think any of the following reasons can be there:

I have NodeMCU close to it. So may be because NodeMCU heatness triggers it.
Some hot air blow near it. But I don't know. It trigger the false positive even in mid-night.
It can be trigger by mosquitoes.
I have my other electric wires going from near by.

I am considering these scenarios correct? If yes then how can I prevent from them?
I tried to put it in a box and make it tightly pack. but still its false trigger. I checked even with multiple sensors and have same problem.
Any suggestions to protect this? I also check people put capacitor to smooth it. And put some resistance on Vin.
My Vin of PIR is connected to 5v and OUTPUT pin to D2.
For reference I am having this code for checking.

#define SIGNAL_PIN D2

void setup()
{
  Serial.begin(115200);
  pinMode(SIGNAL_PIN, INPUT_PULLUP);
//  digitalWrite (SIGNAL_PIN, LOW);
}

void loop() {

    static uint32_t lastSeenHigh = millis();
    static bool pirState = false;
    Serial.println(digitalRead(SIGNAL_PIN));

    // If it's active then record that fact along with the time
    if (digitalRead(SIGNAL_PIN) == HIGH) {
        lastSeenHigh = millis();
        pirState = true;
    } else {
        if ((millis() - lastSeenHigh) > 10000) {
            pirState = false;
        }
    }

    if (pirState == true) {
        Serial.println("Pir Is active");
    }
//
    if (pirState == false) {
      Serial.println("PIR sensor inactive");
    }
    delay(1000);
}

Basic PIR sensor (HC-SR501) contain sensitivity adjustment that will adjust the sensitivity range. Here the link that will help you with adjustment PIR

i tried doing adjustments. And it didnt work the way i wanted it.

can you share your code and schematic?

Change INPUT_PULLUP to INPUT_PULLDOWN as you are looking for HIGH event.

LOL. Those sensors and boards are so cheap I built two motion sensors. Lights come on only when both agree there is movement in the room. I'm using Home Assistant to coordinate the automation, but maybe something ingenious could be done for them to communicate directly.

@azoe, Haha, I have been thinking about doing the same thing. That set-up works well, right?

I had the same issue. PIRs have very sensitive circuitry and can be triggered by the WiFi signal from the ESP8266. The answer is to move them apart and with some decoupling of the power supply lines you should see much better performance. My PIR and ESP are now a couple of metres apart and I use shielded cable to connect them together.

I had the same issue. I tried various solutions on the net. Finally i solved my issue like this.

Supplied the PIR sensor 3.3 v (from the NodeMcu board) instead of 5v (my main PS is 5V)
Connected VCC (3.3v) cable to "HIGH PIN" of trigger pins instead of main (+) pin.
It's not generate false positive signals about 2 hours.

Actually, I'm applied that solution -> https://www.youtube.com/watch?v=2HbbQIqJHoE

I was also going through the same issue. But finally, the issue got resolved.
The issue is the PIR sensor that comes with ESP8266 can work with 3.3V as well as 5V.
By default, the wiring is connected to the 5V which may work fine for the Arduino device but not for ESP8266.
I just removed the red cable (power cable) from the connector and connected to the other side where you can see H. That side also there are 3 pins.
Remove the jumper completely and connect to the first PIN from top.
Just make sure you leave the GND and OUTPUT as it is, but only the RED wire will be connected to the first pin on the other side of the PIR sensor.

I glued some aluminum foil onto a piece of a cereal box and folded it around the PIR sensor. Works like a charm!

Nice Hack, is it reliable can you share a image how it looks like in the end ?

source: Stack Exchange

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

sort: votes


text:
How can I run the arduino IDE 1.8.9 on debian testing as regular user?
When I start the arduino IDE as regular user from my debian testing system, I get a crash right after the splash screen:
Temp/arduino-1.8.9/arduino                                                              :)
Picked up JAVA_TOOL_OPTIONS:
java.lang.NullPointerException
        at processing.app.BaseNoGui.onBoardOrPortChange(BaseNoGui.java:679)
        at processing.app.Base.onBoardOrPortChange(Base.java:1317)
        at processing.app.Base$12.actionPerformed(Base.java:1544)
        at processing.app.Base.rebuildBoardsMenu(Base.java:1494)
        at processing.app.Base.<init>(Base.java:275)
        at processing.app.Base.main(Base.java:151)
Temp/arduino-1.8.9/arduino  7,28s user 0,50s system 183% cpu 4,243 total

When I start it with sudo I can use everything regularly. There are quite a few bug reports mainly in the archlinux community about a similar issue, where they suggest to install a package arduino-avr-core to solve it. But I assume, the reason why it happens for me, is different, since it runs fine with root privileges, and we do not have such a package in debian. Debians arduino IDE from the repos is way to old to use it these days with modern boards.
My Groups: tty uucp dialout cdrom floppy sudo audio dip video plugdev systemd-journal netdev bluetooth lpadmin scanner docker
The file permissions are fine for the ide and the arduino data directory.
The permissions for the usb device are also correct, just in case:crw-rw----+ 1 root dialout 188, 0 Mai  4 11:42 /dev/ttyUSB0
My Java environment:
java --version                                                                          :)
openjdk 11.0.3 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+1-Debian-1)
OpenJDK 64-Bit Server VM (build 11.0.3+1-Debian-1, mixed mode, sharing)

Maybe someone ran into the same problem as well?

If you ran with sudo then your Arduino data directory may be locked to your user. Try deleting it. sudo rm -rf .arduino15 when in your home directory.  I am just installing a VM of debian testing to check it out.

Looking at how it runs with sudo under debain - when run with sudo it uses root's .arduino15. When run as the user it uses the user's .arduino15. So it could just be that your .arduino15 directory is screwed and deleting it will fix it.

Wow... it turned out, that I was not aware of the existence of ~/.arduino15. I tried to delete the ~/Arduino and ~/.arduino direcory several times, but to no avail. Deleting ~/.arduino15 indeed fixed the issue.

IDE version 1.5.0 changed the data directory from .arduino to .arduino15 - I guess there were changes in the content formatting for that version, and they wanted to protect earlier versions.

It turned out, that the current Arduino IDE is using a directory ~/.arduino15 for data. I was not aware of the existence of it. The comments to my question made that clear. I tried to delete the ~/Arduino and ~/.arduino direcory several times, but to no avail. Deleting ~/.arduino15 indeed fixed the issue.

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


text:
How to read this hmackey for arduino?
I understand the HMAC with SHA256 example provides a set of keys:
(https://github.com/Cathedrow/Cryptosuite/blob/master/Sha/examples/hmacsha256test/hmacsha256test.pde)
#include "sha256.h"
uint8_t hmacKey1[]={
  0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b
};
uint8_t hmacKey2[]={
  0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19
};
...

I did a bit research and have a sense that these keys are in hexadecimal form with 0x added as prefix. If I like to use my own key, like a string, abece123*, do I just convert the key string to hex?
I tried to use this site below to convert above hmacKey2 to see what the key may look like. But the result is not recognizable. Here's what I did: copy and past
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10,0x11,0x12,0x13,0x14, 0x15,0x16,0x17,0x18,0x19

to the site below to convert to string.
https://codebeautify.org/hex-string-converter
I am very new to this field. Please help me understand how these key works and and the steps needed to replace one of the preset hmac keys with my own key string (e.g. abece123*). Thanks.

Those are examples for keys. You need one key and you can choose any text with any length.
Did you see this line in the example:
sha.initHmac((uint8_t*)"Jefe",4);

It uses the key "Jefe" with a length of 4.
You can use your own key, but you also need the length.
char myKey[] = "abece123*";
int length = strlen(myKey);
sha.initHmac((uint8_t*)myKey, length);

Yes, I also found this later. Thanks for your attention.

Now that we know your key, don't use "abece123*" anymore. You can for example use a full sentence, something that you can remember and is long (for example more than than 20 bytes).

Yep, that will be my next thing to consider. And there's some discussion here: https://security.stackexchange.com/questions/95972/what-are-requirements-for-hmac-secret-key/96176 . I will use a password generator to do that. Although I couldn't tell how secure it is as there's no tool to test if it can be hacked.

Sometimes I make up a fairy tale story that is completely different from other passwords. For example: "once upon a time there was a blue moon that ate cookies", with or without capitals and with or without spaces.


text:
Shall an active piezo buzzer module draw as much as 10mA on its signal pin?
I have connected an active piezo buzzer to my arduino: KY-012 Active buzzer module.
I was a bit surprised that it drew like ~10mA on the signal pin from my nodemcu, which I find a bit weird, since the signal generator itself is powered separately. Even if 10mA is in spec of the GPIO pins I wonder if that much current is considered a normal amount to expect.
The module draws an additional ~10mA from the power supply line.
Has probably someone the possibility to provide comparable measurements?

For what it's worth: https://arduinomodules.info/ky-012-active-buzzer-module/   ... it has 3 pins, but the middle pin is not even connected and the max current is 30 mA (which is within absolute max current limits of an Arduino GPIO but not 'recommended'.

The middle pin must be connected somehow. It draws a current, when the S pin is connected to VCC. But it is correct, that even when unconnected, the module produces a sound.... weird.


text:
VMA101 Mega 2560 upload error
I have a Velleman VMA101 Arduino Mega 2560.
https://www.velleman.eu/products/view/?id=435498
When I connect it to my computer, I can see it on Port COM18 with a yellow triangle, which means something is wrong. On IDE I had COM3 available, so I went to device manager and chaged the port to COM3.

The drivers are installed correctly when I installed the Arduino IDE 1.8.7.
I tried to get the board's info and I got this:
BN: Unknown board
VID: 04E8
PID: 6860
SN: Upload any sketch to obtain it

After that, I tried to upload an empty project to see whether it will work or not. It didn't work and I got this error message:
avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Desktop\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
An error occurred while uploading the sketch
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

What's wrong with my board?
How can I solve this problem?

The board was working perfectly for months

Uninstall the device and let Windows find it again.

I uninstalled everything (devices, drivers), then installed everything again. The computer recognized the device and installed correctly the driver but I got "code 52" which looks related to unknown signature of the driver. How could this be solved?

Embrace the dark side and upgrade to Windows 10? No driver needs to be installed then.

found solution here https://forum.arduino.cc/index.php?topic=317769.0 thanks anyway


text:
Serial input help
Hey guys I have a LED strip with 6 LEDS
(I control these through Kinect & processing. It sends 1,2,3,4,5,6 to Arduino. This seems to work fine.)
In Arduino LED0,LED1,LED2,LED3,LED4 work perfectly but the last one don't work. it doesn't light up at all.
Anyone know what's going on?

#include <FastLED.h>

#define LED_PIN     13
#define NUM_LEDS    6

CRGB leds[NUM_LEDS];

void setup() {

  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  Serial.begin(9600);

}

void loop() {

  if (Serial.available() > 0) {
int incomingByte = Serial.read();

  //1
if(incomingByte=='1'){
  leds[0] = CRGB(255, 0, 0);
  FastLED.show();}
if(incomingByte=='2'){
  leds[0] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[0] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='4'){
  leds[0] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[0] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[0] = CRGB(0, 0, 0);
  FastLED.show();}

 //2
 if(incomingByte=='1'){
  leds[1] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='2'){
  leds[1] = CRGB(255, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[1] = CRGB(0, 0, 0);
  FastLED.show();}
  if(incomingByte=='4'){
  leds[1] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[1] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[1] = CRGB(0, 0, 0);
  FastLED.show();}

  //3
   if(incomingByte=='1'){
  leds[2] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='2'){
  leds[2] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[2] = CRGB(255, 0, 0);
  FastLED.show();}
   if(incomingByte=='4'){
  leds[2] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[2] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[2] = CRGB(0, 0, 0);
  FastLED.show();}

  //4
   if(incomingByte=='1'){
  leds[3] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='2'){
  leds[3] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[3] = CRGB(0, 0, 0);
  FastLED.show();}
    if(incomingByte=='4'){
  leds[3] = CRGB(255, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[3] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[3] = CRGB(0, 0, 0);
  FastLED.show();}

  //5
   if(incomingByte=='1'){
  leds[4] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='2'){
  leds[4] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[4] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='4'){
  leds[4] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[4] = CRGB(255, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[4] = CRGB(0, 0, 0);
  FastLED.show();}

  //6
   if(incomingByte=='1'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();
if(incomingByte=='2'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='4'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[5] = CRGB(255, 0, 0);
  FastLED.show();}

}
  }
}

here's the processing code:
float x = 100;
float y = 50;
float w = 150;
float h = 80;

import org.openkinect.freenect.*;
import org.openkinect.processing.*;
import processing.serial.*;

// The kinect stuff is happening in another class
KinectTracker tracker;
Kinect kinect;
Serial myPort;

void setup() {
  size(512, 424);
  kinect = new Kinect(this);
  tracker = new KinectTracker();
  String portName = Serial.list()[3]; //change the 0 to a 1 or 2 etc. to match your port
  myPort = new Serial(this, portName, 9600);
}

void draw() {

  tracker.track();
  tracker.display();

  PVector v1 = tracker.getPos();
  fill(50, 100, 250, 200);
  noStroke();
  ellipse(v1.x, v1.y, 50, 50);

   //1
    if (v1.x > 0 && v1.x < 50 ){
    println('1');
    //rect(0,200,200,200);
    myPort.write('1'); }
    //println('0'); }

    //2
  if (v1.x > 50 && v1.x < 100){
    println('2');
    myPort.write('2'); }
 //3
   if (v1.x > 100 && v1.x < 150 ){
    println('3');
    myPort.write('3'); }

    //4
   if (v1.x > 150 && v1.x < 200 ){
    println('4');
   myPort.write('4'); }

    //5
   if (v1.x > 200 && v1.x < 250 ){
    println('5');
    myPort.write('5'); }

    //6
   if (v1.x > 250 && v1.x < 300 ){
    println('6');
    myPort.write('6'); }

}

Can you make the LED light up manually? That is, write simpler code that just turns that LED on and nothing else.

Your problem lies in the position of the closing bracket of the first if statement for LED 6:
//6
if(incomingByte=='1'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();         // here the closing bracket is missing
if(incomingByte=='2'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='3'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='4'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='5'){
  leds[5] = CRGB(0, 0, 0);
  FastLED.show();}
if(incomingByte=='6'){
  leds[5] = CRGB(255, 0, 0);
  FastLED.show();}

} // this is the missing closing bracket
  }
}

This means, that this whole block will only be executed, when incomingByte has the value '1'. This also means, that the last if statement will never be executed. Correct the position of the marked closing bracket and it should work.

Besides that, your code is a very complicated way of doing this. Why not simply switching the incomingByte? Also, to write less code and making it more understandable, use a function to turn all LEDs to off ("resetting" them):
void reset_LEDs(){
    for(int i=0;i<NUM_LEDS;i++){
        leds[i] = 0;
    }
}

void loop(){
if (Serial.available() > 0) {
    int incomingByte = Serial.read();

    switch(incomingByte){
        case '1':
            reset_LEDs();
            leds[0] = CRGB(255, 0, 0);
            break;
        case '2':
            reset_LEDs();
            leds[1] = CRGB(255, 0, 0);
            break;
        ...
    }
    FastLED.show();
}
}

When you stay with such easy conditions, you can even optimize more:
int incomingByte = Serial.read() - '0'; //Convert ASCII character value to decimal int value, by subtracting the ASCII value of zero
if(incomingByte > 0 && incomingByte <= NUM_LEDS){ //Test, if the incomingByte lies between 1 and NUM_LEDS including
    reset_LEDs();
    leds[incomingByte - 1] = CRGB(255, 0, 0); // -1 because array counting starts with 0, we start counting with 1
    FastLED.show();
}

For both versions, you save time, because you we only call `FastLED.show()´ once, when a change happens, not multiple times.

Thank you for this!

If this answers your question, you can accept it as correct. Thanks


text:
Programming arduino with FT232RL, not in sync: resp=0x00
I realize this generic error has been asked about lots of times before, but I have been unable to find an answer that works for me.
I have a bunch of pro mini's that I program with an FT232RL. It works perfectly fine for some time, but eventually it stops working and I get the error:
avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
Using the same FT232RL on an unused pro mini still works fine. Burning a new bootloader through an Uno as ISP works fine, as well as uploading code to the pro mini that way, but even after burning the bootloader the FT232RL does not work on that pro mini again.
I have experienced this exact behavior on three different pro minis in a row now. Is there any sort of factory reset-ish thing I can do other than the bootloader to try to get these back to square one?

Are they 3.3V or 5V Pro Minis?

They're 5V pro minis.

Bang goes my idea then. Oh well. Still, try this anyway: Write some small code to test that the UART is actually functional, and burn it using another Arduino.

do not upload a sketch over ISP after you burned the bootloader. it erases the bootloader


text:
Generating variable frequency of 3 phase SPWM
I got a sample of program to generate 3 phase SPWM from this Controlling output frequency of 3 Phase SPWM Inverter. As far as I understood, the frequency generated is constant. My question is how can I make it a variable frequency generated? I am using Arduino mega right now.

I've edited the code in that post to my latest code! I suggest you take a look at the signal on proteus scope, but first try to filter all signals with 1K ohm resistor and 0.37uF capacitor connected in series. Put your scope probe at the end of resistor. Hope that will help!

can i know what is the max fequency you used in the code? because i'm still trying simulate the code and cant capture the frequency generated. Hope you can clarify me a bit.

It's around 0 - 200Hz. I've checked using my inverter circuit and Oscilloscope.


text:
Using Servo on Timer3 on a Leonardo
I would like to use the Radiohead library and control a servo from the same Leonardo board.
Now the Radiohead library occupies timer1 and therefore cant be used together with the servo library. (It does offer to use timer2 which the Leonardo does not have.)
Are there any other Servo libraries that use timer3 or timer4 which the Leonardo has?
I have already tried:

https://github.com/nabontra/ServoTimer2  does not compile
https://www.pjrc.com/teensy/td_libs_TimerOne.html does not work (calling function blocks)

I wonder if you could use this PWM version of the Servo library written for the Arduino MEGA? Looking at the code, it looks like you would have to remove the "else if (pin == 44)" and "else if (pin == 45)" blocks of code in the attach() and detach() functions in Update Servo_Hardware_PWM.cpp. Just guessing here. I haven't tried it out.
https://github.com/dadul96/Arduino-Servo-Hardware-PWM-Library

Comment from an anon user: Sorry, this won't work. I checked the datasheet for the ATMega32u4 and Timers 3 and 4 can't be used to change the state of a pin. So no, hardware servo control using the above code on a Leonardo.

You could try manually sending the servo pulses with something like:
digitalWrite(SERVOPIN,HIGH);
delayMicroseconds(pulseWidth);
digitalWrite(SERVOPIN,LOW);

As long as the duration of the pulses is consistent, it doesn't matter if they don't occur regularly.
Downsides will be that there may be jitter if there are interrupts running, although there is the advantage that this will work on just about any pin.
If you are looking for a simple proof of concept, this may enough to test it out.

In file ServoTimers.hin standard Arduino Servo library change the timer
#elif defined(__AVR_ATmega32U4__)
#define _useTimer3
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t;

on Windows the file ServoTimers.h is located in C:\Program Files (x86)\Arduino\libraries\Servo\src\avr

thanks, but this leads me to the compile error described here: https://forum.arduino.cc/index.php?topic=527356.0

you get that error only if you don't change the timer number to 3 as I write in the Answer

oki fixed the compile error. now the problem is that as soon as the servo is connected (pin 5) the radiohead library seems to stop working.

could it be a powering problem?

could be, i will try to run it with external power supply and not the usb.

interestingly the internal LED starts to pulsate a few seconds after i connect the servo pin. it stops that again a few seconds after disconnecting it.


text:
UDP behavior different for STM32
I'm facing a weird situation, where the UDP behavior seems different in STM32 porting (stm32duino).
Short question
Besides port and address, what are the other parameters that characterize the UDP protocol?
Long description
My code listens for incoming UDP packets and answer.
The actual packets contains OSC messages, but they are just UDP messages with binary data.
On host side there is a proprietary software (MAX) that send those packets. The issue is the following:

run both Arduino board and MAX software
from software send a packet
the Arduino receives the packet, and answer
the software receive the answer
now if the software sends more packets, they are not received anymore from Arduino

The weird thing is if I use another application to send the very same packets (i.e. PacketSender) all works fine and I can always send and receive correctly.
Furthermore, this happens with the STM32 porting only. The same code compiled for the standard Arduino Uno works fine.
Now some code:
//#define STM32
#define UNO

#if defined(UNO)
#include <SPI.h>
#include <Ethernet.h>
#elif defined(STM32)
  #include <LwIP.h>
  #include <STM32Ethernet.h>
#endif

#include <EthernetUdp.h>

#include <OSCMessage.h>
#include <OSCBundle.h>
#include <OSCData.h>

#if defined(UNO)
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
#endif

IPAddress remoteIP;
int remotePort;
OSCBundle bundleOut;
EthernetUDP Udp;
OSCErrorCode error;

void setup()
{
  Serial.begin(115200);

#if defined(UNO)
  Ethernet.init(10);
#endif
  IPAddress localIP(192, 168, 100, 1);
  IPAddress subnet(255, 255, 0, 0);
  IPAddress dns(192, 168, 1, 1);
  IPAddress gateway(192, 168, 1, 1);

#if defined(UNO)
  Ethernet.begin(mac, localIP, subnet, dns, gateway);
#elif defined(STM32)
  Ethernet.begin(localIP, subnet, dns, gateway);
#endif

#if defined(STM32)
  uint8_t *mac = Ethernet.macAddress();
#endif
  char macString[32];
  sprintf(macString, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  Serial.print("IP Address: ");
  Serial.println(Ethernet.localIP());
  Serial.print("MAC Address: ");
  Serial.println(macString);

  int port = 8888;
  Udp.begin(port);
  Serial.print("UDP port: ");
  Serial.println(port);
}

void processOSCMessage(void)
{
  OSCBundle bundle;

  int size = Udp.parsePacket();
  if (size > 0)
  {
    remoteIP = Udp.remoteIP();
    remotePort = Udp.remotePort();

    while (size--) bundle.fill(Udp.read());
    Serial.print("Source: ");
    Serial.print(remoteIP);
    Serial.print(":");
    Serial.println(remotePort);
    if (bundle.hasError())
    {
      error = bundle.getError();
      Serial.print("Error: ");
      Serial.println(error);
    }
    else
    {
      int size = bundle.size();
      for (int i = 0; i < size; i++)
      {
        OSCMessage msg = bundle.getOSCMessage(i);
        char buffer[32];
        msg.getAddress(buffer);
        Serial.print("Message: ");
        Serial.println(buffer);
      }

      bundle.route("/version", version_handler);
    }
  }
}

void version_handler(OSCMessage &msg, int patternOffset)
{
    OSCBundle bundle;
    Serial.println("Answer to message");
    bundle.add("/version").add(1).add("0.1");
    Udp.beginPacket(remoteIP, 8888);
    bundle.send(Udp);
    Udp.endPacket();
}

void loop()
{
  processOSCMessage();
}

I can't understand the difference between the MAX application and PacketSender. They are both configured to send the same data, to the same address and same port, what else?
MAX is still working after point 5 because if I redirect the address to another pc where I have PacketSender I still receive the messages. It seems it's just the STM32 Arduino library that doesn't receive anymore the packets.
For STM32 I'm using the following setup:

Nucleo F429ZI
STM32Ethernet (https://github.com/stm32duino/wiki/wiki/STM32Ethernet)
LwIP per STM32 (anche questa la trovi nel gestore librerie)

Any further idea how to fix this issue?
UPDATE
Following the suggestion, using WireShark I found the only difference between the two packets: the source port. I'm not saying this is the cause, but it's the only difference I can see.
PacketSender sends packets from the same port it also listens too (i.e. 8888).
MAX sends packets from a random port while it listens to the 8888.
Now I can partially replicate the behavior using PacketSender:

open two instances of PacketSender
A: set UDP port to 8888
B: set UDP port to another, say 50127
from B send the packet to Arduino (STM32)
Arduino receives the packet and answers to 8888
A receive the answer
now if I send more packets from B, they are not received anymore from Arduino, this is the same behavior using MAX
BUT if now I send packets from A they are received from Arduino and answered!

So it seems the problem rises when Arduino answer to a different port than the source one. This make no sense to me because the involved port is the source one (host side). Because UDP has no connection, why this might lead to such an issue!?
Furthermore, using the same code compiled for Arduino UNO, it works fine even at point 7.

I would suggest running Wireshark (or something similar) to examine the packets and see what is actually different.

Thanks, question updated.

Are you using a W5100 interface with the STM32, or does it have its own internal Ethernet controller that just needs a PHY interface? I'm not that familiar with that family of chips.

@Majenko the F429ZI embed an Ethernet controller. It just needs the PHY interface.

I would be inclined to raise it as an issue with the maintainers of the core / library.


text:
Clear Timer on Compare or CTC in ATmega328P, Toggle OC0A on Compare Match
I want to use the CTC on the ATmega328P to play same notes with a speaker, a project that I find in this book.
In the data sheet I read:

For generating a waveform output in CTC mode, the OC0A output can be set to toggle its logical level on each compare match by setting the Compare Output mode bits to toggle mode (COM0A1:0 = 1). The OC0A value will not be visible on the port pin unless the data direction for the pin is set to output.

So I suppose that after I initialize the CTC and set as output the PIN PD5 (where I connected the speaker) the TCNT0 will change as a sawtooth wave (during time) and the PIN PD5 will be or 0V or 5V depending on the TCNT0 value. Is it correct?
So I change a little bit the code that is in the book:
#include <avr/io.h>
#include <util/delay.h>
#include "scale8.h" //Use to convert C2,C3 ... in numbers, for instance C2 = 100

static inline void initTimer(void) {         //Inializzazione del timer
    TCCR0A |= (1 << WGM01);                  /* CTC mode */
    TCCR0A |= (1 << COM0A0);                 /* Toggles pin each cycle through */
    TCCR0B |= (1 << CS00) | (1 << CS01);     /* CPU clock / 64 */
}

static inline void playNote(uint8_t period, uint16_t duration) {

    TCNT0 = 0;                                 /* reset the counter */
    OCR0A = period;                            /* set pitch */
    DDRD |= (1 << PD5);                        /* enable output on speaker */

    for(int i=0; i<duration; i++){             /* Variable delay */
        _delay_ms(1);
    }

    DDRD &= ~(1 << PD5);                        /* turn speaker off */
}

int main(void) {
    // -------- Inits --------- //
    initTimer();

    // ------ Event loop ------ //
    while (1) {
                                                    /* Play some notes */
        playNote(C2, 200);
        playNote(E2, 200);
        playNote(G2, 200);
        playNote(C3, 400);

        _delay_ms(1000);
        _delay_ms(1000);
        _delay_ms(1000);

    }
    return 0;
}

The problem is that the voltage of the PIN PD5 doesn't change! I try to print the voltage using serial but it's always 0V.

How are you measuring pin PD5? (PS I'd change TCCR0B |= (1 << CS00) | (1 << CS01);  to TCCR0B = (1 << CS00) | (1 << CS01);, so it doesn't depend on TCCR0B being zero.)

@Gerben Now I can't measure it directly, so I simple print PORTD and see the corresponding value of PD5. It's always 0.

The timer doesn't manipulate the port registers. It directly controls the physical port. PORTD doesn't get touched.

But reading PIND should reflect the actual values on the pins, no mater if it's alternate output (or even shorted output to the rail, you'll get that shorted level).


text:
Can't use MEGA as Transmitter and UNO as Receiver nRF24L01
I have a project with 7 May Deadline, i really need help on this. Here is the problem, I need to use my Arduino MEGA 2560 as transmitter and Ardino UNO(CH340G) as receiver. I can use uno as transmitter and mega as receiver , but vice versa doesn't works.
I've used the tutorial on this site :
https://howtomechatronics.com/tutorials/arduino/arduino-wireless-communication-nrf24l01-tutorial/
All codes, connections are same, but when i set MEGA as transmitter and uno as receiver, there is no data coming to Serial port of Uno. I really need help on this, i will be very very very grateful. Thank you so much.
Code on MEGA(transmitter)
/*
* Arduino Wireless Communication Tutorial
*     Example 1 - Transmitter Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

Code for receiver(UNO)
/*
* Arduino Wireless Communication Tutorial
*       Example 1 - Receiver Code
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
* Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

    PINS ON MEGA :
    3.3 -- VCC
    GND -- GND
    8   -- CSN
    7   -- CE
    51  -- MOSI
    52  -- SCK
    50  -- MISO
    PINS ON UNO :
    3.3 -- VCC
    GND -- GND
    8   -- CSN
    7   -- CE
    11  -- MOSI
    12  -- MISO
    13  -- SCK

Please show your actual wiring for both devices. Also your code would help.

I have edited my post, thank you so much i will be very grateful for all helps please.

Are both your modules identical? If you swap the modules over does it start working?

I will try it now thanks for advice :D i hope it works

It didn't worked , but thanks for help :D Still waiting for somone to help me btw :D i ll be very thankful if someone can , thanks a lot.

Shame. Still, we know it's not the modules at fault.

Did you add a capacitor to the 3V3? https://www.instructables.com/id/NRF24L01-Fixing-Connection-Issues/

I didn't i 'll try when i get home but vice versa works, mega can work as receiver but not as transmitter, but thank you i will try , still waiting for help , thanks


text:
There's an error I don't know how to fix
I basically have a bread board with an rgb led and a peizo buzzer with a photocell.
I have the codes for both. If I put a code for the rgb, it works. If I put the code for the peizo, it works. Once I paste both codes onto it it says there's an error because "void setup" and "void loop" are already defined. What do I do to get both things to work?
rgb led code:
/*
Adafruit Arduino - Lesson 7. RGB Fader
*/
int redLEDPin = 11;
int greenLEDPin = 10;
int blueLEDPin = 9;
int redSwitchPin = 7;
int greenSwitchPin = 6;
int blueSwitchPin = 5;
int red = 0;
int blue = 0;
int green = 0;

void setup()
{
  pinMode(redLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
  pinMode(redSwitchPin, INPUT_PULLUP);
  pinMode(greenSwitchPin, INPUT_PULLUP);
  pinMode(blueSwitchPin, INPUT_PULLUP);
}

void loop()
{
  if (digitalRead(redSwitchPin) == LOW)
  {
    red ++;
    if (red > 255) red = 0;
  }
  if (digitalRead(greenSwitchPin) == LOW)
  {
    green ++;
    if (green > 255) green = 0;
  }
  if (digitalRead(blueSwitchPin) == LOW)
  {
    blue ++;
    if (blue > 255) blue = 0;
  }
  analogWrite(redLEDPin, red);
  analogWrite(greenLEDPin, green);
  analogWrite(blueLEDPin, blue);
  delay(10);
}

peizo code:
int speakerPin = 12;
int photocellPin = 0;

void setup()
{
}

void loop()
{
  int reading = analogRead(photocellPin);
  int pitch = 200 + reading / 4;
  tone(speakerPin, pitch);
}

you can have only one setup() block and only one loop() block .... you have to merge the code from each pair of the blocks into one block

Putting all other possible issues aside such as pin and timing conflicts.
Rename the sketch setup() and loop() functions, for instance, rgb_led_setup() and rgb_led_loop(), and peizo_setup() and peizo_loop(), then rewrite:
void setup() {
  rgb_led_setup();
  peizo_setup();
}

void loop() {
  rgb_led_loop();
  peizo_loop();
}

Cheers!


text:
Motor isnt spinning when using L298N motor controller
I have a L298 motor controller connected to a motor with a 6 volt power sources. the motor however isn't spinning any ideas I'm using a esp 8266 node mcu board. I would like to use pwm but for right now I'm just trying to get it to work so I disabled the pwm.
//int d0 = 16;
const int d0 = 16;
const int d4 = 2;

//=======================================================================
//                    Power on setup
//=======================================================================
void setup() {
  Serial.begin(115200);
  pinMode(d0,OUTPUT);
  //pinMode(d1,OUTPUT);
  pinMode(d4,OUTPUT);
}

//=======================================================================
//                    Main Program Loop
//=======================================================================
void loop() {
  //PWM Value varries from 0 to 1023
  Serial.println("10 % PWM");
  //analogWrite(d0,102);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("20 % PWM");
  //analogWrite(d0,205);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("40 % PWM");
  //analogWrite(d0,410);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("70 % PWM");
  //analogWrite(d0,714);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

  Serial.println("100 % PWM");
  //analogWrite(d0,1024);
  digitalWrite(d0,HIGH);
  digitalWrite(d4,LOW);
  delay(2000);

}

Did you remembet to supply power to the controller itself?

I did connect 9v to the controller in the is there something else im missing?

Um... The controller itself needs ~5V logic supply voltage (7V max). Where do you connect your 9V supply to? If you have that popular pre-assembled L298N motor board with a built-in linear regulator, and you connect 9V to VCC, you will also have to install the jumper to enable the linear regulator to produce 5V for the logic supply. Or, alternatively, you can connect the "5V" pin to some other 5V supply. Either way, you have to provide a 5V for the logic to work.

https://drive.google.com/file/d/19EKge7SHiktcq1ulWxvT7IfyXD5St_MM/view?usp=sharing

That's a picture of how I have the motor controller setup does it look right?

That doesn't look right. The actual motor power supply is supposed to be connected to the leftmost pin in the group of 3. And in your case it is not connected to anything. The logic power supply (5V) is supposed to be connected to the rightmost pin in the group of 3 (red wire in your picture). What is this red wire? Is this a power supply to L298N? Or is it powering something else from L298N?

You need two supply voltages for this board to work: motor supply, which goes directly to your motor (up to 35V for this L298N board, depends on what your motor needs), and logic supply of 5V, which powers the board's logic chips. If the motor supply voltage is between 7V and 12V, you can derive 5V logic supply from motor supply by enabling this board's built-in linear regulator.

The actual motor power supply should be connected to the VCC terminal of the L298N board you have in your picture. This is the leftmost terminal in the block of 3 in the picture (sometimes it is labeled +12V instead of VCC). In your case it is not connected to anything at all. This is already wrong.
It is not clear what the purpose of the red wire is in your picture.
In your comments you mention different voltages of motor power supply (6V in one place, 9V in another...). If you are feeding this board 9V through the red wire, you are doing it wrong. The rightmost terminal in the block of 3 is the 5V pin. Don't attempt to feed more than 5V to that pin.
If you'll be using the red wire to supply 5V logic power to the L298N board from an external source, then you need to disable this board's own linear regulator - remove the jumper that is shown above the 3-terminal block.
If you'll decide to use it to supply 5V logic power from the L298N board (e.g. to your Arduino), then you have to keep the jumper.
In any case, the leftmost terminal has to be connected to motor power supply.


text:
Serial monitor error message
I connected my ArduCam mini to es8266 board and opened serial monitor. Then this message appeared. It started to appear continuously. I used the code in examples "functions of ov2640". What does it mean?  Why that message appears?  Plz help. Thank you.

it is a watchdog reset. the code doesn't go out of the loop() function

How can i fix it?

I used
"extern "C" {
#include "user_interface.h"
}" in the code before the setup functions

add the sketch to the question

You can "fix" it by removing long loops (while, etc) from your code.

I have added the code as an answer below..

Add the code to your question by editing it. Also format it correctly by selecting it and clicking the {}  button

the sketch is not for esp8266

Is there any example sketch in arduino IDE which i can use to capture image from arducam with esp8266?

@juraj this is the task what i want to do.                        Capture image through arducam mini ov2640 and save it to SD card attached to nodemcu. How can i find the sketch to do this task?

https://github.com/ArduCAM/Arduino/blob/master/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Capture2SD/ArduCAM_ESP8266_V1_OV2640_Capture2SD.ino

I tried using the code you gave in github. Again it shows an error saying "ArduCam start! SPI1 interface error!"

did you wire D0 as CS? the sketch uses io 16 (D0) as SPI CS

I connected cs pin in arducam to D0 in nodemcu


text:
ESP8266 I2C datasheet pins not the same as several examples
According to espressif datasheet of the ESP8266 it uses
MTMS (I2C_SCL) and GPIO2(I2C_SDA) for I2C.
However in several examples I've seen the typically use is GPIO(4&5) or GPIO(0&4) to connect to the I2C.
I guess all method works? but what is the real difference?

Many modules don't have the right pins for I2C available. Thus it was decided that the sensible option would be to use a bit-banged implementation of I2C using software only.
Also GPIO2 has a special meaning for booting, and using it is risky at best, and should be avoided.
Doing it 100% in software has the advantage that any pin combination can be used for I2C.


text:
Nodemcu ESP12-E (ESP8266), Can I reprogramming when the UART pins are defined as GPIO?
I wonder if there may be any problems using the pins that the UART are using as GPIOs, if now I want to be able to reprogram the circuit?
(Of course I will detach the ESP12-E from the mainboard before so)

flash mode is achieved using a combination of GPIO 0, 2 and 15 ... so, since UART is on 1 and 3, it will be flashable if powered up with 0-LOW, 2-HIGH and 15-LOW - since your sketch won't be running in this mode

keep in mind that this pins are the only way to change the application in esp8266 in any case. (OTA is the other way, but it must be supported by the running application)

Sure, you can use the UART pins as general purpose IO pins - however, it's far from ideal - for one simple reason:

The ROM issues messages on the UART at boot time.

This means that when you power the chip up whatever is connected to the UART TX pin will receive pulses of HIGH and LOW.
That may or may not be a problem, depending on what is connected. It's something you need to bear in mind though.

Is the UART TX pin the only pin of this concern then?

Yeah. The RX pin is an input, and during normal boot isn't actually used for anything.

However, the RX (gpio3) pin is apparently pulled HIGH on boot, just like pins 12, 13 and 14 - also, driving gpio 1 (TX) low on boot will prevent boot - one common use for RX is i2s - it's the SD pin for i2s output


text:
My Arduino got stuck and continuous looping in if condition
I'm using RTC and when the if condition is true the Time gots stuck and the condition keeps looping. Please help
Here is my code:
// CONNECTIONS:
// DS1302 CLK/SCLK --> 5
// DS1302 DAT/IO --> 4
// DS1302 RST/CE --> 2
// DS1302 VCC --> 3.3v - 5v
// DS1302 GND --> GND
#include <Servo.h>
#include <ThreeWire.h>
#include <RtcDS1302.h>

ThreeWire myWire(4,5,2); // IO, SCLK, CE
RtcDS1302<ThreeWire> Rtc(myWire);
int servoPin = 3;
Servo Servo1;
void setup ()
{
    Serial.begin(57600);
    Servo1.attach(servoPin);
//    Serial.print("compiled: ");
//    Serial.print(__DATE__);
    Serial.println(__TIME__);

    Rtc.Begin();

    RtcDateTime compiled = RtcDateTime(__TIME__);
    printDateTime(compiled);
    Serial.println();

    if (Rtc.GetIsWriteProtected())
    {
        Serial.println("RTC was write protected, enabling writing now");
        Rtc.SetIsWriteProtected(false);
    }

    if (!Rtc.GetIsRunning())
    {
        Serial.println("RTC was not actively running, starting now");
        Rtc.SetIsRunning(true);
    }

    RtcDateTime now = Rtc.GetDateTime();
    if (now < compiled)
    {
        Serial.println("RTC is older than compile time!  (Updating DateTime)");
        Rtc.SetDateTime(compiled);
    }
    else if (now > compiled)
    {
        Serial.println("RTC is newer than compile time. (this is expected)");
    }
    else if (now == compiled)
    {
        Serial.println("RTC is the same as compile time! (not expected but all is fine)");
    }
}

void loop ()
{
    RtcDateTime now = Rtc.GetDateTime();

    printDateTime(now);
    Serial.println();
    delay(5000);

//here is my problem>>>>

    if(now.Hour() == 22 && now.Minute() == 40)
    {
      Servo1.write(0);
      delay(1000);
      Servo1.write(90);
      delay(1000);

    }

//////////////////////

    delay(5000);

}

#define countof(a) (sizeof(a) / sizeof(a[0]))

void printDateTime(const RtcDateTime& dt)
{
    char datestring[20];
//%02u/%02u/%04u
    snprintf_P(datestring,
            countof(datestring),
            PSTR("%02u:%02u:%02u"),
//            dt.Month(),
//            dt.Day(),
//            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
    Serial.print(datestring);
}

Um... What does "Time gots stuck" mean? Your condition is true for a whole minute.

when the condition is true the time interval of rtc gots stuck and the codition above keeps looping

It is loop() function keeps looping. That's what it is for, as the name suggests. What made you believe that "time interval of rtc gots stuck" is not clear to me.

The time is stuck and the condition keeps triggering..

What made you believe that "the time is stuck"??? The condition should keep triggering again, again and again for a whole minute. That's what you wrote in your code.

Im looking in serial monitor and the time got stuck when the condition is reach. And it keeps triggering the servo again and again..

Post the serial monitor output from printDateTime(now); in loop(). Do you see the same time printed continuously?

The ds1302 is not a good rtc, the ds1307 is better, but the ds3231 is the best by far. The ds1302 can freeze and there can be troubles with the crystal. Could you upgrade to a ds3231. The ds3231 has an internal crystal, so there are no problems with bad quality crystals.

AnT It stuck on condition and the servo keeps triggered 5 to 10 times and the time continue after triggering.

Im not using crystal

i think i have a problem in delay seconds

Im not using crystal -- So.... how does the clock "tick" then...?

You do know that a minute lasts for a whole minute, don't you? It's not some instantaneous thing that only happens for an instant. It's a minute long. A lot can happen in a minute.

The delays in your loop() amount for 12 seconds. So it is perfectly expected to see this if triggered ~5 times per minute.

What is being brought to your attention is the following part of your code...
//here is my problem>>>>

if(now.Hour() == 22 && now.Minute() == 40)
{
  Servo1.write(0);
  delay(1000);
  Servo1.write(90);
  delay(1000);
}

In this code you use an "if" statement and ask:
   if the now.Hour is equal 22 AND if the now.Minute is equal 40 then
    write a 0 to your servo then
    delay for 1000
    then write a 90 to your servo
    and wait another 1000
What is being brought to your attention is that until now.Hour changes or
until now.Minute changes your write 0, delay, write 90, delay will continue
on and on and on until now.Hour changes (which will take a while) or now.Minute
changes. Since minutes are 60 seconds long your code will repeat for all of those
60 seconds...
If you were to change your code to include, oh, lets say now.Second() (like this)--
if(now.Hour() == 22 && now.Minute() == 40 && now.Second() == 00)

Then your code will repeat over and over until now.Second changes (which will take 1 second).
By the time your loop gets back to the "if" statement now.Second will no longer be 00 and it will not be "stuck" for you...

As has been brought to my attention, your 5 second delay will be a problem, so you might find that changing it will allow the now.Second "fix" to work.
In the following part of your code change delay(5000)
void loop ()
{
    RtcDateTime now = Rtc.GetDateTime();

    printDateTime(now);
    Serial.println();
    delay(5000);
}

to something like delay(1000) or so.
That way it will only wait 1 second before dropping out of the loop and checking the loop with the newly added now.Second(). This will make the printDateTime(now) happen every second instead of every 5 seconds, but it shouldn't get "stuck".
Hopefully this helps you to better understand how time (and its parts) work.

a state variable would be a much better solution. with the 5 sec delay in loop() the code could miss the exact second

Aiming for the exact equality with the scheduled time is a bad approach, regardless of how short the delay is. The proper condition should look as (current_time >= scheduled_time && event_has_not_been_triggered_yet). I.e. it should be a greater-or-equal comparison, not an equality comparison.

Ah, experience speaks! I like that, a much better solution...

This approach might be further modified with extra tweaks like: if the above condition is true, but too much time has passed since the scheduled time (due to some unfortunate blocking operation in loop()), then just abandon the event. Depends on the specific application. Sounding an alarm to wake people
up on a weekday morning is typically not a "discardable" event. Feeding the cat, if it is already well past its bedtime, probably is.

Thank you Alexander!  I do not know how to use the 'editor' as well as you, I was unable to add the OP's original code as well as you.  Again, thanks!

You can use four spaces to mark it as a code block.


text:
why sound appears between VCC and GND pins in esp8266 module?
When I use esp8266 as STATION mode and connect a speaker between VCC(3.3v) and GND pin a sound appears like "doop doop". what is this sound?
I test this in version 01 and 12 of esp8266 module and this appear in both versions.
maybe you ask me why I connect speaker to this pins. problem is that when I use pwm of esp8266 for playing a sound, this sound ("doop doop") appear to it also.
What is problem? How can I fix this?

sounds like your power supply is weak. it might also have trouble driving an 8-ohm load (400+ma) plus the MCU. more capacitors would help as well.

Maybe the ESP resetting? It is really not a good idea, to connect a speaker like this.

No .I use different power supply and different battery. I use high pass and low pass filter but it does not fix yet. Also I use capacitor between VCC and GND. I'm wondered now.

If reset occurred LED must be on in a moment. I'm sure reset does not occur

It's called "noise" and is to be expected. Wi-Fi devices are generally very electrically noisy - and the ESP8266 is no exception.

I think noise sound is irregular but this sound is regular and periodic.

As regular and periodic as the transmission of packets over WiFi?

No. when I set esp8266 as station mode, without any connection and sending and receiving packet this problem occur

Just because you aren't sending packets doesn't mean packets aren't being sent. Wi-Fi is complex. There's constant chatter between stations and the AP.

It's true. your mean is packets send in environment such as mac address or Host name?

And others. Key exchange, etc. Lots of things happening. And it all needs lots of current - and that makes noise on the power.

it's not a way for removing this noise from power? I see some project with Node MCU that playing stream audio without this noise. should I use additional hardware?

You can't "get rid" of the noise. You just have to block it from going where you don't want. Filters, capacitors, inductors, etc. They all help.

https://majenko.co.uk/blog/filtering-wifi-noise

thank you so much.


text:
Can Arduinos keep a 500mu timer?
I need to output a serial message on a 500 microsecond interval (10 bytes), can be a little slower but no more than 1 milisecond between messages.
Can it be done with an Arduino? I know there is a delayMicro(), but not sure if it has the resolution.

Assuming serial data transfer to PC, it takes ~700 microseconds to send 10 bytes (i.e. 80 bits) at 115200 baud.  Check your numbers!  If you want faster data transfer, try SPI or ethernet.

It's not related to the delayMicro, but to the max speed of the Serial/UART driver, which is not documented, but according to some people it can reach 500 kbps.
However, 10 bytes, each 500 us (2000 Hz) means 10 * 11 (including some stop/start bit) * 2000 = 220.000 bits, so you have some headroom left. Maybe there is also some timing overhead.
Anyway, probably the only way to go is using an interrupt, and expect the Uno is not able to do anything else.
A better option might be to send less or send smarter (i.e. not 10 bytes, but maybe some compressed/binary form if not already thought about).

"but according to some people it can reach 500 kbps."  You can do better than that.  Per the datasheet, 2 megabits/second can be reached.  Table 24-7. Examples of UBRRn Settings for Commonly Used Oscillator Frequencies, shows 2 Mbps as the max rate achievable with 16 MHz clock.  The IDE only goes to 115,200 so you'll need to use a different serial program to see that data.  The fastest I've tested with is Serial.begin(250000);


text:
problem with char array iteration and strcmp
New to Arduino and programming so forgive me if this is trivial but I've searched and can't find an answer...
Goal: I want to convert decimal values to their equivalent fraction... eg: 0.125=1/8. I think I came up with a simple solution, having one array of decimal values and one array of fraction values and when the input value matches a decimal value return the corresponding fraction value and display it on a tft screen...
Problem: well my simple solution doesn't work for some reason and as stated previously I searched and can't figure out why... I tried declaring the arrays in many ways but with the same result, here is the relevant code but it's only a small fraction of the complete code... the line that is commented out is the one giving me the problem...
//Serial.print("decimal test result: ");Serial.print(fracarray[i]);Serial.println(" match");

when I use that line a random smiley face character appears on the tft screen and keeps the code from running properly.
int checkformatting(char *input, int button){
  char *decarray[]={"0.015625", "0.03125", "0.046875", "0.0625", "0.078125", "0.09375", "0.109375", "0.125", "0.140625", "0.15625", "0.171875", "0.1875", "0.203125", "0.21875",
                  "0.234375", "0.250", "0.265625", "0.28125", "0.296875", "0.3125", "0.328125", "0.34375", "0.359375", "0.375", "0.390625", "0.40625", "0.421875", "0.4375", "0.453125",
                  "0.46875", "0.484375", "0.5", "0.515625", "0.53125", "0.546875", "0.5625", "0.578125", "0.59375", "0.609375", "0.625", "0.640625", "0.65625", "0.671875", "0.6875",
                  "0.703125", "0.71875", "0.734375", "0.75", "0.765625", "0.78125", "0.796875", "0.8125", "0.828125", "0.84375", "0.859375", "0.875", "0.890625", "0.90625", "0.921875",
                  "0.9375", "0.953125", "0.96875", "0.984375"};
  char *fracarray[]={"1/64", "1/32", "3/64", "1/16", "5/64", "3/32", "7/64", "1/8", "9/64", "5/32", "11/64", "3/16", "13/64", "7/32",
                  "15/64", "1/4", "17/64", "9/32", "19/64", "5/16", "21/64", "11/32", "23/64", "3/8", "25/64", "13/32", "27/64", "7/16", "29/64",
                  "15/32", "31/64", "1/2", "33/64", "17/32", "35/64", "9/16", "37/64", "19/32", "39/64", "5/8", "41/64", "21/32", "43/64", "11/16",
                  "45/64", "23/32", "47/64", "3/4", "49/64", "25/32", "51/64", "13/16", "53/64", "27/32", "55/64", "7/8", "57/64", "29/32", "59/64",
                  "15/16", "61/64", "32/32", "63/64"};
    for (int i=0; i<63; i++){
      if (strcmp(decarray[i], input)==0){
        //Serial.print("decimal test fracarray: ");Serial.print(fracarray[i]);Serial.println(" match");
       Serial.print("decimal test result: ");Serial.println(decarray[i]);Serial.println(" match");
      }
    }

    Serial.print(("result mm= ")); Serial.println(conversionresult, 6);
  }
}

Thanks in advance for any help...

This is not the reason for the error, but your arrays should be declared as static const char *const decarray[] = { .... (Even better: relocate the string literals to PROGMEM). As for the actual problem... Apparently something else happens in the rest of the code. You said this is just a fraction of it. BTW, what is conversionresult? Where is it initialized?

@AnT thanks, I'll change the array declaration and look into what relocating to PROGMEM means... like I said very new at this. conversionresult is a global variable float conversionresult; I use it to return the results when converting inches to mm.

Otherwise there seems to be nothing wrong with the code you posted.

@Ant just had time to look into your suggestion that something else was causing the problem... and found it, it was a global float causing the problem... can't actually explain why but it works without that line of code that I originally thought was the problem and doesn't with it.... thanks for the help

It is highly unlikely that "a global float" by itself would cause such problem. Most likely that somewhere else in your code you have undefined behavior. It can be temporarily "spooked"/"swept under the carpet" by making random unrelated changes in the code (like your "global float"), but it will reappear eventually in some other form.

Ok I think I figured out what it was and I'll try and explain here with generic variable names... hopefully it makes sense to you... I have a global float 'float a; then I have 2 other global floats that I use for displaying stuff to the tft… 'float b; float c; then later I need both b and c to equal a... I wrote the code on separate lines... b=a; and c=a;... so to fix it I created a new float called float d; which works fine but messes up a reference to c somewhere else... so I tried to write b=c=a and b, c=a... both work but again no idea if there's a difference or not

b, c=a is equivalent to just c=a, which is not the same as b=c=a.

Ah ok... So b=c=a makes b and c equal a?

Yes, b=c=a; is the same as c = a; and b = a; together. Which means that there was no reason to change your original c = a; and b = a; variant,

I did find it strange that making that change fixed it... I'll do more testing, as you said something might show up later... And that wasn't my true problem...


text:
One Arduino collects data, several other Arduinos use the data. What is a simple way to do this?
I am looking for a way to exchange a few bytes of data from one Arduino to two or more additional Arduinos. It's a one way communication and speed is not a problem. 10Hz is fast enough.
Data Collector Arduino: I have one Arduino with SPI and I2C shields which collects and analyzes data from a CAN-BUS in a motorcycle. The CAN-BUS supplies lots of information but I filter it down to few info like which lights are on, intake temperature, motor RPM, which gear.
Light Control Arduino: This Arduino should know which lights are on. Depending on low beam, high beam, indicators, etc. it will control additional lights which are not part of the original bike.
Motor Control Arduino: This Arduino should know the current RPM, gear, etc. and work with that data.
The question is how do I "transfer" the data from the data collector to the other Arduinos? If it would be a little simpler I would connect some digital pins which the data collector would write and the others would read. But there are not enough pins for my needs and why use 10 pins when maybe 2 are enough.
All the Arduinos use SPI and I2C connected devices so I don't think it's a good idea to use SPI or I2C for communication between the Arduios.
I guess Serial communication would work with 2 Arduinos but not with 3 or even more. Maybe I could use multiplexing or something like that?
Maybe I could let the data collector Arduino write data into some kind of shared memory and the other Arduinos could read it?
What do you suggest? I am sure there are simple solutions out there but I didn't find anything. I don't mind any extra ICs.
Before someone suggest to do all in one Arduino: Maybe it would be possible. But I really like to keep the modules (Arduinos) separate and I want to be able to add others later if I want to. Then I only want to change the software of the collector Arduino and don't touch the others.

why not do everything with one Arduino?

It is possible to send out data from one Arduino to multiple others at once via serial (UART). You simply connect the TX of your master Arduino to the RX of all the slave Arduinos. All receiving Arduinos will get the same data with that. You only need 1 pin (for the connection sender TX to the multiple RX). This is a bit limited to the number of slaves and the speed, but that doesn't seem to be an issue here (since you only have a few).
This is a 1-way communication, since at any line there must not be more than 1 TX (sender). If you have more than 1 TX on a line, you will burn your hardware as soon as both TX send out data simultaneously.
I remember some sites that stated it to be possible to also do multiple sender UART, when you adhere to a protocol and put in some safety hardware (I think they used diodes and current limiting resistors). But that is somewhat out of scope here. If you really need a 2-way communication, you maybe should rethink the whole structure of your solution. As Juraj suggested in his comment, it might then be easier to unite the functions to less Arduinos.

Be sure, that the Arduinos share the same ground. This is needed for any communication, when you don't utilize extra hardware (like an optocoupler).

You can do it simply by addition of extra RX and TX pins by use of library like Software Serial Library. For reference you can go here https://www.arduino.cc/en/Tutorial/TwoPortReceive . By using this library you can increase number of ports in master arduino and you probably can give command to other slave arduino commands through master arduino. In this way each arduino can communicate with each other.

That also imposes problems, since you can only listen to 1 SoftwareSerial interface at any time. But for one way communication that is no problem.


text:
Applying 5v to analogWrite Pin
I am controlling a motor with an Arduino Nano, that motor is controlled by Cytron MD-10c motor controller.
i want to wire a momentary switch in parallel with the analog output PIN from the Arduino and PWM input on the MD-10c, the switch will connect the 5v output from Arduino to the PWN input on the MD-10c. Basically an override to go full power.
Is there any risk of damage with this sort of wiring with the switch?

why don't you do it properly .... use the switch as an input device to the Arduino .... then modify the software to output full power every time the switch is pressed

Not enough pins left on the arduino to accommodate this.

Mhh, if you do this, you definitely should save the PWM pin from sourcing too much current, when it goes to ground while the button is activated. I'm pretty sure, that the motor controller does not source much current, so you can simply add a current limiting resistor between button and PWM pin. Unfortunately I currently don't have an Arduino at hand to test this.

Slide switch with 3 pins should be the solution. It disconnects one pins and connects two others. So if we use pins like "(arduino) (motor) (5V)" when switch is "left" it connects (arduino) to (motor) and when it's "right" it connects (5V) to (motor) and the (arduino) is safely floating.

Yes, depending on the current that will flow.
If your PWM output pin is connected to 5V without a current limiting resistor, nothing will happen during the HIGH phases of the PWM, but you will short the input pin during the LOW phases.
According to the manual of your motor controller, you should be able to use a current limiting resistor to prevent this.
Since the ATMega328P on your Arduino Nano can sink a maximum of 40 mA, that resistor should be at least 125 Ohms. A resistor larger than 1 kOhm should work fine.
The other option would be installing a diode between your Arduino Nano and the motor controller.
This does not require the use of a current limiting resistor.
The motor controller would still work, since the minimal voltage for the pin state to be detected as HIGH is 3V (1), much lower than the ~4.3V you're left with after a diode.


text:
What would cause fuses to be writeable but bootloader not to be writeable?
I am trying to burn a bootloader onto an ATmega328P-AN using an Microcenter knock-off Arduino Uno R3 as my ISP for several days with no luck. The farthest I've gotten is writing and reading a few fuses prior to bootloader burn.
I have checked and rechecked the connections:
Uno    ATmega328P-AN
GND    GND
VCC    VCC
MISO   MISO
MOSI   MOSI
SCK    SCK
SS     RESET

I have a 2.2 uF cap from ground to RESET on my Uno, and a 16 MHz crystal with two 22 pF load caps to ground on my ATmega328P's XTAL pins.
I have ArduinoISP loaded onto the Uno and my bootloader target is "Arduino Pro or Pro Mini", and my processor is set to "ATmega328P (5V 16MHz)".

I am using Arduino 1.8.9 on Windows 10.
Things I've tried:

Multiple boards and ATmega328P ICs - No difference.
Burning a bootloader to an Ebay Arduino Pro Mini knockoff, which worked, but there's no obvious electrical difference between this part and a raw ATmega328P. (Weirdly, the slight progress I made (setting some fuses - see below) was done by bypassing the DTR-cap-pullup reset path and running the ISP SS directly to the reset pin on the ATmega328P chip.)
Using Arduino IDE 1.0.x - No success.
Using a genuine Arduino Uno R1. No success.
Checking all the rails. I have a clean 5V and a clean ground. Unfortunately my lousy scope isn't picking up any of the 16 MHz oscillators, so I'm not sure what my clocks are up to.
In-circuit programming in a populated board with flying leads from the appropriate ICSP nodes. No success.
In-circuit programming with fresh board and just a power supply bypass cap, oscillator, load caps, and supply rails available.

Here's my Arduino IDE terminal output:
    C:\Users\xxx\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/bin/avrdude -CC:\Users\xxx\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

    avrdude: Version 6.3-20171130
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

             System wide configuration file is "C:\Users\xxx\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf"

             Using Port                    : COM3
             Using Programmer              : arduino
             Overriding Baud Rate          : 19200
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : Arduino
             Description     : Arduino
             Hardware Version: 2
             Firmware Version: 1.18
             Topcard         : Unknown
             Vtarget         : 0.0 V
             Varef           : 0.0 V
             Oscillator      : Off
             SCK period      : 0.1 us

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.00s

    avrdude: Device signature = 0x1e950f (probably m328p)
    avrdude: erasing chip
    avrdude: reading input file "0x3F"
    avrdude: writing lock (1 bytes):

    Writing | ################################################## | 100% 0.01s

    avrdude: 1 bytes of lock written
    avrdude: verifying lock memory against 0x3F:
    avrdude: load data lock data from input file 0x3F:
    avrdude: input file 0x3F contains 1 bytes
    avrdude: reading on-chip lock data:

    Reading | ################################################## | 100% 0.01s

    avrdude: verifying ...
    avrdude: 1 bytes of lock verified
    avrdude: reading input file "0xFD"
    avrdude: writing efuse (1 bytes):

    Writing | ################################################## | 100% 0.02s

    avrdude: 1 bytes of efuse written
    avrdude: verifying efuse memory against 0xFD:
    avrdude: load data efuse data from input file 0xFD:
    avrdude: input file 0xFD contains 1 bytes
    avrdude: reading on-chip efuse data:

    Reading | ################################################## | 100% 0.01s

    avrdude: verifying ...
    avrdude: 1 bytes of efuse verified
    avrdude: reading input file "0xDA"
    avrdude: writing hfuse (1 bytes):

    Writing | ################################################## | 100% 0.02s

    avrdude: 1 bytes of hfuse written
    avrdude: verifying hfuse memory against 0xDA:
    avrdude: load data hfuse data from input file 0xDA:
    avrdude: input file 0xDA contains 1 bytes
    avrdude: reading on-chip hfuse data:

    C:\Users\xxx\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/bin/avrdude -CC:\Users\xxx\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b19200 -Uflash:w:C:\Users\xxx\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.23/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex:i -Ulock:w:0x0F:m
    Reading | ################################################## | 100% 0.01s

    avrdude: verifying ...
    avrdude: 1 bytes of hfuse verified
    avrdude: reading input file "0xFF"
    avrdude: writing lfuse (1 bytes):

    Writing | ################################################## | 100% 0.02s

    avrdude: 1 bytes of lfuse written
    avrdude: verifying lfuse memory against 0xFF:
    avrdude: load data lfuse data from input file 0xFF:
    avrdude: input file 0xFF contains 1 bytes
    avrdude: reading on-chip lfuse data:

    Reading | ################################################## | 100% 0.01s

    avrdude: verifying ...
    avrdude: 1 bytes of lfuse verified

    avrdude done.  Thank you.

    avrdude: Version 6.3-20171130
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2014 Joerg Wunsch

             System wide configuration file is "C:\Users\jms\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino14/etc/avrdude.conf"

             Using Port                    : COM3
             Using Programmer              : arduino
             Overriding Baud Rate          : 19200
             AVR Part                      : ATmega328P
             Chip Erase delay              : 9000 us
             PAGEL                         : PD7
             BS2                           : PC2
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             serial program mode           : yes
             parallel program mode         : yes
             Timeout                       : 200
             StabDelay                     : 100
             CmdexeDelay                   : 25
             SyncLoops                     : 32
             ByteDelay                     : 0
             PollIndex                     : 3
             PollValue                     : 0x53
             Memory Detail                 :

                                      Block Poll               Page                       Polled
               Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
               flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
               lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
               calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
               signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

             Programmer Type : Arduino
             Description     : Arduino
             Hardware Version: 2
             Firmware Version: 1.18
             Topcard         : Unknown
             Vtarget         : 0.0 V
             Varef           : 0.0 V
             Oscillator      : Off
             SCK period      : 0.1 us

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.00s

    avrdude: Device signature = 0x000000 (retrying)

    Reading | ################################################## | 100% 0.01s

    avrdude: Device signature = 0x000000 (retrying)

    Error while burning bootloader.
    Reading | ################################################## | 100% 0.01s

    avrdude: Device signature = 0x000000
    avrdude: Yikes!  Invalid device signature.
             Double check connections and try again, or use -F to override
             this check.

    avrdude done.  Thank you.

If I try to burn the bootloader again, I just get the "Device signature = 0x000000 (retrying)" messages, but no fuse write/read cycles.

I am really stumped at this point.
Questions

Am I bricking my ATmega328P parts when the bootloading process is not successful?
What am I missing?

Do yourself a favour and get a proper programmer, rather than using an Arduino. Remove that link from the chain. A USBASP costs <$5 from eBay/Amazon/AliExpress.

That was my next step. What makes the Arduino a poor programmer?

It's not so much a bad programmer - it's awkward and easy to get it wrong. Far simpler to stick to something that is designed for the task - plug in and go.

Cool. A programmer is on the way, and we'll see what happens.

As an aside, are ATmega ICs that don't get a completed a bootloader effectively bricked?

No, not normally. The main way of bricking one is to get the fuses wrong so it needs an external clock. For that you need to apply a 1MHz clock signal to the crystal input to get it to work again. Or use a High Voltage Programmer (Nick Gammon has a tutorial on doing it IIRC).


text:
Frequency measuring using Arduino (AC analog input)
What I aim to do:
To measure the frequency of an AC analog signal generated by an electrodynamic shaker, which has a peak voltage of 10V-- using an Arduino Uno.
What I have tried:
Tried using a circuit similar to an optocoupler (using a 2N2222) transistor to take pulse input, using the pulsein() function. However the duration is always returning as 0.
My questions:

Is this method an acceptable way of measuring frequency?
What could I be doing wrong such that the time duration is always returning 0?
Is there an easier way of carrying out this work?

Will put up the code if asked for. However it is basically just defining a few variables (for pins, duration etc), and then using the pulsein function.

Please provide a schematics or wiring, how you have the signal connected to the Arduino. What form does the signal have? Are you doing some preprocessing, or do you simply rely on the Schmitt Trigger inside the digital input of the Arduino?

I have added the circuit diagram. I'm not using a Schmitt trigger since my professor has explained to me that the circuit I am using will convert the AC signal  to pulses, which can be read by the digital input pins of the Arduino. However, I do admit I am not an electronics engineer, so my knowledge about this is quite limited.

Try adding a resistor between base and emitter of the transistor to pull the base to ground, when the phototransistor of the optocoupler is not conducting. That should keep the transistor base from floating. Though it is only a guess, that this is a problem. Can you observe the signal and the output of the circuit with an oscilloscope?

The output, as shown, goes to the Arduino digital pin. I looked at the input signal to ensure it is indeed sinusoidal. However I have not looked at the output. I will do so. Thank you for your input!

Why the transistor? The optocoupler already includes a (photo-)transistor, so why add another one? 2. pulseIn() measures the length of a pulse, i.e. the time between a rising edge and the following falling edge (or vice-versa). For measuring a frequency, you need the time between two consecutive rising (or falling) edges. 3. What is the range of frequencies you want to measure? What kind of accuracy do you need? There are many methods to measure a frequency, and the “right” one for you depends on your requirements.

This project includes a frequency counter.
https://www.instructables.com/id/Oscilloscope-in-a-Matchbox-Arduino/
From the project page:
This oscilloscope costs the price of an Arduino Nano (£2 and a display (£3) plus a few pence for resistors, etc. It's specification is:

max 1M samples/second, min 1000sps
8-bits per sample
DC 0-5V; AC +/- 550mV, AC +/- 117mV, AC +/- 25mV
USB "PC scope" or built-in display
could be battery-powered
optional logic display
optional frequency meter
optional voltmeter
optional signal generator

My comment: I build it, it's a nice little project and the author is an expert programmer.

Answers should be more selfcontaining. A link-only answer would get completely useless, when the link dies eventually. Please include the key points directly in the answer text.

@chrisl: thanks for the info, done

Is this method an acceptable way of measuring frequency?

Nope, not at all.

What could I be doing wrong such that the time duration is always returning 0?

You are misusing pulsein(), it doesn't work like that; look up the documentation for it!

Is there an easier way of carrying out this work?

Yes; there are many ways, you can research many of them. One thing you can do is make a peak detector, either in hardware or software, and then design a way to get a counts/time, which should correlate to the frequency!


text:
MQTT subscribe callback fails to be called in ESP8266 deepsleep mode
Refer to

ESP8266 deep sleep and MQTT

I executed the code in the given link. However i am not able to receive the subscribe message that are send from MQTT test broker(MQTT Lens) on the serial console.
Please help.
I am receiving successful call to both publish methods
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
const char* ssid = "honored";
const char* ss_pswd = "12345678";
const char* mqtt_server = "iot.eclipse.org";

void callback(char* topic, byte* payload, unsigned int length);
WiFiClient EspClient;

PubSubClient client(EspClient);

void wifi_setup() {
  Serial.print("Connecting to: ");
  Serial.println(ssid);
  WiFi.begin(ssid, ss_pswd);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
void reconnect() {
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    String ClientId = "ESP8266";
    ClientId += String(random(0xffff), HEX);
    if (client.connect(ClientId.c_str())) {
      Serial.println("connected");
      client.publish("outtopic", "hello world, finally");
      client.subscribe("/room/test");
    } else {
      Serial.print("failed, rc=");
      Serial.println(client.state());
      Serial.println("Try again...");
      delay(5000);
    }
  }
}
void sendMQTTMessage() {
  Serial.println("sending your message");
  if (!client.connected()) {
    reconnect();
  }
  client.publish("/sensor/pir", "on");
}
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived: ");
  Serial.println(topic);
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
}

void setup() {
  Serial.begin(115200);
  wifi_setup();
  client.setServer(mqtt_server, 1883);
  sendMQTTMessage();
  client.setCallback(callback);
  delay(2000);
  Serial.println("going into deep sleep");
  ESP.deepSleep(10 * 1000000);
}

void loop() {

}

Once you enter deepsleep the processor will not be woken up by anything but the reset pulse after the deepsleep time expired. Your callback will never be called. Also once you enter Deepsleep you switch off your WiFi connection, no chance of receiving data. Read https://diyprojects.io/esp8266-deep-sleep-mode-test-wake-pir-motion-detector/#.XNGv1UOxWAk

Deep sleep proves useless if there are such restrictions in web based application. How do i save battery and do subscribe call? looks like i have to giveup one or another.

My solution:
update_mqtt() is called before deepSleep
PubSubClient mqtt_client(client);
boolean cb = false;

void callback_mqtt_switch(char* topic, byte* payload, unsigned int length) {
  String lowerstr = "";
  for (uint8_t i = 0; i < length; i++) {
    lowerstr += (char)payload[i];
  }
  lowerstr.toLowerCase();
  DebugOut("Sleep payload: " + lowerstr);
  if (!back_to_sleep) {
    sleep_on = lowerstr == "ein";
  }
  cb = true;
}

void update_mqtt() {
  int i = 0;
  while (!cb && i++ < 30) {
    mqtt_client.loop();
    delay(10);
  }
  #ifdef TEST
    Serial.print("Warte ");
    Serial.println(i * 10); // max. 300ms gewartet
  #endif
  cb = false;
}


text:
Can i use a sparkfun rfid qwiic without an id-xxla?
Sparkfun rfid qwiic
id-20la
I am using an Arduino UNO R3.
You should assume that i don't know anything. If yes can you give some information about how to do it? Thanks for any help.

No. It is not an RFID reader. It just interfaces to an RFID reader. You need an RFID reader to read RFID tags. That Sparkfun board just controls the reader and reads the data from it.


text:
Strange artifact in writing to serial while executing loop
Hope you can see this.
https://gist.github.com/DevilWAH/60ad144d2858f53845ac2e80f84bb070
The main file in this is "morse-led-rfid" which is taking reading data of an RFID tag and then displaying the text as Morse code on to a APA102 / Dotstar LED strip.
The issue is when the function updatestrip(tempbuffer[i]); is called.
Serial.println(F("\n**Start Reading**\n"));

  for (uint8_t i = 1; i < 15; i++)
  {
   if (i != 3 && i!= 7 && i != 11 && i != 15 ) // Skip the non data blocks
    {
     readblock (i, key);
       for (uint8_t i = 0; i < 16; i++)
         {
      updatestrip(tempbuffer[i]);
      Serial.write(tempbuffer[i]);
        }
    }
  }

This is what I am calling to scroll the LED strip and write the letter in morse. if in the code snip it above i comment out "updatestrip...." then i get the txt from the RFID tag printer to serial as i would expect.
as a soon as i un comment it, the strip displays the morse code but the serial output gets garbled, it misses letters, prints reversed "?'s" and repeats its self?
Good output = "My Bunny is the best"
Bad output = "?Bunny is the ?t" (question marks reversed)
Further investigation i found if i leave it uncommented but go all the way to the bottom of the "more-strip" sheet and comment out the "else statement in the shiftLED function" the serial again displays correctly, but of course the led don't :)
void shiftLED() // shift all LED up 1
  {
    for(uint16_t i = ledCount; i > 0; i--)
    {

      if ((colors[i - 1].red == 0 ) && (colors[i - 1].green == 0 ))
       {
          colors[i] = cblack;
        }
      else if (i > 19 && i < 40)
      {
        colors[i] = cred;
      }
     // else
     // {
     //   colors[i] = cgreen;
     // }
     // }

 }

Can any one suggest why the else statement a few function down is affecting the "serial.write(tempbuffer[i])" in the main loop?

Using an i loop inside an i loop is very bad practice. Never nest the same variable like that - it makes it impossible to know what you intend.

Hi, I did actuality think that, and went though and changed this. I have to admit to being a very hacky programmer (not sure i can even call my self that, it an insult to the real ones). Will add to list of things not to do.

In your code colors is declared as
rgb_color colors[ledCount];

This means that the very first iteration of this cycle in shiftLED
for (uint16_t i = ledCount; i > 0; i--)
{
  // access colors[i]
}

will access ledCount[ledCount] which is obviously out of bounds (and will actually write into that location!). The behavior is undefined after that.
Using unsigned types for "backward" array iteration requires a bit of skill. The common idioms are
for (uint16_t i = ledCount; i > 0;)
{
  --i; // do this ASAP

  // access colors[i]
}

or
for (uint16_t i = ledCount; i-- > 0;)
{
  // access colors[i]
}

or
// Careful: this technique is not usable with unsigned types
// narrower than `unsigned int`
for (uint16_t i = ledCount - 1; i != -1; --i)
{
  // access colors[i]
}

This is assuming that you want to iterate over the whole array: from [ledCount - 1] all the way back to [0].
But if you intended to iterate back to [1] and stop short of [0] (which is apparently the case), then a simple fix for your cycle would be
for (uint16_t i = ledCount - 1; i > 0; i--)
{
  // access colors[i]
}

I.e. simply start from ledCount - 1, not from ledCount.

OH! correct me is I am wrong but you mean when LEDCount = 60 the valid array values are 0 though 59? so accessing access colors[i] when i = LEDCount means i am writing to array position 60 not 59! A kind of buffer over flow?

And you got me to go look up more about signed and unsigned. When back at home tonight i will try out your suggestions, thanks for the help.

@DevilWAH Yes, if LEDCount is 60, then the valid indexes for colors array are from 0 to 59. Index 60 is out of bounds.

Just to confirm that sorted it out :) thank you for taking the time out to help and explain.


text:
How can if resolve this conflict between matrix keypad library and neopixel library?
I'm trying to use a 4x3 matrix keypad as a user interface to control parameters of a Neopixel strip control program.
I'm using Adafruit's Neopixel library and This Keypad library.
Both work fine on their own and none of my code, outside this instantiation of the keypad library, interferes with the programs functionality.
The code is around 400 lines so I'm only including a snippet:
I've now included all functions which are called in setup, as well as the one we are supposed to land on in loop() as a result of the switch statement.
#include "math.h"
#include "Adafruit_NeoPixel.h"
#include "Keypad.h"
#ifdef __AVR__
#include "avr/power.h"
#endif

#define PIN 9 //Neopixel data pin
#define NUMPIXELS 300 //currently 300

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};

byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

//f=1/p period should be between 1s and 10s so...
//frequencies should be somewhere between 0.1Hz and 1Hz
int period[NUMPIXELS];

float twoPI = 2 * PI;

int rainbowNow = 0;
unsigned int xOff = 0;

int switcha = 0;

byte hue = 192;
float sat = 0;
float lum = 1;

float lumSave;

int *rgb;

char select = '5';
char hueInc = '6';
char hueDec = '4';
char lumInc = '2';
char lumDec = '8';
char satInc = '3';
char satDec = '1';
char onoff = '0';

boolean holdFlag = 0;

void setup(void) {
  //create array of period lengths for each pixels sine wave
  randomSeed(10);
  for (int i = 0; i < NUMPIXELS; i++) {
    period[i] = random(2, 20);
  }
  Serial.begin(9600);

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'

  //showOff();
  fadeIn();
  sparkle();
}

void loop(void) {

  char key = keypad.getKey();
  change(key);

  switch(switcha) {
    case 0: solidColour(); break;
    case 1: rainbow(); break;
    case 2: twinkle(); break;
    case 3: satSine(); break;
    case 4: hueSine(); break;
    case 5: rainbowCycle(); break;
  }
}

void solidColour() {
  rgb = Wheel(hue, sat, lum);
  for(int i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, strip.Color(rgb[0], rgb[1], rgb[2]));
  }
  strip.show();
  delay(20);
}

void fadeIn() {
  Serial.println("FADE IN");
  for(float j=0; j<1; j+=0.16) {
    rgb = Wheel(hue, sat, j);
    for(int i=0; i<NUMPIXELS; i++) {
      strip.setPixelColor(i, strip.Color(rgb[0], rgb[1], rgb[2]));
    }
    strip.show();
    delay(100);
  }
}

void sparkle() {
  Serial.println("SPARKLE");
  rgb = Wheel(hue, sat, lum);
  strip.setPixelColor(0, strip.Color(rgb[0], rgb[1], rgb[2]));
  for(int i=1; i<NUMPIXELS; i++) {
    int blnk = random(0, NUMPIXELS-1);
    strip.setPixelColor(blnk, strip.Color(0, 0, 0));
    strip.show();
    delay(40);
    strip.setPixelColor(blnk, strip.Color(rgb[0], rgb[1], rgb[2]));
    strip.show();
  }
}

//will create pseudo-Saturation by reducing white with increasing sat
//brightness will be achieved by scaling all by a constant
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
int* Wheel(byte WheelPos, float pseudoSat, float pseudoLum) {
  static int rgb[3];
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    rgb[0] = (255 - WheelPos * 3) * pseudoLum;
    rgb[1] = 0;
    rgb[2] = (WheelPos * 3) * pseudoLum;
  } else if (WheelPos < 170) {
    WheelPos -= 85;
    rgb[0] = 0;
    rgb[1] = (WheelPos * 3) * pseudoLum;
    rgb[2] = (255 - WheelPos * 3) * pseudoLum;
  } else if(WheelPos >= 170) {
    WheelPos -= 170;
    rgb[0] = (WheelPos * 3) * pseudoLum;
    rgb[1] = (255 - WheelPos * 3) * pseudoLum;
    rgb[2] = 0;
  }

  return rgb;
}

void change(char key) {
  if(key == select) { //select
    if(switcha < 5) {
      switcha++;
    } else {
      switcha = 0;
    }
  } else if(key == hueDec) { //fwd
    if(hue > 0) {
      hue--;
    } else {
      hue = 255;
    }
  } else if(key == hueInc) { //back
    if(hue < 255) {
      hue++;
    } else {
      hue = 0;
    }
  } else if(key == lumInc) { //up
    if(lum < 1) {
      lum+=0.05;
    } else {
      lum = 0.05;
    }
  } else if(key == lumDec) { //down
    if(lum > 0.05) {
      lum-=0.05;
    } else {
      lum = 1;
    }
  } else if(key == onoff) {
    if(lum != 0) {
      lumSave = lum;
      lum = 0;
    } else if(lum == 0) {
      lum = lumSave;
    }
   } else if(key == satInc) { //play
    if(sat < 1) {
      sat+=0.025;
    } else {
      sat = 0.025;
    }
  } else if(key == satDec) {
    if(sat > 0.025) {
      sat-=0.025;
    } else {
      sat = 1;
    }
  }
}

So long as I comment out the line Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );, the code runs as expected and the Neopixel strip lights up in the way I have programmed.
However, with that line, nothing lights up at all. The code still reaches all the functions, (I have checked with Serial.print).
(EDIT: It also works with the Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); included so long as I comment out the switch statement in loop(). How can a statement in loop affect the setup function?!)
I think it must have something to do with either interrupts, or a polling frequency within the Keypad library with interferes with the 'delicate' timing of the Neopixels.
The massively frustrating this is that I have solved this problem before on this exact hardware but the code was lost and I'm having to reconstruct it for a repair job.
If you could help me specifically identify the problem, or suggest how I might implement my keypad interface with the neopixels I would be very grateful.
Arduino ide2:1.0.5 (EDIT: also used 1.8.9 with no different result)
Arduino Nano Board
Sodial 4x3 Matrix Keypad
ws2812b rgb 300 neopixel 5M strip

Are you saying IDE version 1.0.5? That is ancient. Upgrade to something current.  I think 1.8.9 is the latest.  www.arduino.cc

The used keypad library doesn't use interrupts, so the problem must lie at another place. Please create a short working example, that shows your problem, so that we can see the whole code, that isn't working. That is better than cutting parts of the code out.

I've added the extra functions to make it (should be) working code. Lights fade in, lights blink, lights go solid colour. Hope that gives you more context.

In some cycles you iterate to NUMPIXELS. In some - to strip.numPixels(). Why the discrepancy? Are they the same?