text:
Modifying normal doorbell to get notification
I'm really not used to Arduino and I would like to know if it would be possible to tweak my doorbell, most specifically the bell itself, to embed a small arduino that would be able to send a notification "somewhere" (well, if it can connect to wifi and send an HTTP request I can handle the rest).
I'm guessing that there will be electricity in the bell itself (to.. ring it I guess) so I could use that to power the Arduino.
My goal is definitelly not to create a "smart" doorbell but to upgrade a tiny bit the one we already have. My biggest problem is that when I am in the office, I can barely hear it and if I turn music on, it becomes impossible.
Before launching myself in this, I'd like to know if it is at all possible. I can (try to) provide more information if needed.
Thanks.
EDIT: I'm guessing that the bell rings when it gets an electric signal when the button at the door is pressed. My goal would be to hook up to that signal to get the arduino to send an HTTP request. Now, my arduino knowledge is very limited and I'd like to see if anyone could give a tiny bit of guidance on how to proceed (which one, which module, ...)
EDIT2: As requested, here is a picture of the bell part:
[![bell][1]][1]
In the center there is a copper coil so I would guess that when someone presses the button, the little hammer (pointy thing going up) hits the 2 metal plates (up and down). I could also see that there is a third cable (purple) hidden behind that is not currently used but I have no clue what it is for or if there is power at all on this thing...
EDIT3: I realized that I have a Friedland D780 on the fuse box (so right next to all the power I can need for an Arduino). It is unclear if I could get the pulse from here though. Anyone?
I can't upload a picture with my phone but I'll add it ASAP...
[1]: https://i.sstatic.net/pdgbs.jpg

In order to help some clue as to what your doorbell is would be helpful.
I have a system where I modified a standard doorbell's powered push button to send a signal via an ESP01 and WiFi to MQTT running on a Raspberry Pi but the permutations and methods are many.

I'm going to try and get more informations and photos

I added a photo in the question as requested.

Most doorbells use AC with a voltage of 8-24 Volt. This voltage is created by a transformer. Where I live this transformer is located in the fuseboard closet. This voltage goes to the bell, but is interrupted by the bell-button, until it's pressed. So to power your device you'd have to rectify the AC to DC, and then regulate the voltage to 5Volt of 3.3Volt. The problem is that you only get power while the button is pressed, so you'd need a way to store enough energy to make your HTTP request.

If you have a multimeter, I'd measure the voltage between the purple wire and the white/blue wires.

After checkin, there is indeed something in the fusebox closet. I'll try to get my hands on a multimeter and do more checks. I'll also look deeper in the fusebox to see what is attached there and if I could potentially modify that.

do you have constant power available to an MCU by the bell? if so, then it's trivial to use an optocoupler to pull a pin low when voltage comes on the coil.

Sorry for the late reply. It occured to me that I was maybe looking at it from the wrong angle. I looked at the fuse box and saw a Friedland D780. Could I get the pulse from there? I'll add a photo of it in the question

Many (most?) household doorbell systems in the US are powered by a simple transformer that converts 120V AC household electric supply to a lower voltage AC. Often 16V AC or 24V AC.
The coil and hammer form a device called a solenoid. When the coil is energized, the hammer (often also called a plunger) is forced in one direction, either up (against gravity) or against a return spring, striking one of the plates. When power is removed, gravity or the return spring pull the plunger back to the rest position, striking the other plate, forming the familiar ding-dong sound.
Power is applied or removed extremely simply -- by the momentary, normally-open pushbutton at your door. When you press the button, the solenoid is energized, and when you release it, the device returns to the normal state.
With regard to powering your Arduino, it is important to understand the difference between AC and DC power. The Arduino requires DC (direct-current) of either a regulated 5V DC into the 5V pin, or unregulated 7-12V DC into the VIN pin, or the regulated 5V DC from a USB device.
I don't know your level of electricity understanding, but there exists quite a bit of information on the difference between AC and DC power. Suffice it to say, you would need some additional circuit to rectify and filter and regulate the 16-24V AC into something between 5V and 12V DC.
Then, there is the issue of the loss of a good power tap while the button is pressed. If you measure the voltage across the contacts of the pushbutton while it is not pressed, you will likely find the full 16V AC or 24V AC, but if you measure those contacts while the button is pressed, you will read 0V AC. This means that tapping off of the pushbutton wires is not a good way to power a device that needs to remain on while reacting to the button press. Whether or not you could tap power off of the solenoid terminals is dependent on the voltage drop across the coil, and still you have the issue to convert the AC to DC at the proper voltage.
If this doorbell is near the ceiling, you will likely find the transformer mounted in the attic space above the ceiling near the doorbell (if there is attic space -- depending on your specific setup).  If there is a power outlet in this attic space, you could plug in a good quality AC-DC 5V adapter there to power the Arduino in the attic. The Arduino will need to remain electrically isolated from the doorbell circuit. To detect the pushbutton press, you could use a current transformer measuring the current flow through either of the 16V AC wires coming off of the transformer (measure with one of the the analog inputs of the Arduino), or with an Opto-isolator, with the transmitter connected to the doorbell circuit in a way that delivers a small current (10mA or so normally) to the transmitter side of the opto-isolator, and read the receiver side with a digital input pin on the Arduino.
Unfortunately, interfacing with a doorbell that uses AC power will require some good planning and evaluation of your doorbell system and how much additional circuitry you are willing to apply.
If you aren't careful, working near the transformer can be very dangerous to your life. Working with 16-24V AC will not be as dangerous to your life, but can easily damage the Arduino beyond repair in the flash of an eye. Take great care.

Much as I like Arduinos, it might be easier to just run a wire from your current doorbell to your office and add a 2nd doorbell, or a piezo buzzer that will run on AC. As others have said doorbells in the US are usually powered by AC, and that power is only available while the doorbell is actually ringing. You would need a constant source of power in order to drive your Arduino long enough to connect to a network and send a signal.
You might be able to build a circuit that rectified the AC power to DC and charged a capacitor, then used that capacitor to drive a DC power supply to the Arduino. The capacitor might hold a charge long enough for the Arduino to make a network connection and send a signal, but you'd need a fair amount of electronics knowledge to make that work.

Some of the piezo buzzers I've seen will run with a wide range of voltages, from 6 to 18. You could put a bridge rectifier on the AC in from the doorbell, then a simple voltage divider to drop the voltage from 24V to 12. Alternately you could use a 2:1 transformer to step down the 24VAC to 12VAC, then a bridge rectifier, and then the piezo buzzer.

If I could offer a different approach -- to maintain isolation between the doorbell AC and an Arduino, you could have the separately powered Arduino 'listen' for the sound of the gong. A cheap mic feeding an analog input does the trick. Mount it in the same housing to isolate it from household and other noises, or maybe tune it to respond to a narrow range of frequencies.
There are other non-contact, non-wired possibilities too -- sense the motion of the solenoid, or its electrical field, etc.


text:
Proto Threading 2 functions
I would like to proto thread two functions to run pseudo-simultaneously. One function takes the input of a force sensor and moves a servo accordingly, and the other takes the input of a gyroscope (MPU650) and moves a different sensor accordingly. Below is my code where I attempt to use timers to handle this.
#include <Wire.h>
#include <Servo.h>
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Servo.h"

int FSR_Pin = A0;
bool isClosed = false;
unsigned long lastMillis = 0;
unsigned long lastMillis2 = 0;

MPU6050 mpu;

int16_t ax, ay, az;
int16_t gx, gy, gz;

Servo handServo;

Servo wristServo;

int pos = 0;
int val;
int prevVal;

void setup(){
  Serial.begin(9600);
  handServo.attach(9);

  Wire.begin();
  Serial.begin(38400);

  Serial.println("Initialize MPU");
  mpu.initialize();
  Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");
  wristServo.attach(8);
}

void handleFingers () {
  int FSRReading = analogRead(FSR_Pin);
  Serial.println(FSRReading);

if (FSRReading > 9) {
 if (pos < 90) {
     handServo.write(pos);
      pos ++;
 }
  isClosed = true;

} else if (isClosed == true && FSRReading < 10) {
  pos = 0;
  handServo.write(pos);
  isClosed = false;
}
}

void handleWrist() {
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

    val = map(ay, -17000, 17000, 0, 179);
    if (val != prevVal)
    {
        wristServo.write(val);
        prevVal = val;
    }

}

void loop(){
  if (millis() - lastMillis > 1000) {
    handleFingers ();
  }
   lastMillis = millis();

 if (millis() - lastMillis2 > 1000) {
    handleWrist();
  }
   lastMillis2 = millis();

}

When I run the code above, the servos move a few degrees each and then do nothing at all. It appears that none of the servos are responsive to the sensor feedback. Something is wrong with my timing or my method of proto threading. I would really appreciate your help, thanks.

Update the previousMillis (lastMillis and lastMillis2) inside the loop with the interval. When enough time has passed the code is executed and the previousMillis will be updated for the next interval. See: https://www.arduino.cc/en/Tutorial/BlinkWithoutDelay

note: your code formatting (indentation) is inconsistent throughout the code.

Jot provided the answer in a comment: you are updating lastMillis in
the wrong place. The correct way is:
if (millis() - lastMillis >= 1000) {
    handleFingers();
    lastMillis = millis();
}

Optionally, you can use lastMillis += 1000 instead of
lastMillis = millis() if you want to precisely control the average
(rather than minimum) update period.
Just to elaborate a bit, the idiom I like for doing this kind of stuff
is as follows:
const unsigned long FINGER_UPDATE_PERIOD = 1000;
const unsigned long WRIST_UPDATE_PERIOD  = 1000;

