text:
How can I program my self made Arduino board using USB to TTL converter?
Recently I got a coupon for JLCPCB which was 100% discount so, I designed my 10 Arduino board specially for my needs and ordered it from JLC PCB. The schematic of the board is given.  At the time while I was designing the board I  thought of using USB to TTL converter which I have one having RX, TX, VCC and GND pins. So, I forgot to add pinouts for MISO which was D13 and also D12. So, how can I program my board now with that USB to TTL converter?
Describing about my board, it has a separate pinout for programming which has pins like GND, VCC, TX and RX. I tried but couldn't upload the program. Please help me out.
Forgot to mention, it uses ATMEGA328P-AU.

Without the ICSP pins you won't be able to program a bootloader into the board. You will have to bodge in some wires to those pins to connect it to a programmer / other Arduino to program the bootloader. Also your LEDs aren't wired right. You need a resistor for each LED, not just one resistor for the whole set.

@Majenko I think you looked for LED5, It is a RGB LED with common positive termianl. So, I used only one resistor.

@Majenko Can't I program using USB to TTL converter? I watched this video and designed my board. https://www.youtube.com/watch?v=sNIMCdVOHOM . He didn't use those ICSP pins.

Yes, it's an RGB common anode. You need one resistor for each LED. Not one for the common. Ask yourself: what's the forward voltage of "the" LED? And what happens if multiple LEDs are on at once?

You can only program through UART if you have a bootloader. The chip doesn't know how to understand UART data by itself. Only once the bootloader is on there will your UART interface do anything at all.

@Majenko Oh, Yes. I forgot about that and neglected this thing. But can you suggest me any way of programming it?

Like I said: solder in some bodge wires to the pins you need. You'll need a steady hand and some thin wires (I use 30 AWG wire-wrap wire with a high temperature PTFE insulation).

Alternatively you would need to program the MCU with the bootloader before soldering it to the board. Either by first soldering it to some other breakout board with the pins you need, or using a TQFP ZIF socket on a breakout board (although those are expensive).

@Majenko Ok. I will do that. Are other components placed right?

Looks reasonable - apart from those RGB LEDs...

@Majenko Will it have any problem if a resistor is connected to MISO pinout of atmega328p? Should I remove the resistor or without removing I can upload the bootloader? It is of 200 ohms

It should be fine. And D13 is SCK not MISO.

Your schematic doesn't have any bypass capacitors. Not on the ATMega, or the voltage regulators. And D1 is the wrong way around.

At the Arduino Website is a tutorial for making an Arduino on a breadbord.


text:
My servo wont follow my cam
So i am trying to make the servo follow my face which will end up my camera following my face
But the servo isnt doing anything please look at this
(Also im only using Horizontal because I would like to start off with that first)
Question : how do i make it so it can move, what am i doing wrong?
Python code : https://pastebin.com/V6SegsQj
Arduino code :
#include<Servo.h>
Servo servoHor; //Horizontal Servo
int x;
int prevX;
void setup()
{
  Serial.begin(9600);
  servoHor.attach(6); //Attach Horizontal Servo to Pin 6
  servoHor.write(90);
}

void Pos()
{
  if(prevX != x)
  {
    int servoX = map(x, 600, 0, 70, 179);
    servoX = min(servoX, 179);
    servoX = max(servoX, 70);
    servoHor.write(servoX);
  }
}

void loop()
{
  if(Serial.available() > 0)
  {
    if(Serial.read() == 'X')
    {
      x = Serial.parseInt();
    }
    while(Serial.available() > 0)
    {
      Serial.read();
    }
  }
}

Pos() is never being called. It can't ever do anything.

source: Stack Exchange

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

sort: votes


text:
Use Arduino Uno as 5V Power Source for Sensors Connected to ESP32 Microcontrollers
I am using an ESP32 WROVER B based microcontroller, which has 3.3V and 5V outputs. Due to poor soldering of the header and attempted removal of the solder (permanently damaged PCB etching electrical contacts around the 5V pin), the 5V pin doesn't output any current, so only the 3.3V works (e.g. lights up a LED). Some of my modules require 5V to work properly (according to their specification) e.g. sensors. Can I provide a 5V power source from another component (e.g. arduino uno 5V output, USB to TTL converter 5V power output or USB power supply) for these or use a GPIO output (I believe these are 3.3 volts only) on the ESP32 device itself, perhaps with level shifting? The ESP32 is powered via USB and no issues there (serial monitor shows it boots up okay).

I would suggest soldering a wire to the 5V pin of the 3.3V regulator, but it sounds like your soldering skills are not up to such a task. Yes you can use power from anywhere you like - just remember to connect the grounds.

A level shifter doesn't magically convert 3.3V to 5V. It takes 3.3V logic signals, and uses a 5V power supply to amplify the signals to 5V. A 3.3V to 5V level shifter requires a 5V external power supply. Second, the GPIO lines on a 3.3V device like an ESP32 will be 3.3V, and very low current. Even if there was a 5V logic pin available, you should not try to use it for 5V power. You need some regulated 5V external power source. A USB power supply, another Arduino, discrete 5V power supply, etc.

Note that using an Arduino Uno as a 5V supply is a poor choice. it needs a 7-12VDC input to it's regulator, and then uses a fairly inefficient linear regulator to regulate that down to 5V. It would also sit their running but doing nothing. Buy a cheap 5V regulated power supply that runs from mains power and be done with it.

you have a development board with esp32 microcontroler. the board has power outputs, not the MCU

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


text:
How to fix HC05 burning even after while using voltage regulator?
I'm using two circuits for my wireless head mouse project, one of them is a transmitter circuit with Arduino Pro Micro, HC05 Bluetooth module, Elechouse Voice Recognition Module V3.1, GY-521 module based on the MPU6050 sensor. The receiver circuit (Arduino Pro Micro + HC05 Bluetooth) will receive the sensor readings from the transmitter circuit. Both modules were powered by USB from the laptop initially. They worked fine. To make the transmitter circuit completely detached from the laptop, I used a 9V battery, and a voltage regulator of 5V. The receiver circuit was still c. I should mention that I was using voltage dividers for both of the transmitter, and receiver circuit's HC05 Bluetooth modules.
onnected to the laptop USB.
.
After using the voltage regulator, the module was working fine but suddenly the HC-05 burnt, led stopped working. Transmission failed. HC05 of the receiver module also burnt after 2 minutes. Why did this happen? What's the solution?
Circuit connection:
Hc05 connection same for transmitter & receiver circuit
HC05 Tx -> Arduino Rx
Hc 05 rx -> 2k ohm -> gnd
Hc05 rx -> 1k ohm -> hc05 tx
Hc05 vcc -> arduino 5v
Hc05 gnd -> arduino gnd
Voice Recognition Module tx -> arduino 8
Rx -> Arduino 9
Vcc- 5v
Gnd - gnd
Mpu6050 sda - Arduino 2
Scl- Arduino 3
Vcc - 5V
Gnd- Gnd
Voltage regulator connection:
The connection was 9V battery +ve to input, -ve to ground, output to Arduino 5V

Can you provide a schematic?

Please show a schematic. Where exactly did you use voltage dividers?

@StarCat I added the schematic in the question. Have a look. The receiver circuit only has the Arduino and the HC05 nothing special there. So, did not draw that one.

have you checked the power supply voltage at HC-05? ... your schematic shows a circuit that provides no power to the components

Are you absolutely sure every module is connected to the same ground? It looks like the ground of your voltage regulator is not connected to the rest of the circuit.

@StarCat , sorry. made a slight error in drawing the schematic. every gnd is connected to the Arduino GND pin in the circuit is connected to the Arduino Pro Micro Gnd. Even the voltage regulator. Then, the 9V battery's ground is connected to the Arduino GND also/

@jsotola, I haven't checked the power supply voltage at the HC-05 as my multimeter is broken. -_-

I've updated the schematic

Your voltage divider pins are backwards the HC05 RX pin needs the divider, not the TX pin.   Its tx would be 3.3v out and the arduino pin wouldn't care it would still work.
Most likely while you were testing before the HC05 was probably already slowly dying.
the HC05 has a very basic 3.3v regulator on board but only a little over 5V input can fry things.
I have always put 75-100ohm in series with the 5V in just in case.
Your circuit is basically good but the the RX/TX pins on the HC05 need reversing.
Analog V. regulators are fairly crude and will vary voltage some.
5.000v accuracy is never dead on. I have seen as high as 5.7V out and that would not be good.
Also the HC05 RX pin is receiving a 5V signal back, sourcing thru the HC05 chip.
Even the Arduino help site warns against 5V if it can be avoided.
from Arduino's site
https://create.arduino.cc/projecthub/electropeak/getting-started-with-hc-05-bluetooth-module-arduino-e0ca81
Sending Data to Arduino via Bluetooth
HC05 module has an internal 3.3v regulator and that is why you can connect it to 5v voltage. But we strongly recommend 3.3V voltage, since the logic of HC05 serial communication pins is 3.3V. Supplying 5V to the module can cause damage to the module.

You said "I should mention that I was using voltage dividers for both of the transmitter, and receiver circuit's HC05 Bluetooth modules."
Voltage dividers are not a good way to lower voltage for power components. The voltage output will vary based on load, and they also dissipate the excess voltage as heat, so you need high current resistors.
Post a schematic of your system with the specific batteries, regulators etc that you are using.

I added the schematic in the question.


text:
How to connect a LiFePO4 battery directly to an esp32?
If I want to connect a LiFePO4 battery (as the power supply) directly to an esp32 - would this be the correct way: the plus of the battery to the 3.3 volt pin and the minus to a ground pin?

No. Absolutely not.
A LiFePO4 battery is 4.2V when fully charged. The absolute maximum voltage of an ESP32 is 3.6V.
You will kill the ESP32.
Instead you need to have a voltage regulator with a very low dropout. Ideally a switching ("buck") regulator with a zero-dropout "pass" mode to give the maximum life from your battery.
Even better is a "buck/boost" battery regulator that will boost the voltage up to a stable 3.3V once the battery voltage drops too low.
If all this is beyond you then you're better off using a powerbank to do the regulation to 5V for you then convert that back down to 3.3V with a simple buck regulator.

The maximum charge voltage is specified here as 3.65 Volt.

@sid_com That's the recommended maximum. They can go up to 4.2V if you want about 1% extra capacity. 3.65 is still above the absolute maximum of an ESP32 anyway.

4.2v is typical of lithium chemistries other than lithium IRON phosphate batteries. One can use a radio control type battery charger and set a maximum charge level to lower than the max for the ESP32. Some capacity may be lost in so doing, but with care, it could be accomplished.

@fred_dot_u https://www.evworks.com.au/page/technical-information/lifepo4-care-guide-looking-after-your-lithium-batt/#:~:text=Tip%201%3A%20Never%20over%20charge%2Fdischarge%20a%20cell!&text=In%20the%20case%20of%20LiFePO4,3.5V%20and%204.2V.

from that page: In the case of LiFePO4 chemistry, the absolute maximum is 4.2V per cell, though it is recommended that you charge to 3.5-3.6V per cell, there is less than 1% extra capacity between 3.5V and 4.2V.

Exactly. Up to 4.2V. If you have that you will fry the ESP32. You really really should have a battery controller on there to keep it at a regulated 3.3V regardless of the battery voltage (above the lower cutoff voltage of course).

