text:
How can I build a simple "Smartwatch" with Arduino Pro Mini and Display?
I want to know how I can build a simple "Smartwatch" with an Arduino Pro Mini and a Display with a size from maybe 1,5" what Display should I use for Touch and color?
I only want simple things like synchonising the time with my Smartphone trough a HC-06 Bluetooth Module.

Please tell us what display you eventually end up using, especially it it's not one already listed at http://www.opencircuits.com/Watch_display .

If your goal is to make a watch you'll need a RTC (Real Time Clock) this can take the form of breakout board, or you can build the circuit yourself. The RTC is needed if you want the mini to display the time. The mini (in fact, most micros) have no internal clock (though they may have a crystal that can simulate time keeping, but this isn't as useful if you want the time)
It sounds like you want an OLED display. They come in watch-like sizes. There are a few small ones. None are touch displays. I have seen larger touch displays. Maybe combine an OLED with a clear capacitive surface?

Yes but I'd like to synchronice the time my Smartphone is showing and is there no small oled Display with 1.5" with Touch ?


text:
DC motor with L289N driver cannot set RPM lower than 130
My setup is using an Uno r3, and the motor driver is an L289N.
I am going to set it to run at a lower RPM, but when adjusting enA or enB to set to below 130, it won't spin.
// connect motor controller pins to Arduino digital pins
// motor one
int enA = 2;
int enB = 7;
int in3 = 5;
int in4 = 6;
int in1 = 3;
int in2 = 4;

void setup()
{
  // set all the motor control pins to outputs
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}
void demoOne()
{
  analogWrite(enB, 130);
  // turn on motor B
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  delay(500);
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  delay(5000);
  // this function will run the motors in both directions at a fixed speed
  // turn on motor A
  // set speed to 200 out of possible range 0~255
  analogWrite(enA, 130);
  // turn on motor B
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  // set speed to 200 out of possible range 0~255
  delay(100); //this function to set masa untuk rotation
  // now change motor directions
  // now turn off motor
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  delay(5000);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(200);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  delay(5000);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
  delay(200);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  delay(5000);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
  delay(100);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
  delay(5000);

  analogWrite(enB, 130);
  // turn on motor B
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  delay(400);
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  delay(5000);
}

void loop()
{
  demoOne();
  delay(3000);

}

And my problem is solved by using 10 and 9 Thank YOU!

Looks like you are controlling two motor outputs via the H-bridge, where the logic inputs are in1,in2 and in3,in4.  First of all, you need
pinMode(in1,OUTPUT);
pinmode(in2,OUTPUT);

One reason why the motors may not spin for analogWrite value less than 130 is that, coincidentally, the voltage output is too low and motor stalls.  Test this two ways: does (1) changing the motor supply voltage or (2) changing the argument of analogWrite actually change the speed?
If no, it may be that pinMode(enA,OUTPUT); sets the output as digital and should be removed.  In that case a number less than 128 gets interpreted as a logic 0 and the motor will not spin.
P.S. your code can be neatened up using port syntax and bitwise operators.
digitalWrite(in1,HIGH);
digitalWrite(in2,LOW);

can be written on a single line with
PORTD |= _BV(in1);

Also
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);

becomes
PORTD &= ~(_BV(in1) | _BV(in2));

On an Uno, D2 and D7 (enA and enB) do not have true PWM (analogWrite) capabilities- they will be 100% on at values of 128 or higher, and off at 127 and lower.
You will need to use 3, 5, 6, 9, 10 or 11 for PWM (i.e. your enA and enB) on the Uno.
See Arduino Reference - analogWrite() for more info on PWM pin availability on Arduino boards.

source: Stack Exchange

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

sort: votes


text:
Can I use WTV020 sound module as SD card reader?
I want to try this example, A Simple Function for Reading CSV Text Files, in order to read a .csv file from an SD card, but I don't have the SD card reader module and can't find it in my country.
What I have found everywhere is this sound module, WTV020-SD, and I wonder if I can use that to read a single .csv file from it, using the SD Arduino library. I checked the module's documentation and there's nothing about it in there.

It seems unlikely, for if you compare the schematic of the WTV020-SD (card reader part only) from the data sheet that you provided:

to the schematic of a bog standard SD card reader:

they are not the same. Instead of interfacing directly to the Arduino, as the standard SD card reader does, the WTV020-SD has additional logic, in the form of a WTV020SD-20S IC.
Therefore the code on the Arduino forums is highly unlikely to work.

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


text:
My Code turns on my LED even when my switch is not pressed
I am trying to create a circuit that will turn my motor when I clap. When the first limit switch is low, and there is only one clap, a solenoid pin is supposed to be engaged (currently an LED), but when I clap once without pressing the limit switch, my LED turns on.
Also, I can't seem to get my code to work properly with the limit switches, to control my motor.
I am not sure what is wrong, can someone help?
I have an Arduino Uno with the following code:
#define sound_Sensor 2
#define EN1 9
#define IN1 8
#define IN2 7
#define solenoid_pin 6
#define LimSwitch1 4
#define LimSwitch2 3

int lastSoundValue;
int soundValue;
long lastNoiseTime = 0;
long currentNoiseTime = 0;
int solenoidPinStatus = LOW;
int status_motor = LOW;
int clap_interval = 200;
int claps = 0;
int pos1 = 1;
int pos2 = 1;

void setup() {
  pinMode(sound_Sensor, INPUT);
  pinMode(EN1, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(solenoid_pin, OUTPUT);
  pinMode(LimSwitch1, INPUT);
  pinMode(LimSwitch2, INPUT);
}

void loop() {

  soundValue = digitalRead(sound_Sensor);
  currentNoiseTime = millis();
  if (soundValue == 1 && lastSoundValue == 0 && (currentNoiseTime > lastNoiseTime + 200))
  {
      if (claps == 0) // allow first to register without much condition
      {
          claps = 1;
          lastNoiseTime = currentNoiseTime;
      }
      else
      {
          if (currentNoiseTime > lastNoiseTime + clap_interval)
          {
              claps++;
              lastNoiseTime = currentNoiseTime;
          }
      }
      Serial.print(claps);
  }
  else
  {
      if (currentNoiseTime > (lastNoiseTime + 3 * clap_interval)) // no claps for a longer duration time to print and/or reset clap
      {
          if (claps > 0)
          {
              while(status_motor == LOW){
                  if (digitalRead(LimSwitch1) == LOW && claps == 1)
                  {
                    solenoidPinStatus = HIGH;
                    digitalWrite(solenoid_pin, HIGH);
                  }

                 if (digitalRead(LimSwitch1) == LOW)
                 {
                    pos1 = 2;
                    status_motor = HIGH;
                    digitalWrite(IN1, HIGH); //Turns on Motor
                    digitalWrite(IN2, LOW);
                    analogWrite(EN1, 200); //Set Speed of Motor
                  }
                 else if (digitalRead(LimSwitch2) == LOW)
                 {
                    pos2 = 2;
                    status_motor = HIGH;
                    digitalWrite(IN1, HIGH); //Turns on Motor99++
                    digitalWrite(IN2, LOW);
                    analogWrite(EN1, 200); //Set Speed of Motor
                 }
              }

              while(status_motor == HIGH){
                if (pos1 == 2 && digitalRead(LimSwitch2) == LOW)
                {
                    status_motor = LOW;
                    digitalWrite(IN1, LOW); //Turns on Motor
                    digitalWrite(IN2, LOW);
                    pos1 = 1;
                }

                else if (pos2 == 2 && digitalRead(LimSwitch1) == LOW)
                {
                    status_motor = LOW;
                    digitalWrite(IN1, LOW); //Turns on Motor
                    digitalWrite(IN2, LOW);
                    pos2 = 1;
                }
              }
          }
             claps = 0; ///reset
      }
  }

// if (solenoidPinStatus == HIGH && status_motor == LOW && digitalRead(LimSwitch1) == LOW)
// {
//   solenoidPinStatus = LOW;
//   digitalWrite(solenoid_pin, LOW);
// }
  lastSoundValue = soundValue;
}

Sorry my wire diagram may not be the easiest to look at...

what is the voltage across Limitsw1 output pin.

how are the switches wired? do you have pull-down resistors?

Where is the diagram?

I think your problem might be connected to wiring.
This is one of the ways you can correctly connect a switch to Pin 8.

In this case you need to configure Pin 8 as INPUT_PULLUP to use internal "pullup" resistor. When switch is not pressed Pin8 is connected to 5V through that resistor and value on the pin is HIGH. When you press the switch it connects Pin 8 to ground (the resistor prevents a short) and that way value on Pin 8 is LOW.
This is code that works correctly with the design above
void setup()
{
  pinMode(8, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop()
{
  if (digitalRead(8) == HIGH)
  {
    Serial.println("It's HIGH");
  }
  else
  {
    Serial.println("It's LOW");
  }

  delay(1000);
}

If you do not configure Pin 8 as INPUT_PULLUP but just normal INPUT (as you did in your code) when the button is not pressed Pin 8 is "floating" (it's not connected to anything) and on a "floating" pin values are random.


text:
Fail programing a Sonoff Dual with Arduino IDE
1) I have a Sonoff Dual, which I wish to upload a Sketch.
2) Other Sonoff basic devices programed the same way, with succes.
But when uploading  the sketch the ( even the generic Blink sketch ) - I do not get any response from the Sonoff device.
3) pins were soldered correctly according this tutorial
4) Uploading the sketch succeeds, using FTDI set to 3.3v.
What might be the reason for it ? What can I do more to check it ? my only guess is that something has happened to Sonoff device - but it uploads successfully.
Guy
Code (edit2)
    /*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Blink
*/
#define LED_BUILTIN 12
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  delay(2000);
  Serial.println("HELLLLLLO");
}

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

Upload
Build options changed, rebuilding all
Sketch uses 251224 bytes (50%) of program storage space. Maximum is 499696 bytes.
Global variables use 28080 bytes (34%) of dynamic memory, leaving 53840 bytes for local variables. Maximum is 81920 bytes.
Erasing 0x80000 bytes starting at 0x00000000
Uploading 255376 bytes from /tmp/arduino_build_214375/Blink.ino.bin to flash at 0x00000000
................................................................................ [ 32% ]
................................................................................ [ 64% ]
................................................................................ [ 96% ]
..........                                                                       [ 100% ]

Addede1: Port Selection:

note: when taken port was not connected ( connects to USB0)
edit3: erasing using esptool.py:
guy@desktop:~$ esptool.py --port /dev/ttyUSB0 --chip esp8266 erase_flash
esptool.py v2.5.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP8285
Features: WiFi, Embedded Flash
MAC: 60:01:94:ad:bf:34
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 2.4s
Hard resetting via RTS pin...

Comments are not for extended discussion; this conversation has been moved to chat.

Your code is not good to detect if it  works.
The esp8266 Serial needs some time until it prints. First print after the Serial.begin() isn't printed. I guess the reason is the USB chip.
According to schematic, the LED in Sonoff Dual is on pin 12