void loop() {
    unsigned long now = millis();

    // Handle the fingers.
    static unsigned long last_finger_update;
    if (now - last_finger_update >= FINGER_UPDATE_PERIOD) {
        last_finger_update = now;
        handleFingers();
    }

    // Handle the wrist.
    static unsigned long last_wrist_update;
    if (now - last_wrist_update >= WRIST_UPDATE_PERIOD) {
        last_wrist_update = now;
        handleWrist();
    }
}

Note that:

The update periods are constants defined at the top of the
program.
millis() only needs to be called once per loop iteration: if the
loop takes many milliseconds to run you would be doing something
wrong anyway.
last_finger_update and last_wrist_update stand for lastMillis
and lastMillis2, which are very poor naming choices.
These two variables are local to loop(), as they are not needed
anywhere else.
These variables are also declared static, which means they are
implicitly initialized to 0 and they preserve their values from call
to call.
I update the timing variables before doing the actual work. This
helps keeping all the timing code together, which makes the code
clearer, especially if the actual work takes many lines of code (e.g.
you do the work inline instead of having it in separate functions).

Some people prefer using libraries for this kind of proto-threading. If
you use the ArduinoThread library, the same could be written as:
const unsigned long FINGER_UPDATE_PERIOD = 1000;
const unsigned long WRIST_UPDATE_PERIOD  = 1000;

Thread updateFingers(handleFingers, FINGER_UPDATE_PERIOD);
Thread updateWrist(handleWrist, WRIST_UPDATE_PERIOD);
StaticThreadController<2> scheduler(&updateFingers, &updateWrist);

void loop() {
    scheduler.run();
}

source: Stack Exchange

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

sort: votes


text:
Arduino - Playing WAV files with a buzzer
I have developed an Arduino program that plays a WAV file from the SD card using a speaker.
This is the circuit schematic

The sketch I'm using is based on TMRpcm library and PWM output
#include <TMRpcm.h>
#include <SD.h>
#include <SPI.h>
int sdpin=10;
TMRpcm tmrpcm;

void setup()
{
    Serial.begin(9600);
    pinMode(sdpin, OUTPUT);
    tmrpcm.speakerPin=9;
    tmrpcm.setVolume(3);
    SD.begin();
}

void loop()
{
    if(Serial.available()>0)
    {
        String data=Serial.readString();
        if(data=="pause")
        {
            if(tmrpcm.isPlaying()==1)
            {
                tmrpcm.pause();
            }
        }
        else if(data=="stop")
        {
            if(tmrpcm.isPlaying()==1)
            {
                tmrpcm.stopPlayback();
            }
        }
        else
        {
            String path="/Music/"+data;
            if(tmrpcm.isPlaying()==1)
            {
                tmrpcm.stopPlayback();
            }
            tmrpcm.play(path.c_str());
        }
    }
}

At first I could play the music with the speaker but then it stopped working and because I don't have enough skill to make one myself, I would like to know if I can use a buzzer for that.
I know that buzzers can be used to generate melody using the tone() function but I'm not sure if I can use them to play wav files using PWM output.
Any help will be appreciated.

I don't have enough skill to make one myself ... skill to make what?  .... the speaker stopped working probably because the output pin on the Arduino blew out

you forgot to ask a question

When driving a passive buzzer, you should always have the signal output from the Arduino go to a transistor tied between the ground and the (-) negative side of the buzzer. Also, if you use a regular NPN transistor, you should also have a small resistor between the Arduino and the transistor base.

The transistor is providing two functions; it's potentially amplifying the signal (if the (+) positive side of the buzzer is at a higher voltage than the Arduino) and it's also isolating (partially) that voltage from the Arduino. This helps save pins!
The resistor is to limit the current going through the transistor and helps keep both your Arduino and the transistor healthy. Voltage thrills, current kills and resistors limit current. If you use a MOSFET you want to change this from a low-ohm series resistor to a high-ohm pull-down resistor -- 4.75K or 10K is fine. A MOSFET is much higher impedance than an NPN transistor and should not be left floating.
Additionally, you want to add a diode between the (+) and (-) terminals on the buzzer. This may be the most important part of the circuit! When oscillating, the buzzer (whether magnetic or piezo) acts like an inductor and will accumulate a charge over time. This will be heard as a slowly diminishing volume from the buzzer. This charge will eventually overcome the protection diodes built into the GPIO pin (or any transistor) and destroy it! The diode blocks that charge loop and saves your chips.

There are different kinds of buzzers. The simplest one is just a piezoelectric transducer in a plastic casing. You can drive it directly by an arduino pin since its impedance is high. It will work fairly well for high frequencies, but don't expect any bass from it.
Another type of buzzer is a piezoelectric transducer connected to a simple oscillator circuit that will generate a waveform with a frequency typically between 1 and 4 kHz. This type of buzzer most likely won't work since the signal produced by your Arduino will be used to power the oscillator circuit rather than drive the piezoelectric transducer.
Please note that the pin you used to drive the speaker is possibly no longer operational. The impedance of the speaker was likely low enough to draw more current than what the pin of the microcontroller is rated for which probably caused damage to it. A non-piezoelectric speaker should never be connected to an Arduino without an amplifier in between.

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


text:
Powering Arduino Pro Mini with different voltage, fuse setting
Arduino Pro Mini commonly comes in two packages, 5V 16MHz and 3.3V 8MHz.

The only difference between those two boards are regulator and clock crystal, right?
What happens if I supply 2V to VCC pin of 5V 16MHz board?
What happens if I supply 2V to RAW pin of 5V 16MHz board?
What happens if I supply 5V to VCC pin of 3.3V 8MHz board?
What happens if I supply 5V to RAW pin of 3.3V 8MHz board?

I read from some websites stating that Arduino Pro Mini power consumption can be reduced by removing regulator.

Does removing regulator cause VCC pin = RAW pin?

Jean created a custom board for Arduino Pro Mini rated at 1MHz 1.8V.

Which pin should I supply voltage after changing fuse setting? (Jean changed the fuse setting but I am not sure where to connect the supply voltage of 1.8V)
Related to question 7, is there a need to remove regulator to supply 1.8V?
Can I supply higher voltage (3V) on board with 1.8V fuse setting?

Reason for question/ Confusion
I want to power Arduino Pro Mini using 3V coin cell. Battery voltage decreases after usage to around 2V. I am thinking of simply inserting 3V coin cell to Arduino with 1.8V setting. But regulator may hinder the operation. That is why I am confused. Sites I visited states the possibility of using lower voltage after changing fuse setting but did not mention where to connect and whether regulator need to be removed.
Furthermore, ATmega328p datasheet states the VCC range is 1.8V to 5.5V. If that is so, why not just plug those voltage to VCC pin of Arduino Pro Mini instead of specifically 5V or 3.3V. Question 1-5 should clear my confusion on this.

Read the datasheet once more. A certain voltage is needed for a certain clock frequency. There is a graph somewhere.
Since the Atmega328p is able to run up to 5.5V for VCC, that 5.5V is for every clock frequency.
Using 2V for VCC is not enough to run it at 16MHz. According to the datasheet even 3.3V is not enough. But 3.3V and 16MHz will work (it is outside the specifications though).
The RAW pin is the voltage before the voltage regulator, right ? Depending on the voltage regulator you can apply a large range of voltage.
See the pinout.
When you remove the voltage regulator, the RAW pin is open. Sometimes I remove the voltage regulator and use 3 AA batteries and feed the 4.5V into the VCC (or 5V pin) of a 8MHz ATmega328p board.

Yes. The bootloader and sketch have to know the clock frequency. A sketch compiled for 8MHz is for a 8MHz Arduino board and a sketch compiled for 16MHz is for a 16MHz Arduino board.
2V is too low. 3.3V should work.
2V is too low. 3.3V depends on the voltage regulator.
No problem. The voltage regulator gets a reverse voltage.
No problem.
No. See the schematic.
To VCC.
Not a "must", but it is highly preferred to remove the voltage regulator, so no current is leaking towards the voltage regulator which gets a reverse voltage.
Yes. The fuses are to lower/disable the BOD, so a higher voltage is no problem.

This is the best tutorial about the power of the Atmega328p : Nick Gammon about Power
ADDED
I forgot to mention to remove the led as well.
This is a Pro Mini with a coin cell.
Lowering the clock speed will make it run at lower voltages, but that will not always reduce the used energy. Doing a calculation at a slow speed takes more time than the same calculation at high speed (and going into sleep mode after that).
ADDED 2
When a low voltage is supplied (for example 2V to a 5V 16MHz Arduino board), the voltage regulator will not work. How much current/voltage is still passed on depends on the voltage regulator. With the BOD disabled, and the microcontroller runs below its required voltage, anything weird can happen. Parts of the chip will work and parts will not. That is why the BOD was invented in the first place (to reset the chip and avoid weird things to happen). I think it is very unlikely that the microcontroller will get damaged with a (too) low voltage.

so if i want to supply 2.5~3V to Arduino Pro Mini, I'll have to reduce the clock frequency and remove the regulator, correct?

Yes, that is correct. For testing your sketch, you don't have to desolder the voltage regulator right now. Just use VCC and ignore the leakage current to the voltage regulator.