The charging voltage for lifepo4 used to be 4.2V but that was killing battery's now it's 3.65V and a fully charged battery is 3.6V which is perfect for the esp32. https://electronics.stackexchange.com/questions/365440/what-is-the-maximum-static-voltage-of-lifepo4-batteries
https://en.m.wikipedia.org/wiki/Lithium_iron_phosphate_battery

I know this question is two years old but it still pops up on research. I just wanted to add something from my experience with this:
If you take an Enerpower HTCFR18650 for example datasheet you see that the maximum voltage isn't 4.2V but 3.65V +/- 0.05V. While this technically is a little bit above the absolute maximum rating of the ESP32 (3.6V), in a non critical environment you can absolutely use the battery without voltage regulator. Just keep in mind that you also will not have any undervoltage protection in this case.
I'm not a fan of this negativity ("you will fry", "you kill you ESP", "Everyone will die"). An ESP32 costs $1. Just try it and if it works its great (it does) and if it doesn't, don't blame me ;)

You are correct. 3.6V is 100% charge. https://electronics.stackexchange.com/questions/365440/what-is-the-maximum-static-voltage-of-lifepo4-batteries

Where are you getting your esp32's for $1 please.


text:
cant read json data esp 32 “parseObject() failed”

hello  I am just trying to make Youtube Subscribe Counter with led matrix 32*8 and esp 32 and I had this problem when I trying to get
subscribers to count
so what is the problem and how I can fix it? `

  ```    //########################  YouTube Subscriber Count Display on LED MATRIX  #############################
        // Receives and displays YouTube channel statistics
        //################# LIBRARIES ################
        String version = "v1.0";       // Version of this program

    #include <WiFi.h>
    #include <WiFiClientSecure.h>
    #include <ArduinoJson.h>     // https://github.com/bblanchon/ArduinoJson
    #include <SPI.h>
    #include <Adafruit_GFX.h>
    #include <Max72xxPanel.h>    // https://github.com/markruys/arduino-Max72xxPanel
    #include <time.h>
    //################ VARIABLES ################
    // Use your own API key by signing up for a free Youtube developer account at http://www.youtube.com
    // LED Matrix Pin -> ESP32 Pin
    // Vcc            -> 3v
    // Gnd            -> Gnd
    // DIN            -> MOSI pin use results of print statement 23 maybe
    // CS             -> SS pin   use results of print statement 5 maybe
    // CLK            -> SCK pin  use results of print statement 18 maybe

    const char* channelId = "UCqTSLaEj9c4hiZkU0FfbaJA"; // See your Channel details click on your channel icon at top-right, then Settings, then Advanced
    const char* apiKey    = "A--------------Aw"; // See https://developers.google.com/youtube/v3/getting-started for an API key, you must enable it to make it work!
    const char* host      = "https://www.googleapis.com";
    unsigned long lastConnectionTime = 0;                 // Last time you connected to the server, in milliseconds
    const unsigned long  postingInterval = 10L*60L*1000L; // Delay between updates, in milliseconds, you should limit your YouTube requests per-day maximum

    //################ PROGRAM VARIABLES and OBJECTS ################
    int pinCS = 5; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
    int numberOfHorizontalDisplays = 4;
    int numberOfVerticalDisplays   = 1;
    int wait   = 35; // In milliseconds
    int spacer = 1;
    int width  = 5 + spacer; // The font width is 5 pixels
    int port   = 443;
    String time_str;

    Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);

    struct channelStatistics{
      long viewCount;
      long commentCount;
      long subscriberCount;
      bool hiddenSubscriberCount;
      long videoCount;
    };

    // Change to your WiFi credentials
    const char* ssid     = "SSid";
    const char* password = "PASS";

    channelStatistics channelStats;

    void setup() {
      Serial.begin(115200); // initialize serial communications
      Serial.println("Mosi="+String(MOSI));
      Serial.println("SS="+String(SS));
      Serial.println("SCK="+String(SCK));
      StartWiFi(ssid,password);
      StartTime();

      //----------------------------------------------------------------------
      configTime(0 * 3600, 0, "pool.ntp.org", "time.nist.gov");
      matrix.setIntensity(0); // Use a value between 0 and 15 for brightness
    // Adjust the LED matrix to your own needs
    //  matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
    //  matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
    //  matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
    //  matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
    //  ...
      matrix.setRotation(0, 1);    // The first display is position is rotated
      matrix.setRotation(1, 1);    // The first display is position is rotated
      matrix.setRotation(2, 1);    // The first display is position is rotated
      matrix.setRotation(3, 1);    // The first display is position is rotated
      lastConnectionTime = millis();
      obtain_subscriber_stats();
    }

    void loop() {
      display_message("Subs: " + String(channelStats.subscriberCount));
      time_t now = time(nullptr);
      String time = String(ctime(&now));
      time.trim();
      display_message(" on " + time);
      if (millis() - lastConnectionTime > postingInterval) { // 15-minutes
        obtain_subscriber_stats();
        lastConnectionTime = millis();
      }
    }

    //################ PROGRAM FUNCTIONS ################

    void display_message(String message){ // Scroll the image left
      matrix.fillScreen(LOW);
      for ( int i = 0 ; i < width * message.length() + matrix.width() - 1 - spacer; i++ ) {
        int letter = i / width;
        int x = (matrix.width() - 1) - i % width;
        int y = (matrix.height() - 8) / 2; // center the text vertically
        while ( x + width - spacer >= 0 && letter >= 0 ) {
          if (letter < message.length()) matrix.drawChar(x, y, message[letter], HIGH, LOW, 1); // HIGH means foreground on, LOW means background off, LOW< HIGH inverts the display
          letter--;
          x -= width;
        }
        matrix.write(); // Send bitmap to display
        delay(wait);
      }
    }

    void obtain_subscriber_stats() {
      String command = "https://www.googleapis.com/youtube/v3/channels?part=statistics&id=" + String(channelId);
      String response = GetRequestFromYoutube(command);
      StaticJsonBuffer <200> jsonBuffer;
      JsonObject& root = jsonBuffer.parseObject(response); // Parse JSON
      if (!root.success()) {
        Serial.println(F("jsonBuffer.parseObject() failed"));
      }
      else
      {

        JsonObject& current                = root["items"][0]["statistics"];
        long subscriberCount               = current["subscriberCount"];
        long viewCount                     = current["viewCount"];
        long commentCount                  = current["commentCount"];
        long hiddenSubscriberCount         = current["hiddenSubscriberCount"];
        long videoCount                    = current["videoCount"];
        channelStats.viewCount             = viewCount;
        channelStats.subscriberCount       = subscriberCount;
        channelStats.commentCount          = commentCount;
        channelStats.hiddenSubscriberCount = hiddenSubscriberCount;
        channelStats.videoCount            = videoCount;

      }
      Serial.println("      View Count = " + String(channelStats.viewCount));
      Serial.println("Subscriber Count = " + String(channelStats.subscriberCount));
        Serial.println(GetRequestFromYoutube(command));
        Serial.println(response);
      //  Serial.println(jsonBuffer.parseObject(response));

    }

    String GetRequestFromYoutube(String request) {
      String headers, body = "";
      bool Headers    = false;
      bool currentLineIsBlank = true;
      int  MessageLength = 1000;
      // Connect with youtube api over ssl
      WiFiClientSecure client;
      if (client.connect(host, port)) {
        Serial.println(".... connected to server");
        char c;
        int ch_count=0;
        request += "&key=" + String(apiKey);
        request = "GET " + request;
        Serial.println(request);
        client.println(request);
        int now   = millis();
        while (millis()-now < 1500) {
          while (client.available()) {
            char c = client.read();
            if(!Headers){
              if (currentLineIsBlank && c == '\n') {
                Headers = true;
              }
              else{
                headers = headers + c;
              }
            } else {
              if (ch_count < MessageLength)  {
                body = body+c;
                ch_count++;
              }
            }
            if (c == '\n') {
              currentLineIsBlank = true;
            } else if (c != '\r') {
              currentLineIsBlank = false;
            }
          }
        }
      }
      return body;
    }

    ////////////// WiFi, Time and Date Functions /////////////////
    int StartWiFi(const char* ssid, const char* password) {
      int connAttempts = 0;
      Serial.print(F("\r\nConnecting to: ")); Serial.println(String(ssid));
      WiFi.begin(ssid, password);
      while (WiFi.status() != WL_CONNECTED ) {
        delay(500); Serial.print(".");
        if (connAttempts > 20) {
          Serial.println("\nFailed to connect to a Wi-Fi network");
          return -5;
        }
        connAttempts++;
      }
      Serial.print(F("WiFi connected at: "));
      Serial.println(WiFi.localIP());
      return 1;
    }

    void StartTime(){
      configTime(0, 0, "0.uk.pool.ntp.org", "time.nist.gov");
      setenv("TZ", "GMT0BST,M3.5.0/01,M10.5.0/02",1); // Change for your location
      UpdateLocalTime();
    }

    void UpdateLocalTime(){
      struct tm timeinfo;
      while (!getLocalTime(&timeinfo)){
        Serial.println("Failed to obtain time");
      }
      //See http://www.cplusplus.com/reference/ctime/strftime/
      Serial.println(&timeinfo, "%a %b %d %Y   %H:%M:%S"); // Displays: Saturday, June 24 2017 14:05:49
      char output[50];
      strftime(output, 50, "%a %d-%b-%y  (%H:%M:%S)", &timeinfo);
      time_str = output;
    }
    ```

why are you not providing all information? ... I am very certain that the error message is longer than parseObject() failed

this is the full problem if you read the code you will find this if statment
      if (!root.success()) {
        Serial.println(F("jsonBuffer.parseObject() failed"));
      }```
it just printing this message in the serial monitor

print the content and take a look at the byre json. It's probably either too long too fit into 200 bytes or the formating is broken.

The documentation for ArduinoJson 5 lists the reasons why parseObject() may return false:

The input is not a valid JSON
The StaticJsonBuffer is too small
The StaticJsonBuffer is too big (stack overflow)
The DynamicJsonBuffer fails to allocate memory
You called parseObject() instead of parseArray()
The nesting limit is too low

A glance at your code suggests that the problem is number 2: the StaticJsonBuffer is too small.
Indeed, I don't know what the input looks like, but 200 bytes is probably too small to store the result.
You can use the ArduinoJson Assistant to compute the required capacity for the JsonBuffer. Don't forget to switch to a DynamicJsonBuffer if it becomes bigger than 4 KB.
Lastly, I really recommend that you switch to ArduinoJson 6 because it offers more features, better performance, better memory usage, and better error reporting, all with the same code size and portability.


text:
Understanding the pin diagram for MPU6050 IMU
I was reading this tutorial about the MPU6050 IMU and I was unable to understand why the pin configurations vary so much when compared to this schematic for EasyEDA.
The tutorial has this pin configuration :

Whereas the EasyEDA schematic looks like this :

I am not sure how to reconcile the two. Why does the schematic have 24 pins while the first diagram has only 8? Also I don't know what all the 24 pins are for.

that looks like a correct schematic diagram of the MPU-6050 module ... at least, the connector pinout is the same ... what problem are you having? ... you did not ask any questions

I see 24 pins in the top diagram ... 6 pins on each of the 4  sides of the square chip ... you don't really need to know what the pins are for ... you only need to concern yourself with the pins in J1

Ah! Thanks! Missed that completely. So if I were building a schematic first, it would work fine if I were to connect the relevant 8 pins to the microcontroller and replicate the rest of the schematic as is (from the second diagram)?