changed to 12- still no reaction :(

add delay(2000) after Serial.begin ()

tried without any response. see code edit.


text:
Fail using OTA - Network ports
I was using OTA to upload sketches to ESP ports I have ( around 10 ESPs).
For some time now - I'm having some kind of a trouble I would like to share, since I've read some similar topics, but all didn't work.
The problem is when trying to select Network Port as I did before, sometimes I see all, sometimes part, sometimes only one or two, and sometimes after selecting to one I want to upload to, it fails since it disapears from that list by the time it starts the upload.
I'm using IDE 1.8.8 on a Linux machine - same issue,
Tried on mac, using both 1.8.8 and even downgraded to 1.8.7 - and I'm getting the same issue.
What might be the cause for that ?

it could be the wifi AP or router - my wifi router for example does not handle ESP8266's very well at all (WRT32X) - it's a known issue with this router. One way to fix it on the WRT32X is to turn off WMM

@JaromandaX I have a Xiami R3 router. Do you know if it applies as well ? what is WMM ?

no idea, I just presented a similar issue ... WMM is wifi multimedia mode or something like that

nevermind, I thought the latest dev version of arduino/esp8266 fixed this issue - but OTA still fails most of the time

@JaromandaX as a workaround ( mostly works, but still..) after a reset command ( which is an MQTT predefined command), the particular device pops back into that list.


text:
How should I decide the cut-off frequency for my low-pass filter?
I'm trying to generate some basic thumping stereo sound using Arduino's PWM pins along with low-pass filters.
This is the frequency spectrum for the sound I want to play using Arduino UNO's PWM pins:

Based on this, I think (from what I understand) the cut-off frequency for the low-pass filter should be around 8900Hz. But, wouldn't the PWM function operate at a much higher frequency to generate the same wave? If that's how it'll be, how should I decide the cut-off frequency for my low-pass filter?
I understand that the fastest frequency one can get for 8-bit PWM on an UNO is 62.5 kHz. So, I might not be able to generate this wave using the UNO itself. Unfortunately, I won’t be able to use another microcontroller for this project. However, what I can do to solve this issue is - generate a different sound wave of lower frequency. If someone can help me with finding out by how much will the frequency of the wave increase if I use PWM to generate it, I’ll be able to generate an appropriate wave.

Yes, you would need a PWM frequency much higher than the frequency you want, but the PWM frequency of the UNO is fixed at 490Hz (see https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/). Doesn't look like that's going to work.

@PMF I think it is possible to increase the default frequency. Found some tutorials online, but here’s a similar question on this forum: https://arduino.stackexchange.com/questions/25609/set-pwm-frequency-to-25-khz

If you have an Uno or some similar AVR-based board, the fastest frequency you can get for 8-bit PWM is 62.5 kHz. You could go faster at the expense of resolution.

You'll probably want a Teensy for this.

@towe Unfortunately, I won’t be able to use a Teensy for this project. However, what I can do to solve this issue is- generate a different sound wave. If someone can help me with finding out by how much will the frequency of the wave increase if I use PWM to generate it, I’ll be able to generate an appropriate wave.

That looks like the spectrum of an 8-bit sound that is playing low bass notes only.  Most everything above that looks like noise floor.  (You can only get about 6 dB range per bit of resolution, so 8 bits gives about 48 dB max.)  If this is the case, you definitely don't want to reproduce the upper frequencies.  If you want to stick to your original PWM scheme, use pins 5 or 6 because they use 980 Hz PWM instead of 490.  I suggest you determine the filter by trial and error, since it comes down to how much PWM carrier you can tolerate.  You can make a simple RC filter using the formula F = 1 / (2 * pi * R * C) where F is the cutoff frequency in Hz, R is ohms, and C is farads (that's 10^6 microfarads per farad).  This type of simple filter will have a very soft cutoff frequency, about 6 dB per octave, so if you set it for 123 Hz (3 octaves below 980 Hz) the 980 Hz PWM will be reduced by 18 dB.  The R connects to the PWM pin, and the C goes from the other end of R to ground, as does the signal output.  The formula assumes that there is no output load, so you should connect an amplifier there.  If you are like most folks, you probably have fewer capacitor values on hand than resistor values, so pick the C value first.  Let's say it's 1 uFd.  Then if you use R=1K the cutoff will be 159 Hz.  Change R while listening to the output


text:
Using PWM pins on the UNO to generate Stereo Sound
I am trying to generate stereo sound using an Arduino UNO. Instead of using a separate DAC chip (as shown here), can I use the PWM pins on the UNO along with a low-pass filter?
Also, would I need any additional circuitry if I go this path?

To achieve stereo sound, you would need to be able to control either the volume or the phase (or preferably both) of the signals. As far as I know, neither of them are controllable by default.

Yes that would work. You need one PWM pin per Channel. That's the principle of Class D Amplifiers. Yes, you would need additional circuitry. One low pass filter per channel. The better the filter, the better the audio quality. And don't expect to achieve HiFi Quality ;-).

You can generate "stereo sound", but I don't think you'll like it.  The PWM frequency is only 490 or 980 Hz, which is going to be plainly audible unless you filter the output very severely.  So you'll only be able to produce low frequency sounds, about like what comes out of the woofer speakers in your home stereo.  In other words, nothing like music.  Might be OK for certain experiments, but nothing you'd want to listen to for pleasure.
As far as additional circuitry, you'll need to convert the DC outputs of your two low-pass filters to AC before you try to drive headphones.  This requires a big decoupling capacitor for each channel. If you are going to drive a separate amp, you might be able to skip the capacitors since most amps have them built into the inputs.

Thanks for your response. Also, I think I can change the frequency of UNO’s PWM pins.


text:
Arduino Parse data serially on VB
I am working with Arduino Uno, I have tracker application running on Arduino Uno board. I am sending data in comma separated value. Now I want to view data into Visual Basic. I have code as below. The below code is working with fake values but as soon it live stream data split functions gives out error.
Serial output data looks like this.
Start,Latitude:13.00,longitude:60.00,MODE:1,DIR:1,Local Date:0/0/0,Local Time:5:30:2,tracker_des_angle:0.00,tracker_actual_pos:57.22,Wind Speed :0.00,END
Start,Latitude:13.00,longitude:60.00,MODE:1,DIR:1,Local Date:0/0/0,Local Time:5:30:4,tracker_des_angle:43.00,tracker_actual_pos:69.20,Wind Speed :0.95,END
Start,Latitude:13.00,longitude:60.00,MODE:1,DIR:0,Local Date:0/0/0,Local Time:5:30:6,tracker_des_angle:43.00,tracker_actual_pos:16.34,Wind Speed :1.85,END
Start,Latitude:13.00,longitude:60.00,MODE:1,DIR:0,Local Date:0/0/0,Local Time:5:30:8,tracker_des_angle:43.00,tracker_actual_pos:11.89,Wind Speed :2.77,END

visual basic code:
Option Explicit On

Imports System
Imports System.IO.Ports
Imports System.Text

Public Class Solar_Track
    Dim comPORT As String
    Dim receivedData As String = ""
    Dim strArray() As String
    Dim Data As String
    Dim latitude() As String
    Dim longitude() As String
    Dim Local_date() As String
    Dim Local_Time() As String
    Dim Mode_oper() As String
    Dim Dir_motor() As String
    Dim Act_pos() As String
    Dim Dis_pos() As String
    Dim wind_pos() As String
    Dim start As Boolean
    Dim End_Result As Boolean
    Dim result As Boolean

    Sub Parse_receivedata(ByVal msg As String)

        RichTextBox1.Text &= msg
        Data = msg

        strArray = Split(Data, ",")
        latitude = Split(strArray(1), ":")
        Text_Latitude.Text = latitude(1)

        longitude = Split(strArray(2), ":")
        Text_Longitude.Text = longitude(1)

        Mode_oper = Split(strArray(3), ":")
        Text_Mode.Text = Mode_oper(1)

        Dir_motor = Split(strArray(4), ":")
        Text_MotorDir.Text = Dir_motor(1)

        Local_date = Split(strArray(5), ":")
        Text_LocalDate.Text = Local_date(1)

        Local_Time = Split(strArray(6), ":")
        Label_hour.Text = Local_Time(1)
        Label_min.Text = Local_Time(2)
        Label_Sec.Text = Local_Time(3)

        Dis_pos = Split(strArray(7), ":")
        Text_TrackerDesire.Text = Dis_pos(1)

        Act_pos = Split(strArray(8), ":")
        Text_TrackerActual.Text = Act_pos(1)

        wind_pos = Split(strArray(9), ":")
        Text_Windspeed.Text = wind_pos(1)

    End Sub

    Sub data_parse()
        Data = "Start,Latitude:13.00,longitude:60.00,MODE:1,DIR:1,Local Date:0/0/0,Local Time:5:30:2,tracker_des_angle:0.00,tracker_actual_pos:54.48,Wind Speed :0.00,END"
        strArray = Split(Data, ",")

        latitude = Split(strArray(1), ":")
        Text_Latitude.Text = latitude(1)

        longitude = Split(strArray(2), ":")
        Text_Longitude.Text = longitude(1)

        Mode_oper = Split(strArray(3), ":")
        Text_Mode.Text = Mode_oper(1)

        Dir_motor = Split(strArray(4), ":")
        Text_MotorDir.Text = Dir_motor(1)

        Local_date = Split(strArray(5), ":")
        Text_LocalDate.Text = Local_date(1)

        Local_Time = Split(strArray(6), ":")
        Label_hour.Text = Local_Time(1)
        Label_min.Text = Local_Time(2)
        Label_Sec.Text = Local_Time(3)

        Dis_pos = Split(strArray(7), ":")
        Text_TrackerDesire.Text = Dis_pos(1)

        Act_pos = Split(strArray(8), ":")
        Text_TrackerActual.Text = Act_pos(1)

        wind_pos = Split(strArray(9), ":")
        Text_Windspeed.Text = wind_pos(1)

    End Sub

    Private Sub Solar_Track_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Enabled = False
        comPORT = ""
        For Each sp As String In My.Computer.Ports.SerialPortNames
            comPort_ComboBox.Items.Add(sp)
        Next
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comPort_ComboBox.SelectedIndexChanged
        If (comPort_ComboBox.SelectedItem <> "") Then
            comPORT = comPort_ComboBox.SelectedItem
        End If
    End Sub

    Private Sub BtConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connect_BTN.Click
        If (connect_BTN.Text = "Connect") Then
            If (comPORT <> "") Then
                SerialPort1.Close()
                SerialPort1.PortName = comPORT
                SerialPort1.BaudRate = 9600
                SerialPort1.DataBits = 8
                SerialPort1.Parity = Parity.None
                SerialPort1.StopBits = StopBits.One
                SerialPort1.Handshake = Handshake.None
                SerialPort1.Encoding = System.Text.Encoding.Default
                SerialPort1.ReadTimeout = 10000

                SerialPort1.Open()
                connect_BTN.Text = "Dis-connect"
                Timer1.Enabled = True
                Timer_LBL.Text = "Timer: ON"

            Else
                MsgBox("Select a COM port first")
            End If
        Else
            SerialPort1.Close()
            connect_BTN.Text = "Connect"
            Timer1.Enabled = False
            Timer_LBL.Text = "Timer: OFF"
        End If

    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        receivedData = ReceiveSerialData()
        ''RichTextBox1.Text &= receivedData
        Parse_receivedata(receivedData)
        receivedData = ""
        '' data_parse()
    End Sub
    Function ReceiveSerialData() As String
        Dim Incoming As String
        Try
            Incoming = SerialPort1.ReadExisting()
            If Incoming Is Nothing Then
                Return "nothing" & vbCrLf
            Else
                Return Incoming
            End If
        Catch ex As TimeoutException
            Return "Error: Serial Port read timed out."
        End Try

    End Function

    Private Sub BtClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtClear.Click
        RichTextBox1.Text = ""
    End Sub