Thank you for the clarification. One last question. What happens if i feed a lower voltage on a regulated Arduino? i.e feeding 2v on 5V regulator (assuming clock frequency is ok). will it stress the battery or voltage regulator or arduino?
Edit - okay. that answered my last question. thanks

I have added a ADDED section. Someone uses a coin cell. I prefer three AA batteries. No stress with a lower voltage to the regulator. I will not work, that's all.

ADDED 2 section added.

Can't use three AA as size matter in my project. Otherwise, I could have used li-ion and step up to 5V for easier usage. ADDED 2 well answered my question. More things to read (BOD and gammon tutorial). yay

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


text:
How does ESP8266 work as web server with Arduino?
I am trying to learn internet of things with smart home. I will connect an ESP8266 and an Arduino with the IBM Bluemix server to control a circuit from a public IP.
I want to start with the local network for now. I have gone through a couple of links which seem like a great start http://allaboutee.com/2014/12/30/esp8266-and-arduino-webserver/
They explain how it works, and have source code but no circuit diagram. How should I connect the ESP8266 with Arduino for this example ?

#include <SoftwareSerial.h>

const byte rxPin = 2; // Wire this to Tx Pin of ESP8266
const byte txPin = 3; // Wire this to Rx Pin of ESP8266

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial esp8266(rxPin,txPin);

void setup() {
  Serial.begin(9600);
  esp8266.begin(9600);
  delay(1000);
}

void loop() {
  Serial.println("Sending an AT commands");
  esp8266.println("AT");
  delay(30);
  while(esp8266.available()) {
    String data = esp8266.readStringUntil('\n');
    Serial.println("Got response from esp8266: " + data);
  }
}

The exact same way as any other ESP8266 example. The fact that you are using it as a web server doesn't change how you wire it.
For that specific code snippet it even tells you in the comments:
// make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3

In case of ESP8266 act as web server, can we connect TX/RS of ESP8200 to any digital pins of arduino ?

Like I said: the fact you're using it as a web server makes absolutely no difference to how you wire it. It's using SoftwareSerial. SoftwareSerial will work on any pins. Take your pick.

I have this code https://pastebin.com/1miy33ne but esp is not sending a message as this condition while(esp8266.available()) { always fails

I have added my pictorial representation of my project in question

How about power? How about ground? How about the other pins that are required to make the ESP8266 work? Every single Arduino tutorial for the ESP8266 shows you those.

I see. Thanks for giving hint. Lemme try :)

Another hint: Do a google image search for "ESP8266 Arduino". You will get thousands of pictures showing you how to wire it.

Yup, trying to do same..


text:
How to determine Flash size?
I need to determine the flash size of my ESP8266 on my NodeMCU module in order to flash the AT firmware onto the board. Apparently different boards come with differently-sized flash memories. Can anyone tell me the easiest way to find the flash size?

By reading the manual for your NodeMCU. Which version is it?

It's Version 1.0

The version 1.0 uses the ESP-12E which has 4MB flash.

esptool.py -p COM5 -c esp8266 flash_id (you can find esptool inside ESP-IDF SDK components/esptool_py)

use ESP.getFlashChipRealSize()  in your code.

Arduino's ESP8266 support includes an example sketch called CheckFlashConfig. This probes the board, and prints the flash memory size.

The easiest way (windows at least) is to use Espressif's flash download tool - don't select anything to flash to the device, select the appropriate com port, click start, and the details of the device will appear in the Detected Info window

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


text:
Pattern detection in sensor data
I'm using a heart rate sensor along with an Arduino for a project of mine. I have to determine whether the heartbeat is following a particular pattern (eg: when when heartbeat regularizes a lot after a period of increased or largely varying, I need to trigger an alarm to show that it has regularized).
Can anyone give me suggestions on how I can go about doing this? Are there any libraries or software for doing basic statistical analysis on data like this?

I think you might be better looking at 'generic' C or C++ libraries for stats and then porting them to an Arduino.  Not sure how complete the Maths lib is on Arduinso though

Seems like you only need to calculate the BMP, or beat per minute. Measure the time between e.g. 5 beats. Then divide 300000 (5601000) by this time in milliseconds. You use the average of 5 beats to get a more stable number.

This Arduino topic is an over-simplification and not very robust, but it presents in code the basic principle of threshold detection and the subtraction of adjacent pulse times (period).  BPM = 60.0 / period in seconds.
If you want something that would work under a larger range of conditions, you can add the three primary missing features used by medical instrumentation.

Automated zeroing, which can be accomplished with an analog filter and pull-up or with a digital high pass filter that attenuates frequencies below 0.3 Hz.  This can be done with a series capacitor leading to the analog input being sampled, with a pull up resistor to V+ and another resistor to ground to center the Voltage to an appropriate positive steady state value.
Attenuation of frequencies above those representing a pulse to avoid false triggers from high frequency noise, cross-talk, or transients, which can be accomplished with an analog filter or with a higher sample rate and a digital low pass filter that attenuates frequencies above 100 Hz 1.
Dynamic range compression, which detects the trend in pulse amplitude and continuously adapts the trigger threshold accordingly to avoid false indication of beats or the missing of weaker but legitimate beats.

To do the filtering digitally, you may want to read up on DSP (digital signal processing).  There are several great books on it, and you can search for simple algorithms for both low pass filters and high pass filters in GitHub or elsewhere in the open source community.

[1] Wikipedia's article on low pass filters

Great answer! I would add that the first thing to do is to get a few sample waveforms from the same hardware setup in order to test the algorithms and choose the parameters (e.g. cutoff frequencies) on the computer, before porting to the Arduino.


text:
Where to connect BLK and GRN pins of Openlog board on my Uno?
I have the following SD card reader on the left side from Sparkfun. In the tutorial they have it connected directly into an Arduino Mini, which has BLK and GRN pins> I would like to connect it to an Arduino UNO. Where do I connect these pins or can I ignore them? Thanks for your help.

This must be one of the weirdest connection diagrams ever. If you flipped one of the boards over, none of the wires would cross. This is by design, as you are supposed to physically plug one into the other.

If you read the page about the OpenLog board you can see (on the schematic link) what the pins mean:

I've added the labelling on the board in blue.  The GRN pin (DTR in the schematic) is actually an input, which resets the chip:

Thus:

GRN should be connected to RESET on your Uno, so that when you reset the Uno, you rest the OpenLog.
TXO (transmit out) on the OpenLog would be connected to serial input on the Uno (ie. digital pin D0 - labelled RX).
RXI (receive input) on the OpenLog would be connected to serial output on the Uno (ie. digital pin D1 - labelled TX).
You can see that GND and BLK are both ground pins, and thus should be connected to ground.
VCC (RAW on their schematic) is the voltage input to the 3.3V very-low-dropout voltage regulator MIC5205 on the OpenLog. This will accept input voltages in the range 3.3V to 12V. (The datasheet seems to suggest a maximum of 16V, but it might get rather hot if you did that). Connecting VCC to +5V on the Uno would be satisfactory.

It quite simple and stupid that they named the pins with those name. You simply connect:
BLK > ground
GRN > RESET
The weird pin abreviations can cause quite a bit of confusion.
Extra links for help.

Your link is to a guide for connecting an Arduino and an FTDI, which is not what this is.  The correct guide is at https://learn.sparkfun.com/tutorials/openlog-hookup-guide and while it is unclear if it will matter in practice the official recommendation (ie, from the people who designed the openlog) is different from yours.

Well, Its written at the bottom of my link what BLK and GRN means. Well I think the issue is resolved so yeah. You are welcome to write your own anwser.

"Its written at the bottom of my link what BLK and GRN means" again, your link is not about the board in question.  If you go by your link, GRN is an output but on the board this question is actually about, GRN is an input.


text:
Subtraction with doubles returning zero erroneously
I have a function that takes as parameter some doubles and does a subtraction operation on it. However I'm getting a result of 0 when one of the parameter is 0 for some reason.
int calcPID(double current, double desired, double k){
  double diff;
  diff = desired - current;
  Serial.print("desired = ");
  Serial.print(desired);
  Serial.print(", current = ");
  Serial.print(current);
  Serial.print(", diff = ");
  Serial.println(diff);
  int r = (int)diff;
  return r;
}

Output
desired = 250.00, current = 1.69, diff = 248.31
desired = 250.00, current = 0.00, diff = 0.00

When the current is 0.00 the result (diff) is also 0.00, when it should be 250. Can someone tell me what's going on?

I can't reproduce that.
int calcPID(double current, double desired, double k) {
  double diff;
  diff = desired - current;
  Serial.print("desired = ");
  Serial.print(desired);
  Serial.print(", current = ");
  Serial.print(current);
  Serial.print(", diff = ");
  Serial.println(diff);
  int r = (int)diff;
  return r;
}

void setup ()
{
  Serial.begin (115200);
  Serial.println ();
  calcPID (1.69, 250, 42);
  calcPID (0, 250, 42);
}  // end of setup

void loop ()
{
}  // end of loop

That gives expected output of:
desired = 250.00, current = 1.69, diff = 248.31
desired = 250.00, current = 0.00, diff = 250.00

I strongly suspect you are passing NaN (not a number) or Inf (infinity) instead of zero. If you add another test line like this:
 calcPID (1.0 / 0, 250, 42);

Then you get the result:
desired = 250.00, current = inf, diff = inf

Now I know you reported getting zero, but earlier versions of the IDE printed 0 for NaN or Inf. I suggested a change to the way the libraries handle that which has been implemented in more recent versions.
Here, for example.