it is unclear what you mean by building a schematic first ... if you were building your own board, then you would probably need most of the support components on that module ... if your project already ran on 3.3 V, then you would not need the regulator or the LED or one of the filter caps ... the MPU-6050 chip requires very minimal set of support components, as you can see in the schematic diagram


text:
Can Only Upload Arduino Sketch Once to Custom Mega2560 Board
I created a custom Arduino based off the Mega2560 R3. It uses the ATMega16U2 uC as the USB interface between ATMega2560 uC and the PC.
The bootloader on the 2560 is uploaded by using an Arduino Micro via ArduinoISP. I followed this tutorial from Instructables on uploading the bootloader/firmware for the 16U2 except I modified some parts for the 2560 instead of the UNO. Here is my added section in the /program Files (x86)/Arduino/hardware/arduino/avr/boards.txt
unorestore.name=MEGA2560 16U2 Restore Firmware
unorestore.bootloader.tool=arduino:avrdude
unorestore.bootloader.low_fuses=0xff
unorestore.bootloader.high_fuses=0xd9
unorestore.bootloader.extended_fuses=0xf4
unorestore.bootloader.file=Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex
unorestore.bootloader.unlock_bits=0x3F
unorestore.bootloader.lock_bits=0x0F
unorestore.build.mcu=atmega16u2
unorestore.build.f_cpu=16000000L
unorestore.build.board=uno.build.board=AVR_MEGA2560
unorestore.build.core=arduino:arduino
unorestore.build.variant=standard

The problem is after I upload a sketch (with a size say over 10 kB), I can't upload any new sketch and get this timeout error message instead as shown below. Not even a simple blink sketch. The TX and RX LED connected to the 16U2 uC that flashes during an sketch upload doesn't even blink once.

The only way I can get it take another sketch is to "re-flash" the bootloader on the 2560 uC via ArduinoISP. The TX and RX led now flashes during the sketch upload. Of course, this is a huge hassle as I don't want to do "re-flash" the 2560 bootloader every time I want to upload a sketch.
I don't have this problem on my Elegoo Mega2560 R3 clone board so I'm thinking it might be something wrong with my 16U2 firmware/bootloader. Anyone have any idea what else might be causing this?

Why are you compiling for the atmega16u2?

the first upload after flashing the bootloader doesn't require a reset to bootloader. following uploads require a reset before upload. does your auto-reset circuit work?

@Majenko that is the selection for burning the bootloader onto the ATMega16U2 via ArudinoISP.

@Juraj I never heard of this before. I pretty much copied the official schematic. Is the reset the same as pulling the reset pin on the 2560 to ground before the sketch upload?

You shouldn't be uploading a bootloader to the 16U2. You install the CDC/ACM firmware over DFU. Are you sure you aren't installing the 16U2 bootloader onto the Mega2560?

@Majenko I burned the "MEGA2560 16U2 Restore Firmware" to the ATMega16U2 uC and burned the "Arduino/Genuino Mega or Mega 2560" to the ATMega2560 uC. Both done via ArduinoISP. I double checked that I didn't get them flipped.

@Majenko I originally tried to use the ATmel Flip to flash the hex files for the Mega2560 to the 16U2. But for some reason, it won't accept the it but will accept the hex files for the UNO. So if I went with it, I'd have the computer recognize my mega as a uno

What exact file is it you are having to re-flash? The 16U2 CDC/ACM firmware or the ATMega2560 UART bootloader?

@Majenko the official hex file for the ATMega16U2 for the Mega2560 R3: "Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex". It can be found here: https://github.com/arduino/ArduinoCore-avr/tree/master/firmwares/atmegaxxu2

@Majenko The "Arduino-COMBINED-dfu-usbserial-atmega16u2-Mega2560-Rev3.hex" file is what I burned to the 16U2 but can't be done via Atmel Flip software. The Arduino Mega2560 bootloader is what I have to re-flash in order to upload a new sketch as of now.

Ok. So why tell us all about the 16U2 when the problem bootloader is the 2560 one? It sounds like there may simply be a problem with your reset circuit rather than your firmwares. Try hitting reset on the board when attempting your second upload.

@Majenko I wasn't sure if it might be something to do with the 16U2 so I just put that info out there. I tried the reset to ground before hitting upload and it worked! I wonder what causing the reset issue. In the boards.txt file, the bootloader fuse line is "mega.menu.cpu.atmega2560.bootloader.high_fuses=0xD8" which is the correct default, isn't it?

That would make no difference. Please show us your schematic and board so we can examine the reset circuit for ourselves.

@Majenko Here is the EasyEDA share link: https://easyeda.com/salesagriculex/lcmr-v5 I'm comparing my schematic to the official eagle schematic right now to see if I missed anything.

I'm finding it hard to find my way around your schematic. I hate the modern way of having components with little labelled stubs instead of drawing proper nets linking things together. You can follow nets. You can't follow a little arrow and a name. And that EDA can't seem to do a simple search. So far all I have found for RST D7 on the 16U2, RESET on the 2560 and a pin on the ICSP. Are there other places where RST exists on that schematic?

Following the traces in the PCB layout editor it would appear not. Ok. I see a problem here.

@Majenko that should be all the RESET connections. I noticed on the official eagle schematics, there is circle between the REST net and the RESET pin on the 2560 chip.  The RESET pin on the 2560 also have the upper line above it.

Your RESET circuit is wrong.

You have no pullup resistor on the RESET pin of the ATMega3560.
You have an extraneous pulldown resistor on the D7 pin of the 16U2.

That means your 16U2 will not be able to trigger a reset of the ATMega2560 to run the bootloader.
Remove the pulldown on D7 of the 16U2 and add a 10kΩ pullup to the RESET pin of the ATMega2560. Without that pullup:

The chip may not run properly as RESET is floating (it may have an internal pullup, I can't recall)
The capacitor linking the 16U2 D7 and RESET of the ATMega2560 won't be able to generate a proper reset pulse. This will be exacerbated by the 1kΩ pulldown.

On the Mega2560 reference schematic RN1A is the pullup in question.

Thanks a lot for your find! Really appreciate it! I'll add the pull up resistor RN5A. As for the pull down resistor on D7 of the 16U2, it's from RN3D on the reference schematic. I'll remove that then. It said it's for USB Boot En.

I think that means it's for enabling DFU mode on the 16U2 - it may be related to why you can't use flip?

I was able to use the Flip software to upload the Uno hex file to a fresh new 16U2 but it can't just for the mega hex file. It said it was too large. Anyways, I added the pullup resistor and removed the pulldown resistor and it works now! I can upload a new code without having to re-flash the bootloader. You saved a huge amount of time for me. Would you accept a small tip via paypal if that's allowed? It's not much but as a way of thanks for your time.

Wow. If you really want to, sure. There's a "donate" link on UECIDE.org that goes to me if you really want to.

Majenko, I don't see a schematics in the question

@Juraj the link to it was posted under the comments of the original question post. The schematic itself has been turned private since the issue was solved.


text:
Why Can't I Program my Atmega168 Pro Mini?
I'm trying to program a Atmega168 Pro Mini 3.3V/8mhz I bought online. I followed a tutorial that walks through the steps of how to program a Pro Mini with an Arduino Uno. However, in their example they are uploading code to a Atmega328 Pro Mini though I don't think it matters.
Anyway, I followed the same steps as they did (namely hooking up Uno's ground -> ground, 3v -> Vcc, Reset -> DTR, tx->tx, rx->rx). When I attempted to upload via Arduino IDE I got the message that the programmer was not responding. I also noticed that the transfer led on the Uno was not lighting up. Did I screw up something? Also, are my hookups correct? I would think tx pin should connect to rx pin, but I just followed the instructions. Would appreciate any thoughts

Did you remove the MCU from the Uno?

yup, I took off the 328 chip

Hookup is not correct, the RX, TX lines need to be crossed!

@UmarSear That's wrong. In this instance the Uno is only being used as a USB to UART adaptor, so TX->TX and RX->RX is correct. You would swap them only if you wanted the ATMega328P on the Uno to communicate with the ATMega168 on the Pro Mini.

Your hookup seems to be correct. However check if there is a capacitor on the pro-mini board between DTR and reset pin, some arduino clones don't come with one.
If there isn't any you can simply connect a capacitor like this:
Reset pin (Arduino Uno) -> Capacitor (0.01uF for example) -> DTR (pro mini). The reason for this hookup is exmplined well here

They're also interfacing the 5V UNO to the 3.3V Pro Mini with no consideration for the logic level difference.  Sometimes you get away with that.  Anyway, rather the start another answer, I figured I'd just tack this onto yours, for integration into it or not.


text:
Configure Arduino Portable IDE
I am following this page (among others similar) about creating a portable Arduino IDE.
Though the steps are declared as easy...

Downloading the v.1.8.13 Windows ZIP file for non admin install,
Creating the portable folder,
Executing the arduino.exe file.

...I got stuck with this error:

This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted

I uninstalled v.1.8.13, then installed v.1.6.0, and never had any problems with JRE, until now.
What I am missing?

I'm using zip files since forever without issues. JRE is packed in subdirectory, so it should be working without it installed on OS level. That portable directory is great, never heard about it before.

@KIIV So, how shoud I use a packaged JRE in the Arduino Unzipped folder? What am I missing?

Just unpack arduino ide, jump into its directory and start Arduino.exe. It's expecting to have java in subdirectory. Btw, when I renamed java subdirectory, I've got exactly the same error message. (another way might be creating symlink to the system java instalation directory, or find out how to create Arduino.exe without that java bundling)

These instructions are interesting. Mainly section "Issues / Solution #1" - "When I used default Windows 'extract all' it didn't create half the folders which included java.".


text:
How can TEENSY Microcontrollers read ASCI Variables from X-PLANE 11
TEENSY Boards have in the USB-MODE "FLIGHTSIM" direct access to the variables = DATAREFS
of X-PLANE 11.
You can use FLIGHTSIMINTEGER and FLIGHTSIMFLOAT but not a varible for CHARs like the ID of a waypoint
for example "IBZ" or "EDDF" .
I need to read the CHARs to use them in the Display of my FlightSimPanel.
ANY IDEA ?

it is unclear what you are asking about ... please edit your post and explain what you are asking ... pretend that we cannot read your mind

Please show the code that you're having problems with. Reading data from flight simulators is not something everyone is familiar with.


text:
DIY Arduino with USB port
I am planing on making Arduino from scratch. I found many examples on internet, but they all need another Arduino for programming. How can I make Arduino with USB interface for programming and serial data transfer? Would I need something called FTDI? Basically I want same Arduino you can buy, just build it from separate parts.

If your atmega328 isn't preloaded with bootloader firmware, you need a programmer (which can be an arduino running a special sketch). And you need some USB to TTL-Serial, which can be an FTDI or CP120x or CH340 or similar.module.

There are two critical things that make an "Arduino". There is the hardware, and there is the bootloader.
The hardware is nothing special. It's just an MCU and the required minimal support hardware. What really makes it an Arduino is the bootloader which allows it to be programmed over the serial connection (via USB usually).
Without that bootloader the only way to program the MCU is over the hardware programming interface (typically ICSP for an AVR MCU), and for that you need some form of hardware programmer.
And of course that means the only way to put the bootloader onto the chip is to use a hardware programmer.
So you have two options:

Program the bootloader into the chip using a hardware programmer (which you can make with an Arduino), or
Buy an ATMega328P chip with the bootloader pre-programmed.

Once you have the bootloader installed then yes, you can program the chip over UART (through USB with a USB to UART adaptor such as an FT232).


text:
OLED 'SH1106_WHITE' was not declared in this scope
I was following FREE Functions to draw graphs on OLED displays on YouTube but mine OLED display doesn't support Adafruit_SSD1306 library,but it works on Adafruit_SH1106.h driver.
The code that is shared with YouTube video
/*

  This program provides functions to draw:
  1. horizontal bar graph
  2. vertical bar graph
  3. dial
  4. cartesian graph

  It requires an microcrontrioller Arduino, teensy and a 0.96 dispaly (1306 driver chip)

  display. sources
  https://www.amazon.com/Diymall-Yellow-Arduino-display.-Raspberry/dp/B00O2LLT30/ref=pd_lpo_vtph_147_bs_t_1?_encoding=UTF8&psc=1&refRID=BQAPE07SVJQNDKEVMTQZ
  https://www.amazon.com/dp/B06XRCQZRX/ref=sspa_dk_detail_0?psc=1&pd_rd_i=B06XRCQZRX&pd_rd_wg=aGuhK&pd_rd_r=1WJPXAG68XFSADGDPNZR&pd_rd_w=DAAsB

  Adafruit libraries
  https://github.com/adafruit/Adafruit-GFX-Library/archive/master.zip
  https://github.com/adafruit/Adafruit_SSD1306

  Revisions
  rev     date        author      description
  1       12-5-2017   kasprzak    initial creation

  Pin settings

  Arduino   device
  5V        Vin
  GND       GND
  A0        read an input voltage from a pot across Vcc and Gnd (just for demo purposes)
  A1
  A2
  A3
  A4        SDA on the display. or use dedicated pin on board if provided
  A5        SCL on the display. use dedicated pin on board if provided
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  13

*/

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define READ_PIN            A0
#define OLED_RESET          A4
#define LOGO16_GLCD_HEIGHT  16
#define LOGO16_GLCD_WIDTH   16

// create what ever variables you need
double volts;
double bvolts;
double x, y;

// these are a required variables for the graphing functions
bool Redraw1 = true;
bool Redraw2 = true;
bool Redraw3 = true;
bool Redraw4 = true;
double ox , oy ;

// create the display object
Adafruit_SSD1306 display(OLED_RESET);

void setup() {

  Serial.begin(9600);

  // initialize the display
  // note you may have to change the address
  // the most common are 0X3C and 0X3D

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  // if you distribute your code, the adafruit license requires you show their splash screen
  // otherwise clear the video buffer memory then display
  display.display();
  //delay(2000);
  display.clearDisplay();
  display.display();

  // establish whatever pin reads you need
  pinMode(A0, INPUT);

}

unsigned long OldTime;
unsigned long counter;

  void loop(void) {

  // read some values and convert to volts
  bvolts = analogRead(A0);
  volts = (bvolts  / 204.6 ) ;

  // draw any of the following, sorry for the crazy long arguement lists
  // note 0.96 isn't very big, so you can't show many graphs at the same time
  // also colors are hard coded
  // the display i use draws text at the top in yellow--we'll use that for drawing the title

  // call one of these functions
  DrawBarChartV(display, bvolts, 25,  60, 40, 40, 0, 1024 , 256, 0, "A0 (bits)", Redraw1);
  //  DrawBarChartH(display, volts, 10, 45, 100, 20, 0, 5, 1, 0, "A0 (volts)", Redraw2);
  //  DrawDial(display, volts, 65, 50, 25, 0, 5 , 1, 0, 200, "A0 (volts)", Redraw3);

  // for multiple graphs uncomment the next 2 lines
  //  DrawBarChartV(display, bvolts, 5,  60, 10, 40, 0, 1024 , 256, 0, "A0 (bits/volts)", Redraw1);
  //  DrawDial(display, volts, 90, 50, 25, 0, 5 , 1, 0, 200, "A0 (bits/volts)", Redraw3);

  // or show a cartesian style graph to plot values over time (or whatever)

    DrawCGraph(display, x++, bvolts, 30, 50, 75, 30, 0, 100, 25, 0, 1024, 512, 0, "Bits vs Seconds", Redraw4);
    if (x > 100) {
    while (1) {}
    }

  delay(1000);

  }

  /*
  This method will draw a vertical bar graph for single input
  it has a rather large arguement list and is as follows

  &d to pass the display object, mainly used if multiple displays are connected to the MCU
  curval = date to graph (must be between loval and hival)
  x = position of bar graph (lower left of bar)
  y = position of bar (lower left of bar
  w = width of bar graph
  h =  height of bar graph (does not need to be the same as the max scale)
  loval = lower value of the scale (can be negative)
  hival = upper value of the scale
  inc = scale division between loval and hival
  dig = format control to set number of digits to display. (not includeing the decimal)
  label = bottom lable text for the graph
  redraw = flag to redraw display. only on first pass (to reduce flickering)

*/

void DrawBarChartV(Adafruit_SSD1306 &d, double curval, double x , double y , double w, double h , double loval , double hival , double inc , double dig, String label, bool &Redraw)
{
  double stepval, my, level, i, data;

  if (Redraw) {
    Redraw = false;
    d.fillRect(0, 0,  127 , 14, SSD1306_WHITE);
    d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
    d.setTextSize(1);
    d.setCursor(2, 4);
    d.println(label);
    // step val basically scales the hival and low val to the height
    // deducting a small value to eliminate round off errors
    // this val may need to be adjusted
    stepval = ( inc) * (double (h) / (double (hival - loval))) - .001;
    for (i = 0; i <= h; i += stepval) {
      my =  y - h + i;
      d.drawFastHLine(x + w + 1, my,  5, SSD1306_WHITE);
      // draw lables
      d.setTextSize(1);
      d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
      d.setCursor(x + w + 12, my - 3 );
      data = hival - ( i * (inc / stepval));
      d.print(data, dig);
    }
  }
  // compute level of bar graph that is scaled to the  height and the hi and low vals
  // this is needed to accompdate for +/- range
  level = (h * (((curval - loval) / (hival - loval))));
  // draw the bar graph
  // write a upper and lower bar to minimize flicker cause by blanking out bar and redraw on update
  d.drawRect(x, y - h, w, h, SSD1306_WHITE);
  d.fillRect(x, y - h, w, h - level,  SSD1306_BLACK);
  d.drawRect(x, y - h, w, h, SSD1306_WHITE);
  d.fillRect(x, y - level, w,  level, SSD1306_WHITE);
  // up until now print sends data to a video buffer NOT the screen
  // this call sends the data to the screen
  d.display();

}

/*
  This method will draw a horizontal bar graph for single input
  it has a rather large arguement list and is as follows

  &display to pass the display object, mainly used if multiple displays are connected to the MCU
  x = position of bar graph (upper left of bar)
  curval = date to graph (must be between loval and hival)
  y = position of bar (upper left of bar (add some vale to leave room for label)
  w = width of bar graph (does not need to be the same as the max scale)
  h =  height of bar graph
  loval = lower value of the scale (can be negative)
  hival = upper value of the scale
  inc = scale division between loval and hival
  dig = format control to set number of digits to display. (not includeing the decimal)
  label = bottom lable text for the graph
  redraw = flag to redraw display. only on first pass (to reduce flickering)
*/

void DrawBarChartH(Adafruit_SSD1306 &d, double curval, double x , double y , double w, double h , double loval , double hival , double inc , double dig, String label, bool &Redraw)
{
  double stepval, mx, level, i, data;

  if (Redraw) {
    Redraw = false;
    d.fillRect(0, 0,  127 , 16, SSD1306_WHITE);
    d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
    d.setTextSize(1);
    d.setCursor(2, 4);
    d.println(label);
    // step val basically scales the hival and low val to the width
    stepval =  inc * (double (w) / (double (hival - loval))) - .00001;
    // draw the text
    for (i = 0; i <= w; i += stepval) {
      d.drawFastVLine(i + x , y ,  5, SSD1306_WHITE);
      // draw lables
      d.setTextSize(1);
      d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
      d.setCursor(i + x , y + 10);
      // addling a small value to eliminate round off errors
      // this val may need to be adjusted
      data =  ( i * (inc / stepval)) + loval + 0.00001;
      d.print(data, dig);
    }
  }
  // compute level of bar graph that is scaled to the width and the hi and low vals
  // this is needed to accompdate for +/- range capability
  // draw the bar graph
  // write a upper and lower bar to minimize flicker cause by blanking out bar and redraw on update
  level = (w * (((curval - loval) / (hival - loval))));
  d.fillRect(x + level, y - h, w - level, h,  SSD1306_BLACK);
  d.drawRect(x, y - h, w,  h, SSD1306_WHITE);
  d.fillRect(x, y - h, level,  h, SSD1306_WHITE);
  // up until now print sends data to a video buffer NOT the screen
  // this call sends the data to the screen
  d.display();

}

/*
  This method will draw a dial-type graph for single input
  it has a rather large arguement list and is as follows

  &display to pass the display object, mainly used if multiple displays are connected to the MCU
  curval = date to graph (must be between loval and hival)
  cx = center position of dial
  cy = center position of dial
  r = radius of the dial
  loval = lower value of the scale (can be negative)
  hival = upper value of the scale
  inc = scale division between loval and hival
  sa = sweep angle for the dials scale
  dig = format control to set number of digits to display. (not includeing the decimal)
  label = bottom lable text for the graph
  redraw = flag to redraw display. only on first pass (to reduce flickering)
*/

void DrawDial(Adafruit_SSD1306 &d, double curval, int cx, int cy, int r, double loval , double hival , double inc, double dig, double sa, String label, bool &Redraw) {

  double ix, iy, ox, oy, tx, ty, lx, rx, ly, ry, i, Offset, stepval, data, angle;
  double degtorad = .0174532778;
  static double px = cx, py = cy, pix = cx, piy = cy, plx = cx, ply = cy, prx = cx, pry = cy;

  if (Redraw) {
    Redraw = false;
    // draw the dial only one time--this will minimize flicker
    d.fillRect(0, 0,  127 , 16, SSD1306_WHITE);
    d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
    d.setTextSize(1);
    d.setCursor(2, 4);
    d.println(label);
    // center the scale about the vertical axis--and use this to offset the needle, and scale text
    Offset = (270 +  sa / 2) * degtorad;
    // find hte scale step value based on the hival low val and the scale sweep angle
    // deducting a small value to eliminate round off errors
    // this val may need to be adjusted
    stepval = ( inc) * (double (sa) / (double (hival - loval))) + .00;
    // draw the scale and numbers
    // note draw this each time to repaint where the needle was
    for (i = 0; i <= sa; i += stepval) {
      angle = ( i  * degtorad);
      angle = Offset - angle ;
      ox =  (r - 2) * cos(angle) + cx;
      oy =  (r - 2) * sin(angle) + cy;
      ix =  (r - 10) * cos(angle) + cx;
      iy =  (r - 10) * sin(angle) + cy;
      tx =  (r + 10) * cos(angle) + cx + 8;
      ty =  (r + 10) * sin(angle) + cy;
      d.drawLine(ox, oy, ix, iy, SSD1306_WHITE);
      d.setTextSize(1);
      d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
      d.setCursor(tx - 10, ty );
      data = hival - ( i * (inc / stepval)) ;
      d.println(data, dig);
    }
    for (i = 0; i <= sa; i ++) {
      angle = ( i  * degtorad);
      angle = Offset - angle ;
      ox =  (r - 2) * cos(angle) + cx;
      oy =  (r - 2) * sin(angle) + cy;
      d.drawPixel(ox, oy, SSD1306_WHITE);
    }
  }
  // compute and draw the needle
  angle = (sa * (1 - (((curval - loval) / (hival - loval)))));
  angle = angle * degtorad;
  angle = Offset - angle  ;
  ix =  (r - 10) * cos(angle) + cx;
  iy =  (r - 10) * sin(angle) + cy;
  // draw a triangle for the needle (compute and store 3 vertiticies)
  lx =  2 * cos(angle - 90 * degtorad) + cx;
  ly =  2 * sin(angle - 90 * degtorad) + cy;
  rx =  2 * cos(angle + 90 * degtorad) + cx;
  ry =  2 * sin(angle + 90 * degtorad) + cy;

  // blank out the old needle
  d.fillTriangle (pix, piy, plx, ply, prx, pry, SSD1306_BLACK);

  // then draw the new needle
  d.fillTriangle (ix, iy, lx, ly, rx, ry, SSD1306_WHITE);

  // draw a cute little dial center
  d.fillCircle(cx, cy, 3, SSD1306_WHITE);

  //save all current to old so the previous dial can be hidden
  pix = ix;
  piy = iy;
  plx = lx;
  ply = ly;
  prx = rx;
  pry = ry;
  // up until now print sends data to a video buffer NOT the screen
  // this call sends the data to the screen
  d.display();

}

/*

  function to draw a cartesian coordinate system and plot whatever data you want
  just pass x and y and the graph will be drawn huge arguement list

  &display to pass the display object, mainly used if multiple displays are connected to the MCU
  x = x data point
  y = y datapont
  gx = x graph location (lower left)
  gy = y graph location (lower left)
  w = width of graph
  h = height of graph
  xlo = lower bound of x axis
  xhi = upper bound of x asis
  xinc = division of x axis (distance not count)
  ylo = lower bound of y axis
  yhi = upper bound of y asis
  yinc = division of y axis (distance not count)
  title = title of graph
  &redraw = flag to redraw graph on fist call only

*/

void DrawCGraph(Adafruit_SSD1306 &d, double x, double y, double gx, double gy, double w, double h, double xlo, double xhi, double xinc, double ylo, double yhi, double yinc, double dig, String title, boolean &Redraw) {

  double i;
  double temp;
  int rot, newrot;

  if (Redraw == true) {
    Redraw = false;
    d.fillRect(0, 0,  127 , 16, SSD1306_WHITE);
    d.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
    d.setTextSize(1);
    d.setCursor(2, 4);
    d.println(title);
    ox = (x - xlo) * ( w) / (xhi - xlo) + gx;
    oy = (y - ylo) * (gy - h - gy) / (yhi - ylo) + gy;
    // draw y scale
    d.setTextSize(1);
    d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
    for ( i = ylo; i <= yhi; i += yinc) {
      // compute the transform
      // note my transform funcition is the same as the map function, except the map uses long and we need doubles
      temp =  (i - ylo) * (gy - h - gy) / (yhi - ylo) + gy;
      if (i == 0) {
        d.drawFastHLine(gx - 3, temp, w + 3, SSD1306_WHITE);
      }
      else {
        d.drawFastHLine(gx - 3, temp, 3, SSD1306_WHITE);
      }
      d.setCursor(gx - 27, temp - 3);
      d.println(i, dig);
    }
    // draw x scale
    for (i = xlo; i <= xhi; i += xinc) {
      // compute the transform
      d.setTextSize(1);
      d.setTextColor(SSD1306_WHITE, SSD1306_BLACK);
      temp =  (i - xlo) * ( w) / (xhi - xlo) + gx;
      if (i == 0) {
        d.drawFastVLine(temp, gy - h, h + 3, SSD1306_WHITE);
      }
      else {
        d.drawFastVLine(temp, gy, 3, SSD1306_WHITE);
      }
      d.setCursor(temp, gy + 6);
      d.println(i, dig);
    }
  }

  // graph drawn now plot the data
  // the entire plotting code are these few lines...

  x =  (x - xlo) * ( w) / (xhi - xlo) + gx;
  y =  (y - ylo) * (gy - h - gy) / (yhi - ylo) + gy;
  d.drawLine(ox, oy, x, y, SSD1306_WHITE);
  d.drawLine(ox, oy - 1, x, y - 1, SSD1306_WHITE);
  ox = x;
  oy = y;

  // up until now print sends data to a video buffer NOT the screen
  // this call sends the data to the screen
  d.display();

}

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

For my purpose of running this project in my OLED I replaced all SSD1306 keyword with SH1106. Except this project every other projects works on this OLED by replacing SSD1306 keyword with SH1106.
Getting this error in Ardunio IDE 'SH1106_WHITE' was not declared in this scope
Arduino: 1.8.13 Hourly Build 2020/04/21 12:25 (Linux), Board: "Arduino Uno"

/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawBarChartV(Adafruit_SH1106&, double, double, double, double, double, double, double, double, double, String, bool&)':
sketch_oct07a:162:33: error: 'SH1106_WHITE' was not declared in this scope
     d.fillRect(0, 0,  127 , 14, SH1106_WHITE);
                                 ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:162:33: note: suggested alternative: 'SH1106_LCDWIDTH'
     d.fillRect(0, 0,  127 , 14, SH1106_WHITE);
                                 ^~~~~~~~~~~~
                                 SH1106_LCDWIDTH
sketch_oct07a:163:20: error: 'SH1106_BLACK' was not declared in this scope
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:163:20: note: suggested alternative: 'SH1106_128_64'
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
                    SH1106_128_64
sketch_oct07a:187:30: error: 'SH1106_WHITE' was not declared in this scope
   d.drawRect(x, y - h, w, h, SH1106_WHITE);
                              ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:187:30: note: suggested alternative: 'SH1106_LCDWIDTH'
   d.drawRect(x, y - h, w, h, SH1106_WHITE);
                              ^~~~~~~~~~~~
                              SH1106_LCDWIDTH
sketch_oct07a:188:39: error: 'SH1106_BLACK' was not declared in this scope
   d.fillRect(x, y - h, w, h - level,  SH1106_BLACK);
                                       ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:188:39: note: suggested alternative: 'SH1106_128_64'
   d.fillRect(x, y - h, w, h - level,  SH1106_BLACK);
                                       ^~~~~~~~~~~~
                                       SH1106_128_64
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawBarChartH(Adafruit_SH1106&, double, double, double, double, double, double, double, double, double, String, bool&)':
sketch_oct07a:221:33: error: 'SH1106_WHITE' was not declared in this scope
     d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                 ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:221:33: note: suggested alternative: 'SH1106_LCDWIDTH'
     d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                 ^~~~~~~~~~~~
                                 SH1106_LCDWIDTH
sketch_oct07a:222:20: error: 'SH1106_BLACK' was not declared in this scope
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:222:20: note: suggested alternative: 'SH1106_128_64'
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
                    SH1106_128_64
sketch_oct07a:246:47: error: 'SH1106_BLACK' was not declared in this scope
   d.fillRect(x + level, y - h, w - level, h,  SH1106_BLACK);
                                               ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:246:47: note: suggested alternative: 'SH1106_128_64'
   d.fillRect(x + level, y - h, w - level, h,  SH1106_BLACK);
                                               ^~~~~~~~~~~~
                                               SH1106_128_64
sketch_oct07a:247:31: error: 'SH1106_WHITE' was not declared in this scope
   d.drawRect(x, y - h, w,  h, SH1106_WHITE);
                               ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:247:31: note: suggested alternative: 'SH1106_LCDWIDTH'
   d.drawRect(x, y - h, w,  h, SH1106_WHITE);
                               ^~~~~~~~~~~~
                               SH1106_LCDWIDTH
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawDial(Adafruit_SH1106&, double, int, int, int, double, double, double, double, double, String, bool&)':
sketch_oct07a:283:33: error: 'SH1106_WHITE' was not declared in this scope
     d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                 ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:283:33: note: suggested alternative: 'SH1106_LCDWIDTH'
     d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                 ^~~~~~~~~~~~
                                 SH1106_LCDWIDTH
sketch_oct07a:284:20: error: 'SH1106_BLACK' was not declared in this scope
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:284:20: note: suggested alternative: 'SH1106_128_64'
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
                    SH1106_128_64
sketch_oct07a:333:49: error: 'SH1106_BLACK' was not declared in this scope
   d.fillTriangle (pix, piy, plx, ply, prx, pry, SH1106_BLACK);
                                                 ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:333:49: note: suggested alternative: 'SH1106_128_64'
   d.fillTriangle (pix, piy, plx, ply, prx, pry, SH1106_BLACK);
                                                 ^~~~~~~~~~~~
                                                 SH1106_128_64
sketch_oct07a:336:43: error: 'SH1106_WHITE' was not declared in this scope
   d.fillTriangle (ix, iy, lx, ly, rx, ry, SH1106_WHITE);
                                           ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:336:43: note: suggested alternative: 'SH1106_LCDWIDTH'
   d.fillTriangle (ix, iy, lx, ly, rx, ry, SH1106_WHITE);
                                           ^~~~~~~~~~~~
                                           SH1106_LCDWIDTH
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino: In function 'void DrawCGraph(Adafruit_SH1106&, double, double, double, double, double, double, double, double, double, double, double, double, double, String, boolean&)':
sketch_oct07a:388:33: error: 'SH1106_WHITE' was not declared in this scope
     d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                 ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:388:33: note: suggested alternative: 'SH1106_LCDWIDTH'
     d.fillRect(0, 0,  127 , 16, SH1106_WHITE);
                                 ^~~~~~~~~~~~
                                 SH1106_LCDWIDTH
sketch_oct07a:389:20: error: 'SH1106_BLACK' was not declared in this scope
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:389:20: note: suggested alternative: 'SH1106_128_64'
     d.setTextColor(SH1106_BLACK, SH1106_WHITE);
                    ^~~~~~~~~~~~
                    SH1106_128_64
sketch_oct07a:433:28: error: 'SH1106_WHITE' was not declared in this scope
   d.drawLine(ox, oy, x, y, SH1106_WHITE);
                            ^~~~~~~~~~~~
/tmp/arduino_modified_sketch_953644/sketch_oct07a.ino:433:28: note: suggested alternative: 'SH1106_LCDWIDTH'
   d.drawLine(ox, oy, x, y, SH1106_WHITE);
                            ^~~~~~~~~~~~
                            SH1106_LCDWIDTH
exit status 1
'SH1106_WHITE' was not declared in this scope

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

I am new to this field. Any help will be appreciated.

In the Adafruit_SH1106.h header file, SH1106_WHITE and SH1106_BLACK are defined simply as WHITE and BLACK respectively.
So instead of writing SH1106_WHITE try replacing it WHITE and SH1106_BLACK as BLACK respectively.
Eg:-  fillRect(0, 0,  127 , 14, WHITE);

Also change the SH1106_BLACK to BLACK


text:
Is this LED Strip Schematic correct?
I am trying to simulate a 12V LED strip as per this tutorial. However the schematic I tried to make on EasyEDA looks quite different from the images on the website. I wanted to know if what I did is correct.

Schematic and wiring diagram are not the same. They seem to use different RGB LEDs. The wiring diagram has common anode RGB LEDs, while your schematic uses a common cathode RGB LED. The difference is, which side of the LED gets switched.
In the common anode configuration, all anodes (positive lead) of the individual color LEDs are connected together, while the cathodes (negative leads) are brought out, so that you can switch them via the MOSFETs. That means, that the MOSTFETs are connected between the strips color component pins and ground.
In the common cathode configuration, all cathodes (negative lead) of the individual color LEDs are connected together, while the anodes (positive leads) are brought out for you to switch them. In this case, the MOSFETs are connected between the strips color component pins and Vcc.

Besides that, you should be careful with providing 12V at Vin of an Arduino Uno. While it is possible, you can very fast get the linear voltage regulator to overheat, when providing 12V. It dissipates the excess voltage (so 7V, to get it to 5V down) as heat. The voltage regulator is not cooled, so you might run into this issue, with the wiring diagram. It depends on your much current you draw from the regulator.


text:
How to find out if HX711(amplifier and 24-bit ADC) is damaged or not?
I'm using this ADC with a load cell for weight measurement, I had 4 strain gauges and mounted them on a cantilever structure that I made out of acrylic sheet, used calibration program from here: https://github.com/olkal/HX711_ADC/blob/master/examples/Calibration/Calibration.ino,
followed the steps but it gave calibration factor as 0.00 and the output was NaN or inf . I used another program from here: https://github.com/queuetue/Q2-HX711-Arduino-Library/tree/master/examples/simple_scale and the output was just hovering around 83868. So I thought that the mounting was the problem and used a load cell (green label, CZL 601) with the above and found the same results by doing the above.
Then I thought maybe the ADC is at fault , measured the power output from Arduino to the board and it was around 5 V , but when I measured between the E+ and E- , I got 0 V. Since it is the excitation voltage to the bridge, it should be around 5V too right?
Is this the right way of checking the board?
P.S. I measured the four wires of the load cell and connected the opp. ends of the bridge to the E+ , E- , A+ , A- (order doesn't matter here right? connected the pairs that showed the rated resistance to E's and A's separately)
Here's a [pic][1] of the connections
Between White and green wire the Resistance is 350 ohm
Between Bk( connected in the board ) and the red it is 408 ohm
Between White and red it was 263 ohm
Between white and bk it is 320 ohm
Between bk(not connected in the board) and all others it is around 1 MOhm (so ignored that)
[1]: https://photos.app.goo.gl/4HEmZaN1EwZ7Mjur7

Start by checking the communication between the Arduino and the HX711. If that isn't working then you won't see anything useful. E+ won't be 5V until told to be by the Arduino.

@Majenko can you pls elaborate how do I do that! Also since I'm giving the 5V output of UNO to VCC of the HX711 module , I assumed E+ will be 5V ! (Just saw the datasheet , there's a transistor in between )

@Majenko do you mean reading the Dout pin by giving some voltage to A+ ?

Examine the DOUT and CLK pins using either a logic analyser or oscilloscope.

I don't have those things , its actually a small project that I'm doing for my home!  Any other method, that doesn't require more electronics!! Really appreciate the help, it's just that it's not a practical option for me! Thanks

Double check your wiring. Post a picture of your setup so we can check your wiring for you.

@Majenko Couldn't attach here , so attached as a link ...

Have you changed the pin numbers in the sample code to reflect the pins you are using in your setup?

Yes I did! I have gn it as 8 and 9 !

You wouldn't have been the first not to. So it sounds like something is dead. Your Arduino looks some what "battered". You may want to make sure those pins actually work by blinking an LED through them. If they do then it could be that the HX711 is dead. The only way to be sure without more kit is to replace it and see what happens.

Although... looking more closely at your photo - you haven't soldered the headers to your HX711 breakout board. You need to do that or they won't be making a good contact.

Thank you for your I/p. Since I just bought it , I thought I'll plug and see! I'll try to test out other possible causes and let you know!

@Majenko your observations were spot on! once I soldered the components everything fell in place, thanks again!!!

Looking closely at the photo of your setup I can see that you haven't soldered the header to the breakout board. Whilst there are headers available that don't require soldering, and ways of making header connections that don't require soldering, this isn't either of those.
Without solder the connection to the board will be intermittent at best and non-existent in general.


text:
Send message to multiple number
sim.println("AT+CMGS=\"+91xxxxxxxxxx\"\r");
I don't want to write this. I want to write mobile number on serial monitor in Arduino and on that number, i want to send message. how can I do?

I changed the qs for you, hope I made the right corrections!

@SomasundharamSampath Where did you get the information for your edit of the question? Have I missed something here?

@Mehul What exactly is your problem with this? Is it about the serial communication? Or is it about putting together the received number for sending to the GSM module? What have you tried so far? Have you looked at some of the many examples and tutorials about serial communication?

I saw this comment/ answer  https://arduino.stackexchange.com/a/78443/11957

Actually, there are different different number which may don't know every time.
Every time i change number and install on board that is not possible. so i want to make code in which write number and send same message on it.


text:
Az Delivery ESP32 DevKitC V2 PIN names/number
i wonder where to find out the PIN names for the Az Delivery ESP32 DevKitC V2.
There is a pin out graphic, but it does not say how the Pin addresses are:
https://cdn.shopify.com/s/files/1/1509/1638/files/ESP_-_32_NodeMCU_Developmentboard_Pinout_Diagram.jpg?4479111012146266271
I thought maybe it's just the number of the GPIOs but that's wrong. In the first example script only PIN 1 was named as the address for the board intern LED.

There are no pin names on the ESP32. GIOx is pin x.

Well there is a GIPIO 0 and 0 is already the board LED, so that's not possible

It's perfectly possible. Connections aren't exclusive. You can have a connection going to both a pin at the edge of the board and to an LED. Look at pin 13 of the Arduino - that goes to a pin on the edge of the board and to the on-board LED.

ESP32 boards don't use "names" for their IO pins. There is a direct 1:1 mapping between the internal "GPIO" number and the pin number.
To do something with pin G21 on the board you use pin number 21. To do something with pin G14 you use pin number 14.
By all accounts that board differs from other ESP32 devkits in that the LED is on GPIO1 rather than the normal GPIO0 that all the other boards use. I suspect that this is the source of your confusion.

To finalize the confusion you need to digitalWrite(1,LOW) and not  digitalWrite(1,HIGH) to turn the LED on. Ooof

@Stack one end of the LED is connected to V+ ... pulling the other end low lights it ... it is not so confusing really ... if it continues to give you problems, then define ON and OFF ... in the end, pulling a pin of a device low, to activate it, is very common practice ... just look at solenoid driver circuits

This "active low" driving method stems from the early days of semiconductors when you would have a low impedance LOW and a high impedance HIGH output - for example RTL where a transistor pulls the output down and a resistor pulls it up. Later when CMOS came on the scene you'd have a low resistance N-channel FET for the LOW and a higher resistance P-channel FET for the HIGH allowing more current to be sunk than could be sourced by an output. These days it's not a problem as the P- and N-channel FETs are much more closely matched - but the hangover is still there in many designers' minds.


text:
Dealing with a Signal Source
The following circuit is a simplified version of a more complex system. For testing purposes, the 555 Timer was added to serve as a test signal source with frequencies set by the resistors in series. Each arbitrary signal is indicated by a push button and the Arduino needs to be able to distinguish what button has been pushed. Unfortunately, there can only be 3 buttons and more cannot be added. This is where the problem occurs. How can you reliably indicate which push button has been pressed without interfering with the arbitrary waveform?
At first, my original thought was to have the Arduino sample the signal based on that sample the Arduino would be able to tell which button is pressed.
When button 1 in the pink is pushed the Arduino receives a takes the following
sample of the signal.

843
848
849
849
849
849
   // Time 0 when button is pushed
532
414
500
373
463
346
425
370
386
476
346
442
642
788

Moving the input

    // At t = 0 the Serial Monitor reads zero
    998
    998
    998
    998
    998
    0
    0
    0
    0
    0
    998
    0
    0
    0
    0
    0
    0
    0
    0
    0
    998
    0
    0
    0
    0
    998
    0
    0
    0
    998
    998
    998
    0
    998
    0
    0
    0
    998
    0
    0
    0
    0

Moving the analog input does not make it any easier to distinguish which button was being pushed. Which is why I decided to ask the community on how to deal with this. I have tried using a relay and simply hard coding all of the cases but the result is a system is not very robust and is vulnerable to easily break over time.

What is the role of the 555 chip in that circuit?

The 555 chip is being used to generate 3 waves.

Does this answer your question? Multiple Push buttons to one input

I need to apologize for the previous wording of my question I believe I made it difficult to understand. I am still relatively new to electronics in the future I will work to improve this.

After a day or two of working on this problem, I have found that it is best to avoid using the analog pins and stay away from directly interfacing with the 555 Timer. This is a simplified version of a more complex circuit and the 555 Timer represents some arbitrary signal source. For example, on mobile radio, you push a button to send out a certain frequency. That is the concept here only the frequencies cannot be adjusted yet. Now that it has been clarified that the 555 Timer has been placed in the circuit for debugging purposes here is the best solution I have found to this problem. First, I have found that it is doable to read in from the analog pin on the Arduino but not easy. This leaves a lot of room for error being that the waveform is arbitrary with some random frequency. Therefore, I have opted to use the digital pins on the Arduino.

by using the digital pins I have now only have to worry about whether the button is high or low. Then NPN transistors were used to act as switches once the button is pushed. The diodes then were added to maintain a steady voltage across the base of the transistor. For testing purposes, the LCD was removed and replaced by an LED. As far as the code is concerned it is nothing extraordinary or complex as shown below. Therefore, I believe this may be the best way to go about solving this problem.
const int D_pin10 = 10;
const int D_pin9 = 9;
const int D_pin8 = 8;
int led = 13;
void setup()
{
  pinMode(D_pin10 , INPUT); // pin 10 is an input
  pinMode(D_pin9 , INPUT); // pin 10 is an input
  pinMode(D_pin8, INPUT); // pin 10 is an input
  pinMode(led, OUTPUT);
}

void loop()
{
  int High_Low10 =0;
  int High_Low9 =0;
  int High_Low8 =0;

  High_Low10 = digitalRead(D_pin10);
  High_Low9 = digitalRead(D_pin9);
  High_Low8 = digitalRead(D_pin8);

  if(High_Low10 == HIGH)
  {
    digitalWrite(led, HIGH);
  }
  else if(High_Low9 == HIGH)
  {
    digitalWrite(led, HIGH);
  }
  else if(High_Low8 == HIGH)
  {
    digitalWrite(led, HIGH);
  }
  else
  {
    digitalWrite(led, LOW);
  }
  delay(1000);
}

If your aim is to detect button presses accurately, and use one pin per button, you don't need transistors, diodes or any other hardware apart from pushButtons. You can directly connect to pushbutton via an internal pull-up resistor and accurately read button states.

The goal is to control the astable 555 Timer with the pushbuttons. The diodes and transistors are functioning as a switch.

There's an easy way to achieve reading multiple pushbuttons using single analog input.
All you need to do is create some voltage dividers at different voltages which can be read using analogRead. The last resistor,R6, in the diagram below ensures that the pin reads 0 when no push-button is pressed (i.e pull-down resistor).
In the diagram below, connect Vcc to 5V on the Arduino.

Try it out, you should be able to get well spaced out values for different push buttons!

R1 ... R5 can have different values, which might spread the ranges per button more evenly

Re “1M”: Note that, on the Uno, the ADC is specified for a source output impedance no larger than 10 kΩ.

@EdgarBonet The 1M is just a float-prevention pulldown. By having it so high it prevents the input floating with no buttons pressed and at the same time has little effect on the readings. Worst case the output impedance with Button 1 pressed would be  799.36Ω. With nothing pressed there's no output to have an impedance. Just ground through a resistor. Yes, it may slow down the transition from a valid reading to nothing, but that's not a problem.

@Majenko: “nothing” is a valid reading.

Yes, but it's not an actively valid reading that is being driven by the rest of the circuit - just a "stop it floating" nothingness.

This is correct but utilizing the voltage divider is quite difficult in this scenario.


text:
Can I use LiFe PO4 batteries in a 18650 battery shield?
Is it safe to use LiFe PO4 batteries in a 18650 Battery Shield (sometimes called Lithium-Battery Shield)?

In my opinion it is NOT SAFE, if your 18650 Battery Shield also charges the battery.
Anyhow some pages state that it is possible to charge LiFePo4 batteries with 4.2V instead of the recommended 3.65V. https://www.powerstream.com/lithium-phosphate-charge-voltage.htm
LiFePo4 batteries have a smaller energy density and therefore capacity. Thus those are not as explosive as Li-Ion batteries. But you are risking damaging the battery and shorten its lifespan.


text:
Can not upload to Arduino Nano BLE 33
I am new so please be nice :)
I am trying to upload the Blinky example to my Arduino Nano BLE 33 but I get this error message from the Arduino IDE:
No device found on ttyACM0
Set binary mode
Send auto-baud
An error occurred while uploading the sketch
Set binary mode

Any idea what I could try?
I am running the Arduino IDE as superuser in Manjaro (latest versions of everything). If you need any more information please feel free to ask.
Full IDE output:
Sketch uses 77820 bytes (7%) of program storage space. Maximum is 983040 bytes.
Global variables use 42192 bytes (16%) of dynamic memory, leaving 219952 bytes for local variables. Maximum is 262144 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyACM0
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
PORTS {/dev/ttyACM0, } / {/dev/ttyACM0, } => {}
Uploading using selected port: /dev/ttyACM0
/root/.arduino15/packages/arduino/tools/bossac/1.9.1-arduino1/bossac -d --port=ttyACM0 -U -i -e -w /tmp/arduino_build_408944/Blink.ino.bin -R
No device found on ttyACM0
Set binary mode
Send auto-baud
An error occurred while uploading the sketch
Set binary mode

try a double-reset and then upload

are you being logged in as a root?

if you are running  as both user and root, the udev may have mapped device for user already, and as such is bussy with another process
Try sticking to user and giving yourself sufficient rights. it is not a good idea to do too much stuff as a root. Well build modern distro (less then 10 year old should give you sufficient access without need to resort to un-safe practices). If you are on advanced user distro (eg Gentoo)  see suitable Arduino How--to

Send us a picture of: Tools->Port (or write options down) when trying to program. they would be something like /dev/
Although tell us if you are using wired or wireless programming

@Tomas, the uploader output in Question shows, it can access the port

I have already tried double resetting, that did not work.
I am logged in as root.
I do not run as both user and root, however you are right and I should not run it as root. I did so to have the sufficient rights for sure.
The option for the Port is: /dev/ttyACM0 (Arduino Nano BLE 33)
Thank you guys.

Update: I just tried in Windows and uploading works fine here...
And now it is working in Manjaro as well, very weird.

It appears you are using Linux. In order to communicate you must establish yourself as being allowed to use it, that is the dial out function. "sudo usermod -a -G dialout " should work but you need to log out then back in before it takes effect. After that you are all set.

I am not sure if he is using serial port or over Bluetooth as I am not sure if nano BLE supports over bluetooth programing. (otherwise the nano may be mapped to /dev/ttyUSB0 (number may change).
While I appreciate that on ubuntu (Debian based Distros) you use sudo, but not all distros (I personally keep sudo disabled). Adding user to dialout group is only correct step on some distros and only for some form of programing... Better follow tutorial for your distro

the uploader output in Question shows, it can access the port. for access rights settings on Linux I am sure we have an answer here somewhere so this would be a duplicate

When trying to add the user to the dialout group I get this message: "usermod: group 'dialout' does not exist". However I am running the Arduino IDE as superuser so I should have sufficient rights.
I am using the USB port of the board to program it.
Unfortunately I have not found a solution for this problem anywhere.
Thank you guys.

I never run in supervisor as I can do a lot of damage to the system. Beyond this I cannot offer anymore help.


text:
Can I use The mpu6050 with this?
I am making a project with 3 arduinos (2 slave, 1 master) and I want to know can I use the mpu6050 since it uses the I2c communication.

You're using I2C for the Arduino->Arduino communication?

yes i am using  it

Yes, but only from the master. You have one I2C bus with three slave devices on it - two arduinos and one mpu6050.

thank you for the help

You can but keep the I2C wires less then about 30cm. If they are going to be further apart consider something like RS485 or CAN. Are you sure you need three?

Yes i do I am making a car/ drone combo https://www.youtube.com/results?search_query=smart+ideas+consept+drone&pbjreload=102


text:
Digispark uploading not working in KDE Neon (Linux)
I am using KDE Neon and have downloaded the Arduino IDE via the Snap store. It worked well with the ESP8266 and other Arduions. But when I tried to upload a simple sketch or an example sketch to my Digispark, I get an error message. I have selected the right Board and the micronucleus programmer. I have also installed libusb. But I always get the following error message:
/home/myusername/snap/arduino/41/.arduino15/packages/digistump/tools/micronucleus/2.0a4/micronucleus: error while loading shared libraries: libusb-0.1.so.4: cannot open shared object file: No such file or directory

Maybe https://github.com/micronucleus/micronucleus/wiki/Ubuntu-Linux helps.

Install libusb-0.1-4 in whatever package manager KDE Neon uses.

I had the same problem when using the snap package of the Arduino IDE. I solved the problem by installing the Arduino IDE from the official web page: https://www.arduino.cc/en/software
You might have to run the Arduino IDE with sudo or better add a custom udev rule in case you now get following assertion error:

'micronucleus_connect: Assertion `res >= 4' failed.'

Solving the assertion error is further described in following post: https://digistump.com/board/index.php?topic=106.0

Thank you for your answer! It is working now.


text:
Can't send Twilio SMS using Nodemcu esp8266
I am using Twilio for sending SMS in my project. I am measuring temperatures and if the temperature is too high, an SMS is sent. In my code I also have a read and a push to Firebase Realtime Database. In this case (where there is only one read and one push) everything works fine and the message is sent. However, after adding another set to Firebase the SMS is not sent. The error I get is  "Last SSL error was: Unable to allocate memory for SSL structures and buffers". I also added the command, which prints the free heap just before the message is sent and it prints that I still have 24000 free heap. In other cases, where I did not set values to Firebase, my free heap was also 24000 and the message was sent properly. Do you have any suggestions how to solve this problem?
Here's my code:
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
#include "OneWire.h"
#include "DallasTemperature.h"
#include "twilio.hpp"
#include <ESP8266WebServer.h>
#include <WiFiManager.h>

#define FIREBASE_HOST "***"
#define FIREBASE_AUTH "***"
const char* account_sid = "***";
const char* auth_token = "***";
FirebaseData firebaseData1;
FirebaseData firebaseData2;
FirebaseJson tms;
FirebaseJsonArray arr;
String path = "/Test/Stream";
int sms = 0;
String c;
int b;

#define WIFI_SSID "***"
#define WIFI_PASSWORD "***"

const char fingerprint[] = "BC B0 1A 32 80 5D E6 E4 A2 29 66 2B 08 C8 E0 4C 45 29 3F D0";
String to_number    = "***";
String from_number = "***";
String message_body    = "Hello from Twilio and the ESP8266!";
String master_number    = "***";
String media_url = "";
Twilio *twilio;
ESP8266WebServer twilio_server(8000);
const char* host = "api.twilio.com";
const int   httpsPort = 443;
WiFiClientSecure client;

#if USE_SOFTWARE_SERIAL == 1
#include <SoftwareSerial.h>
extern SoftwareSerial swSer(14, 4, false, 256);
#else
#define swSer Serial
#endif

#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float temp1 = 0;

unsigned long sendDataPrevMillis = 0;

void printResult(FirebaseData &data);
void printResult(StreamData &data);
void streamCallback(StreamData data)
{
  Serial.println("Stream Data1 available...");
  Serial.println("STREAM PATH: " + data.streamPath());
  Serial.println("EVENT PATH: " + data.dataPath());
  Serial.println("DATA TYPE: " + data.dataType());
  Serial.println("EVENT TYPE: " + data.eventType());
  Serial.print("VALUE: ");
  printResult(data);
  Serial.println();
}
void streamTimeoutCallback(bool timeout)
{
  if (timeout)
  {
    Serial.println();
    Serial.println("Stream timeout, resume streaming...");
    Serial.println();
  }
}
void setup()
{
  Serial.begin(115200);
  WiFiManager wm;
  bool res;
  res = wm.autoConnect("AutoConnectAP", "password");
  if (!res) {
    Serial.println("Failed to connect");
  }
  else {
    Serial.println("connected");
  }
  twilio = new Twilio(account_sid, auth_token, fingerprint);
  twilio_server.begin();
  sensors.begin();
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);

  firebaseData1.setBSSLBufferSize(1024, 1024);
  firebaseData1.setResponseSize(1024);
  firebaseData2.setBSSLBufferSize(1024, 1024);
  firebaseData2.setResponseSize(1024);
  if (!Firebase.beginStream(firebaseData1, path))
  {
    Serial.println("------------------------------------");
    Serial.println("Can't begin stream connection...");
    Serial.println("REASON: " + firebaseData1.errorReason());
    Serial.println("------------------------------------");
    Serial.println();
  }
  Firebase.setStreamCallback(firebaseData1, streamCallback, streamTimeoutCallback);
}

void loop()
{
  if (millis() - sendDataPrevMillis > 5000)
  {
    sendDataPrevMillis = millis();

    sensors.requestTemperatures();
    temp1 = sensors.getTempCByIndex(0);
    Serial.print("");

    tms.set(".sv", "timestamp");
    Serial.print("FIRST HEAP");
    Serial.println(ESP.getFreeHeap());
    firebaseData2.pauseFirebase(false);

    if (Firebase.getString(firebaseData2, "002/alarm")) {
      if (firebaseData2.dataType() == "string") {
        Serial.println(firebaseData2.stringData());
      }
    } else {
      Serial.println(firebaseData2.errorReason());
    }

    int myInt = firebaseData2.stringData().toInt();
    firebaseData2.clear();

    Serial.println("HEAP BEFORE SET");
    Serial.println(ESP.getFreeHeap());
    if (temp1 < myInt) {
      if (Firebase.setInt(firebaseData2, "/serial/sms", sms))
      {
        printResult(firebaseData2);
      }
      else {
        Serial.print(firebaseData2.errorReason());
      }
    }
    firebaseData2.clear();

    if (temp1 > myInt) {
      firebaseData2.clear();
      Serial.print("HEAP BEFORE SENDING MESSAGE");
      Serial.println(ESP.getFreeHeap());
      String response;
      bool success = twilio->send_message(
                       to_number,
                       from_number,
                       message_body,
                       response,
                       media_url
                     );
     if (!client.connect(host, httpsPort)) {
    Serial.println("- Connection failed.");
    char buf[200];
                int err = client.getLastSSLError(buf, 199);

                buf[199] = '\0';

                Serial.println("Last SSL error was:");

                Serial.println(buf);

                Serial.print("ERRCODE: ");
                Serial.println(err);
     }
    }
    else {
      firebaseData2.clear();
    }
    Serial.print("HEAP BEFORE PUSH");
    Serial.println(ESP.getFreeHeap());
    delay(0);
    arr.clear();
    arr.set("/[0]", temp1);
    arr.set("/[1]", tms);
    firebaseData2.pauseFirebase(false);
    if (Firebase.push(firebaseData2, path + "/Int", arr))
    {
      //      Serial.println("PASSED");
      //      Serial.println("PATH: " + firebaseData2.dataPath());
      //      Serial.println("TYPE: " + firebaseData2.dataType());
      //      Serial.print("VALUE: ");
      //      printResult(firebaseData2);
      //      Serial.println("------------------------------------");
      //      Serial.println();
    }
    else
    {
      //      Serial.println("FAILED");
      //      Serial.println("REASON: " + firebaseData2.errorReason());
      //      Serial.println("------------------------------------");
      //      Serial.println();
    }
    firebaseData2.pauseFirebase(true);
    firebaseData1.pauseFirebase(true);
    firebaseData1.clear();
    firebaseData2.clear();
    Serial.print("LAST HEAP");
    Serial.println(ESP.getFreeHeap());
  }
}

//Helper function for printing the response/received data
void printResult(FirebaseData &data)
{
  if (data.dataType() == "int")
    Serial.println(data.intData());
  else if (data.dataType() == "float")
    Serial.println(data.floatData(), 5);
  else if (data.dataType() == "double")
    printf("%.9lf\n", data.doubleData());
  else if (data.dataType() == "boolean")
    Serial.println(data.boolData() == 1 ? "true" : "false");
  else if (data.dataType() == "string")
    Serial.println(data.stringData());
  else if (data.dataType() == "json")
  {
    Serial.println();
    FirebaseJson &json = data.jsonObject();
    //Print all object data
    Serial.println("Pretty printed JSON data:");
    String jsonStr;
    json.toString(jsonStr, true);
    Serial.println(jsonStr);
    Serial.println();
    Serial.println("Iterate JSON data:");
    Serial.println();
    size_t len = json.iteratorBegin();
    String key, value = "";
    int type = 0;
    for (size_t i = 0; i < len; i++)
    {
      json.iteratorGet(i, type, key, value);
      Serial.print(i);
      Serial.print(", ");
      Serial.print("Type: ");
      Serial.print(type == FirebaseJson::JSON_OBJECT ? "object" : "array");
      if (type == FirebaseJson::JSON_OBJECT)
      {
        Serial.print(", Key: ");
        Serial.print(key);
      }
      Serial.print(", Value: ");
      Serial.println(value);
    }
    json.iteratorEnd();
  }
  else if (data.dataType() == "array")
  {
    Serial.println();
    //get array data from FirebaseData using FirebaseJsonArray object
    FirebaseJsonArray &arr = data.jsonArray();
    //Print all array values
    Serial.println("Pretty printed Array:");
    String arrStr;
    arr.toString(arrStr, true);
    Serial.println(arrStr);
    Serial.println();
    Serial.println("Iterate array values:");
    Serial.println();
    for (size_t i = 0; i < arr.size(); i++)
    {
      Serial.print(i);
      Serial.print(", Value: ");
      FirebaseJsonData &jsonData = data.jsonData();
      //Get the result data from FirebaseJsonArray object
      arr.get(jsonData, i);
      if (jsonData.typeNum == FirebaseJson::JSON_BOOL)
        Serial.println(jsonData.boolValue ? "true" : "false");
      else if (jsonData.typeNum == FirebaseJson::JSON_INT)
        Serial.println(jsonData.intValue);
      else if (jsonData.typeNum == FirebaseJson::JSON_FLOAT)
        Serial.println(jsonData.floatValue);
      else if (jsonData.typeNum == FirebaseJson::JSON_DOUBLE)
        printf("%.9lf\n", jsonData.doubleValue);
      else if (jsonData.typeNum == FirebaseJson::JSON_STRING ||
               jsonData.typeNum == FirebaseJson::JSON_NULL ||
               jsonData.typeNum == FirebaseJson::JSON_OBJECT ||
               jsonData.typeNum == FirebaseJson::JSON_ARRAY)
        Serial.println(jsonData.stringValue);
    }
  }
  else
  {
    Serial.println(data.payload());
  }
}
//Helper function for printing the response/received stream data
void printResult(StreamData &data)
{
  if (data.dataType() == "int")
    Serial.println(data.intData());
  else if (data.dataType() == "float")
    Serial.println(data.floatData(), 5);
  else if (data.dataType() == "double")
    printf("%.9lf\n", data.doubleData());
  else if (data.dataType() == "boolean")
    Serial.println(data.boolData() == 1 ? "true" : "false");
  else if (data.dataType() == "string" || data.dataType() == "null")
    Serial.println(data.stringData());
  else if (data.dataType() == "json")
  {
    Serial.println();
    FirebaseJson *json = data.jsonObjectPtr();
    //Print all object data
    Serial.println("Pretty printed JSON data:");
    String jsonStr;
    json->toString(jsonStr, true);
    Serial.println(jsonStr);
    Serial.println();
    Serial.println("Iterate JSON data:");
    Serial.println();
    size_t len = json->iteratorBegin();
    String key, value = "";
    int type = 0;
    for (size_t i = 0; i < len; i++)
    {
      json->iteratorGet(i, type, key, value);
      Serial.print(i);
      Serial.print(", ");
      Serial.print("Type: ");
      Serial.print(type == FirebaseJson::JSON_OBJECT ? "object" : "array");
      if (type == FirebaseJson::JSON_OBJECT)
      {
        Serial.print(", Key: ");
        Serial.print(key);
      }
      Serial.print(", Value: ");
      Serial.println(value);
    }
    json->iteratorEnd();
  }
  else if (data.dataType() == "array")
  {
    Serial.println();
    //get array data from FirebaseData using FirebaseJsonArray object
    FirebaseJsonArray *arr = data.jsonArrayPtr();
    //Print all array values
    Serial.println("Pretty printed Array:");
    String arrStr;
    arr->toString(arrStr, true);
    Serial.println(arrStr);
    Serial.println();
    Serial.println("Iterate array values:");
    Serial.println();
    for (size_t i = 0; i < arr->size(); i++)
    {
      Serial.print(i);
      Serial.print(", Value: ");
      FirebaseJsonData *jsonData = data.jsonDataPtr();
      //Get the result data from FirebaseJsonArray object
      arr->get(*jsonData, i);
      if (jsonData->typeNum == FirebaseJson::JSON_BOOL)
        Serial.println(jsonData->boolValue ? "true" : "false");
      else if (jsonData->typeNum == FirebaseJson::JSON_INT)
        Serial.println(jsonData->intValue);
      else if (jsonData->typeNum == FirebaseJson::JSON_FLOAT)
        Serial.println(jsonData->floatValue);
      else if (jsonData->typeNum == FirebaseJson::JSON_DOUBLE)
        printf("%.9lf\n", jsonData->doubleValue);
      else if (jsonData->typeNum == FirebaseJson::JSON_STRING ||
               jsonData->typeNum == FirebaseJson::JSON_NULL ||
               jsonData->typeNum == FirebaseJson::JSON_OBJECT ||
               jsonData->typeNum == FirebaseJson::JSON_ARRAY)
        Serial.println(jsonData->stringValue);
    }
  }
}

Thanks for your help in advance!


text:
Dual Channel Reading with 16 bit AD7705(SPI)
I want to read 2 separate voltage readings by AD7705 ADC and send the data to Arduino(Master). What is the correct program flow should I implement to get dual-channel operation working. How data will be sent to master when both the channels are converting the voltage.
Thanks in Advance.

the data would be sent one bit at a time, since the data path is serial ... it is unclear what you are asking

Correct flow? Switch to channel 1, perform conversion, read data... Same for the second channel. And repeat

"How data will be sent to master" is controlled by the master. That's why it is called master. What's your question/problem?

Thank you for your response. I understood.


text:
Arduino IDE on Attiny45: What kind of power does a chip need?
I have this little AtTiny45 which I'm loading a program with Arduino as ISP.
My goal to use this chip along with a op amp, a piezo buzzer and a press button, and have it automatically sleep between uses.
I intend to use 2 3V pill batteries in parallel (specifically CR2032 if this makes a difference) as the power source, so here are my two questions:

Can 2 3V pill batteries in parallel power a small application that will produce audible sound?
How long could these batteries last --based on constant use-- if someone used this item for an hour per day?

Thanks jsotola! I've updated the question to fit more the need as I was not as clear as necessary. It has a press button which will spark a sound for a short while then resume sleep.

Everything depends on used parts, and overall current consumption... For now it's just "it might or it might not" to almost every question you have

Assuming 5mA when on, one hour a day; 2µA when sleeping the rest of the time; I get around 40 days of runtime. But you can probably have the MCU sleep in between task during that 1 hour of usage. You might have to find a way to turn of the opamp when it's not needed, to keep the sleep current as low as possible. I'm unsure how much current a piezo uses, but I don't think it's much.

I guess one could provide current to an opamp through a transistor?

@Gerben I followed the link very useful! Thank you


text:
AMIS30543 - Library code | Order of pinDirection and pinOut
This piece of code was taken from AMIS30543- Arduino library,
void init(uint8_t slaveSelectPin) {
    ssPin = slaveSelectPin;
    digitalWrite(ssPin, HIGH);
    pinMode(ssPin, OUTPUT);
}

Facts I know

digitalWrite - makes the pin to the corresponding voltage level
pinMode - makes the pin either input or output
ssPin is active low pin usually.

So I was wondering before setting the pinDirection why the pin is made HIGH, Then immediately after that the pinDirection was declared as OUTPUT
Also I know , if a pin was made HIGH and on the next line if the direction of the same is set as  INPUT will bring the internal pull up resistor in action .
So what am I missing here. More over in Arduino does the order of pinMode/digitalWrite matter.? if So what is the meaning of this particular lines of code Github link to the library

The library is doing this to make sure, that the pin will never go low during initialization.
Imagine doing it the other way round:
pinMode(ssPin, OUTPUT);
digitalWrite(ssPin, HIGH);

If the corresponding PORT bit is set to zero (LOW) previously (which is also the standard after reset/power cycle), the pin will go LOW for a very short time, until digitalWrite() sets it HIGH again. That LOW time is short, but it might needlessly activate the slave. If you first use digitalWrite(ssPin, HIGH), you activate the internal pullup (as standard mode after reset/power cycle is INPUT) and set the corresponding PORT bit to 1. Thus, when you now change the pin mode, the pin is HIGH immediately, without ever going to LOW in between.
Internally the Arduino uses 3 SFRs (Special Function Registers), which are directly connected to the IO hardware of the pins. The DDR register of each port controls the "pin mode" aka direction of the pin (input or output). The PORT register controls the output value (HIGH or LOW; or turning the pullup resistor on or off in input mode). The PIN register reflects the current state of the pin (for reading it). In this case the double function of the PORT register is important, as it activates the internal pullup resistor, when set while in input mode.

This initialization will work with spi communication for PIC32 microchip too?