End Class

Posting your question twice doesn't make it more fit for the Arduino community. Flagging it as duplicate AND off-topic.

Looks like you are using a timer to regularly read the data from the serial port... I think you'd be better using the DataReceived() event of the SerialPort class.
The other thing is that you are just reading whatever data is in the buffer (with ReadExisting) if all that is in the buffer is 2 or 3 characters (not a full line) then your Parse_receivedata() will not be able to split it based on ,
You want to keep appending the received data to a StringBuilder (or similar) until you hit a CR/LF and then pass it to the Parse_receivedata() function:
Psuedo code would be something like:
// class scoped variable
rxData = ""

...
// inside the DataReceived() event
rxData += SerialPort1.ReadExisting()
If (rxData.Contains(Environment.Newline)) Then
  lines = rxData.Split(Environment.NewLine)
  toParse = lines[0]
  rxData = lines[1]
  ParseRxData(toParse)
End If

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


text:
Transistor for DC motor and 9v
I have this schematic for a DC motor in my arduino, now I want to add 9v battery.
But I've seen that people use TIP120 transistor, I have BC548B,
can I just put the 9v with that transistor?

What are the ratings of your motor, or do you have a datasheet for. otherwise, connect to 9V directly and measure the current draw and add give that info too.

The datasheet says 30 volt is the maximum.

@Gerben the transistor is max 100mA this is surely not good for a motor?

That's the maximum. Just like you can put a 5w light bulb in the same socket as a 100w light bulb. The motor will use the amount of current it needs, even thought there might be more current available.

@Gerben and if the motor draws too much, poof, white smoke and fun :) The OP never stated a motor type. The OPs circuit is what they want to do(from what I can tell, with Vin as source), although if the motor ran on 5V it is possibly a low current then, but you could max the draw if the thing stalls or is under load. With a 5W you might not see much though.

If you use PWM, be sure to use a Transistor(preferably a MOSFET) that has max voltage 3times the supply voltage and a flyback diode.Also, measure the current drawn by the motor when connected directly to 9V supply.The max current rating of the transistor used should be approx 2 times the current drawn by the motor(in the prev test).

There are many circuits using the TIP120 NPN transistor because it is a darlington transistor. This is used because its max voltage is 60V and the max current is 5A, this means you can control a variety of external high current devices with low voltage circuitry because of the darlington arrangement.
You can use the BC548B with your motor(low current) and a 9V battery as it does handle 30V, but it is limited to 100mA, which is fine for tiny low current motors. But these are actually Amplifier transistors, so there main design area is not for inductive loads.
I recommend the TIP120 as this will ensure that you don't trash a transistor with current spikes as you could easily go over the 100mA spec of the BC548.

Firstly, I see no external power supply in your schematic.
Secondly, you certainly CANNOT use a BC548 for controlling a motor.
MOSFETS are the best.

If you use PWM, be sure to use a Transistor(preferably a MOSFET) that has max voltage 3times the supply voltage and a flyback diode.Also, measure the current drawn by the motor when connected directly to 9V supply.The max current rating of the transistor used should be approx 2 times the current drawn by the motor(in the prev test).

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


text:
Brand new to Arduino, and can't even make an LED blink
So I'm going through Getting Started With Arduino. I skipped to making a LED blink when you press a button.
First I wrote the code, then I copied it directly from the .pdf I have, neither has worked.
The code is here:
// Example 02: Turn on LED while the button is pressed
const int LED = 13;   // the pin for the LED
const int BUTTON = 7; // the input pin where the
                      // pushbutton is connected
int val = 0;          // val will be used to store the state
                      // of the input pin
void setup() {
  pinMode(LED, OUTPUT);   // tell Arduino LED is an output
  pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop(){
  val = digitalRead(BUTTON); // read input value and store it
  // check whether the input is HIGH (button pressed)
  if (val == HIGH) {
    digitalWrite(LED, HIGH); // turn LED ON
  } else {
    digitalWrite(LED, LOW);
  }
}

You need to have a resistor in series with that LED or you will damage it and/or your board.

The sketch uses pin 13, i.e. the built in LED; I think the one at the top right is unconnected.

@Nick: The book doesn't say that. It shows a drawing with the LED connected directly to pin 13 and ground.

Chuck the book out and get a different one. That's incorrect. Also, can you get the blink sketch to work? Disregard the button and just see if you can get an LED to blink on its own.

It looks like you are right. However that book was written years ago when the Arduino had a built-in resistor. Modern ones don't.

@uint128_t Yeah, blink makes the built in LED blink, which is progress. I'm starting to wonder if pin 13 does anything.

Do you have a multimeter? You can measure the pin voltage to make sure it's doing what you expect. And RSM is right, to make the switch work, you need to bridge your power rails.

Other than what what Nick Gammon said that you need the resistor from the board to led, as that will cause your microcontroller pins to get damaged.
The other possible problem is the two breadboards you have put together, the power rails have not been bridged between the two boards. This means that the switch is not providing any logical state to the microcontroller.
Also the only reason why the led is show in the book as a separate thing is that it is meant as an educational exercise to make you build something, the L led will do the same thing.

the power rails have not been bridged between the two boards - you are totally right. You can see from the red line on the board that the two sides are not connected.

In fact they are just two smaller boards which happen to be adjacent. Those power and ground lines won't be connected.

@NickGammon I think some believed the power is transfered wirelessly when placed adjacent to one another, which unfortunately many newcomers are ill informed about the way the things work. Its the second time I've seen this.

Nah, they just don't realize that the board doesn't run all the way through. I've had a few lengthy arguments about this in the past. :)


text:
Arduino on breadboard, and then soldered using a board made on Eagle but won't work
So I'm looking to create an arduino clone to mount on one of my robots. I started off making the arduino on a breadboard, using the instructions found on Arduino's own website and I succeeded. It works as well, I've checked it with the "blink" project.
I then drew the schematic in Eagle:

Next, I created a board and routed it, giving the following result:

Finally, I transferred it onto a copper clad, soldered it, but it doesn't work. Tried pretty much everything I could think of but there seems to be something wrong and I cant work out what it is.
Can someone please help?
Hassan

I haven't worked out why it's "not working", but some comments on your PCB:

Your crystal is too far from the clock pins
Your crystal capacitors are most definitely too far from the crystal
There are no decoupling capacitors on your Vcc / AVcc pins

Your crystal should be right next to the pins on the chip that it is connected to, and the capacitors for it should be immediately next to that. The layout you have at the moment, if it actually works, will be radiating huge amounts of EMI and would immediately fail any emissions test you'd care to perform.
Without decoupling capacitors on the power pins the chip may not function properly.
Edit: I have just found your main mistake
You haven't linked the output of your regulator sub-circuit to Vcc. Power gets regulated but goes nowhere.

Thank you very much Majenko
.
http://i.imgur.com/rnENfP1.png
Here are the changes -- Is this what you meant? I'm not sure what you mean by your point 3. about the decoupling capacitors, no idea :( maybe you could elaborate if I havent already corrected the mistake? Thanks so much once again :D

It's worth fixing the power and decoupling issues by soldering wires and components onto the present board before you make a new one.  The crystal should work in the near term, but do move it closer, however the crystal loading capacitor position is indeed terrible - chisel those traces and add replacement caps keeping both the crystal-signal and also ground connections to the caps short.  Or you can test the chip with its internal oscillator - point being use modifications to your existing board to make sure nothing else is wrong before you fabricate another.


text:
How do I set my sampling rate?
I want to monitor the vibration from a motor running at 9.5Hz at 565rpm. I am using Arduino Uno and the ADXL345 as my condition monitoring equipment. How do I set the sampling frequency? I want to sample at at least 5x more than the operating frequency which is 50Hz, which will give a interval of 0.02 sec. However, to collect 2500 readings, I would need to take around 300 sec which is 0.12sec per reading different from the preset value at 0.02 sec.
Is my code wrong somewhere? Or what can I do to speed up the process?
#include <Wire.h>
#define DEVICE (0x53)    //ADXL345 device address
#define TO_READ (6)        //num of bytes we are going to read each time    (two bytes for each axis)
#define THRESH_ACT  (0x24)
#define THRESH_INACT  (0x25)
#include <SPI.h>
#include <SD.h>
File myFile;

// Declare Variable
byte runComplete; //setting the number of iteration
int i; //delare i for count
byte buff[TO_READ];//6 bytes buffer for saving data read from the device
float x, y, z; //Acceleration variable
float x1, y1, z1; //Acceleration variable

void writeTo(int device, byte address, byte val) {
  Wire.beginTransmission(device); //start transmission to device
  Wire.write(address);        // send register address
  Wire.write(val);        // send value to write
  Wire.endTransmission(); //end transmission
}

void readFrom(int device, byte address, int num, byte buff[]) { //reads num bytes starting from address register on device in to buff array
  Wire.beginTransmission(device); //start transmission to device
  Wire.write(address);        //sends address to read from
  Wire.endTransmission(); //end transmission
  int n = Wire.requestFrom(device, num);    // request 6 bytes from device
  if( n == num)
  {
      Wire.readBytes(buff, n);
  }
    }
void regAddress()
{
    int regAddress = 0x32;    //first axis-acceleration-data register on the ADXL345
    readFrom(DEVICE, regAddress, TO_READ, buff); //read the acceleration data from the ADXL345

     //each axis reading comes in 10 bit resolution, ie 2 bytes.  Least Significat Byte first!!
     //thus we are converting both bytes in to one int
    x = (((int)buff[1]) << 8) | buff[0];
    y = (((int)buff[3])<< 8) | buff[2];
    z = (((int)buff[5]) << 8) | buff[4];

    x1 = (x/256);
    y1 = (y/256);
    z1 = (z/256);

 Serial.println(" ");
    Serial.print("X: ");Serial.print(x1); Serial.println(" mm/s2");
    Serial.print("Y: ");Serial.print(y1); Serial.println(" mm/s2");
    Serial.print("Z: ");Serial.print(z1); Serial.println(" mm/s2");
    Serial.println(" ");

    myFile = SD.open("x30.txt", FILE_WRITE); // if the file opened okay, write to it:
    if (myFile) {
      Serial.print("Writing to X.txt...");
      myFile.println(x1);
      myFile.close();// close the file:
      Serial.println("done.");
    } else {
      Serial.println(F("error opening x.txt")) ;// if the file didn't open, print an error:
    }

    myFile = SD.open("y30.txt", FILE_WRITE); // if the file opened okay, write to it:
    if (myFile) {
      Serial.print("Writing to Y.txt...");
      myFile.println(y1);
      myFile.close();// close the file:
      Serial.println("done.");
    } else {
      Serial.println(F("error opening Y.txt")) ; // if the file didn't open, print an error:
    }
      myFile = SD.open("z30.txt", FILE_WRITE);// if the file opened okay, write to it:
    if (myFile) {
      Serial.print("Writing to Z.txt...");
      myFile.println(z1);
      myFile.close();// close the file:
      Serial.println("done.");
      Serial.println("");
    } else {
      Serial.println(F("error opening Z.txt")); // if the file didn't open, print an error:
      Serial.println("");
    }
       }

void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
  writeTo(DEVICE, 0x2D, 0);   //Turning on the ADXL345
  writeTo(DEVICE, 0x2D, 16);  //Turning on the ADXL345
  writeTo(DEVICE, 0x2D, 8);   //Turning on the ADXL345
  writeTo(DEVICE, 0x31, 8);
  Serial.println("Initializing Accelerometer...");
  Serial.print("Initializing SD card...");
  Serial.println("");
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    Serial.println("");
    return;
  }
  delay(2000);
}

 void loop() {
   if (runComplete == 0){
  for (i=0; i<2501; i=i+1){
 Serial.print("Number of iteration(seconds) = "); Serial.print(i);
 Serial.println("");
 regAddress();
     delay(200);
   }
  runComplete = 1;
  }
}