If this doesn't answer your question, please post a Minimal, Complete, and Verifiable example - like I did above.

I think NaN is probably it because when I compare current > 1 and current <= 1 both came out to false.

dang it i was such a poopoohead before now i get it thnx

You are not providing the input values in the correct type:
calcPID(0.00, 250, 0.0);

will return 0, while
calcPID(0.00, 250.0, 0.0);

will return 250
UPDATE
Here you can get a working test case: it's running on a different processor, so don't expect to behave exactly as the 8bit MCU at Arduino's core.

Is this based on a test, or a source-code reading, or what?  What's the name of the library .cpp and .h files you looked at?  How do you account for implicit type conversion not occurring?

@jwpat7 I didn't look at any library, I just looked at the above code and the only viable option I was able to find is if the OP is expecting type conversion to occur in C as if it was Java. When I posted my answer there was only the calcPID function reported, but now, looking at the updated example I'm more convinced about my answer, so much I updated it with a test.

@Roberto Lo Giacco The difference is, that on Arduino (IDE) are headers for *.ino done before standard C++ compilation
#include <stdio.h> // on *.ino it is done in IDE hidden way
int calcPID(double current, double desired, double k) ; // forward definition, for *.ino it is done in Arduino IDE hidden way
int main()
{
    calcPID (1.69, 250, 42);
    calcPID (0, 250, 42);
    calcPID (0.0, 250.0, 42);
    return 0;
}

int calcPID(double current, double desired, double k) {
  double diff;
  diff = desired - current;
  printf("desired = %5.2f, current = %5.2f, diff = %5.2f, true = %i\n", desired, current, diff, diff > 0);
  int r = (int)diff;
  printf("desired = %5.2f, current = %5.2f, diff = %i, true = %i\n", desired, current, r, r > 0);
  return r;
}

This compiles and executes on your machine well a gives correct result same as @Nick Gammon have.
Without the definition int calcPID(double current, double desired, double k) ; standard C assumes definition with ints and makes different conversions, which leads to your "incorrect" result. So the result depends on forward definition, which Arduino does behind scene. But for *.cpp and *.h it may be different, so it would be interesting, how bakalolo organized his code.


text:
How to break connection HM10 Bluetooth?
I have 2 HM10 Bluetooth modules connected to 2 Arduino Teensy running the following code.
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);
  // If the baudrate of the HM-10 module has been updated,
  // you may need to change 9600 by another value
  // Once you have found the correct baudrate,
  // you can update it using AT+BAUDx command
  // e.g. AT+BAUD0 for 9600 bauds
}

void loop() {
  char c;
  if (Serial.available()) {
    c = Serial.read();
    Serial1.println(c);
  }
  if (Serial1.available()) {
    c = Serial1.read();
    Serial.print(c);
  }
}

By pairing them using the AT commands I was able to send messages back and forth by writing to Serial1. However now when I try to send AT commands it will just send the string to the other module instead of replying OK etc. How do I break the connection and make the AT commands work again?
The tutorial I used to pair the modules.

Give us the final set of commands you sent to the Bluetooth modules to get them to pair and then forward your input to each other.

I'm voting to close this question as off-topic because it is about the command set of the HM10 module, not Arduino.

I'd say this is something you only encounter on Arduinos (Serial.println(), Arduino Teensy and etc.) so I think this suits Arduino SE. Neither can I think of a better SE community to answer this question.