Hint: Try measuring the time to perform regAddress(). Looks like that is in the range of 0.1 second??

Hint: Improve regAddress() by first removing all the Serial.print() statements.

Hint: Use a single data log file. Write all three values to this file. Keep it open during the data collect.

After speeding up regAddress(), instead of delay(), use an if (millis() -previousMillis >20){previousMillis=millis();... } to control the rate.

Record the raw data, then after the sampling is done, re-read the data and report or recode the data in whatever format you need.

0.02 seconds means 20 ms, not 200. Your delay time is too long. Try using millis or micros instead of delay for average deviation. Using delay will accumulate lags caused by process time.
Try to sacrifice memory to log the data first (using for()  & data array), and then write to serial later.


text:
External Power for MicroServo (SG92R)
Why won't my MicroServo run at external 5v power supply? , I've tested my power supply and can light up 1 LED and also run the servo mainly on arduino and it works just fine. Im currently using a computer power supply using the red wire(5v). I'm not very knowledgeable with voltage and stuff and im hoping someone can answer.

and here is my power supply...

I've checked the power supply terminals but nothing is wrong there. Also, i've tried 10k potentiometer to be supplied by it but when i read it in serial.begin it just reads "0, 0, 0, 0, 1023, 1023, 1023, 1023" over and over again. Sorry about the formats im still new.

are you trying to power the servo by using only one wire connected to the power supply?

Im using ground and red wire to connect to servo and yes using power supply to power the servo

even adapters that supplies 4.8v volts still won't power

Did you connect all grounds? You might want to show us your circuitry.

Or take a picture of your project such that it is clear how components are connected.  That is, a picture where it is clear where all the wires are are going.

The image you uploaded shown quite clearly that you have not connected the grounds between the Arduino circuit and the servo circuit. In order for it to work, the servo should reference the signal line to ground, currently only PC power supply is providing ground, so the Arduino signal line is floating.
Check out the attached image and connect the GND as shown in dotted yellow line.

Oh wow , it works now. Didn't know about that, I thought as long as the GND and +5 of servo must be connected to power supply terminals it'll work. Im learning new things thanks alot

You are welcome, you can also mark the answer so it will show as solved your issue.


text:
How to GET HTTP Request from Arduino to Firebase?
I have an Arduino UNO and SIM808 and I'm trying to send my GPS data to the Firebase. I have successfully created a website which I can post data from the website to the Firebase. However I'm trying to send my data from Arduino to the website which failed constantly. I have no idea what is the error.
These are my codes:
  /*
    ### Get GPS data
    1. This example is used to test SIM808 GPS/GPRS/GSM Shield's reading GPS data.
    2. Open the SIM808_GetGPS example or copy these code to your project
    3. Download and dial the function switch to Arduino
    4. open serial helper
    4. Place it outside, waiting for a few minutes and then it will send GPS data to serial

    create on 2016/09/23, version: 1.0
    by jason

  */
  #include <DFRobot_sim808.h>
  #include <SoftwareSerial.h>

  #define PIN_TX    10
  #define PIN_RX    11
  SoftwareSerial mySerial(PIN_TX, PIN_RX);
  DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

  #define APN "diginet"
  #define USER ""
  #define PASS ""
  unsigned long previousMillis = 0;
  long interval = 60000;

  String the_year, the_month, the_day, the_hour, the_minute, the_second, the_time;
  String latitude, longitude;

  //DFRobot_SIM808 sim808(&Serial);

  void setup() {
    mySerial.begin(9600);
    Serial.begin(9600);

    //******** Initialize sim808 module *************
    while (!sim808.init()) {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
    }

    //************* Turn on the GPS power************
    if ( sim808.attachGPS())
      Serial.println("Open the GPS power success");
    else
      Serial.println("Open the GPS power failure");

  }

  void loop() {
    //************** Get GPS data *******************
    getGPS();

    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis > interval) {
      previousMillis = currentMillis;
      sendtoFirebase();
    }

  }

  void getGPS() {

    if (sim808.getGPS()) {
      delay(500);
      the_year = sim808.GPSdata.year;
      the_month = sim808.GPSdata.month;
      the_day = sim808.GPSdata.day;
      the_hour = sim808.GPSdata.hour;
      the_minute = sim808.GPSdata.minute;
      the_second = sim808.GPSdata.second;
      the_time = the_year + " / " + the_month + " / " + the_day + " " + the_hour + ": " + the_minute + ": " + the_second;
      Serial.print(the_time);
      //Serial.print(sim808.GPSdata.year);
      //types(sim808.GPSdata);

      latitude = String(sim808.GPSdata.lat, 6);
      longitude = String(sim808.GPSdata.lon, 6);
      Serial.println(latitude);
      Serial.println("longitude : ");

      Serial.println(longitude);

      sim808.latitudeConverToDMS();
      sim808.LongitudeConverToDMS();
      //Serial.print("latitude : ");
      //        Serial.print(sim808.latDMS.degrees);
      //        Serial.print("\^");
      //        Serial.print(sim808.latDMS.minutes);
      //        Serial.print("\'");
      //        Serial.print(sim808.latDMS.seconeds,6);
      //        Serial.println("\"");
      //    Serial.print("longitude :");
      //    Serial.print("longitude :");
      //    Serial.print(sim808.longDMS.degrees);
      //    Serial.print("\^");
      //    Serial.print(sim808.longDMS.minutes);
      //    Serial.print("\'");
      //    Serial.print(sim808.longDMS.seconeds, 6);
      //    Serial.println("\"");

      //    Serial.print("speed_kph :");
      //    Serial.println(sim808.GPSdata.speed_kph);
      //    Serial.print("heading :");
      //    Serial.println(sim808.GPSdata.heading);

      //************* Turn off the GPS power ************
      //sim808.detachGPS();
    }
  }

  void sendtoFirebase() {

    boolean newData = false;
    for (unsigned long start = millis(); millis() - start < 2000;) {
      while (sim808.getGPS()) {
        newData = true;
      }
    }

    if (newData) {
      newData = false;

      String deviceId = "ABC1235";

      Serial.print("Device ID:");
      Serial.println(deviceId);

      Serial.print("Time:");
      Serial.println(the_time);
      Serial.print("latitude:");
      Serial.println(latitude);
      Serial.print("longitude:");
      Serial.println(longitude);

      String temp;

      //build the URL to the proxy
      String url = "http://myfypproject.epizy.com/firebase.php?arduino_data=25.00";
      //  url += "&deviceid=";
      //  url += String(deviceid);
      //  url += "&lat=";
      //  url += String(latitude);
      //  url += "&lon=";
      //  url += String(longitude);

      Serial.println(url);
      sendATcommand("AT+CFUN=1", "OK", 2000);
      //AT+CGATT = 1 Connect modem is attached to GPRS to a network. AT+CGATT = 0, modem is not attached to GPRS to a network
      sendATcommand("AT+CGATT=1", "OK", 2000);
      //Connection type: GPRS - bearer profile 1
      sendATcommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"", "OK", 2000);
      //sets the APN settings for your network provider.
      sendATcommand("AT+SAPBR=3,1,\"APN\",\"diginet\"", "OK", 2000);
      //enable the GPRS - enable bearer 1
      sendATcommand("AT+SAPBR=1,1", "OK", 2000);
      //Init HTTP service
      sendATcommand("AT+HTTPINIT", "OK", 2000);
      sendATcommand("AT+HTTPPARA=\"CID\",1", "OK", 1000);
      //Set the HTTP URL sim800.print("AT+HTTPPARA="URL","http://ahmadssd.000webhostapp.com/gpsdata.php?lat=222&lng=222"\r");
      //sendATcommand("AT+HTTPPARA=\"URL\",\"http://myfypproject.epizy.com/firebase.php?arduino_data=25.00\"", "OK", 1000);
      mySerial.print("AT+HTTPPARA=\"URL\",\"");
      mySerial.print(url);
      sendATcommand("\"", "OK", 1000);
      //Set up the HTTP action
      sendATcommand("AT+HTTPACTION=0", "0,200", 1000);
      //Terminate the HTTP service
      sendATcommand("AT+HTTPTERM", "OK", 1000);
      //shuts down the GPRS connection. This returns "SHUT OK".
      //sendATcommand("AT+CIPSHUT", "SHUT OK", 1000);

    }

    return 1;
  }

  int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout) {
    uint8_t x = 0, answer = 0;
    char response[100];
    unsigned long previous;

    //Initialize the string
    memset(response, '\0', 100);
    delay(100);

    //Clean the input buffer
    while (mySerial.available() > 0) mySerial.read();

    if (ATcommand[0] != '\0') {
      //Send the AT command
      mySerial.println(ATcommand);
    }

    x = 0;
    previous = millis();

    do {
      //if there are data in the UART input buffer, reads it and checks for the asnwer
      if (mySerial.available() != 0) {
        response[x] = mySerial.read();
        //Serial.print(response[x]);
        x++;
        // check if the desired answer (OK) is in the response of the module
        if (strstr(response, expected_answer) != NULL) {
          answer = 1;
        }
      }
    } while ((answer == 0) && ((millis() - previous) < timeout));

    Serial.println(response);
    return answer;

  }

I keep get the error of 603.
AT+HTTPACTION=0
OK
+HTTPACTION: 0, 603, 0

Below are my PHP, website to firebase codes:
    <?php
require_once 'firebaseLib.php';
// --- This is your Firebase URL
$url = 'https://projectname-default-rtdb.asia-southeast1.firebasedatabase.app/';
// --- Use your token from Firebase here
$token = 'XXXXXXXXXXJYszyqIJxr3UuGl1Zr6qHG03K';
// --- Here is your parameter from the http GET
$arduino_data = $_GET['arduino_data'];
// --- Set up your Firebase url structure here
$firebasePath = '/GPSdata';

/// --- Making calls
$fb = new fireBase($url, $token);
$response = $fb->set($firebasePath, $arduino_data);
echo $url;
sleep(2);

UPDATE:
I can get code 200, but there isn't any result in my firebase or my website.

the title of your post does not match the content ... the title says post to firebase ... the question says post to intermediate webpage ... why don't you post to firebase directly?

because I found out that, SIM808 only can do HTTP request but Firebase required HTTPS request which I need a intermediate webpage.

SIM808 HTTPS.

It is just the server problem. I just changed a website and it works.


text:
MCU fuses used by Pro Mini and ATMega 2560 and power down
In context of Pro Mini and ATMega2560
Fuses, as documented in chip factory doc are complex topics (I have not really used it before), appreciate pointers and advises, to narrow down those that are needed for contexted task and left un-needed in their default modes.
Which fuses are used within context of the IDE in general, and in specific of software loading via bootloader and ISP?
Which fuses related to sleep and power down modes, in context that individual chip modules can be set to various power-saving modes via registers. Does fuses play a part in getting the power-saving effect?
Many thanks in advance

Have you looked at the datasheets yet?

Most fuse settings will work fine. The only power-saving fuse is disabling the brownout detection, but it's better to do that in software. There isn't any need to change the fuses in most cases.

The data sheets are the ultimate source. However, that may be a bit overwhelming. I find the below great resources very helpful.
1) Online Fuse Calculator There are many others.
2) avrdude-GUI
there are many others out there.
3) the .\arduino-1.5.7\hardware\arduino\avr\boards.txt
uno.bootloader.low_fuses=0xFF
uno.bootloader.high_fuses=0xDE
uno.bootloader.extended_fuses=0x05

4) I also read the fuses from any device before I stomp over them. And check into what each mean.
As for narrowing down the features the Online Calculator very helpful to start with and then read into the data sheet for ones of interest.
For the most part there have several questions and answers for low power modes, using interrupts to re-awake. Where there appears to no direct fuses to save power, outside of clock source and speed. Arguably Brown Out detect is a fuse, but that is not directly related to saving power.


text:
What software is available for use with AVRISP and USBASP on ATMega48, 328, 2560?
What software is available for use with AVRISP and USBASP on ATMega328, 2560 for read/write fuse, flash and EEPROM for UNO, Pro Mini and Mega2560 board?
(a fact question not opinion) Which software did you use?
Did it work straight forward (like the software did all the needed 'auto select')?
Does it need human selection for options, etc. on the above 3 boards?
Do I need WinAVR installed before able to use the 'ISP software'?

Almost everyone uses either AVRDUDE (directly or indirectly, e.g. via the Arduino IDE) or the upload capability in Atmel Studio. I cannot speak for AS, but AVRDUDE does require options to tell it which programmer and device to use. WinAVR includes AVRDUDE, but is not strictly required as Win32 downloads are available at the AVRDUDE site.

As Ignacio Vazquez-Abrams mentioned, you should look into Atmel Studio. You can use a 3rd party AVR programmer (Arduino w/isp) or one from Atmel. The IDE is awesome and has a lot of features like setting fuse bits.


text:
Why is my Analog Input channel adding voltage to my signal?
EDIT: Here are the links to the sensor spec sheet (http://www.omega.com/temperature/pdf/HX71.pdf) and manual (http://www.omega.com/Manuals/manualpdf/M4543.pdf) for your reference.
I'm using a relative humidity (RH) sensor with an Arduino Mega. The RH sensor runs off of +/- 24V  (which is being sourced by a power supply), and outputs a signal from 0-5VDC. Naturally, I am plugging this output signal into my A0 channel. There is a bare Earth Ground wire that is wired to the power supply's earth ground (possible error?) Arduino's GND is connected to the power supply's EARTH GND, fyi.
I compared the voltage reading in my Arduino Serial Monitor to a reliable Fluke multimeter, and the analog input channel is adding ~.2 Volts!
From some research, I have read about "high impedance" "source impedance" "internal wiring of Arduino" etc, but unfortunately I am failing to grasp the reason why this is happening. I'd like to know so then I could figure out a solution on my own.
Below is a schematic of what I'm dealing with so that it may better illustrate my issue (also my code). Thank you for your time, and I appreciate your help!
)
void setup()
{

Serial.begin(9600);

}

void loop()
 {

  float hs1 = ((( analogRead(A0) * ( 5.0 / 1024.0) ) )* 20.0 );

  Serial.print("RH%");
  Serial.print(":");
  Serial.print(hs1);
  Serial.print(";");
  Serial.println();
  delay(1000);

}

Link to the RH sensor data sheet?

Oh yes! here's the spec sheet: http://www.omega.com/temperature/pdf/HX71.pdf and the manual http://www.omega.com/Manuals/manualpdf/M4543.pdf

I'm using model HX71-V1, thank you @Majenko

One of the biggest mistakes people make when calculating the voltage of an ADC is they assume the chip is running at 5.000000 volts. Have you measured the 5V pin of the Arduino with your Fluke?

How do you know your fluke is accurate ? :). You could measure the 5v using A1 and 'calibrate' your reading on the fly.

Wow, you guys are gonna get a KICK out of this!
The analog input channel was not adding millivolts to my Analog Input signal. I stupidly was not supplying my Arduino Mega with 9V!! I had it running off of the USB port, which was affecting my 5V reference (thank you @majenko for pointing that out!).
I measured the 5V pin and it was fluctuating between 4.41-4.21 volts. My colleague made a comment and I reviewed the Arduino Mega datasheet. It must be supplied with 7-12 volts in order for the 5V to output correctly.
Once I hooked my Power Vin + GND to my power supply, set that at 9V/.08amps my analog input readings were accurate.
Thank you everyone for your help!


text:
Choosing the right mosfet to switch on-off a neopixel strip
I,m trying to find the right mosfet or transistor to switch on-off a neopixel strip to safe battery power on a Lipo 3.7v using a pro mini 3.3v.
My Animation-Setup and Power Comsumption with 35 Neopixels is :

Sparkel      : 20mA
Knight Rider : 80mA
Pulse        : 600mA

So the maximum  current for the ledstrip is 600mA @ 3.7v
My first thought was to use the 2N 2222 - Transistor NPN TO-18 60V 0,8A 0,5W.
But then i realize the worst case:
What happens if the all 35 Neopixels turn full white caused by a software glitch or a bug in the code. Full white means every neopixles consumes 60mA.
Total power comsumption: 35 X 60mA = 2.1A
Would be destroyed the 2N2222? Because it could handle only 800mA drain current?
How can I avoid this situation. So I read about Mosfet like this one FQP30N06L :
N channel power MOSFET
TO-220 Package
Vds = 30V max
Max current = 62A
Vgs = 2.35V max
Rds_on = as low as 8.7 milliohm - depending on Vgs

What do you think will it work to switch on/off the led if:

the drain current is between 20mA - 600mA - 2.1A
ledstrip Vcc is 3.7v
pro mini out 3.3V at max 40mA

Or is there an other suitable Mosfet for this problem than the FQP30N06L with 62 Ampere for these hardware setup with only 2.1 Ampere Peak @ 3.7v ?

Any reason why you don't want to use this mosfet? It looks to me like it will do the job. (PS make sure you set the data-pin for the neopixels to an input, before turning off the mosfet)

You refer to a 2N2222 handling 800 mA.  However, the 2N2222 datasheet shows 600 mA as its maximum rating for Collector Current – Continuous.  Moreover, from the On Characteristics table, Collector – Emitter Saturation Voltage at 500 mA current could be as high as 1 V.  In typical circuits with high base drive it usually is less, eg about 0.2 V typical with 50 mA base drive, which is more current than a typical AVR output is rated for.  Anyhow, the Neopixels won't operate if your switch drops any significant voltage from the supply.  Using a 2N2222 might work ok, or briefly, or intermittently, or not at all  – depending on the quality of the  2N2222 and the amount of base drive.
You refer to a FQP30N06L handling 62 Amperes.  However, the FQP30N06L datasheet shows 32 A as its rating for Drain Current - Continuous (vs 128 A for Drain Current - Pulsed, which is irrelevant here).
Using a FQP30N06L at its maximum 32 A continuous drain current would require careful heatsinking and perhaps 10 V of VGS drive to achieve low RDS(on), like 27 mΩ. With low VGS of say 3.3 V, RDS(on) might be twice as much.  For example, if it were 45 mΩ, going above 4 or 5 A current would be problematic without careful heatsinking:  4 A → P = 4²·0.045 = 0.72 W, enough to heat up a not-heatsinked unit's junction by about 45℃ or 80℉.
But the FQP30N06L should work ok for your 600 mA typical-case scenario, and also should be ok with the 2 A worst-case as well.


text:
Back EMF from Relay causing trigger on INPUT pin
I am wiring up a light show for my pickup truck.
I have installed various high power spotlights and light bars into a dedicated relay/fuse box in the engine bay. These relays are wired into a switch panel in the dashboard and work beautifully using the manual switches.
I have subsequently set up a brain...

An Arduino Uno R3, programmed with 3 different light sequences;
An 8 bank 5v relay module, driven from Digital Out Pins 6 to 12, each relay on the module fires a separate light (via the existing relays in the engine bay).
A 4 Channel RF receiver, provides Digital In Pins 3 to 5, to select one of the three sequences, and Digital In Pin 2 Interrupt as a stop/reset button.

I have set this up to start a sequence from an RF button, and programmed the Arduino to fire the relays, including strobe, which was working great on the LED's I attached while testing.
However, when I wire them up to bridge the switches on the dashboard (in turn firing the relays in the engine bay), the Arduino receives a positive signal on INPUT_PULL Pin 2 after a couple of flashes. I think this is something to do with an interference caused by the back EMF from the relay coils in the engine bay, possibly striking the relay module causing it to fire the interrupt pin 2 and causing a reset.
Looks like I need a snubber. I think the best answer is to install a flyback diode across the coil on the relay in the engine bay, but have been trying to figure out how I can wire these up within the blue box, without dismantling the relays installed in the engine bay. I thought maybe I could connect general ground to the manual switch (long route of achieving the same circuit), which helped but after a few more flashes the Arduino gets a signal to reset again. I have lots of diodes and RC Snubber circuits from Amazon which I was going to try, maybe across the Module Relay contacts.
This is a circuit for one of the eight lights.
Please advice how I can reduce this interference using snubbers or some other modification, ideally within the blue box.
Thanks

UPDATE:
I have managed to get a working setup by removing the resistor and the 5v feed to the RF Relay. Also adding a Diode from earth to the top side of the Module Relay connector. See updated circuit below. Seems to be working, though I'll have a go at adding RC Snubbers as suggested.

I don't see how the "relay for light 1" relay can interfere with the Arduino, other that the change in load generating some noise on the 12V DC. I think the real problem is running 8 relays from the 5V created by the UNOs voltage regulator. Especially with a noisy 12V input. I don't think the UNOs power supply circuit is made for automotive. I'd get get one of those phone chargers for cars, and use that to power the UNO and relay board.