To Break Connection via BT Commands, I do the following (programmatically):
command 1: AT
command 2: AT+IMME1
When the BT is in Work Mode it does not recognize regular BT commands.  The exception to this is the AT command by itself. But, it must be followed by another command (#2) within the Supervision Timeout Period which is fairly quick. IMME1 takes the BT back to AT Mode where it is no longer connected and will recognize your AT[+...] commands. If the Save Setting is enabled, it will attempt auto-reconnect too quickly...

I was able to break the connection with:
AT
The data sheet says to use AT+PWRM1, but it didn't work for me. Instead the above command dropped the connection to the remote device.
From the Datasheet:

Execute “AT+PWRM1” command, Module will auto into sleep mode when
power on or disconnect from remote device.

Somehow I ended up in such an endless auto-reconnect loop after activating AT+ROLE1 without setting AT+IMME1 first. Nothing seemed to help, not even pulling PIO0 low for 1s. I still don't even know which device my HM-10 was connecting to. It just autoconnected to something on boot...
The only way I could find to break out of this endless loop  was using this sketch below. The trick was that I had to wait for "OK" response after "AT" before issuing the follow-up command "AT+RENEW" to restore factory settings.
#include <SoftwareSerial.h>

SoftwareSerial BTserial(8, 9);

void waitForOK()
{
  while (!BTserial.available());

  char c = BTserial.read();
  Serial.write(c);
  c = BTserial.read();
  Serial.write(c);
}

void setup()
{
  Serial.begin(9600);
  BTserial.begin(115200); // fw v700 changed default to 115200, otherwise use 9600
  Serial.println("BTserial started at 115200");

  BTserial.write("AT");
  waitForOK();
  BTserial.write("AT+RENEW");
  waitForOK();
  BTserial.write("AT+IMME1");
  waitForOK();
}

From the device datasheet:
System KEY function (PIO0) if Low > 1000ms:
7.3.1 If Module is in sleep mode Module will wake up immediately, if AT+NOTI value is “1”, module will send “OK+WAKE” string through UART.
7.3.2 If Module has already connected to remote device Module will disconnect from remote device.
7.3.3 If Module is standby mode Module will reset to default configuration. Then restart.


text:
How to stop loop in the serial monitor?
I want to make a serial program with input from the serial monitor and show each character with its binary and ASCII codes.
At the end of the program, I want to show the whole message sent from the serial monitor but I don't know how to stop the loop. Can someone help me please?
Here's my program:
String dataST;

void setup() {
  Serial.begin(9600);
  Serial.println("Message sent by serial monitor : ");
}

void loop() {
  for (int i = 0; i < 400 ; i++) {
    if (Serial.available()) {
      char dataOK = Serial.read();
      dataST += dataOK;
      Serial.print(dataOK);
      Serial.print(" = ");
      delay(200);
      for (int i = 7; i >= 0; i--) {
        byte bytes = bitRead(dataOK, i);
        Serial.print(bytes, BIN);
      }
      Serial.print(" = ");
      int dataAS = dataOK;
      Serial.print(dataAS);
      Serial.println(" ");
      Serial.println(" ");
    }
  }
  Serial.println("Message : ");
  Serial.print(dataST);
  dataST = "";
}

The result from the program above is:
Message sent by serial monitor :
Message :
Message :
Message :

And the result I want is:
Message sent by serial monitor:
H = 01001000 = 72

e = 01100101 = 101

y = 01111001 = 121

Message :
Hey

Please help me.

Please take a look at the documentation of SerialEvent.
This might be exactly what you are looking for (after several small tweaks)
Code from the example:
/*
  Serial Event example

  When new serial data arrives, this sketch adds it to a String.
  When a newline is received, the loop prints the string and clears it.

  A good test for this is to try it with a GPS receiver that sends out
  NMEA 0183 sentences.

  NOTE: The serialEvent() feature is not available on the Leonardo, Micro, or
  other ATmega32U4 based boards.

  created 9 May 2011
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/SerialEvent
*/

String inputString = "";         // a String to hold incoming data
bool stringComplete = false;  // whether the string is complete

void setup() {
  // initialize serial:
  Serial.begin(9600);
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

void loop() {
  // print the string when a newline arrives:
  if (stringComplete) {
    Serial.println(inputString);
    // clear the string:
    inputString = "";
    stringComplete = false;
  }
}

/*
  SerialEvent occurs whenever a new data comes in the hardware serial RX. This
  routine is run between each time loop() runs, so using delay inside loop can
  delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag so the main loop can
    // do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

An embedded system is never meant to stop. If/when your loop() function exits (returns), it will be immediately called again.
If you need a process that runs to some state of completion and than stops, you're better off to leave loop() empty and write your own function that does what you need it to do, and call it at the end of setup().
You can either put an infinite loop at the bottom of your function:
for(;;);

is one way to do it, or just let it return to setup(). Then setup() will exit, your empty loop() function will be called (infinitely), which accomplishes the same thing.

Or sleep (most of the time)?


text:
ATTINY85 and POT
I need to read a potentiometer value from an ATTINY85.
I have big fat 10K POT but for this use case I need it to be very small so I used a salvaged 2.4K one, the kind that is soldered directly onto a PCB.
I am using tinkercad to prototype my project and I am facing a very weird problem. Everytime I read from the POT Pin, I get the value of 512 (using the debugger)
Here is a screenshot of my prototype:

The goal is to power the circuit and the lamp (does not matter what is there, consider it just a load) with a 9V battery, use a 5V regulator to power the ATTINY85 and use an NPN transistor to turn the lamp/load on or off.
For information, the whole regulator and transistor setup is tested and works like a charm.
Here is the code I wrote for the this case:
void setup()
{
  pinMode(PB0, INPUT);
}

int potValue = 0;

void loop()
{
  potValue = analogRead(PB0);
  delay(100);
}

Not real fancy right?
Now no matter what use for the POT, and I tried 2.4K, 10K and up to 100K, the value read by the ATTINY is always 512.
Do you see something wrong in this setup?
Could it be a bug in tinkercad? (I'd be surprised though)
I could try and share this circuit within tinkercad if someone would be willing to have a look...
EDIT: I just tried with PB2 as suggested but not the value is always 58:

Since you never display the reading from the pot, how do you know what it is?   Try printing it.

Port PB0 is not an ADC pin on the ATTiny85. Choose PB2, PB3, PB4 or PB5.

I know the value of the pot reading because tinkercad has a debugger

I'll try another pin straight away

I see you have a wire bridging the ground on one side of your breadboard to the other side. Don't you also need to bridge the +5V rail between sides of the breadboard? (in addition to using an analog pin.)

@DuncanC no as the input from the top rail is 9v and I use the 5v regulator to power the lower rail and the ATTINY85. Ground is common however

Note that you would need a resistor on the base of the NPN transistor.

Why do you think you need a smaller value pot? The resistance of the pot makes almost no difference to the readings the Arduino makes. It only has an effect when you go to very large (>1MΩ) values. By reducing to a smaller number all you're doing is wasting power.

When I way that I need a smaller POT I meant that the physical object needs to be smaller than the 10K one I have as I need to have an end result as small as possible, no relationship to the POT resistance at all, sorry for the confusion

Here it does not make a difference, but the PXn notation is no the same as a pin number, which gets used by Arduino functions. PB1 will be defined as 1, because it is the second bit in the registers for Port B (start counting from 0). So on a bigger microcontroller PC1 will also be 1. Pin numbers are different and on the Attiny85 just happen to be the same (because of the low pin number)

Did you see the comment of Edgar Bonet? You need a resistor at the base of the transistor. You must limit the current through the base in order not to destroy the transistor or the ATTINY.  If I had to switch a load with an ATTINY I would use a MOSFET because they have a very high  input impedance (resistance) on the gate (base) pin. So the ATTINY pin won't be stressed. ;-)

I indeed saw the comment and actually used a resistor in my real life circuit. However I read that the resistor is mainly used to control the output value. So I kind of fail to understand how/why it is that could destroy either part. FYI I used a 1k resistor, no clue if that's enough. I looked through the documentation on my transistor but did not managed to find the info

@GeorgesLegros The transistor is like a diode between the base and the emitter. That means, that the current through it rises exponentially with the voltage. It can esaily exceed the max current of 20mA (and also the absolute maximum of 40mA) and thus destroy the digitial output hardware of that pin. A resistor reduces that current, so that is does not get blown. With 20mA max and 5V you could use 5V/20mA=250 Ohm to be safe, even, when the transistor would be shorted. Raise the value as you like, be careful with lower values.

Thanks for the explanation, it makes more sense now. In my circuit I am switching a 9v input with the transistor, does that mean I should then have a minimum value of 450 Ohm for that resistor? In other words, should I base that calculation on the ATTINY and thus the pin or on the current I am switching?

Port PB0 is not an ADC (analog input) pin on the ATTiny85.
Available pins of the ATTiny85 (from the Atmel ATtiny 25, 45, 85 datasheet):
Choose PB2, PB3, PB4 or PB5 if you need an analog input.
Additional information: When built in TinkerCAD, using PB2 as an analog input does not seem to work correctly and produces a fixed value. Using PB3 did work correctly however. This might be a bug in TinkerCAD.

Just tried and I get another weird fixed value: 58...

I edited the question so I could upload a picture of the new setup using PB2 and the debugger output

Just for fun, I built the same circuit (but simplified) in TinkerCAD and strangely enough I could not get it to work with PB2, but PB3 did work. I guess this is a bug in TinkerCAD. I haven't used it before until today but I'm pretty sure I've built it correctly.

Indeed, it works like a charm with PB3! Thanks! Can you add this comment to your answer so I can accept it (I guess it is clearer for future references)

I've added the comment to my answer.

I tried PB5 on tinkercad and it just getting "random" values event if I don't touch the POT. I shall send an email to the support just to let them know. However, do you confirm that it "should" work ok PB2? I'll do some tests on my breadboard to validate. Problem is that the real use case is actually making use of PB3 already...

PB5 is probably preconfigured as a RESET pin so I'm not sure it's wise to use it for anything other than that. I am not too familiar with the Analog part of the ATtiny's but I do know that (just like other AVRs) there's only a single A/D converter that the 4 analog inputs are connected to via an analog multiplexer and it should not make a difference what input pin is used (as long as it is not used for anything else).

That image can be a bit confusing if you don't know what to look for. Look at the pins that have ADC0, ADC1, ADC2, ADC3 next to them. As is Analog to Digital Converter <number>.

Just made another test and it seems like PB4 is also creating a problem as I get the same randomness as I was having with PB5 (RESET). I opened a support ticket with Tinkercad, looking forward to the answer, will keep you posted.


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

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

How can i fix it?

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

add the sketch to the question

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

I have added the code as an answer below..

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

the sketch is not for esp8266

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

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

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

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

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

I connected cs pin in arducam to D0 in nodemcu


text:
HC-02 Bluetooth module not visible
I am trying to connect to my robot car with the HC-02 module. The problem is that the module is visible on my phone only while the arduino uno board is connected to my laptop. At this point I can pair my phone with the module, but I can't controll the car. When I disconnect the car from my laptop and turn it on, HC-02 is not visible anymore. It's blinking fast which means it should be available for connecting. I cant access the AT mode and I don't know what to do anymore. Has anyone had problems with this.
My phone is Android, I also tried with another one and still not working.
I also removed arduino uno from the car, I connected only the Bluetooth module. I can see HC-02 when Arduino is connected to the PC with the USB cable. But when I disconnect it from the PC and power it with the battery it disappears from available devices.

can you share your code and schematic here.

I added the code. I also explained it a little more

Try another serial using SOFTWARE Serial Library for ardunio for HC-02. Then connect arduino to your laptop and try to control your car and attach your full code here. Copy Paste you code here.

I tried with your solution and it works, thanks. There is obviously problem with the RX0 and TX1 pins.


text:
Sharing serial output from one to many arduinos (plus a computer) via USB hub
I am trying to send rotary encoder output from an UNO to seven Trinket M0s and a computer via a (powered) USB hub.

Currently the UNO → Laptop bit works great, serial monitoring works via the hub for everyone and I'm able to get a master/slave connection going between the UNO and a Trinket via Arduino's Wire library. But Wire uses pins, and I haven't had any luck finding a similar solution for USB. Thus far, the best leads seem to be around using something like stty in a bash script to listen for what each port is up to but I'm so far in over my head at this point that that might just be wishful thinking.
I'm not looking for a solution here, just some suggestions as to where to head next. Specifically:

Is the Wire library useful for USB communication?  Is there something similar (master/slave-wise) that would be helpful?
Assuming the serial/listen thing works, are there good ways to re-route data to different ports? Currently my best guess is something like $ echo $encoderVal > /dev/cu.usbmodem????? to each one individually ... but that might be a completely noobish notion.)
i2c keeps on coming up in searches, but looks like overkill. Is that a direction to head?
Is this all completely nuts?

Anyways, thanks to everyone in advance.
Update
Ok! Thanks to the advice of @Gerben and @chrisl I ended up routing everything around with PySerial, and (for the extremely limited purposes of this little project) it works well! Here's what is currently working:
import serial
from time import sleep
import os

# Connect to each Arduino individually
serialUno = serial.Serial("/dev/cu.usbmodem141101", 9600, timeout=0)
serialTrinket1 = serial.Serial("/dev/cu.usbmodem1414401", 9600, timeout=0)
# (+ 6 more. serialTrinket2, serialTrinket3, etc)

# Open a text file to save the encoder value in
f = open("encoderVal.txt", "w")

while True:
  # Read encoderVal from the UNO
  data = serialUno.read(9999)
  if len(data) > 0:

    # Send data to each trinket
    serialTrinket1.write(data)

    # Save val to text file to Unity
    with open('encoderVal.txt', 'r+') as f:

      # Wipe the file so it's only the most recent value
      f.truncate()
      dataStripped = data.strip()

      # Return the last int in the data stream
      dataSplit = dataStripped.split('\n')
      f.write(dataSplit[-1])

  sleep(0.05)

# Close serial connections & file on interrupt
serialUno.close()
serialTrinket1.close()
f.close()

As for the laptop end of the equation, I abandoned the serial library that I had been using in favor of this Unity-to-Python tool, which works perfectly.
The only issue thus far is that PySerial loses the occasional few bytes here and there, which outputs a wonky number ever 30 or so. That'll be tomorrow's project.  Thanks everyone for your help!

Why not using Serial (UART) for this? You can connect one transmitter board (the Uno in this case) to multiple receiver boards ( the Trinkets)

I'd use something like Python on the PC, to connect to all the serial ports of the UNO and Trinkets. Have the Python code parse the incoming data (i.e. rotary encoder position), and send it to those boards that need that data. Or even simpler. Read incoming serial data, and send it to all available serial ports (kind of like a repeater). The only thing I don't understand is why you even have a PC in your setup. What's its use? Using something other that USB, means you could run the whole system without the PC attached.

@chrisl Ok, but would that not be adding extra complexity? (First search brought up Emulating UART over USB which gets us to virtual COM ports and ... more.

@Gerben That seems like a solid plan. I'll start researching serial & python.  Re: your question, the PC has to be there because the serial input from the rotary encoder is running a Unity game (the whole HDMI side of this not in the diagram.)

Is the Wire library useful for USB communication? Is there something similar (master/slave-wise) that would be helpful?

The Wire library does I2C communication, which has absolutely nothing to do with USB. Actually the USB connection on the Uno is not native. The Atmega328P on the Uno only has a Serial (UART) interface, which is onboard connected to another chip (Atmega82U or others), which has native USB support. That chip will do the USB communication. The driver on the PC will then emulate a Serial COM port, so that it is something like a "Serial COM port over USB" connection. USB is complex and you should not tinker with it directly, unless you are very advanced in this direction. And I don't think, doing that would help you here.

Assuming the serial/listen thing works, are there good ways to re-route data to different ports? Currently my best guess is something like $ echo $encoderVal > /dev/cu.usbmodem????? to each one individually ... but that might be a completely noobish notion.)

Since you have a complete Unity game, you have to program something in that direction. Using the bash seems not good here. I don't know, if you can communicate with serial COM ports from Unity (since I haven't worked with it yet), but doing this in Python works like a charm. There are many tutorials out there, that show how to do it.

i2c keeps on coming up in searches, but looks like overkill. Is that a direction to head?

If that is an overkill depends on your exact requirements for the system. Sure, the I2C protocol has a bit of overhead, but maybe you need the functionality.

Is this all completely nuts?

Currently it seems a bit like that. I think, this due to you not having a good structure for the project. To help you with that, I will explain some possibilities below.

As I understood, you have the following setup: The Uno has a rotary encoder, that controls a game on the PC. All boards (Uno and Trinkets) have one LED strip, that should light up depending on what happens in the game.
You have now 2 basic structures for the communication:

Doing everything over an own USB connection. This is what you sketched above. Every board has it's own serial COM port (which actually get's emulated over USB by the driver) on the PC and your game/program on it has to connect to all these and send the appropriate data. Sure this is a possible design, but it comes with downsides: Currently it doesn't seem, that you already have implemented the communication program. That is important in this design, but that's not really about Arduino and depends on how you are programming the game in Unity (haven't done that before and don't know how to connect a serial device to it. Maybe through a python script). The second problem is, that you will have choose the serial port for every board, when you start the game. The port numbers/names are not always the same; it's up to the operating system to set these. That's not a great usablity.
You can use other communication interfaces between the boards directly. In this case only the Uno would be connected via USB to the PC and every data would go through the Uno. What kind of interface you should use depends on your exact requirements. Since you didn't specify them in detail, I will explain some examples:

Every Trinket get's the exact same data and nothing must be read from them: In this case you can use the Serial (UART) interface. It uses the pins, that are marked with RX (receiving pin) and TX (transmitting pin). Normally this connection is only between 2 boards, but it is possible to simply connect multiple receivers (with their RX pin) to exactly 1 transmitter (with it's TX pin).
The Uno has one hardware Serial interface, which is also used to communicate with the PC. If it is OK, that the PC also get's the data, which is meant for the Trinkets, (and the Trinkets get the data, that are meant for the PC) you can use this interface and wire the Uno's TX to all Trinket RX pins. You can google how to read data from the interface with the Serial library, which is directly available with Arduino. If you don't want the PC to get the same data, you can set up a SoftwareSerial interface (with the library with that name). That provides the same interface, but is handled in software, because the Uno doesn't have another hardware Serial (UART) interface.
In both cases you would transmit the data from the PC (data out of the game) via the USB serial port to the Uno, which then in turn sends it further to all the Trinket boards. They read the data and act accordingly. Everytime the Uno senses new rotary encoder positions, it will send data to the PC.
For connected the Uno with a Trinket, you only need 2 wires in this design (1 for Uno TX to Trinket RX and 1 ground wire). Of course, you also would have to provide power to the Trinkets. Please see below for that matter.
Every Trinket can be address individually and data can also be read from them: In this case I2C can be the way to go. For the communication you need at least 3 wires (SDA, SCL and ground). Every Trinket joins the I2C bus with a configured address. The Uno acts as master on the bus. He can call a Trinket by it's address and send or request data. The I2C protocol is more structured than serial (UART), because it is divided into transmissions. This works great, if the Trinkets can all get different data, and if you also want to read data from them. Be sure to give very Trinket a unique address on the bus. For the program part look into the Wire library.
Individual sending and receiving in a very fast manner: If you need the individual data transmitting and reading from I2C, but you also need the communication to be very fast, you can use SPI. The SPI bus doesn't use addresses, but Slave Select pins. You need 1 pin on the master (Uno) for every slave device. If you want to communicate with one Trinket, you pull it's Slave Select pin to LOW. This bus needs 5 wires (MISO, MOSI, SCK, Slave Select and ground), but the communication can be very fast; way faster than I2C. Look into the SPI libary for the programming of this.

Providing power: Depending on your design and the number and type of the LEDs, you have to look into, how you supply the needed power to the boards. In the design, that you sketched above, (every board directly to USB) the boards themselves should have enough power, but LED strips can be very power hungry, getting fast to currents over 1A. The pinout of Adafruits Trinket M0 shows a maximal current of 500mA from the Vusb pin. The 5V pin of the Uno can handle about 200mA (as I remember, currently not sure. You can google this).
If you choose a design with only the Uno connected to USB, you might need an extra power supply, so that you can provide the power for all Trinkets and their LEDs with it. Please adhere to the current limits of the components, or you may fry your boards.
I hope, that help's. Have fun

Thanks for putting all the time in to this answer. As you'll see I ended up with a far hackier solution than you'd probably advise, but hey, it kinda works!

First, read a bit about USB, it is an entire protocol, not just a hardware/pin based interface. It is actually quite involved. Then it will be clearer to you why a USB (from the Nano) solution will be... difficult.
Based on my understanding, I would use your #2 idea and what has been suggested, and do the following...

Setup the Uno as a USB slave, not a master.
Using the PC, connect to the Uno and the Trinkets.
When the PC gets data from the Uno have the PC "repeat" it to the Trinkets.

I think this will be the easiest and quickest solution.


text:
nRF24L01 not communicating
I have been using two nRF24L01 to communicate with each other using a simple Arduino Uno Board. It worked for 5 days and now all of a sudden it is now working. I tried to change the modules and the Arduino boards too, but even if trying a simple example the communication between them is not happening.
I googled everything and tried every option, it is not working.
I used printDetails() to check the config of the modules. It shows everything is ok but I am not able to understand if the transmitter or the receiver is the problem. Please guide me to solve this problem. Also how to make sure if both are working (any debugging technique)?
I have been trying it for 9 days now, and I badly want it to work.
The code I am using is very simple code. It doesn't have any errors.
Receiver code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CNS, CE
String response;
boolean done = false;

void setup() {
  delay(500);
  Serial.begin(9600);
  radio.begin();
  radio.setPALevel(RF24_PA_MIN);
  radio.openReadingPipe(0,0xF0F0F0F0AA);
  radio.startListening();
}

void loop() {
  if (radio.available()) {
    radio.read(&response, sizeof(response));
    done = true;
  }
  if (done) {
    Serial.println(response);
  }
  done = false;
  delay(1000);
}

Sender code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CNS, CE
String request;

void setup() {
  delay(500);
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(0xF0F0F0F0AA);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop() {
  while (Serial.available() > 0) {
    request = Serial.readString();
    Serial.println(request);
    radio.write(&request, sizeof(request));
    delay(1000);
  }
}

You have to edit this question and include the printDetails() output here too, you saying "everything is ok" isn't enough.

You cannot use the String class here. You should use a char[ ] . The & operator and sizeof operator when used against a String object refer to the object handle.

Hello,
You need to set a channel to both NRF:
void setup() {
   delay(500);
   Serial.begin(9600);
   radio.begin();
   radio.setChannel(0x55); //set the channel
   radio.openWritingPipe(0xF0F0F0F0AA);
   radio.setPALevel(RF24_PA_MIN);
   radio.stopListening();
   radio.powerUp(); //Power up the radio
}

Change this.
void loop() {
    if (radio.available()) {
        radio.read(&response, sizeof(response));
        done = true;
    }
    if (done) {
        Serial.println(response);
        done = false;
    }
    //done = false;
    delay(1000);
}

Maybe you should check your power supply. If it worked for 5 days, then it should be ok with your boards and module. If it don't work anymore it could be broken board, broken module or power supply.


text:
Delay a part of the void loop
I have two different programs written for my Arduino. One checks the room temperature every 5 seconds. The other one looks for IR remote signals.
I would love to combine those 2 programs, yet the problem is the delay from the room temperature sketch.
If I would combine them. it means my IR script won't be working for a full 5 seconds (because of the delay of the room temperature script) then it will be able to receive a fraction of a second and then the temperature sketch goes again.
#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int led = 12;
const int inPin = 0;

void setup() {
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  int value = analogRead(inPin);
  float millivolts = (value / 1024.0 ) * 5000;
  float celsius = millivolts / 10;
  Serial.println(celsius, 1);
  delay(5000);
  if(irrecv.decode(&results)) {
    //this checks to see if a code has been received
    if(results.value == 0xFF6897) {
      //if the button press equals the hex value 0xC284
        digitalWrite(led, HIGH);
        // turn the LED on (HIGH is the voltage level)
        delay(1000); // wait for a second
        digitalWrite(led, LOW);
        // turn the LED off by making the voltage LOW
        delay(1000); // wait for a second//do something useful here
    }
    irrecv.resume(); //receive the next value
  }
}

Does anyone know how to keep the IR part active and the temperature measure every 5 seconds, and do this simultaneously?
Or do I need another Arduino?

Take a look at the BlinkWithoutDelay example bundled with the IDE. It shows you exactly what you need to know.

that was kinda what I was looking it is not working flawless yet, but I think it will work Thank you!

does anyone know how to keep ...

think about ways to conditionalize execution on time elapsed. I showed a short while ago ways to construct a software timer and you may want to look into that.


text:
Arduino emits signal A (infrared) but another Arduino receives everything but A (IR-LED problem)
Situation: I was trying to make a simple Arduino program that mimics my TV-Remote ON-OFF button.
Diagnosis: It just won't work. So just to check I grabbed another Arduino (2) and added my IR-Sensor to that one and let it look for the signals sent by Arduino (1).
Conclusion: Even though I ran exactly the same program in a loop sending IR signals, Arduino (2) noticed each time another IR signal. The received signals didn't even look like the IR signal I sent.

The program I use to mimic my remote: Link to the Github. It is an example of a Lib
It could be the LED. Just a LED I picked up without being specific. Link to the Documentation of the LED

You should use an oscilloscope or logic analyzer to examine what you are actually sending from your program and compare that with what you think you are sending.

Sorry not enough rep to comment. Had to answer instead.
So if your schematic is correct then you just fried your LED. You need a series resistor between vcc and the LED.
If it's not accurate and you have the resistor in place, I'd check the LED anyway, it could be a dud. Apply voltage with a resistor and look at it with your cell/mobile phone digital camera, you should see it through the camera glow dimly.
If all is good then it might be the wavelength of the LED, which is 850nm. Most IR LED's I've used are 950nm, actually they all were.
Now I don't know what the specs of your receiver are but it might be out of its sensing (is that a word?) range, also it only has a 20° viewing angle, so check the alignment of transmitter and receiver.
I'm also confused by your statement that your getting signals that don't look like IR. This makes me wonder if your sensor is hooked up properly. It could be background IR or from another source. Look around the room or test elsewhere.

My answer assumes there is no issue with the sketch. Could you post your sketch. How did you verify that the Arduino/IR LED actually sent a signal?

I will upload my sketch when I get home. I did check if it glows with my phone, and it does. "How did you verify that the Arduino/IR LED actually sent a signal?" I used my phone for that and another arduino which has a IR reciever. (I know for sure that the reciever is working because I made lots of consistent recordings of my TV-remote. :)


text:
How to reset ESP8266 wifi module
I have programmed ESP8266 to make it accessible over the network using below program.
First Program
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

//SSID and Password of your wifi router
const char* ssid = "Moto";
const char* password = "reset1234";

ESP8266WebServer server(80);

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

  WiFi.begin(ssid, password);     //Connect to your WiFi router
  Serial.println("");

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

  //If connection successful show IP address in serial monitor
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //IP address assigned to your ESP

  server.begin();                  //Start server
  Serial.println("HTTP server started");
}

void loop() {
  server.handleClient();          //Handle client requests
}

It is working fine, What is the way to reset it to run below program? I wanted to send AT commands on serial monitor using below program which has been uploaded successfully but not responding AT commands on Serial Monitor, as ESP8266 is running above program and showing output of above program on running below program on Serial Monitor.
I want to reset ESP8266 so it responds to below program. What is the way ?
Connected to Moto
IP address: 192.168.43.115
HTTP server started

SecondProgram
#include "SoftwareSerial.h"

SoftwareSerial esp8266(2, 3); // RX, TX

void setup()
{
  Serial.begin(9600); // serial port used for debugging
  esp8266.begin(9600);  // your ESP's baud rate might be different
}

void loop()
{
  if(esp8266.available())  // check if the ESP is sending a message
  {
    while(esp8266.available())
    {
      char c = esp8266.read();  // read the next character.

      Serial.write(c);  // writes data to the serial monitor
    }
  }

  if(Serial.available())
  {
    delay(10);  // wait to let all the input command in the serial buffer
    Serial.write("Hello");
    // read the input command in a string
    String cmd = "";
    while(Serial.available())
    {
      cmd += (char)Serial.read();
    }
    // send to the esp8266
    esp8266.println(cmd);
  }
}

You need to reinstall the AI Thinker AT firmware.
Here's how you do it: How to flash ESP8266 firmware update ESP-01 AI thinker
Last time I did it I used the esptool.py program, and used the ai-thinker-0.9.5.2.bin firmware (there's two versions on there, the default 115200 baud, and a 9600 baud variant).
On Linux I then used the command:
foo@bar:~$ ./esptool.py --port /dev/ttyUSB0 --baud 57600 write_flash 0 ai-thinker-0.9.5.2.bin
Connecting....
Detecting chip type... ESP8266
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 512KB
Flash params set to 0x0000
Compressed 520192 bytes to 165297...
Wrote 520192 bytes (165297 compressed) at 0x00000000 in 29.0 seconds (effective 143.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...

This was, of course, with GPIO0 held LOW for programming mode (I actually use an adaptor with a programming switch that controls GPIO0), and for other operating systems you will need to change the port name to suit (COM3:, /dev/cu.usbmodem4873, etc).

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

Comments are ephemeral. Lengthy explanations should be merged into the answer (including graphics) rather than being in comments.

//reset settings - in case of trouble just put in your code
//wifiManager.resetSettings();

That`s all you need

If you had formatted your code correctly, your answer may have made more sense.

ESP.restart(); //done


text:
AT command is not responding on serial monitor
I am trying to send AT commands to ESP8266. I re-flashed ESP8266 https://i.sstatic.net/z0hoc.jpg I followed this tutorial http://remotexy.com/en/help/esp8266-firmware-update/ and I hope it re-flashed successfully as there was no error.
When I uploaded this program http://www.pastebin.com/frhZY7tD I am trying to run AT command at 9600 baud rate on serial monitor then no response..
Below is how my circuit looks like

#include "SoftwareSerial.h"

SoftwareSerial esp8266(2, 3); // RX, TX

void setup()
{
  Serial.begin(9600); // serial port used for debugging
  esp8266.begin(9600);  // your ESP's baud rate might be different
}

void loop()
{
  if(esp8266.available())  // check if the ESP is sending a message
  {
    while(esp8266.available())
    {
      char c = esp8266.read();  // read the next character.

      Serial.write(c);  // writes data to the serial monitor
    }
  }

  if(Serial.available())
  {
    delay(10);  // wait to let all the input command in the serial buffer
    // read the input command in a string
    String cmd = "";
    while(Serial.available())
    {
      cmd += (char)Serial.read();
    }
    // send to the esp8266
    esp8266.println(cmd);
  }
}

Trying to execute AT command -

On clicking on send button then it shows empty response like below -

When I unplug power wire and plug it back then it prints some garbled message on serial monitor. I checked voltage on RX also, it was around 3.5V that seems also OK.

I am facing this issue after I flashed WiFi firmware to ESP8266 then back AT firmware. It seems that AT firmware was not flashed successfully so I tried to erase everything using below command.

esptool.py --port /dev/ttyUSB0 erase_flash

C:\Users\williams>esptool.py --port COM4 -b 9600 erase_flash
esptool.py v1.3
Connecting...................

A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for pack
et header

Before execute above command, I made changes in my circuit like below :-

Update
I have re-flashed ESP8266 on 115200 baud rate, and uploaded empty program then it started to respond AT commands. I connected as like above only change is TX to TX and RX to RX respectively. Alright!
AT

OK
AT

OK
AT+GMR

AT version:0.50.0.0(Sep 18 2015 20:55:38)
SDK version:1.4.0
compile time:Sep 18 2015 21:46:52
OK

Well, I want to send AT commands from the Arduino serial monitor window to ESP8266 and print ESP8266 response to the command. When I upload above program then it stops to respond, same result as like empty screen this is weird. Isn't ?

Comments on the question are for clarifying the question - not answering it. If you have an answer please post it.

The ESP's AT firmware is probably configured for a higher baud rate, 115200 is typical. SoftwareSerial only works reliably up to 9600 baud. It can transmit "reliably enough" at 115200 for you to blindly send change-baud commands, though the ESP's response will probably be garbled. So you need to either: Reduce the ESP's baud rate or use the Uno's hardware serial port for the ESP, which means giving up the Uno's terminal output and makes it a pain to reconnect your PC each time you need to update the Uno's code. I've described the process of changing the ESP's baud-rate in more detail in
this answer.
Update: I'm not familiar with various AT comand-interpreter revs; my ESPs are all running with the firmware rev came on them; "AT+GMR" (show version info) replies:
AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04

There is no AT+CIOBAUD command listed in my ESP8266 AT Instruction Set document rev 1.5.3). The only one listed that affects baud rate - and the one I  use - is:
AT+UART_DEF=<baud>,<databits>,<stopbits>,<parity>,<flowcontrol>

, or:
AT+UART_DEF=9600,8,1,0,0

for 9600 baud, 8 bits, 1 stop-bit, no parity, no flow control. You probably know, but just in case, note that you will lose communication immediately after you change the ESP's baud rate, until you then change the local baud rate to match.
Update2:

This is program pastebin.com/dquCNYJj I am not sure what wrong I am
  doing

That code sets SoftwareSerial to 115200 baud; it can not run fast enough to receive data at that speed.
Update 3:
Since you've updated the ESP's firmware unsuccessfully, it's hard or impossible to know what's going on. The output in your screenshot looks rather like the result of a baud mismatch between the ESP and your terminal. You need to get a clean firmware update to the ESP before you can expect it to respond correctly and rely on its output to diagnose any other problems.
Update 4:
I'm not sure if we're talking about the same thing so please forgive me if you already know this; we might be talking about (at least) three different baud-rates:

The rate in use during flashing of new firmware to the ESP;
The default rate that new firmware will start listening at, whenever it is booted;
The actual rate used at any given time between the ESP with its new firmware and the Arduino or some other device external to the ESP.

My own experience is with using the factory-installed AT Interpreter firmware. I have never needed to update it so I don't have personal experience with (1).
(2) and (3) are programmable by the Arduino. When I first use a new ESP (or after you've just re-flashed its AT Interpreter), it will listen at a factory-default baud rate (mine have all defaulted to 115200). There are commands to change the current rate (not saved across a reboot) and/or the default baud (saved for all future sessions).
I almost always change its default rate to 9600 to use it with an Arduino software serial port. This is my initialization for a new device, using an Arduino to talk to the ESP. (Don't transmit my '#...' comments):
# Start talking at the ESP's default rate (115200 on my factory-fresh ones).
AT+RST                         # Reset
AT+UART_DEF=9600,8,1,0,0       # Default baud to 9600,N,8,1,no flow ctl
# Here, change the Arduino's port to match: 9600 in this case.
AT+CWMODE=1                    # Station mode (client)
ATE0                           # Command echo off

From now on, the ESP will wake up listening at 9600 baud, in Station Mode as a client, with no command echo.

I tried to change baud rate, first in my program then build then upload then same baud rate on serial monitor. For example esp8266.begin(115200);  then compile then upload it then 115200 on serial monitor then executed lot of commands AT+CIOBAUD=9600 then no response simply empty everytime. I repeated same process with 9600, 38400, 57600, 74880, 115200 and on sending any command on serial monitor, it does not give any response only empty everytime

can you suggest stable AT firmware for ESP8266 which runs on 9600 baud rate ? I think it is some issue with AT firmware, installed it like C:\Users\williams>esptool.py --port COM5 --baud 57600 write_flash 0 ai-thinker- 0.9.5.2.bin

I executed suggested command but in no response, empty response :( This is my ESP8266 flash settings http://imgur.com/a/scfty

This is program https://pastebin.com/dquCNYJj I am not sure what wrong I am doing

I have updated my question and added more detail. Please see

I have tried multiple times, by keeping same baud rate in ESP and terminal and tried different baud rate but no luck now I am trying to erase ESP8266 firmware using this command esptool.py --port COM4 -b 9600 erase_flash but getting an error `esptool.py v1.3
Connecting...................
A fatal error occurred: Failed to connect to ESP8266: Timed out waiting for pack
et header`

Even though If you see this https://imgur.com/a/J8Ueh I re-flashed ESP at 9600 baud rate

The rate during flashing isn't what's important here - the rates used by the Arduino and the ESP during communication is. They have to be made to match (if they don't already) when you run that firmware start a communication session with the Arduino.

Yes it is same. Some kinda when I made changes in my code like esp8266.begin(9600); then I kept same baud rate on serial monitor also, in this case 9600.

Thanks JRobert. It worked as @Rahul Rastogi suggested. It is working on 115200 baud rate, I simply uploaded empty program. When I am running my program which is in question then it is not working as it is not responding AT commands. I connected my circuit as like in the question. Do you have an idea why it is so ? Isn't this program is to send commands to ESP8266 and read a response of ESP8266 and print it on Serial Monito

Yes, that code is a "terminal program" for an ESP on pins 2 &3. Please update your question with this information: What started working? What doesn't work, i.e. what did you do; what did you expect would happen; what happened instead?

I have updated my question. Could you please see

On your last picture, you should connect the Rx of your Arduino to the Tx of your ESP8266 and vice versa.
If you did that and it doesn't work, try to upload an example sketch in order to determine if it's the code or the connexions that are problematic.
I recommend that you use the WiFiScan example, since that example doesn't require to change the code or to include other libraries othet than the ones from ESP8266Community.

SoftwareSerial esp8266(2, 3); // RX, TX - Doesn't this line manages own ? or Do I need to use RX/TX of Arduino ?

Try this:
/*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.

 The circuit:
 * RX is digital pin 2 (connect to TX of other device)
 * TX is digital pin 3 (connect to RX of other device)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo and Micro support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example

 This example code is in the public domain.

 */
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
  // mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Explain why this code solves the problem.

Is it possible that this is a hardware connection issue? According to the datasheet of the ESP8266, it states that the maximum voltage input is 3.6V, but by connecting directly to the Arduino, the signal output by Arduino would be more than 3.6V. (Around 5V output)

Instead of connecting directly, you might want to perform Level shifting first? (5V to 3.3V, vice versa)
(Here's the link to the ESP8266 datasheet: https://nurdspace.nl/images/e/e0/ESP8266_Specifications_English.pdf)

I have 3.6V on RX of ESP8266, I checked with multimeter. I made using some resistors as well I tried with 2xAA batteries but same kinda of issue and provided around 3.6 V to ESP8266 but no luck.

Have you tried sending the AT Commands via a USB-UART adapter instead?

I tried to connect with using putty + USB-UART, it didn't work

First of all, Please check if you are giving proper voltage and current both to ESP8266. I've seen it not working if it doesn't get proper voltage and current.
Secondly, Connect your Rx,Tx of ESP8266 to Rx,Tx of Arduino respectively. Then, try doing one thing, just upload empty sketch having empty setup() and loop() function only.
Then, open serial monitor select your baud rate (mostly either 9600 or 115200) and you are all done! Sending "AT" via serial monitor input field will show you "OK" in serial monitor response window.

It worked as you suggested. It is working on 115200 baud rate. When I am running my program which is in question then it is not working. I connected my circuit as like in the question. Do you have an idea why it is so ? Isn't this program is to send commands to ESP8266 and read a response of ESP8266 and print it on Serial Monitor

I have updated my question, please check it

Ok.. let me understand! You said, It worked as you suggested. So, it worked on 9600 baud rate but not on 115200 baud rate?

It worked on 115200 baud rate, when I run empty program. When I follow steps which is in my question and on same baud rate then it does not work

authors: Игорь Ворончихин


text:
Issues while making ESP8266 as web server
I have programmed ESP8266 with below program. I used USB to TTL convert to program ESP8266. This is how I wired my circuit:
USB TTL---------------- ESP8266 ESP-01
GND-----------------------GND
TX---------------------------RX
RX---------------------------TX
3.3V-----------------------VCC & CH_PD
GND------------GPIO0
#include <ESP8266WiFi.h>

const char* ssid = "shiv";//type your ssid
const char* password = "manmohan@12345";//type your password

WiFiServer server(80);

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

  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");

}

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();

  // Match the request

  int value = LOW;
  if (request.indexOf("/LED=ON") != -1) {
    value = HIGH;
  }
  if (request.indexOf("/LED=OFF") != -1){
    value = LOW;
  }

  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("");

  client.print("Led pin is now: ");

  if(value == HIGH) {
    client.print("On");
  } else {
    client.print("Off");
  }
  client.println("

");
  client.println("Click here turn the LED on pin 2 ON
");
  client.println("Click here turn the LED on pin 2 OFF
");
  client.println("");

  delay(1);
  Serial.println("Client disonnected");
  Serial.println("");

}

It was successful, here are the logs:
Archiving built core (caching) in: C:\Users\williams~1\AppData\Local\Temp\arduino_cache_375631\core\core_esp8266_esp8266_generic_CpuFrequency_80,FlashFreq_40,FlashMode_dio,UploadSpeed_115200,FlashSize_512K64,ResetMethod_ck,Debug_Disabled,DebugLevel_None_____feb0d75f3cf4e05271af4f91549cd009.a
Sketch uses 230073 bytes (52%) of program storage space. Maximum is 434160 bytes.
Global variables use 32376 bytes (39%) of dynamic memory, leaving 49544 bytes for local variables. Maximum is 81920 bytes.
Uploading 234224 bytes from C:\Users\williams~1\AppData\Local\Temp\arduino_build_189179/sketch_may14d.ino.bin to flash at 0x00000000
................................................................................ [ 34% ]
................................................................................ [ 69% ]
.....................................................................            [ 100% ]

Once this was completed, I opened serial monitor and it was empty there, baud rate was 115200. It is weird, Isn't ?
I followed this tutorial https://create.arduino.cc/projecthub/ROBINTHOMAS/esp8266-esp-01-webserver-7248ca and on serial monitor it should be like below snapshot. What wrong I am doing ? Can anyone help me.

Tying GPIO0 to ground puts the ESP into programming mode, allowing you to flash it.  To actually run the code, pull it high - that is, disconnect it from ground and connect a resistor (about 10k) between GPIO0 and +3.3v.
Do the same with RST.

I disconnected GPIO0 to ground, then restarted Arduino software then selected port COM5 then open serial monitor then still same result .. here is my settings http://imgur.com/a/kT4kS

Here is serial monitor snapshot http://imgur.com/a/T4tXg

You might need to pull it high, as I explained in the answer. You might also need to pull RST high in the same way.

Thanks! I resolved it by connecting with Arduino, it worked :) +1

Could you explain what you did please, for my interest and for future reference?

I have posted an answer how I resolved it

Thanks @Mark Smith. I used UART to flash new firmware to ESP8266. I connected Arduino and ESP8266 in this way to test ESP8266 new firmware:
Arduino ---------------- ESP8266 ESP-01
GND-----------------------GND
TX---------------------------TX
RX---------------------------RX
3.3V-----------------------VCC & CH_PD
Then I opened Serial Monitor on 115200 baud rate and it started to work as expected. Cheers!