I have one of those, was running it off of a 5v USB connection initially, read an article saying that you should not power them from the USB connector. So I even tried from a 9v battery to try and isolate the problem. For now I am just trying with 1 relay until I get it working.

@Gerben Seems I should widen the net slightly for full disclosure. I've narrowed it down to something else... I have a 4 button RF Remote Control, the receiver is in the blue box, one of the buttons fires another relay that has an interrupt input into the Arduino, and does an _Init(). Seems this is being fired when "relay for light 1" is disengaged. I will update the question and the diagram.

Since the problem is with the Arduino post a schematic, not a frizzy thing showing how it is connected showing all connections and power.

@Gil I'm not sure what you are asking of me... Are you saying that there is not enough detail in my circuit diagram? I'm open to suggestion on how I can make this question better.

You show the Arduino + connected to the vehicle electrical system, Is that Vin? What other protection if any have you added to that feed? Most if not all of the electromechanical devices such as relays will generate noise when cycled, that typically appears on the 12V system. You show three different grounds, they should all be the same. Have you taken any precautions for the alternator noise?

No, it's as is, connected to the battery, other than fuses, though I've got a 5v USB adapter, like the cigarette lighter ones. The earth like symbol is for the chassis of the car, all connecting back to the car battery. The issue i see is some interference from the back emf of the Light 1 Relay some how sending a positive signal to the Arduino digital in pin 2 with the interupt enabled.

Are you using an internal pullup resistor on Pin 2? The internal pullup is about 20K to 50K, but there is also a 10K external pulldown on that pin. It should be either pullup or pulldown, but not both. Also consider using a 1K resistor instead of the 10K to provide a stronger pulldown and greater noise immunity. And you could replace all the relays with MOSFETs.

@tim thanks for the info, to be honest my knowledge on this is a little rusty from my Electronics A Level 30 years ago. I need to do some reading on pullup and pulldown, and MOSFETs. With that 30 years in IT, I naively thought running an Arduino with relays was like computer logic, I remember now that it's not, feels like it's back to basics for me :).

That 10K resistor should be removed completely. It's not achieving anything useful, and is in fact causing the input to be far too sensitive to noise. You should use a pullup resistor of 10K or less instead of the internal (very weak) pullup.

There are two things to tackle in your schematic. First is snubber networks. These are used to aid in the prevention (or rapid extinguishing) of sparks between the contacts of switching gear (like relays). You should attach one across the contacts of each relay. It is these sparks that create most of the "airborne" EMI.
A diode across a relay's coil only deals with "wire-born" EMI (in the form of induced back-EMF) and has no relevance in your circuit due to the galvanic isolation of the first stage relay and the driver circuit in the module.
The second, and more important, thing to deal with is your input pin.  Firstly the built-in pull-up resistor is very very weak. It's usually around 30kΩ, and that is very easy for "airborne" EMI to overcome.  You should avoid using it. Instead an external pull-up resistor of no more than 10kΩ (I'd recommend 1kΩ as a good value) should be used.
Secondly you have a 10kΩ resistor in series with your switching contacts. This will not be helping to get a logic LOW level when the switch contacts are closed since it forms a resistive divider with the pull-up resistor. As it is it happens to just work with the internal pull-up, since the internal pull-up is greater than the 10kΩ series resistor. Reduce the pull-up with an external and that will no longer be the case.
That 10kΩ resistor should be removed completely.
Here is your circuit with modifications in red:

That looks like a good plan, I'll give it a shot. I have actually been trying a few things and got it to work. First I removed the resistor, removed the 5v wire to the same relay, left as INPUT_PULLUP. Then I added a Diode from ground to the top side of the Module Relay for flyback. That seems to work, strobe and everything, but I may have a ticking timebomb!!

Added an updated circuit with my changes. Thoughts?

@MattD I would still recommend adding the smaller pullup resistor on the input pin. It will help it be more immune to noise. Snubbers are still a good idea to add, although the diode you added is doing most of the job of the snubber for the inductive load of the second relay. You should consider adding one to the second relay's contacts though, if only to increase their lifetime.

Thanks for your help, it's all working now, got 4 inputs and 8 outputs to do the same, that's a fair bit of wiring, I think I'll need to put together a strip board to tidy it all up.

The internal pullup was ok when the car wasn't running, but was not enough with the engine on. Putting in the 1K external pullup resistor worked a treat, even when running. Thanks!

Here is a general idea of a MOSFET alternative for switching the light on and off.
Click to simulate in Falstad.
You can click the switch and the H/L input to see how it operates while running the simulation.
The p-channel MOSFET in series with Light 1 could be FQP27P06.
The n-channel MOSFETs are of much lower power.
Using MOSFETs eliminates both the RFI/EMI interference from sparks across relay contacts and the surges/noise from the collapsing electric field of the coils of the relays.

I like the idea of this (still getting my head around it tbh)... but I can't get around the wiring in the engine bay, that needs to be the existing relay. I think it's too much of a change for me at the moment, though I will consider parts of this if I end up taking it further. Thanks


text:
Arduino sketch- How to add Time Stamp for outgoing MQTT
I'm writing a sketch in order to upload to a Sonoff device ( Remote relay, based ESP8266 ).
All is working great, but I wish my MQTT pubs to contain following format:
[ DATE & TIME ] msg
ESP8266 is connected to the internet.
I;m looking for a way doing it (including periodic time updates ) without running all 1MB memory, meaning: a code that
1) get time from external source (LAN or WAN )
2) update it every 24h
3) Lite code ?
Thanks

please ask a specific question

updated, tough it seemed straight foreward

look into NTC, i think there's a built-in example, if not it's a very common lib with examples once added in the manager.

@dandavis You mean NTP surely...

@Majenko: good eye, that's what i meant, NTP. network time prototcol.

Start with the ESP8266WiFi "NTPClient" example.  That will teach you how you can get the "Unix Epoch" time from the internet.
That value can be fed directly into TimeLib to keep track of the time for you (indeed, TimeLib includes an NTP example for Arduino Ethernet that should help you get started).  Do that periodically (daily, hourly, whatever), and you have your time.  TimeLib can then give you the date and time as individual components (hours, minutes, etc), which you can then construct together (I'd use snprintf) to include in your MQTT message:
int len = strlen(message) + 25;
char mqttMessage[len];
snprintf(mqttMessage, len, "[%04d/%02d/%02d %02d:%02d:%02d] %s",
    year(), month(), day(), hour(), minute(), second(), message);

mqttMessage => "[2018/08/11 20:36:24] foo"


text:
Error saving SPIFFS on ESP8266 - only after 3rd entry
EDIT1 - This phenomena occurs only after reboot using button or ESP.reboot()
I'll try to make my question more focused:

I have library that saved log events to SPIFFS.

From 3rd entry (in the following example - epoch clock entries), it saves wrongly somehow (jump to Take-4 below).

Following code is an example using only relevant functions from that library.

Quick explanation:
T is holding epoch clock, that stores it right after boot.
write(const char *message, bool NOW) function - gets a message to store, and a boolean NOW if it has to be saved immediately rather than delayed save (delayed saved is implemented only in library, while here it gets saved instantly.)
void _write2file() writes the buffer to SPIFFS.
int getnumlines() returns number of entries saved (seeking for _EOL chars). In code below it acts as information only that serves displaying the problem, while when used in real library code, it limits the number of entries of the log.
void rawPrintfile() prints in human readable manner log's contents.
And last, the only function which does not belong to the library, void insert_log_entry(), simply enter a log entry (always the same one, after reboot).
Take 1-After uploading the sketch, you get this result on:
19:58:00.125 -> add buffer #0: 1234567890

19:58:00.191 -> total Lines before: 0
19:58:00.191 -> entries in buffer: 1
19:58:00.257 -> ~~~ Saved in /logfile.txt ~~~
19:58:00.257 -> row #0 {1234567890}
19:58:00.257 -> ~~~ EOF ~~~

Explanation: there was 1 entry to buffer, no- entries before, and a printout of file contents. So far- OK!
Take 2 - Pressing reboot button, and results are:
19:58:07.747 -> Start!
19:58:07.814 -> add buffer #0: 1234567890

19:58:07.814 -> total Lines before: 1
19:58:07.814 -> entries in buffer: 1
19:58:07.814 -> ~~~ Saved in /logfile.txt ~~~
19:58:07.814 -> row #0 {1234567890}
19:58:07.814 -> row #1 {1234567890}
19:58:07.814 -> ~~~ EOF ~~~

Explanation:again 1 entry in buffer, 1 entry in log, and a printout of 2 entries.
Take 3
Pressing reboot button again, and results are:
19:58:10.167 -> Start!
19:58:10.200 -> add buffer #0: 1234567890

19:58:10.200 -> total Lines before: 2
19:58:10.233 -> entries in buffer: 1
19:58:10.233 -> ~~~ Saved in /logfile.txt ~~~
19:58:10.233 -> row #0 {1234567890}
19:58:10.233 -> row #1 {1234567890}
19:58:10.233 -> row #2 {1234567890}
19:58:10.233 -> ~~~ EOF ~~~

Explanation: same, but now 3 entries are saved.
Take 4!!!
19:58:11.194 -> Start!
19:58:11.227 -> add buffer #0: 1234567890

19:58:11.227 -> total Lines before: 2
19:58:11.260 -> entries in buffer: 1
19:58:11.260 -> ~~~ Saved in /logfile.txt ~~~
19:58:11.260 -> row #0 {1234567890}
19:58:11.260 -> row #1 {1234567890}
19:58:11.260 -> row #2 {12345678⸮⸮⸮1234567890}
19:58:11.260 -> ~~~ EOF ~~~

Explanation: Now here is the unsolved error- 4th entry gets mixed up with 3rd, causing it to count only 2 entries (where it had to be 3), and row #2 is now mixed.
In purpose - I simplified the code to focus on the problem itself, which I can't find it root cause for this error (rather that showing entire library , consisting delayed save and delete line function, when log gets full).
`
#include <FS.h>
unsigned long T = 1234567890;

char *_logfilename = "/logfile.txt";
int _buff_i = 0;
#define TEMP_LOG_SIZE 10
#define TEMP_LOG_LEN 150
int _logSize = TEMP_LOG_SIZE;                 // entries
int _logLength = TEMP_LOG_LEN;                // chars in each entry
char _logBuffer[TEMP_LOG_SIZE][TEMP_LOG_LEN]; // Temp buffer for delayed write
const char _EOL = '\r';
unsigned long lastUpdate = 0;

void insert_log_entry()
{
  char a[25];
  sprintf(a, "%d", T);
  write(a, true);
}
void rawPrintfile()
{
  int row_counter = 0;
  bool new_line = true;

  File file = SPIFFS.open(_logfilename, "r");
  if (!file)
  {

    Serial.println("Failed to open file for reading");
  }
  Serial.print("~~~ Saved in ");
  Serial.print(_logfilename);
  Serial.println(" ~~~");
  while (file.available())
  {
    if (new_line)
    {
      Serial.print("row #");
      Serial.print(row_counter++);
      Serial.print(" {");
      new_line = false;
    }
    char tt = file.read();
    if (tt == _EOL)
    {
      new_line = true;
      Serial.println("}");
    }
    else
    {
      Serial.print(tt);
    }
  }
  file.close();
  Serial.println("~~~ EOF ~~~");
}
int getnumlines()
{
  int row_counter = 0;

  File file = SPIFFS.open(_logfilename, "r");
  if (file)
  {
    while (file.available())
    {
      char tt = file.read();
      if (tt == _EOL)
      {
        row_counter++;
      }
    }
  }
  file.close();
  return row_counter;
}
void write(const char *message, bool NOW)
{
  sprintf(_logBuffer[_buff_i], "%s%c", message, _EOL);

  Serial.print("add buffer #");
  Serial.print(_buff_i);
  Serial.print(": ");
  Serial.println(_logBuffer[_buff_i]);
  _buff_i++;
  lastUpdate = millis();

  if (NOW == true)
  {
    _write2file();
  }
}
void _write2file()
{
  int num_lines = getnumlines();
  Serial.print("total Lines before: ");
  Serial.println(num_lines);
  Serial.print("entries in buffer: ");
  Serial.println(_buff_i);

  File file1 = SPIFFS.open(_logfilename, "a");
  if (!file1)
  {
    Serial.println("Failed to open file for appending");
  }
  else
  {
    for (int x = 0; x < _buff_i; x++)
    {
      file1.print(_logBuffer[x]);
    }
    _buff_i = 0;
    lastUpdate = 0;
  }
  file1.close();
}

void setup()
{
  Serial.begin(115200);
  Serial.println("\n\nStart!");
  SPIFFS.begin();
  insert_log_entry();
  rawPrintfile();
}

void loop()
{
  delay(50);
}

Comments are not for extended discussion; this conversation has been moved to chat.

Well , getting to answer was complicated.

It happens only after reboot ( button, or ESP.reset() ), somehow after 2nd attempt, every time - getting this ( see THIS):

19:58:11.194 -> Start!
19:58:11.227 -> add buffer #0: 1234567890

19:58:11.227 -> total Lines before: 2
19:58:11.260 -> entries in buffer: 1
19:58:11.260 -> ~~~ Saved in /logfile.txt ~~~
19:58:11.260 -> row #0 {1234567890}
19:58:11.260 -> row #1 {1234567890}
19:58:11.260 -> row #2 {12345678⸮⸮⸮1234567890}   <----- THIS ----
19:58:11.260 -> ~~~ EOF ~~~

@Peter, in comments referred for github issue , that pointed out that there is a known problem regarding reboots and validity of data stored. Issue was solved by using file.flush() - but this solution did not solve the problem

When searching ESP8266 core, it pointed out an erros SPIFFS- regarding data saved and it validity

only after updating LittleFS for all instances in code (somehow when checked as part of Peter's suggestion, only few instances were changed from SPIFFS ), solved that problem. no file.flush() or delay() is required.


text:
Fail upload sketches to ESP8266 only on Ubunto 20.04.3
I installed a fresh copy of Ubuntu 20.04, and Arduino IDE1.8.16. At the beginning adding user to dialout group enabled uploading sketch to Aruino AVR family, and ESP32, but still ESP8266 gives this error:
Sketch uses 260889 bytes (24%) of program storage space. Maximum is 1044464 bytes.
Global variables use 27980 bytes (34%) of dynamic memory, leaving 53940 bytes for local variables. Maximum is 81920 bytes.
esptool.py v3.0
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____
Traceback (most recent call last):
  File "/home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/upload.py", line 66, in <module>
    esptool.main(cmdline)
  File "/home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 3552, in main
    esp.connect(args.before, args.connect_attempts)
  File "/home/guy/.arduino15/packages/esp8266/hardware/esp8266/3.0.2/tools/esptool/esptool.py", line 529, in connect
    raise FatalError('Failed to connect to %s: %s' % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

So I tried to erase flash using esptool.py :
guy@desktop:~$ esptool --chip  auto --port /dev/ttyUSB0 erase_flash
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to Espressif device: Timed out waiting for packet header

Since AVR's and ESP32 work properly using USB's and ACM's I can guess that is is not a problem with the ability to access serial comm.
What might it be ?

There is something wrong with some new kernels of Ubuntu 20.04 LTS, interfering with ESP8266 core uploading process
5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
I had the same issue and downgraded the kernel to
5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
solved the issue

The issue happens to ESP8266 core uploading process, with the following tested Ubuntu cores

linux-5.11.0-37-generic
linux-5.4.0-89-generic
linux-5.4.0-88-generic

and tested OK with

linux-5.11.0-38-generic
linux-5.11.0-36-generic
linux-5.8.0-48-generic
linux-5.4.0-90-generic
linux-5.4.0-86-generic

Temporarily fix
To temporarily fix the issue by using working kernel, e.g. linux-5.4.0-86-generic
A. Select from GNU GRUB boot menu

Advanced options for Ubuntu

Ubuntu, with Linux 5.4.0-86-generic

If you don't have that kernel, install by

sudo apt install linux-image-5.4.0-86-generic

Reboot and select 5.4.0-86-generic from GNU GRUB boot menu

To save the selected GRUB settings
More info GRUB Simple-configuration

Edit /etc/default/grub by

$ sudo gedit /etc/default/grub

Add to the file

 GRUB_DEFAULT=saved
 GRUB_SAVEDEFAULT=true

Activate the change so that last selected value is used for the next boot.

$ sudo update-grub

Update
Just testing OK with latest kernel

linux-5.11.0-38-generic
linux-5.4.0-90-generic

It seems recent kernel release has fixed the issue


text:
RF24- Splitting and sending a longer than 32 byte payload
In order to send a long payload I've created the following function:
void splitMSG(const char *msg, const int arraySize, const int len)
{
  Serial.print("Array size: ");
  Serial.println(arraySize);
  byte numPackets = (int)(arraySize / len);
  byte P_iterator = 0;
  if (arraySize % len > 0)
  {
    numPackets++;
  }
  Serial.print("num_Packets: ");
  Serial.println(numPackets);

  while (P_iterator < numPackets)
  {
    char t[len + 1];
    char *ptr1 = msg + P_iterator * (len);
    strncpy(t, ptr1, len);
    t[len + 1] = '\0';
    Serial.println(t);
    radio.write(&t, sizeof(t));
    P_iterator++;
  }
}

The split message is sent to the serial monitor to verify it is as expected.
**On the sending device :
void loop()
{
  radio.stopListening();

  char send_msg[] = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";  // <----- input msg
  splitMSG(send_msg, sizeof(send_msg), 10);                  // <----- split to 10 bytes a packet
  delay(1000);
  // Serial.println("±±±±±±±±");
}

On the serial monitor I get:
08:06:17.569 -> Array size: 37
08:06:17.569 -> num_Packets: 4
08:06:17.569 -> 1234567890
08:06:17.569 -> ABCDEFGHIJ
08:06:17.569 -> KLMNOPQRST
08:06:17.569 -> UVWXYZ

**On the receiving device:
void loop()
{
  if (radio.available())
  {
    while (radio.available())
    {
      char buf[32];
      radio.read(&buf, sizeof(buf));
      Serial.print("got msg: ");
      Serial.println(buf);
      radio.flush_rx();
    }
  }

  delay(100);
}

On the serial monitor I get:
08:08:18.462 -> got msg: 1234567890⸮⸮⸮⸮
08:08:18.561 -> got msg: ABCDEFGHIJKLMNOPQRSTUVWXYZ
08:08:19.555 -> got msg: 1234567890ABCDEFGHIJKLMNOPQRST⸮⸮⸮⸮
08:08:20.549 -> got msg: 1234567890ABCDEFGHIJKLMNOPQRST⸮⸮⸮⸮
08:08:21.576 -> got msg: 1234567890ABCDEFGHIJKLMNOPQRST⸮⸮⸮⸮
08:08:22.570 -> got msg: 1234567890ABCDEFGHIJKLMNOPQRST⸮⸮⸮⸮
08:08:22.669 -> got msg: UVWXYZ

Does the problem with radio.write ' buffer , or the way I split the message ?

t[len + 1] = '\0';

Your array is declared as having len+1 bytes of storage. So the last index is len, not len+1. You're writing the zero one past the end of the array, thus you're not transmitting it (and sending one byte of "garbage" instead).


text:
LCD display and ultrasonic sensor not functioning
I am doing fish feeder project with level detection for the feeds but lcd display and ultrasonic sensor did not function.
#include <LiquidCrystal.h>
#define trigPin 12              // the trig pin to digital pin 12
#define echoPin 13              // the Echo pin to digital pin 13
#define L 8
#define M 9
#define H 10
// #define trigmotor 1 //closelid
int led = A1;           // LED indicator to digital pin A1
#include <Servo.h>
Servo MyServo;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

const int thresholdH = 0;
const int thresholdM = 70;
const int thresholdL = 90;
// defines variables
long duration;
int distance;
float percentLV;

void setup()
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600); // Starts the serial communication
  pinMode(led,OUTPUT);
  digitalWrite(led,LOW);            //set the led off(initial condition)
  lcd.begin(16, 2);
}
void loop()
{

int degreesOfRotation = 8;
int servoPinNumber = 11;
float hoursBetweenMeals = 12;
float mealDelayTime = 0;

{
    MyServo.attach(11);
    MyServo.write(degreesOfRotation);
    mealDelayTime = hoursBetweenMeals * 1800000;
    delay(20);

    while(degreesOfRotation < 152) {
        MyServo.write(degreesOfRotation);
        delay(10);
        degreesOfRotation += 1;
    }
    while(degreesOfRotation > 8) {
        MyServo.write(degreesOfRotation);
        delay(10);
        degreesOfRotation -= 1;
    }
    delay(mealDelayTime);
}

{
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = (duration * 0.034 / 2);
  float percentLV = (40 - ( distance - 16 )) * 100 / 40;

  if (percentLV > thresholdL && percentLV < 100) {

    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("PLEASE REFILL!");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, HIGH);
    digitalWrite(M, LOW);
    digitalWrite(L, LOW);
    //digitalWrite(trigmotor, HIGH);
    //delay(3000);
    //digitalWrite(trigmotor, LOW);
    //delay(1000);
    digitalWrite (led, HIGH);      // Turn on the led indicator
    delay(20);
  } else if (percentLV <= thresholdL && percentLV > thresholdM) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("U May Refill Now");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, LOW);
    digitalWrite(M, HIGH);
    digitalWrite(L, LOW);
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, HIGH);      // Turn on the led indicator
    delay(20);
  } else if (percentLV <= thresholdM && percentLV > thresholdH) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Take it easy");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    digitalWrite(H, LOW);
    digitalWrite(M, LOW);
    digitalWrite(L, HIGH);
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, LOW);      // Turn off the led indicator
    delay(20);

  } else {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("FULL!!");
    lcd.setCursor(0, 1);
    //lcd.print(distance);
    lcd.print(percentLV);
    lcd.print(" %");
    //digitalWrite(trigmotor, LOW);
    digitalWrite (led, LOW);      // Turn off the led indicator
    delay(20);

    Serial.print("PercentLV: ");
    Serial.print(percentLV);
    Serial.println("%");
  }
  delay(1000);

}

}

Hello and welcome. Could you please be more specific about the errors you get. "not function" is quite hard to debug for the readers of your question. You might also want to add details about your system, display, and sensor. Note that you can always edit your question to include these details (do not put them in the comments section).

it did not function at all...the lcd display did not turn on and same goes to the ultrasonic sensor

Can you post a wiring diagram and specify the hardwares you are using?

Do these components work individually? Try making a "test sketch" for both the components to verify that they work and that your code works.

i am using servo motor, lcd display and ultrasonic sensor @rvbarreto

Ok, but we have to know which motor and which sensor. We need to know the model. We also have to know which arduino board you are using and - this is very important - how you are wiring them. Without this information nobody will be able to help you.

servo motor MG-995, ultrasonic sensor HC-SR04, lcd display 16x2 and arduino uno r3

There doesn't appear to be anything wrong from a quick glance.  Have you got the right library for the LCD?
The chances are there is something wrong with your LCD.  So check your connections again.  Now create a new sketch that just prints hello world on the LCD, or better still use an example.  If that works, then the problem is an interaction between components.
So write a sketch that spins the servo back and forth while printing a message on the LCD.
Did that work, now add in the ultrasonic sensor and the code.
Now the other bits, and if that works, then you could look at what you have done differently, or just thank your lucky stars :)


text:
Cannot locate Rx Tx pins on SIM800a GSM module
I recently bought a SIM800a GSM module in India and I am unable to find the Rx Tx pins of the module to make calls using a Arduino duimilanove.
The main problem is also that I can't find the data sheet for Sim800a in the net so that I can use a multi meter to determine the Rx Tx pins.
Here are some screenshots of the module-

There is no label showing Rx Tx here. There is I2C protocol(SCL,SDA) but I dont know how to code in Arduino for making a call using I2C.
I found a SIM800a picture on ebay with labels(not the data sheet) but when I tried using the pins in that manner it did not work. The SIM800a I have is connected to the network as the network led blinks after 3 sec and when I call it then the alarm rings. But it is unable to transmit calls or sms.

This is the code I am using. I remove the Rx Tx pins before uploading the code and immediately put them after uploading.

char phone_no[]="9953642386";
void setup()
{
Serial.begin(9600);  //Open Serial Connection at baudrate 9600
delay(5000);
Serial.println("AT"); // Wake up GSM
Serial.print("ATD"); //Dial the phone number using ATD command
Serial.print(phone_no);
Serial.println(";"); // Semicolon is a must at the end
delay(5000);
Serial.println("ATH"); // After a delay of 5 secs Hang the call
}
void loop()
{
// empty loop.If you enter the above code here,the call will be made FOR EVER repeatedly.
//Take Caution while coding under loop.At some condition you’ve to terminate the Call
}

Otherwise is it possible to use the SDA and SCL pins for this purpose of calling to a phone from the gsm module ?
Any help would be appreciated.

This datasheet may help you.  On page 14 you can see TXD and RXD are pins 9 and 10.
Orientation is hard to determine, but it appears that pin 1 is where the most red on the label is.

You should now be able to trace where those pins go to. They look like they go to high numbered pins, around the 11/12 area.

Thanks found the pins :) didnt realize the data sheet of sim 800a and sim 800 will be the same


text:
Passing HardwareSerial and SoftwareSerial as a Class Property
I wish to know if there is a way to use a single property Serial0 to hold a HardwareSerial or a SoftwareSerial or other class instances supporting basic methods such as available(), read() and write(), in order to make a CustomSerial Class (polymorphism?).
class CustomSerial{
    <GenericSerial??> Serial0;
    char c;
    void read(void){
        c=Serial0.read();
    }
};

The calls should be:
CustomSerial SerialCus;
int n=SerialCus.available();
char c=SerialCus.read();
SerialCus.write(c);

What should I use as GenericSerial class, or what should be the proper use? I tried the Stream class (as the answer pointed), but for some reason the functionality is not preserved (it writes unknown characters). Should indeed Stream be the generic class I need for this?

If you can not make a common class, then you can use a template. If the class (any class) has a .available() and .read() and .write(), then the compiler fills in the used class.

A base type for Arduino hardware serial classes, SoftwareSerial and other software serial classes and some other Arduino classes is Stream (reference). Stream.h on GitHub

class CustomSerial {

private:
  Stream &stream;

public:
  CustomSerial(Stream &_stream) : stream(_stream) {}

  int read() {
    return stream.read();
  }

  int available() {
    return stream.available();
  }

  int peek() {
    return stream.peek();
  }

  void write(byte b) {
    stream.write(b);
  }

};

SoftwareSerial Serial0(10, 11);
CustomSerial SerialCus(Serial0);

void setup() {
}

void loop(){
  if (SerialCus.available()) {
    char c = SerialCus.read();
    SerialCus.write(c);
  }
}

I indeed used Stream for defining the property, but for some reason, this do not work the same way as using HardwareSerial, hence i have been unable to extend it for SoftwareSerial instances.

@hyprfrcb, I added code to the answer

This setting works perfect!... And also address how to use the Stream references... :)

The AltSoftSerial uses the Stream as well.


text:
WiFi Connection With a Enterprise WLAN
I have an ESP32 and want to connect it to the WLAN at my office. Based on my current knowledge of the Arduino, we use the WiFiClass to connect to a WLAN and then use a WiFiClient to use the WiFi for data transfer.
In order to connect to the WLAN at my office, a certificate is needed. I have asked the network guys to issue a x.509 certificate and plan to use the WiFiSecureClient class.
The problem is that my WiFi.begin(ssid) method never leaves the following while loop:
Wifi.begin(ssid); // my office needs a certificate to connect to the wifi at the first place
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}

Note that to connect to my office network, no password is needed. The x.509 certificate is enough for the connection to establish.
Only after a WiFi connection is established, I can set the WiFiSecureClient parameters of the CA. But to connect to the WiFi, I need the certificate.
This is very confusing. Could someone please clarify a way our for me in this situation.

You're confusing WiFi access and a secure connection to a remote server. WiFiClientSecure is for the latter (such as https://) not the former. You only want to use WiFiClientSecure if the remote server you are connecting to uses SSL or TLS. You haven't got that far, so remove WiFiClientSecure from your mind completely.

@Majenko thank you for the tip. My goal is to connect to get WiFi access. But the WiFi access needs a certificate. There is no username or password. I only know the SSID of the WLAN and have a x.509 certificate.

@Roboticsnerd, you could publish here as answer the solution based on Majenko's answer, if it works?

@Juraj I am working on it. Will publish if it works for me.

The Arduino API for ESP32 does not support your desired configuration.
The ESP32 is capable, but there is no easy "Arduino" interface to configure it.
Instead you will have to directly interface with the ESP32 SDK and configure things manually.  That won't be easy.
This example code shows you how it can be done - however that code is not designed to run in the Arduino environment, so you will first need to understand exactly what it is doing and then adapt it to suit.


text:
Conditions with GSM module SIM900 doesn't execute
I'm executing this code to control a LED with GSM SIM900 message but there are two problems. First, it receives messages sometimes and some times doesn't. The second is that it doesn't execute the if conditions that are on the GSM message when received.
Is there a problem with my GSM module? Can any one help?
#include <SoftwareSerial.h>
SoftwareSerial gsm(9,10);
String msg;
const int LED = 13;

void setup() {
  gsm.begin(9600);
  Serial.begin(9600);
  Serial.println("PUMP CONTROL");
  Serial.println("t : to receive text");
  delay(1000);

  pinMode(LED, OUTPUT);
  digitalWrite(LED, LOW);
}

void loop() {
  if (Serial.available()>0)
  switch(Serial.read())
  {
    case 't':
    showSMS();
    break;
  }

  while(gsm.available() > 0)
  {
    Serial.write(gsm.read());
  }
  if ( msg == "ON")
  {
    Serial.println("ON");
    digitalWrite(LED, HIGH);
     Serial.println("ON1");
    delay(1000);
  } else if (msg == "OFF")
  {
    digitalWrite(LED, LOW);
    delay(1000);
  }
  if(msg != "") msg = "";
}

void showSMS()
{
 gsm.print("AT+CMGF=1\r");
 gsm.print("AT+CNMI=2,2,0,0,0\r");
 delay(1000);
 msg = "";
 while(gsm.available() > 0)
 {
  msg += gsm.read();
 }
 Serial.println(msg);
}

There are some basic commands that you should run before checking the messages. Like AT\r\n and check network status available or not and there are some more.

I’ve solved the condition problems by making the condition with the ASCII code of ON and OFF.
I replaced:
if ( msg == “ON”)

with
if(msg.indexOf("ON")>=0)

and replaced:
else if (msg == "OFF")

with
if(msg.indexOf("OFF")>=0)


text:
Can the Arduino (Nano) bootloader be updated via itself and the Arduino IDE or is an ISP required?
I ran into the following error with a recent Arduino IDE version (1.8.9) when trying to upload to an "Arduino Nano" clone (ATmega328P):
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x18
...
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x18
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

The problem could be resolved by choosing "ATmega328P (Old Bootloader)" as Processor in the Tool menu - as now suggested to me and solved in Arduino Nano uploading gives error: avrdude: stk500_recv(): programmer is not responding.
The change was made in August 2018 with the release of Arduino IDE 1.8.6: https://github.com/arduino/Arduino/releases/tag/1.8.6
Details about the different bootloaders are described in
Arduino Nano ATmega328P bootloader difference.
It seems the fuses have to be changed in order to make full use of the newer, smaller bootloader, so an ISP will have to be used anyway.
But is the bootloader able to update itself (via Tools > Burn bootloader) or is there an intermediate "bootloader update sketch" available?

On ATmega328p and similar ATmega MCUs with bootloader support, the application is not allowed to write to flash. Only code running in bootloader area of the flash memory is allowed to write to flash. Bootloader area is at the end of the flash and the beginning is set with the BOOTSZ fuses.
The write to flash page is done in two steps. First step is deleting the contents of the flash page, second step is write the new data to the flash page. In bootloader area* it is allowed to first prepare the data to temporary buffer page, then delete the flash and write the data in one step. So in theory the bootloader could overwrite itself with a function running in the last flash page. But I don't know about bootloader which would do it.
To write a bootloader an ISP programmer is necessary. Or other Arduino with the "Arduino as ISP" sketch.
*note: the read-while-write area at the end of flash has the size of the largest bootloader area possible and is not determined by BOOTSZ.

I think you CAN write to the bootloader from a Sketch if you can make sure the writing method is within the No-Read-While-Write section of the application flash. This is much easier when not using the Arduino IDE. (Also this is not possible if the bootloader occupies the entire NRWW section, which is not the case for OptiBoot used by Arduino.)

@Kwasmich, the boundary for SPM execution is BOOTSZ fuse