text:
Yun UBoot Prompt Not Showing
I have a Geeetech Iduino Yun Shield. I accidentally flashed the wrong firmware image (not the sysupgrade) to the board. I then tried using the Yun UBoot Reflash method. However, when I open the console monitor from the IDE and restart/reboot the board, I do not get the UBoot prompt. I have attempted to run it at least ten times without receiving any console/serial output.
EDIT: The shield is running on a Leonardo base board.
Is there anything I can do to load the correct firmware onto the board and get it operational or is the board truly bricked? If so, is it possible to obtain a new Atheros AR9331 board to replace the existing one or should I buy a new Yun?
Update: I have tried to get the shield to do an FTP boot, as detailed here by Majenko. I get to the stage where I get the dr_boot> prompt. However, when I type in tftpboot 0x81000000 dragino2-yun-common-v2.0.6-kernel.bin, I get no feedback; it just sits there indefinitely (unless I interupt the process). I can't figure out what I'm doing wrong.

What board is the shield plugged into?

I'm voting to close this question as off-topic because it is about OpenWRT embedded Linux on an AR9331, not Arduino.  TFTPBOOT is a complicated process - you need wired Ethernet connected, need to set up the network details, need to be running a server with the proper image, etc - you need to seek help with this in an OpenWRT forum, not here.   Another option is to hold the ar91k processor in reset and use a tool to re-write the SPI flash chip.

@ChrisStratton Can it not be argued that while the question is to do to the OpenWRT embedded Linux on an AR9331, that happens to be the chip/system used on an Arduino shield, thus making it tangentially relevant and (partially) on topic to Arduino, rather than specific to OpenWRT and an AR9331, therefore completely off-topic? Is there a SE site that would be a better fit for the question?
I'm not stating that your reasoning for closing is flat-out wrong, just that it seems somewhat restrictive/hair-splitting.

The point is that this has nothing to do with the Arduino ecosystem, and everything to do with OpenWRT - the simple solution didn't work according to your comments, so you really need to dig into the OpenWRT documentation from primary OpenWRT sources, rather than depend on the tiny trickle of 3rd hand information that might make it here.  The shield you are working with right now is not an Arduino of any sort - you may be able to plug it into one, but the Arduino has nothing to do with the issue and would be best not connected during this Linux system image repair.

The shield is very different to the real Yun when it comes to serial communication.
Typically the Atheros's UART is mapped to pins 0/1 of the shield for communication with the board it is plugged in to. Those pins are also the pins you use to communicate with the PC, so the normal YunSerialTerminal sketch can't be used.
Instead you will have to lift those pins out of the socket they go into (depending on the shield you may just be able to bend them slightly) and then manually connect them (along with ground) to an external USB to UART adaptor (e.g., FT232) to use for the communication.  Nothing needs to be installed into the Arduino board since that is now just being used as a power supply.
See this answer for which pins to use to run the shield stand-alone.

Thanks; I'll give it a try. Just to clarify that I understand your answer; the base board needn't have the Yun Serial sketch, but it should be loaded onto the shield through the separate UART. (I'm assuming that the shield has a AT Mega chip as found on the Leonardo.)

No, nothing needs loading anywhere. You just plug things together and connect to your USB to UART cable with a terminal program (maybe the serial console). If you have a suitable external power supply you can even do away with the Arduino and power the shield direct.


text:
Makeblock Arduino keeps stopping from motor overpower protection
I got a makeblock Arduino. Sometimes when I make it go forward at full speed, all motors stop for 3 seconds and it beeps shortly. I think it is that the motors are a little hard to turn for a moment and it stops to prevent damage to the motors. It is getting very annoying. Is there any way to disable it or make it less sensitive?

It is unlikely the pause in operation is because of the motors.  It is more likely the Makeblock is stopping because the  motor controllers are too hot.  Next time try to identify which chips on the board are controlling the motors and test if they are getting hot to the touch.  If so, consider adding heat sinks to these chips to mitigate any heat dissipation problems.
An alternative explanation involves a limited power supply.  It could be that when the motors are demanding high current, the voltage drops and the processor resets.  Consider a power supply that can offer more amperage.  Or larger capacity batteries.

source: Stack Exchange

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

sort: votes


text:
HC-SR04 pulse at multiple angles
I have a HC-SR04 sensor mounted on a stepper motor, mounted on a car.
The idea is this:

The car moves forward with the ultrasonic sensor facing the front
If the sensor reads a small distance the car do the following:

Stop
Turn the sensor to the left and get a new distance
Turn the sensor to the Right and get a new distance
Drive slightly backward
The car turns the to direction the distance was the highest
Drive forward again

I think I must have wrongly understood how the echo/ultrasonic sensor works. Because when I read values to the left and right, it will always return zero, but reading values when driving forward works very well.
Below is the relevant code
//Trigger
void triggerEcho(){
  digitalWrite(echoTrigPin,LOW);
  delayMicroseconds(5);
  digitalWrite(echoTrigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(echoTrigPin,LOW);
}

//Trigger, receive and calculate distance (cm)
long getEchoDistance(){
  triggerEcho();
  pinMode(echoRecPin, INPUT);
  long echoDuration = pulseIn(echoRecPin, HIGH);

  return echoDuration / 58;
}

void loop(){

  long distance = getEchoDistance();

  //If front obstacle is encountered
  if((distance < 5) && (distance != 0)){
      carStop();
      servo.write(180);                     //turn echo sensor left
      delay(250);
      long distanceL = getEchoDistance();   //trigger and read sensor value
      servo.write(0);                       //turn echo sensor right
      delay(250);
      long distanceR = getEchoDistance();   //trigger and read sensor value

      //this will always show distance as 0
      Serial.print("  LEFT :"); Serial.print(distanceL); Serial.print("\n");
      Serial.print("  RIGHT:"); Serial.print(distanceR); Serial.print("\n");

      carDriveBackward(135, 1.185, 1.0);     //drive backwards
      delay(250);
      if(distanceR>distanceL)                //turn in the direction that was furthest
        carTurnRight(100,1250);
      else
        carTurnLeft(100,1250);
      carStop();
      servo.write(90);                        //face sensor forward
      delay(250);
    }
    else
      carDriveForward(135, 1.185, 1.0); //R - L
}

I bet something is wrong with how I'm implementing the triggerEcho() and getEchoDistance(). I excluded anything on the wiring and pins, as the reading of the distance is very correct when reading the facing the front.

I doubt you have misunderstood the way ultra sound works.  You send a pulse and then go quiet waiting for a reply.  The time it takes to send the pulse is the minimum distance you can detect things at.
If you are not getting returns left and right then it could be there is nothing there or turning the head is breaking a connection.
Firstly jack the vehicle up off the floor so it doesn't go anywhere.
Place a solid object (book) in front of the vehicle and make sure it detects it.
Now place the same object to the right of the vehicle, do it detect it?
Stop the US sensor when it is looking right (by killing the power) and check that it is looking horizontally.  Check the connections, are they being pulled loose?
Your code looks fine, you US works forwards so I think it is a mechanical issue with your car.

So I found out that it had to do with my pins. I was using pin 1 and 2 for trigger and echo. For some reason, I really don't understand why, but using Serial.print() function had an effect on using pin 1 and 2 properly (is that even possible? Do these pins have a relation to that?). Anyway, I switched to other pins, and it works in all direction. Except that I get some messed up results sometimes, but I think my sensor is too near the floor.
I mark your answer as correct, as you were right, its a mechanical issue. Thank you:)

Ok. Googling a little bit tells me that pin 1 and 2 are somewhat special:)

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


text:
Using the Tian handshake line
I've set up a Yun before to use the handshake line on pin 7 (thanks to this great forum post) and now I have a new project that I want to do something similar with the Tian. Based on the schematic, it's a similar idea: set the output, mark the output low. But so far I haven't been able to get it working. Anyone know how to adopt the following command from /etc/rc.local to the Tian?
# Added section to set the handshake line.
# GP19 is connected to D7 of the 32U4 processor.
# This requires setting GP22 high to enable the U7 level shifter.
# This GPIO is already exported.
# Then GP19 needs to be exported, set to output, and finally brought low.
echo 1 > /sys/class/gpio/gpio15/value
echo 21 > /sys/class/gpio/export
echo "high" > /sys/class/gpio/gpio21/direction
echo 0 > /sys/class/gpio/gpio21/value

This code is what I'm using now: it's the forum poster's text with my updates for the Tian.


text:
NodeMCU with RFID RC522 and I2C interface LCD module together

I'm newbie in Arduino programming so I hope to get a clear answer.
I have NodeMCU v1 12-E, I connected it with RFID RC522 as in attachment picture.
Now my question:
I need to connect I2C interface LCD module with it to print some words in.
The RFID use the default SDA and SCL pins on NodeMCU V1.0 "D1 and D2" also when I see wiring for the LCD I2C it use same D1 and D2 pins.
So now if I change the RFID instance creation code to
MFRC522 mfrc522(0,2);

//SS_PIN 3 RST_PIN 4

Is the RFID will work as previous pins and the LCD will work also?

this is will not work in I2C bus just go with the UART protocol this will work perfectly and its communication is very easy

You can have multiple devices on the I2C bus so long as they all have different addresses.  This means you should be able to connect D1 and D2 to the RFID and LCD.  HOWEVER I'm not sure that you are using I2C to talk to the RFID board, if you aren't then you may need to move the RFID boards pins and leave I2C on D1&2.

Thank you for reply Code Gorilla, I tried to change i2c to d3 and d4 for RFID, and the default d1 and d2 for I2C lcd module. they worked perfectly together.


text:
Serial Comm. timing issue between Arduino and Pyserial
This is my first post to Stack Exchange so please forgive any formatting errors.
I am conducting an experiment that has 7 total sensors: 5 thermocouples, 2 humidity sensors and 1 pressure sensor. I am reading their signals via Arduino Mega analog input ports. I chose to use Python to save and compile the data in a nice csv file, therefore I am using Pyserial.
My problem is that I cannot go above 1 sample/second. As you can see in my code, I have a 1 second delay in Arduino and Python. I have ran successful calibration tests with my thermocouples, so I know at that rate Python and Arduino are communicating well. Anything faster than 1 sample/second (i.e. I change my delays to .5 or .25 seconds), a timing error occurs and my data is "cut up" and sent in odd chunks instead of the standard layout I programmed.
Additionally, I tried to increase the baud rate from 9600 and anything above that will send "garbage" ASCII characters (e.g. little blank blocks and odd characters) to the Serial Comm. I changed the baud rate in Arduino, Python and the COM port in my devices manager settings to no avail.
I would really like to increase my sampling rate to increase my signal-to-noise ratio and I believe it's good practice as a metrologist to have a higher sampling rate than 1 samp/sec. I am sending ~1072 bits each time I write to the Serial Comm (if I'm counting right??) so I should have enough room to increase the amount of bits to send per second (around 3 times what I am currently sending).
In summary, my two main issues are: if I increase the baud rate, I get garbage in my Serial Comm and if I try to increase my "sampling rate" by decreasing my delays, timing issues appear and my data is split up erroneously. Should I be using a different function, like Serial.flush()?
I greatly appreciate any feedback, thank you for your time!
// Data acquisition
// updated  March 30, 2017

//Note: This version is for TEMPERATURE, HUMIDITY and PRESSURE data
acquisition ALONE. No motor/conveyor control.

//***GLOBAL VARIABLES***//

float lfactor = 125.0;
float afactor = 1.15;

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

//Standard setup with analogReference to 5Volts.

void setup() {

Serial.begin(9600);
}

void loop() {

//******THERMOCOUPLES*******//

//get voltage reading
// [code]; TC # - Location

float tcv1 = analogRead(A4) * ( 5.0 / 1024.0 ); //TC 1
float tcv2 = analogRead(A7) * ( 5.0 / 1024.0 ); //TC 2
float tcv3 = analogRead(A8) * ( 5.0 / 1024.0 ); //TC 3
float tcv4 = analogRead(A9) * ( 5.0 / 1024.0 ); //TC 4
float tcv5 = analogRead(A10) * ( 5.0 / 1024.0 ); //TC 5

//convert to temperature using custom equation based on 5V reference
float tc1 = ( 188.7755 * tcv1 ) - 245.3959;
float tc2 = ( 188.7755 * tcv2 ) - 245.3959;
float tc3 = ( 188.7755 * tcv3 ) - 245.3959;
float tc4 = ( 188.7755 * tcv4 ) - 245.3959;
float tc5 = ( 188.7755 * tcv5 ) - 245.3959;

//******HUMIDITY SENSORS********//

float hs1 = ((( analogRead(A13) * ( 5.0 / 1024.0) ) / 5.0 ) * 100.0 ); //HS
1
float hs2 = ((( analogRead(A15) * ( 5.0 / 1024.0) ) / 5.0 ) * 100.0 ); //HS
2

//******PRESSURE SENSORS********//

//obtain voltage signal from Sensirion sensor
float pvolt = analogRead(A0) * (4.995 / 1024.0);

//convert to Pascals using equation from datasheet, including altitude
compensation
//P = lfactor * (voltage[V] - .250 ) / 3.750

float pressure =  lfactor * ( pvolt - .250 ) / 3.750;
float pascals = pressure * afactor;

Serial.print("TC1");
Serial.print(":");
Serial.print(tc1);
Serial.print(";");

Serial.print("TC2");
Serial.print(":");
Serial.print(tc2);
Serial.print(";");

Serial.print("TC3");
Serial.print(":");
Serial.print(tc3);
Serial.print(";");

Serial.print("TC4");
Serial.print(":");
Serial.print(tc4);
Serial.print(";");

Serial.print("TC5");
Serial.print(":");
Serial.print(tc5);
Serial.print(";");

Serial.print("RH 1");
Serial.print(":");
Serial.print(hs1);
Serial.print(";");

Serial.print("RH 2");
Serial.print(":");
Serial.print(hs2);
Serial.print(";");

Serial.print("Pressure");
Serial.print(":");
Serial.print(pascals);
Serial.print(";");

Serial.println("");
delay(1000);

  }

Python Code:
from threading import Thread
import time
import serial
import os
global datalist
global fileName

global motorspeed

motorspeed = 0

def serInitialization():
    #activate the serial port, if possible
    try:
        ser = serial.Serial('COM9', 9600) #initialize the serial port
        print "Serial connection successful."
        return ser
    except:
        print "Error: serial port cannot be initialized"
        while(1):
            voidholder = 1

def getDateTime():
  """Function grabs current time and date, then returns values in a 2-
 element list. """
   timeNow = time.strftime("%H:%M:%S")
   dateToday = time.strftime("%m/%d/%y")
  return [dateToday, timeNow]

def writetocsv(data):

    """ function writes datalist values to a csv file. If daily csv file
exists already,
    list values are simply appended to end of file. If it does not, function
creates the file,
    then appends values.
    """

    global csv_success

    header = ["date", "time", " ", "TC1", " ", "TC2", " ",
"TC3", " ", "TC4", " ", "TC5", " ", "HS1", " ", "HS2"," ",
"PRESSURE", " ", "PRESSURE(alt)", "\n"]

    fileName = str(time.strftime("%m_%d_%y_")+ "log.csv")

    if os.path.exists(fileName):
        f = open(fileName, "a")

    else:
        f = open(fileName, "a+")

        for element in header:
            f.write(element + ",")
        f.write("\n")

    for element in data:
        if type(element)==str:
            f.write(element + ",")
        if type(element) == list:
            for i in element:
                f.write(i + ",")

    f.write("\n")
    f.close()
    csv_success = True

def mainprogram():

    data = []

    if ser.inWaiting():
        datetimeData = getDateTime()

        for i in datetimeData:
            data.append(i)

        val = ser.readline().strip('\n\r').split(';')
        print "Current readings: "
        for i in range(0,len(val)):
            sensorData = val[i].split(':')
            data.append(sensorData)

            print sensorData

        writetocsv(data)

        time.sleep(1)

        print "\n" * 50

#Initializes the serial port with the arduino so now we can read what
Arduino is sending us!
print "*******************************"
print "DATA ACQUISITION PROGRAM       "
print "*******************************"
print "Data files are saved under "
print "C:\\Users\\lpaw\\Downloads\\python workspace"
print "*******************************"

ser = serInitialization()

while True:

   mainprogram()

Screenshots of errors:

I suspect I already know where your sampling-rate problem is, but can you post an example of a 'good' vs a 'bad' set of received data?

Yes let me run some tests and get those for you. thanks!

@brhans I hope those images help, those are examples of bad data formatting. It shouldn't be repeating the variables.

Your main problem is in erroneously having a delay in both the sender and the receiver.  While this sometimes works by lucky accident, it essentially never does what is hoped for by those who try it.
In a system such as this, you should have a delay in the sender only, in order to produce quasi-regular sample intervals, but no delay in the receiver.  Rather, the receiver should accept data whenever the transmitter produces it, or more specifically in your case, every time it completes a terminated line of data.
But you also seem to want to write the data in an organized way as sets of measurements.  To do that, you should reject data until you see the first "TC1", then collect lines to fill in a data block until and end of data condition is recognized (in your case a blank line), and write it out to disk in a timestamped file.  You may also want to include code that abandons a corrupted block unwritten if any of the intermediate reading headers aren't as expected, and goes back to looking for the next hopefully clean TC1, or marks it as erroneous, or whatever.
To use a different baud rate, you must apply a matching setting in both the Arduino and the python ends of the link.
Also note that while the Arduino serial monitor is indeed useful for debugging, you must not have it open while trying to collect data with python - this will either cause an error in that one program is disallowed, or the two programs to fight over the data and each get incomplete results.
Another technique which can be simple and useful, especially during development, is to write every received line of serial data out to a text file with a numeric timestamp at the start of each line.  You can then have a second process which reads this file, grabs complete multi-line records, and writes them out using either the timestamp of the first or last element of the record.  In particular this lets you get an intermediate view of the data to understand any oddities.  With various Unix style command line tricks you can even run the first program both saving the intermediate format and feeding the second record extraction program in real time.

Okay, I understand what you're saying. The reason why I have a delay is because I need to be able to observe the data in real time, and I wasn't able to run a GUI. So I have the program delayed so I have enough time to read the data in the Python Shell . I'll just bite the bullet and learn threading (I was struggling with that, thus I went with my current [crappy] setup). Thanks so much for your help!!

Threading is not the solution to this either.  What you should do is pipe the output through a pager, or capture it to a file and view that separately.

But isn't threading how I would be able to both continuously "capture" data and print it out to a user interface simultaneously?

I will look into that, thank you again @Chris Stratton

You certainly should use a single Serial.flush at the end of your loop()
Serial.println("");
Serial.flush()
delay(100);

Remember you have limited SRAM to store characters.
I'd suggest you should use the inbuilt serial monitor in the Arduino IDE with the above alteration, and increase your baud rate. There should be no problems sending data at 115k baud.
You should also consider sending a signal back from Python that you have received a valid reading string (ACK/NAK) that way you can remove delays altogether (you still need the flush).

This is not the issue

@ChrisStratton ...then please share you knowledge.

Serial output blocks until there is room in the buffer.  All your change would do is extend the sample interval beyond what is intended by the transmission time of whatever has not yet been sent, while without the flush() it is extended by only any portion that has not yet fit in the outgoing data buffer.

Does your Python code have any way of determining the start & end of a data set?
Does it 'assume' that when it reads a chunk of data from the serial port that the first byte it gets will always be the start of a "Cond.temp" and the last byte will be the ; at the end of Press(alt)?
After reading a chunk of data, do you have any check to see if it is complete or if you should wait a few 10's of milliseconds and go back to read some more?
I'm assuming the answers to these questions are No, Yes & No.
Your PC and your Arduino are running completely asynchronously - neither one really knows what the other is doing.
When your python code reads a chunk of data from the serial port (I'm making another assumption here - that you're not reading it byte-by-byte), you have no way of knowing that the beginning of that chunk is really the beginning of your data set.
Similarly, you also have no way of knowing that the end of that chunk is the end of your data set - maybe it's only a small piece - or maybe you're getting the beginning of the next set glued to the end of this on.
If you're using a USB-Serial adapter then your data is even more likely to arrive in bits & pieces which you'll need to reassemble - just by the nature of how these beasties often work - they could be buffering some number of serial bytes before packaging them together in a single USB packet.
You need some way of flagging the start and/or end of your data sets. Even something as simple as a \n newline character at the end of each one might work for you.
Then, you need to read in and buffer the data you're receiving until you know you've reached the end of a data set.
So, for the \n example:
 - read some stuff
 - add it to a buffer
 - do you have a \n anywhere in the buffer?
 -- yes - pull that section from the start of the buffer up to the \n & process it
 -- no - go back to the beginning and wait for more stuff
 - after you've pulled some stuff out of the buffer to process,
don't just forget the rest - it could be the start of your next data set!
 - move it to the start of your buffer
 - rinse & repeat
For your baud-rate issue I can't say much for sure. The garbage you're seeing is typical for a mismatched baud-rate situation.
Check that your particular Arduino supports the baud rates you're trying to use at whatever clock speed you're running it at.
Check that your USB-Serial adapter (if you're using one) works at those speeds (either loop pins 2&3 and type to yourself in a terminal or get another, preferably different one, and hook them together with a 3-wire link pin 2-3, pin 3-2, pin 5-5).

I have a feeling it is the USB cable. I did not know that was a potential issue until I started researching this problem. Thank you so much for the thorough answer. I am still digesting it and as soon as I reach a solution I will post it. I am more familiar with circuits and sensor hardware than software- so this has been tricky to learn. Anyways, thanks again!

Additionally @brhans I don't think I need to increase my baudrate just yet. The amount of bits that my Arduino spits out to Serial Comm is 1072 (roughly). That means at a baud rate of 9600, I can print "Cond.Temp:45.74;Heat.Temp:45.53; etc" at least 3 or 4 times per second to be within the baud rate. Am I understanding it correctly?


text:
No such file or directory compilation terminated
I tried a simple blink for my fingerprint sensor which is GT-511C1R, but I have experienced of having an error.

FPS_Blink.ino:12:26: fatal error: FPS_GT511C1R.h: No such file or directory
  compilation terminated.

I downloaded the whole library but still same error.

I'm voting to close this question as off-topic because the problem is the poster's lack of basic programming skills.

If the OP has a basic lack of understanding of programming that is a valid topic for them to post about and request help.

@CodeGorilla. From Help Center, What Are Off-Topic: "Off topic: If your question is about coding not related to Arduino, try Stack Overflow.  If the solution would be the same with or without Arduino, then it's usually a general coding question."

@LookAlterno - I understand why you say that, but this is about the inability to find a file, which is an IDE setup issue.  Also I suspect the your original answer may have lost something in "translation", because it comes across quite elitist, which I'm sure is not what you meant.

@CodeGorilla. I feel this "elitist" thing is something worthy of discussion in Meta. I have already touch the subject in Meta, without any response. Have a look at my answer in https://arduino.meta.stackexchange.com/questions/2459/2017-moderator-election-qa-question-collection

Please learn how to install a library from here. And see if error is coming or not.


text:
Suggest me Arduino device with USB for Mass storage
I want to make a temperature data logger by using Arduino.
I can read a data every 1sec and I want to store 30days data with date&Time.
In data logger, I want to write a temperature data with date&time in the .csv file and this file will be generated after I attaching USB.
So, Please suggest me Arduino board with USB compatible(working on 3V battery) and also suggest me EEPROM who able to store 30 days data.

Take a look at the Atmel SAMD21 xplained pro. Not an Arduino, but it's more powerful and has support for USB mass storage.

This sounds like a job for a Raspberry Pi

60 samples per minute, 60 minutes per hour, 24 hours per day, 30 days - that's 2592000 samples. At 10 bytes per sample (a very generous allocation) that's less than 30MB of data.
You could fit that many many times over on even the smallest of today's SD cards, so why mess with the complexity of USB? Any Arduino can work with an SD card.
A bigger concern of yours should not be the storage medium, which is trivial - you should instead be thinking about how you will run the board off a 3V battery for 30 days.

2937600 = 60602434.   60602430 = 2592000.

@JamesWaldby-jwpat7 You're not wrong there. My mouse must have been operating in nonagesimal at the time...

Despite your poor written question, I'll reply to you with a code, I used in my temperature logger 2 weeks ago. Includes LCD, temp sensor and SD card.
Delay is set for 9,1s which sums up with the calculation times of Arduino to 10 +/- 0.05 sec.
Lower it down to 100ms, if you want to be written every 1 second.
PS: The lower row, most right: There is a sign in letters, the condition of the sistem.
N = something's wrong, not inserted card/not connected SD card module
O = everything's okay, it's data logging
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>
#define ONE_WIRE_BUS 6 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); LiquidCrystal lcd(8, 7, 5, 4, 3, 2);

const int chipSelect = 10;

void setup() {

  Serial.begin(9600);   Serial.println("Arduino Digital Temperature // Serial Monitor Version");   sensors.begin();
     lcd.begin(16, 2);   lcd.setCursor(0, 0);   lcd.print("Temperatura:");   //*********************************************
    while (!Serial) {   }   lcd.setCursor(15, 1);   lcd.print("??");   Serial.print("??");

  if (!SD.begin(chipSelect)) {
    Serial.println("NO");
      lcd.setCursor(15, 1);
      lcd.print("NO");
    return;   }   else   {   lcd.setCursor(15, 1);   lcd.print("OK");   Serial.println("OK");   }   //********************************************* }

void loop() {

  String dataString = "";

  float abc;

  sensors.requestTemperatures();     Serial.print("Temperature is: "); Serial.println(sensors.getTempCByIndex(0));   lcd.setCursor(0, 1);   lcd.print(sensors.getTempCByIndex(0));

  File dataFile = SD.open("datalog.txt", FILE_WRITE);

    if (dataFile) {
    dataFile.println(sensors.getTempCByIndex(0));
    dataFile.close();    Serial.println(sensors.getTempCByIndex(0));
    }
       else {
    Serial.println("error opening datalog.txt");   }

  //delay(9100);    }


text:
EEPROM PUT and GET audio playback
I am new to Arduino.
My project is an electronic piano that has 8 tactile switch keys that can play 8 octaves. I want to record a song that a user plays on the keys into EEPROM. I have implemented it. However, the playback is bad. You can't hear different note frequencies but you can hear soft buzzing when a note is supposed to be played.
Here is my code. Could you please help me find the problem? Thank you in advance.
#include <EEPROM.h>
#include "pitches.h"
#define speaker A5
#define record_button 3
#define play_button 5
#define record_led 2
#define play_led 4

int eeAddress = 0;
int eeAddressplay = 0;
const int inPot = A1; // potentiometer to change octaves (8 octaves total)
byte octave;
byte tone_out;
int tone_key; // frequency of key
boolean silence;
int maxNumber = 500;
byte time = 20;
byte check = 0;
byte buttons[] = {6,7,8,9,10,11,12,13};
int saveSounds[500];
int saveNumber = 0;

byte melody1[8] = {
  NOTE_C1 , NOTE_D1, NOTE_E1, NOTE_F1, NOTE_G1, NOTE_A1, NOTE_B1, NOTE_C2};
byte melody2[8] = {
  NOTE_C2 , NOTE_D2, NOTE_E2, NOTE_F2, NOTE_G2, NOTE_A2, NOTE_B2, NOTE_C3};
int melody3[8] = {
  NOTE_C3 , NOTE_D3, NOTE_E3, NOTE_F3, NOTE_G3, NOTE_A3, NOTE_B3, NOTE_C4};
int melody4[8] = {
  NOTE_C4 , NOTE_D4, NOTE_E4, NOTE_F4, NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5};
int melody5[8] = {
  NOTE_C5 , NOTE_D5, NOTE_E5, NOTE_F5, NOTE_G5, NOTE_A5, NOTE_B5, NOTE_C6};
int melody6[8] = {
  NOTE_C6 , NOTE_D6, NOTE_E6, NOTE_F6, NOTE_G6, NOTE_A6, NOTE_B6, NOTE_C7};
int melody7[8] = {
  NOTE_C7 , NOTE_D7, NOTE_E7, NOTE_F7, NOTE_G7, NOTE_A7, NOTE_B7, NOTE_C8};

//PIANO FUNCTION
void freePlay()
{
  octave = map(analogRead(inPot),0,1023,1,7);
  if (digitalRead(buttons[0]) == HIGH) {
    tone_out = 0;
    silence = false;
  }
  else if (digitalRead(buttons[1]) == HIGH) {
    tone_out = 1;
    silence = false;
  }
  else if (digitalRead(buttons[2]) == HIGH) {
    tone_out = 2;
    silence = false;
  }
  else if (digitalRead(buttons[3]) == HIGH) {
    tone_out = 3;
    silence = false;
  }
  else if (digitalRead(buttons[4]) == HIGH) {
    tone_out = 4;
    silence = false;
  }
  else if (digitalRead(buttons[5]) == HIGH) {
    tone_out = 5;
    silence = false;
  }
  else if (digitalRead(buttons[6]) == HIGH) {
    tone_out = 6;
    silence = false;
  }
  else if (digitalRead(buttons[7]) == HIGH) {
    tone_out = 7;
    silence = false;
  }
  else {
    silence = true;
  }

  if (silence == false)
  {
    switch(octave)
    {
    case 1:
      tone_key = melody1[tone_out]; break;
    case 2:
      tone_key = melody2[tone_out]; break;
    case 3:
      tone_key = melody3[tone_out]; break;
    case 4:
      tone_key = melody4[tone_out]; break;
    case 5:
      tone_key = melody5[tone_out]; break;
    case 6:
      tone_key = melody6[tone_out]; break;
    case 7:
      tone_key = melody7[tone_out]; break;
    }
    tone(speaker,tone_key);
  }
  else {
   noTone(speaker);
   delay (5); }
}

//SETUP FUNCTION
void setup()
{
 for(int i = 0; i < 8; i++)
 {
  pinMode(buttons[i], INPUT);
 }
 pinMode(speaker, OUTPUT);
 pinMode(melody_button, INPUT);
 pinMode(record_led, OUTPUT);
 pinMode(play_led, OUTPUT);
 pinMode(inPot, INPUT);
}

//MAIN CODE
void loop() {
freePlay();
if (digitalRead(record_button) == HIGH) {
  digitalWrite(record_led, HIGH);
    for(int i = 0; i < maxNumber ; i++) {
      octave = map(analogRead(inPot),0,1023,1,7);
        if (digitalRead(buttons[0]) == HIGH) {
        tone_out = 0;
        silence = false;
        }
        else if (digitalRead(buttons[1]) == HIGH) {
        one_out = 1;
        silence = false;
        }
        else if (digitalRead(buttons[2]) == HIGH) {
        tone_out = 2;
        silence = false;
        }
        else if (digitalRead(buttons[3]) == HIGH) {
        tone_out = 3;
        silence = false;
        }
        else if (digitalRead(buttons[4]) == HIGH) {
        tone_out = 4;
        silence = false;
        }
        else if (digitalRead(buttons[5]) == HIGH) {
        tone_out = 5;
        silence = false;
        }
        else if (digitalRead(buttons[6]) == HIGH) {
        tone_out = 6;
        silence = false;
        }
        else if (digitalRead(buttons[7]) == HIGH) {
        tone_out = 7;
        silence = false;
        }
        else {
        silence = true;
        tone_key = 0;
        }

        if (silence == false) {
        switch(octave) {
        case 1: tone_key = melody1[tone_out]; break;
        case 2: tone_key = melody2[tone_out]; break;
        case 3: tone_key = melody3[tone_out]; break;
        case 4: tone_key = melody4[tone_out]; break;
        case 5: tone_key = melody5[tone_out]; break;
        case 6: tone_key = melody6[tone_out]; break;
        case 7: tone_key = melody7[tone_out]; break;
        }
        tone(speaker,tone_key);
        delay(time);
        }
        else {
        noTone(speaker);
        tone_key = 0;
        delay (time);
        }

    saveSounds[saveNumber] = tone_key;
    saveNumber++;
    if (digitalRead(play_button) == HIGH){
    break;}
    }

digitalWrite(record_led, LOW);
tone(speaker, 700);
delay(200);
noTone(speaker);
check++;
}

for (int i = 0; i<500; i++) {
  EEPROM.put(eeAddress,saveSounds[i]);
  eeAddress = eeAddress + 2;
}

if(check >= 1) {
  while (0 == 0){
    freePlay();
    if(digitalRead(play_button) == HIGH) {
      digitalWrite(play_led, HIGH);
        for(int i = 0; i < maxNumber; i++) {
        if(saveSounds[i] != 0) {
          tone(speaker,EEPROM.get(eeAddressplay,saveSounds[i]));
          eeAddressplay = eeAddressplay + 2;
          delay(25);
        }
        else {
          noTone(speaker);
          delay(time);
        }
        }
      noTone(speaker);
      digitalWrite(play_led,LOW);
    }
    freePlay();
  }
}
}

I don't have an answer on your question, sorry for that. However, some general comments: in freePlay you can make a loop instead of the first 8 if statements, even for the second 8, if you make from melody an array (so melody[melody_nr][...]
In loop, you can also make a for loop of the 8 if statements, and second again using the same melody[melody_nr][...] variable. This will greatly reduce your code size (and maintainable etc).

Thank you for your message. I'm new to Arduino and C programming. I don't really understand what you mean. Could you please give an example?

I am not being sarcastic, but have you checked the volume control?  It could be you need more power to the speaker.  Another possibility is you are outputting to the 'LINE' rather than the 'SPEAKER'.  It could be something to do with the resistance of your speaker not matching your circuit.

The whole thing was working prior to me saving the data into EEPROM.

NOTE: this is not an answer, but a response not able to put in a comment as request from the submittor mirandamg.
For the first example
Instead of
if (digitalRead(buttons[0]) == HIGH) {
  tone_out = 0;
  silence = false;
}
else if (digitalRead(buttons[1]) == HIGH) {
  tone_out = 1;
  silence = false;
}
...

Use
for (int buttonIndex = 0; buttonIndex < 8; buttonIndex++)
{
    if (digitalRead(buttons[butonIndex] == HIGH)
    {
       tone_out = buttonIndex;
       silence = false;
    }
}

This method does not work directly for variables melody1, 2, 3...
Therefore, make an array, instead of:
byte melody1[8] = {
...

use
byte melodies[8][8] = {
...

The first 8 is for the number of melodies, the second is for the number of notes.
You can improve it even further by making 2 constants:
const byte NR_OF_MELODIES = 8; // Number of melodies
const byte NR_OF_NOTES = 8;    // Number of notes per melody

And the array can be created s
byte melodies[NR_OF_MELODIES][NR_OF_NOTES] = {

If you make a const for the number of buttons:
const byte NR_OF_BUTTONS = 8; // Number of physical buttons

Then also the first line in the loop in my example can be changed as:
for (int buttonIndex = 0; buttonIndex < NR_OF_BUTTONS; buttonIndex++)

If you later need to change the number of notes, melodies or buttons, you don't need to iterate over your application to find all values. Especially since they are all 8.


text:
Is it possible to save different values on address 0 and 1 in EEPROM?
I want to save different values on address 0 and 1 on eeprom I tried to change it but when I put data on address 0 and also put data on address 1 the address 0 change its value stored into random number and vice versa .. Is it possible to change the value of respective address without affecting others ..
CODE
in the setup
     int eepromSize=EEPROM.length();
      Serial.print("EEPROM found, size=");
      Serial.println(eepromSize);
        // Get the last fade value (as an integer)
      EEPROM.get(0, WATEREQFORN1);
      Serial.print("Last Value N1: ");
      Serial.println(WATEREQFORN1);

      EEPROM.get(1, WATEREQFORN2);
      Serial.print("Last Value N2: ");
      Serial.println(WATEREQFORN2);

The user will input the value that will be save in eeprom i use switch because the user will input like this example .. 100A or 23B
case 'A':
        Serial.print("Case A got ");
        Serial.println(val);
        WATEREQFORN1 = val;

            EEPROM.put(0, WATEREQFORN1);
            Serial.print("DATA SAVE TO EEPROM");

        break;
      case 'B':
        Serial.print("Case B got ");
        Serial.println(val);
         WATEREQFORN2 = val;
         EEPROM.put(1, WATEREQFORN2);
         Serial.print("DATA SAVE TO EEPROM");

        break;

The problem is, when I change/write value into address 0 and after that change/write also into address 1 the value on address 0 also change into different random numbers.

Yes. Post your code so we can see where you went wrong.

@Majenko I edit my question and add my code ,

What are WATEREQFORN1 and WATEREQFORN2? You only show a bit of your code, and have omitted what may be the most important parts - your variable definitions.

unsigned int WATEREQFORN1; unsigned int WATEREQFORN2; That is the value the user enter sir .. example 200A it will be get by case a and be assign in WATEREQFORN1as show in my code WATEREQFORN1 = val the val initially hold the serial value 200 and pass to WATERECFORN1

The variable names in all upper case is a style problem you should address.  Conventionally, C and C++ programmers use all-upper-case names to designate defined constants or macros.  Contravening that convention can lead to confusion if other people use or maintain the code.  Instead of WATEREQFORN1 consider waterEq1, etc.
The problem of your second value overwriting part of the first in EEPROM is an allocation problem.  Presumably the WATEREQ... variables are multiple bytes in length.  EEPROM.get() and put() read and write data types with multiple bytes using several consecutive bytes of EEPROM.  For example, if WATEREQFORN1 is a real and takes 4 bytes, it will occupy cells 0, 1, 2, 3 in EEPROM.
The following code snippet shows a way to automatically and systematically allocate EEPROM space.  The sizeof operator returns the size in bytes of its argument.  Thus, an expression like WaterAddr2=WaterAddr1+sizeof waterEq1 correctly sets WaterAddr2 to be the next available cell after waterEq1, no matter what type waterEq1 is.
enum { WaterAddr1=0, WaterAddr2=WaterAddr1+sizeof waterEq1, DelayAddr=WaterAddr2+sizeof waterEq2 };
...
case 'A':
  waterEq1 = val;
  EEPROM.put(WaterAddr1, waterEq1);
  break;
case 'B':
  waterEq2 = val;
  EEPROM.put(WaterAddr2, waterEq2);
  break;
case 'D':
  Delay = val;
  EEPROM.put(DelayAddr, Delay);
  break;
  ...

Thanks I think thats  the problem , I follow your advice and It Works like a charm .. :D

the allocation is the problem ..

EEPROM.put() and EEPROM.get() write or read the object you pass them. An int is 2 bytes so that is what they write or read. It sounds like you intended for the functions to only handle 1 byte. In that case, make the your variable's data type something that is 1 byte, such as int8_t; otherwise allocate 2 bytes of EEPROM to each.
Update:
It works because you had only allocated 1 byte in EEPROM for each variable but you store 2-byte variables. Now you're storing 1-byte variables, which matches your EEPROM allocation.

So instead of unsigned int i will use byte ? because i only want to save numbers.

It works now that i change the unsigned int WATEREQFORN1; into byte WATEREQFORN1 i dont know why but it works , when i write new data to  WATEREQFORN2 the WATEREQFORN1 dont change into random numbers

Probably WATEREQFORN1 is an int or word, at least more than one byte.
If you write a 2 byte value on address 0, it will occupy address 0 and 1.
When you overwrite address 1 (again with a 2 byte value), it will occupy addres 2 and 3, destroying the LSB part of the value written to byte 0.
Try writing on address 0 and 2 (or 0 and 4 when using 4 bytes).

Is it possible to change the value of respective address without affecting others ..

Yes, if the two values are 8-bit types.
Otherwise, No.


text:
Using voltage divider to read voltage from sensor
Good morning,
I would like to use an Arduino Duemilanove to read the voltage signal generated from a current sensor (CSLA2CD). The datasheet for this sensor can be found here.
The problem is that the sensor requires a supply voltage of 6 to 12v. The signal output voltage is half the supply when no current flows through the sensor. I am using a 8v regulator for its supply, so the signal voltage may range from 4v (no current sensed) all the way to about 6v (about 60 amps).
Unless I'm mistaken, the arduino's analog pin can detect from 0v to 5v. So it would only accurately provide me data up to the 5v signal mark.
My questions are:

Would a voltage divider be a good solution to reduce the signal voltage to a range the Arduino can read? If so,
what would be the best resistor combination to use?

If there are better solutions than a voltage divider then please share.
Thanks very much!

It should work, but I don't know if its the best way.
Because the maximum voltage is 12 volts (I know you are only giving it 8, but you don't want to fry your board) you need the divider to send the Arduino 5/12 of the power.  You don't need much current, so you can use big values or resistors.  10K and 24K should work, but you should research or test this before you hook it up to you kit.

Thank you for the quick reply!
The Arduino will never receive the full 12v  because i'm powering the sensor separately from the Arduino. The Arduino is only connected to the sensor via the analog pin and ground. The most voltage it would ever get into its analog pin would be 8v if there was a catastrophic failure with the sensor and it sent the full supply. That may still be enough to kill the pin, but probably not the whole Arduino, as far as I know.
So you're recommending that I test the system using 10K for R1 and 24K for R2? Just want to clarify.

@Andres: If you know for sure that the input voltage will never be more than 8 V, then you could use 10 kΩ between the sensor and the Arduino and 15 kΩ between the Arduino and ground. The Arduino will then read no more than 4.8 V.

Honeywell has also Current Sensors for 5V (the CSNX series). If you are only reading DC currents, then you can add a little capacitor parallel to the 15k resistor of about 10nF (1nF to 100nF) to reduce some noise. Do you have a modern 3.3V Arduino Due or do you really have a very old Duemilanove ? For the Duemilanove it is allowed to pull or push 1mA into a Arduino pin. That means with 10k and 15k the Arduino is protected for voltages from -10V to 19V. A voltage divider is accurate and works very well, anything else (for example OpAmps) would only introduce more inaccuracy.


text:
Multiplex 7 segment during delay (external IC?)
I am using some sensors with the arduino which take a second to receive the data from them. My guess is that there is a delay used somewhere in the library. During this time the multiplexed displays stop working as the rapidly changing grounds are temporarily paused and only one of the displays has the digit lit up. I could change the sensor I'm using (DHT11) to something I could AnalogRead, however I'm curious if there is an external IC for this which drives multiplexed displays with some sort of serial communication or I2C between the arduino and it. I could use a separate arduino(or ATTiny) and write some code for it to do this, but is there a class of chips which already do this? Something where you could pass bytes of the digits and the multiplex delay and it continues to multiplex until the next data is received.
I don't mind if in this time the digits are left in their last states similar to how it would operate if they were directly driven rather than multiplexed. If anyone has insight that would be great!

Perhaps a MAX7219 would do what you want.

The MAX7219CNG+ is a 8-digit serially interfaced LED Display Driver for LED matrix displays.
  The MAX7219 is compact, serial input/output common-cathode display drivers that interface microprocessors (¦ÌPs) to 7-segment numeric LED displays of up to 8 digits, bar-graph displays or 64 individual LEDs.
  Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment and digit drivers and an 8x8 static RAM that stores each digit.
  Only one external resistor is required to set the segment current for all LEDs.
  A convenient 4-wire serial interface connects to all common ¦ÌPs.
  Individual digits may be addressed and updated without rewriting the entire display.
  The MAX7219 also allow the user to select code-B decoding or no-decode for each digit.


text:
Shift Register on ATMEGA328p
I want to learn more about the shiftout function used with Arduinos and used the implementation with my ATMEGA328p.
The Setup
This is the original shiftout function used in Arduino Programming, except that I replaced 1 with HIGH.
#define F_CPU 1000000UL
#define BAUD 9600UL
#define LSBFIRST 0
#define MSBFIRST 1
#define HIGH 0x1
#define LOW  0x0
#define INPUT 0x0
#define OUTPUT 0x1

#include <avr/io.h>
#include <util/delay.h>
#include <USART.h>
#include <pinDefines.h>

#define DATA PD7
#define LATCH PB2
#define CLOCK PB0

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
    uint8_t i;
    for (i = 0; i < 8; ++i) {
        if (bitOrder == LSBFIRST) {
            PORTD |= (!!(val & (HIGH << i)) << DATA);
            } else {
            PORTD |= (!!(val & (HIGH << (7 - i))) << DATA);
        }
        PORTB |= (HIGH << clockPin);
        PORTB &= ~(HIGH << clockPin);
        }
}

Main
int main(void)
{
    initUSART();
    DDRD |= (HIGH << DATA);
    DDRB |= (HIGH << LATCH) && (HIGH << CLOCK);

    PORTB |= (HIGH << LATCH);
    shiftOut(DATA, CLOCK, LSBFIRST, 1);
    printBinaryByte(PIND);
    PORTB ^= (HIGH << LATCH);

    /* Replace with your application code */
    while (1)
    {

    }

    return (0);
}

I created an example to understand more about the function, but the outcome does not add up to what I expected to see.
Szenario
PORTD |= (!!(val & (HIGH << 0)) << DATA);

This is what I expect for val = 1

(HIGH << 0) = 00000001
val & (HIGH << 0) = 00000001 & 00000001
!!(val & (HIGH << 0)) = 1
PORTD |= (1 << DATA)

As PORTD is the data pin on the shift register, it should get 00000001.
When I print the binary number within PORTD I get: 10000111 and my LED Array connected to the 74HC595 displays: 10101111
I am really lost.... I checked the connections to the LEDs and they are all good. Can you explain to me why I receive this awkward result?

This is what I expect for val = 1
PORTD |= (1 << DATA)
As PORTD is the data pin on the shift register, it should get 00000001.

your deduction is correct and the code is correct -> remember this is the case for LSBFIRST. so "val = 0x01" should be sent out as "0b1000 0000", which is precisely what the code is doing.

!(val & (HIGH << 0))

the "!!" operator is often used to turn a logic value into either '1' or '0'.
the code for shiftout() can be greatly improved.

First of all, PORTD represents the current output state of 8 physical GPIO pins (I think some devices have fewer pins on a port but usually there's 8).  I think what you're trying to do is shift a sequence out of a single pin. So just reading it will only tell you what each of the 8 pin states are at that moment, not what you shifted out.  I think Arduino's way of doing things is actually harder than just writing the plain C code so I'll ignore it (what is the '!!' ???).
So taking a step back, here's code for pushing an 8bit number serially out of a pin:
uint8_t serialData = 0b10011101;  // random data to shift out
uint8_t pin = 3;                  // the pin on PORTD we want to toggle

uint8_t i;
uint8_t nextBit;
for (i = 0; i < 8; i++) {

  // Find the nextBit value to set by shifting our input data by our index
  //   and clearing the other values.  E.g. if serialData == 0b10011101 and
  //   i == 2 then (0b10011101 >> 2) == 0b00100111.  0b00100111 & 1 == 1
  nextBit = (serialData >> i) & 0b00000001;

  // If the next bit is a one, we "or" it to set it
  if (nextBit) {
    // The 'or' operator can only set bits to 1
    PORTD |= 1 << pin;        // in this case, (1 << 3) == 0b00001000
  } else {
    // The 'and' operator can only clear bits to 0
    PORTD &= ~(1 << pin);    // in this case, ~(1 << 3) == 0b11110111
  }
}

If you want to add a "clock" pin to go along with the data (like the arduino code) then you can set the clock pin to whatever state before the "for" loop then use an "xor" operator to toggle it each time through the loop:
clockPin = 4;

// just before the 'for' loop set the clock to whatever starting state you
//   want.  In this case I'll start it at 0.
PORTB &= ~(1 << clockPin);
.
.
.
// Now in the 'for' loop (at the bottom for example)
PORTB ^= (1 << clockPin);

If you want the clock to toggle up then down in a sing loop cycle then you can just repeat the 'xor' twice in a row or force the state using 'or' and 'and' operators.  Also, pay attention to timing, you might be toggling things too quickly if the microcontroller clock is fast.  You can add delays to the loop to shape the timing of the pattern.

That is some ugly and needlessly slow code!
Nonetheless, I think the main point you need to keep in mind is that when you OR the value 00000001 into PORTD, you are only changing the bottom bit to a 1 - all other bits will be left untouched to whatever value they already had.
So, it seems that PORTD had the value of either 10000111 or 10000110 before you executed PORTD |= (1 << DATA) (which is the equivalent of PORTD |= 0b00000001)....
   10000110
OR 00000001
===========
   10000111

The output of your shift register is also just an artifact of whatever the most recent series of bits that you sent to it was. Each time you send a new bit, whatever was there will get shifted over and only the single new bit will be shifted in.
Make sense now?


text:
How do I know the IP address assigned to an ESP8266?
I have programmed an ESP8266 using the circuit and program below. I tried to open the SerialMonitor once the program is uploaded to the ESP8266. I am getting an error when I am trying to open the SerialMonitor.

Error opening serial port 'COM5'. (Incorrect serial port)

What is the way to get the IP address assigned to the ESP8266?
#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
}

you can't run the wifi off the 3.3v of most ftdi adapters; when it's idle in the "ready to flash" mode, it uses less power and works just fine. power the ESP from an external source and your serial port should work again.

if you have GPIO permanently wired to GND, as your diagram implies, then your "sketch" will never be executed on the ESP

@dandavis do you mean that should I plug VCC and CH_PD of ESP8266 to other power source instead of FTDI ? I have 2XAA cell holder https://s3-ap-southeast-1.amazonaws.com/a2.datacaciques.com/wm/307176851/3849027817/859640786.JPG and what voltage cell should I use here ?

@JaromandaX Alright, I will remove it so should we only GND to GND other than no wire to GND in any circuit ?

you are supposed to give the 01 3.3v. Two fresh AAs will probably be enough to get it working, but won't last the full battery charge. This is why ESP8266 devboards are popular. i keep a few of these around, but you can use an AMS1117@3.3v and feed it the raw 5v to save cash...

@dandavis "you are supposed to give the 01 3.3v." - Do you mean I should keep connected VCC and CH_PD  to 3.3 of FTDI and GPIO1 of ESP8266 with other power source ?

no, don't use the 3.3v of the ftdi at all. run the batteries to vcc+chpd+gnd, and the ftdi to rx+tx+gnd

@dandavis Ah Well, Gotcha :) I will try it

i edited that in; forgot becuase i always solder a wire between vcc on chpd on my 01's when i unwrap them

@dandavis can you suggest what battery should I use in 2XAA cell holder https://s3-ap-southeast-1.amazonaws.com/a2.datacaciques.com/wm/307176851/3849027817/859640786.JPG what voltage it should be to avoid esp8266 burn ?

you won't burn out an 01 easily: they have internal protection; don't ask how i know ;). two plain fresh alkaline AAs should give about 3.2v; the ESP-01 works from ~2.8-3.7...

@dandavis Alright! I will buy cells today in evening, will try it. :)

@dandavis Do you think Serial Monitor is not opening because of insufficient power to ESP8266 ? I am getting this error on opening SerialMonitor Error opening serial port 'COM5'. (Incorrect serial port)

If you give your board a name with
WiFi.hostname("MyESP8266");

(for example) you can then look on your router in the section that lists DHCP assignments (on my Netgear it's Attached Devices). That should then show you the IP address of all the attached devices, including the ESP8266 which you will easily identify by its name.
Another option is to use mDNS. Look at some of the examples that come with the ESP8266 core and libraries to see how.

I used the app "Fing" on my phone. It shows you the devices that are connected to your WiFi. After entering all freacking IP adress aviable, found that the last one was the one of my esp8266 and a beautiful window saying "hello from esp8266!" appeared.

I like that app :-) Small thing is that it doesn't work when you put your esp in deep sleep like I did ;-)


text:
loading custom code onto SparkFun Blynk Board
we're trying to add some code to the SparkFun Blynk Board. We don't want to overwrite the firmware, because that allows it to work with the iphone app, but we need to add our own voids and Blynk. Write commands in order to control this servo RC car via wifi wit the Joystick XY. any ideas?
our code:
#include <Servo.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_NeoPixel.h>
#include <SoftwareSerial.h>
//#define BLYNK_PRINT Serial

char BlynkAuth[] = "6dfb81c116d84003a505056239c23559";
char ssid[] = "Linksys23266";
char pass[] = "roboboyz";

Servo servoR;
Servo servoL;

int pos = 90;

void forward()
{
  servoR.write(110);
  servoL.write(110);
}

void turnRight()
{
  servoR.write(80);
  servoL.write(90);
  delay (2000);
}

void turnLeft()
{
  servoR.write(90);
  servoL.write(80);
  delay(2000);
}

void reverse()
{
  servoR.write(70);
  servoL.write(70);
  delay(2000);
}

void Stop()
{
  servoR.write(94);
  servoL.write(94);
  delay(2000);
}

void setup()
{
  Blynk.begin(BlynkAuth, ssid, pass);  // wifi username and password
  servoR.attach(12);
  servoL.attach(13);
  Serial.begin(9600);
  delay(1000);
}

BLYNK_WRITE(V1)
{
  int x = param[0].asInt();
  int y = param[1].asInt();

  // Do something with x and y
  Serial.print("X = ");
  Serial.print(x);
  Serial.print("; Y = ");
  Serial.println(y);
  if(y>220)
  forward();
  else if(y<35)
  reverse();
  else if(x>220)
  turnRight();
  else if(x<35)
  turnLeft();
  else
  Stop();
}

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

Is this something I'd have to send serial from the Blynk Board of the Joystick X/Y over wifi to another microcontroller, like a Leonardo? How would I do that? Can you add "serial.write" into the blynk board to get that information?

do you really want your steering to travel thousands of miles instead of dozens of feet?

Functions aren't called voids. They are called functions.

That's not how microcontrollers work. You have one firmware and only one firmware. When you upload firmware you replace the existing firmware. You cannot "add" to it.
Instead you will have to write a new firmware that contains all the code you need to do the entire job.

Technically all bootloaders prove this wrong.

@Ghanima Yeah, all right Mr Pedant. Bootloaders are a completely separate program stored in a separate section of memory and run separately to your main firmware. You don't modify them either.

A bootloader does not modify existing code. A bootloader deletes existing code and replaces it with completely different code. Just because the bootloader happens to live in flash alongside your program and you have the option of running that instead of your program and it happens to accept programming data and write that to flash it does not "prove it all wrong" since the bootloader does precisely what I described in my answer.

Well, the blynk board is pretty damn limited then, as I can upload a whole crapton of custom code to virtually any other microcontroller.
we're going to try and send ints from the XY coming in via wifi to the Blynk board via serial to another controller.

@Nick You can upload all the code you like, you just have to make sure that it includes the code you require to communicate with the iPhone app.

@Majenko what about with the custom Voids I have? will that mess anything up at all? we're just trying to have the XY values pass through those voids so they can drive the car (aka sending PWM values to the servo motors).

I don't know, I have never used Blynk. Maybe you should check out the Blynk Arduino library. It's linked from the getting started page. I am sure it has examples you can build on.

A bootloader resides in code memory and runs on the µc hence it is firmware. It furthermore allows to store and run other pieces of software - that also qualifies as firmware. So there are two pieces of firmware on the system and that contradicts the point your answer makes one and only one... I know that it is beyond doubt that you know how firmware and bootloaders work and I also know that this is mainly beside the point of the question. So, my apologies if you considered my comment inapt.

@Ghanima A bootloader does not and can not modify existing firmware. So what if it sits there in flash? So what if it allows you to replace code wholesale. It still cannot modify existing firmware!

@Ghanima Oh, and the keyword you have conveniently completely ignored there is "YOU". The user only has one firmware. The bootloader is not something the user ever should tinker with. The user can only upload (yes, using the bootloader if there is one) ONE piece of firmware, and only ONE piece of firmware runs at a time and that firmware CANNOT be modified.


text:
Wifi proof with WeMos D1 ESP8266 Ad-Hoc
I am trying to use a WeMos module to send a broadcast message through an peer-to-peer network (Ad-Hoc). The thing is that i can't give a SSID nor Password to that network, i just can define it through them IP Addresses. As you suspect i don't have a specific idea of the configuration of the Wemos module.
What am I talking about?
I need to receive messages in a IEEE802.11 software-defined radio module. In this module I can't establish a network, just listen to a channel, and read whatever someone is sending. Think about it as a sniffer. But in this case i can assign to this module a MAC and IP within the Network.
What do I need?
I need just to:
Initialize peer-to-peer (Ad Hoc) network without an SSID nor Password.
Set a channel (I do it with channel 13, it is most times free).
Send a broadcast message in that channel to the SDR module in the network.

In other words
Module SDR:
 - IP:192.168.123.2
 - MAC: xxx
Wemos
 - IP:192.168.123.3
 - MAC: xxx
Through Wemos:

wifi, send broadcast message

The mask is /24, then it is going to send the message to all IPs from 192.168.123.2 to 192.168.123.254, then, for sure to the SDR Module, and i could receive it.
Thanks in advance.
Best regards,
Cristian

if there's not a formally connected peer, i doubt it would bother to broadcast. Look into the Nrf24L01, or even the 433Mhz wireless modules; they naively broadcast.

ESP8266 does not currently support Ad-Hoc/IBSS mode.


text:
Speedometer slow reaction arduino
I'm trying to make a speedometer, with utilization of interrupt for get number of pulse and some calculation for getting speed, but when compute speed the arduino freeze for some second and i lose alot of impulse and false all my successive capture of impulse. Why? thanks for reply
const int contaImpulsi = 2;
volatile int impulsi =  0;
int impulsiOld = 0;
static int appoggio = 0;
unsigned deltaT[3];
unsigned vel = 0;

void setup() {
  Serial.begin(9600);
  attachInterrupt(contaImpulsi, definisciTempi, RISING);
}

void loop() {

  if (impulsiOld == impulsi || impulsi > impulsiOld)
  {
    if (appoggio == 3) {
      deltaT[3] = millis();
      appoggio = 0;
    }
    if (appoggio == 2) {
      //Serial.println("ASSEGNO DELTA T 2");
      deltaT[2] = millis();
      //Serial.println(deltaT[2]);
      appoggio = 3;
    }
    if (appoggio == 1) {
      //Serial.println("ASSEGNO DELTA T 1");
      deltaT[1] = millis();
      appoggio = 2;
    }
    if (appoggio == 0) {
      //Serial.println("ASSEGNO DELTA T 0");
      deltaT[0] = millis();
      appoggio = 1;
    }
  }
  impulsiOld = impulsi;

  if (appoggio == 3) {

    int t1 = (deltaT[1] - deltaT[0]);
    int t2 = (deltaT[2] - deltaT[1]);
    int dividi = t1 + t2;
    vel = (((690 * 2000 / dividi) * 3.6) / 10) * 0.85; // here i think is where the program freeze

    Serial.println("------------------------------------------");
    Serial.print("SPEED: ");
    Serial.println(vel);
    Serial.println("------------------------------------------");
  }
}

void definisciTempi() {
  impulsi++;
}

You should make impulse volatile, otherwise its value could be cached.

IF it is that line then I can see why it might be an issue.  Can you refactor the formula so there is only one multiplication operation instead of all those constants?  An alternative system design might be to use an independent counter IC that you query periodically, that way the calculation and presentation is separated from the counting.

Your deltaT has 3 elements, but you are writing to 4 and only reading from 3.

And when appoggio is 3, appoggio gets set to 0 and the if block for appoggio == 0 gets also executed in the same loop.

First off a comment on your variable types. It's not the cause of your problem, but just something to watch for in future:
int impulsi =  0;

This should be voltatile (Edit: I see you updated that, that's ok).
unsigned deltaT[3];
unsigned vel = 0;

These lack a type. As such the default to int. Your deltaT array should be unsigned long since it stores time. It will overflow very rapidly otherwise.
Now on to your problem.
The core of your problem is your methodology of calculating the speed. This bit:
if (impulsiOld == impulsi || impulsi > impulsiOld)
{
  ...
}
impulsiOld = impulsi;

is going to be running pretty much always. That's because impulsiOld and impulsi will either always be the same (since you set them to be the same) or impulsi is going to be greater than impilsiOld since you received a pulse in the brief interlude when it's not running that bit.
And that means that all your deltaT entries are going to be the same most of the time.  Which leads me on to the next bit:
int t1 = (deltaT[1] - deltaT[0]);
int t2 = (deltaT[2] - deltaT[1]);
int dividi = t1 + t2;
vel = (((690 * 2000 / dividi) * 3.6) / 10) * 0.85;

If delatT[1] and deltaT[0] are the same, then t1 will be 0. The same goes for t2. 0 + 0 = 0, so dividi will also be 0.
And that means:
690 * 2000 / 0

Which will be a divide by zero exception and will cause the MCU either to lock up or to reboot. If the latter you will see the bootloader run for a couple of seconds.
There are two normal methods of calculating the speed from pulses, and I am not sure what your method is trying to be.
The simplest one is to just count the number of pulses over a given period. Increment the count in your ISR, and after a second has elapsed (or longer, or shorter, depending on the frequencies you are working with) you reset the count to 0 (after storing it elsewhere) and calculate the speed from that stored count.
The other way is to just take the time between two successive pulses. You can average it, maybe with a rolling (AKA moving) average, or just take the raw value depending on what you are measuring.  This method is a little harder since you need to do more work per pulse.
The two methods differ in critical ways when it comes to outputting the results. The first method will always give you a value every second (or whatever time period you use), but it can't cope with pulses that are further apart than the time period you use. The second method doesn't much care about the time between the pulses, but you can only get a meaningful reading if a pulse arrives, which if that is a while means you get no reading for a while. It's harder to determine "not moving" from that.
Also you should look at the use of critical sections when accessing your impulsi variable outside the interrupt routine. It more than 8 bits, so all access to it will be non-atomic and could be interrupted by the ISR.


text:
Problem with Arduino and INA226 power meter module
I am new to the use of Arduino in general, and to the INA226 Module for power metering.
I first got everything set up WITHOUT anything plugged to the INA226 module metering pins (V+, ISens+, Isens-, V- not connected to any power source) and running a sample code that gets data being read by the INA226, of course, all values return 0, but at least I know the program runs and the arduino can connect to the INA226. Now, the problem comes when I try to get some reading such as 5V or even 3.3V from the Arduino pins.
I connected the circuit as follows:

simulate this circuit – Schematic created using CircuitLab
(I noticed that I wrote A6 instead of A4, sorry about that)
But when I do this, there is no reading at all from the serial console. I tried connecting the V+ and Isens+ directly to the 5V pin leaving everything else as shown in the diagram, but the Arduino board doesn't even turn on.
I tried referencing other sources, but their tests use external power supplies or other equipment I don't have.
I would be really thankful if someone could lend me a hand here or help me understand why am I having this problem and how can I make it read something basic such as 5V or 3.3V directly from the Arduino board.
Thanks!

I normally use 4.7K for the pull ups, don't know if that will make a difference

You need a shunt resistor between Isens+ and Isens- to get any meaningful readings. You also need a load between V+ and Isens+. The way you have it wired right now makes no sense.

@majenko Thank you very much for your reply. I tried getting the load from the Arduino board itself as I don't have many resources and I want to test this INA226 module. Also, as far as I know there is already a shunt resistor embedded into the Module, do I need an additional one?

There is a discrepancy in pin terminology between your schematic & what TI uses in their datasheets. I don't see anything in their datasheets using I+ or I-. I only see V+ & V-. These 2 pins perform all your voltage & current measurements depending on the "mode" you tell the IC to use.
As near as I can tell based on your schematic, you should be seeing the voltage reading based on what is applied between V+ & V- (In your case, 3.3vdc) if you've told the chip to read the bus voltage channel.
You should also be getting a current reading between the V+ & V- pins if you've told the chip to read the shunt voltage channel. Since the part is designed for a full scale voltage differential of 36v between the V+ & V- pins, I suspect a reading of about 10% of max (based on a 3.3v differential).
I confess to not knowing the board or its operation but having looked it up on the TI website, it does appear to have a few jumper settings & a calibration routine to follow. There's a user guide on TI's website as well as the usual technical data pages. Perhaps those will assist in setting the jumpers correctly. ina226 data sheet & eval board user guide
bc

Thank you very much for your detailed reply @user33722 . This module I'm using has some additional components such as the shunt resistor you mentioned I was missing, it's all integrated into it. Turns out it was just a simple wiring problem and now I got it working fine.
For future reference, this is where more information can be found for this module and wiring https://strawberry-linux.com/pub/ina226-manual.pdf (Japanese)

If this is the usual Arduino-style module with a shunt resistor already in it, then with your schematic, you have [nearly] shorted your supply rail. Your schematic should have the load wired in series to the Isense+ and Isense- terminals, and the V+ and V- terminals should be connected in parallel across the voltage powering the load.
The current must "pass through" the Isense terminals, and the module has to measure the voltage across the load in order to be able to get both I and V to compute power consumption.


text:
Wrong computation Number
im trying to make a speedometer with arduino Nano Board but when i use interrupt im getting "strange" number on variables t1 or t2 going under 0 there is the code:
volatile int impulsi =  0;
int impulsiOld = 0;
volatile int appoggio = 0;
//static int inizioDiNuovo = 0;
volatile unsigned int deltaT[3];
long t1=0;
long t2=0;

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

  pinMode(2, INPUT_PULLUP);
  attachInterrupt(0, definisciTempi, RISING);

}

void loop() {

  Serial.println(impulsi);
  if (impulsi == impulsiOld || impulsi > impulsiOld)
  {
    ;
  }
  //Serial.print("N IMPULSI: ");
  //Serial.println(impulsi);
  if (appoggio == 3) {
    appoggio = 0;
    Serial.print("DELTA T 0 : ");
    Serial.println(deltaT[0]);
    Serial.print("DELTA T 1 : ");
    Serial.println(deltaT[1]);
    Serial.print("DELTA T 2 : ");
    Serial.println(deltaT[2]);

    t1 = (deltaT[1] - deltaT[0]);
    if (t1 == 0) {
      t1 = 1;
    }
    t2 = (deltaT[2] - deltaT[1]);
    if (t2 == 0) {
      t2 = 1;
    }
    int t = t1 + t2;

    Serial.print("TEMPO T1 ");
    Serial.println(t1);
    Serial.print("TEMPO T2 ");
    Serial.println(t2);

  }

}

void definisciTempi() {
  impulsi++;
  switch(appoggio){

    case 2:
    //Serial.println("ASSEGNO DELTA T 2");
    deltaT[2] = millis();
    //Serial.println(deltaT[2]);
    appoggio = 3;
    break;

    case 1:
    //Serial.println("ASSEGNO DELTA T 1");
    deltaT[1] = millis();
    appoggio = 2;
    break;

    case 0:
    //Serial.println("ASSEGNO DELTA T 0");
    deltaT[0] = millis();
    appoggio = 1;
    break;

  }
}

how suggest i changed
unsigned int t1=0; unsigned int t2=0; into `long t1=0; long t2=0;`

output on Serial now have negative number it's for the interrupt??:
DELTA T 0 : 8785
DELTA T 1 : 8666
DELTA T 2 : 8706
TEMPO T1 40
TEMPO T2 -119  <------how 8706-8666= -119 ?

this is my pulse generator code:
const int pin = 2;
void setup() {
  pinMode(pin,OUTPUT);

}

void loop() {
 digitalWrite(pin,HIGH);
 delay(40);
 digitalWrite(pin,LOW);
 delay(40);
}

appoggio Isn't defined as volatile. All variables that get changed in the interrupt, and used in the main loop need to be volatile.

thanks i made appoggio volatile but don't change the result , every time negative number , thanks

Move "appoggio = 0;" to after al the serial.prints.

After you set appoggio = 0; and interrupt might fire, and change the variables you are currently working on.

What will happens if you get an interrupt between printing the deltas and calculating the t values? You'll end up with the t values being calculated with the new delta values (or half with the old ones, half with the new ones) . You need to disable interrupts, make a copy of the delta values and then re-enable them. You then base all your outputs and calculations on the copies.

Oddly, with the delta numbers shown: deltaT[1] - deltaT[0] == -119 and deltaT[2] - deltaT[1] == 40. In the output it appears that t1 and t2 have swapped values.

Andrew THANKS for your reply, now i just disable the interrupt for make some compute operation without problem, thanks again

The interrupt may be triggering between the Serial.print and the actual calculations, as stated by @Andrew.
Evidence supporting that fact is that your deltas are recorded in order 0, 1, 2 (ie: delta 0 < delta 1 < delta 2), However in the example output delta 0 is larger than delta 2, which suggests that a new round of delta recordings had started but not yet completed.
Updating this section as follows should fix the issue:
if (appoggio == 3) {

  noInterrupts(); // Disable interrupts while calculating

  appoggio = 0;
  Serial.print("DELTA T 0 : ");
  Serial.println(deltaT[0]);
  Serial.print("DELTA T 1 : ");
  Serial.println(deltaT[1]);
  Serial.print("DELTA T 2 : ");
  Serial.println(deltaT[2]);

  t1 = (deltaT[1] - deltaT[0]);
  if (t1 == 0) {
    t1 = 1;
  }
  t2 = (deltaT[2] - deltaT[1]);
  if (t2 == 0) {
    t2 = 1;
  }
  int t = t1 + t2;

  Serial.print("TEMPO T1 ");
  Serial.println(t1);
  Serial.print("TEMPO T2 ");
  Serial.println(t2);

  interrupts(); // re-enable interrupts

}

unsigned int t1=0;
unsigned int t2=0;

Integers on an 8 bit system can only store 16 bits of data. For unsigned that is 0 - 216-1, or 0 - 65535.
Make them unsigned long and they can store 0 - 232-1, or 0 - 4294967295.
Also, since they are unsigned, any negative value will wrap around to the maximum again. An unsigned can't store a negative value.

I'm simulating the pulse with another arduino board, how an impulse timing be negative? i have setted the time to 40ms for each pulse(sorry for my english)

now i make the change to unsigned int to unsigned long but now this the output: DELTA T 0 : 3269 DELTA T 1 : 3309 DELTA T 2 : 3349 TEMPO T1 4294967096 TEMPO T2 40

You may well be suffering from a lack of critical sections which I mentioned in your previous question.


text:
HMC5883L tilt compensation
I have a HMC5883L 3-axis magnetometer. I would like to add tilt compensation to my Arduino Uno project.
Since the IC has 3 axis that it measures (X,Y,Z) is it possible to add tilt compensation without an accelerometer? If yes would this how do I find an equation to do the calculation. Is this equation found from http://bluelemonlabs.blogspot.fi/2013/08/arduino-simple-compass-with-hmc5883l.html correct?

No. You need an accelerometer.
If you read the article you link to you can see this bit:

There are many margin of improvement. First, we ought compensate the potential tilt of the device using the accelerometer data from the ADXL345, for example using the info on my previous post!

To do tilt compensation you need three axes of both magnetometer data and accelerometer data to scale and merge those three axes.


text:
Did I damage my Arduino?
I was trying to build a Bluetooth controlled car. I was near completing it but what I did wrong was that I connected the 5 V output of L298 motor driver to 5V pin of Arduino where I was supposed to connect it in Vin. My Arduino got heated for a couple of seconds. Knowing that I immediately disconnected. Now serial port doesn't work in my Arduino. The serial port option turned gray. I even tried replacing the ATmega IC but got the same result. What might have happened?

sounds like you should be able to reprogram it with another ardunio and still use gpio

Yes, it sounds like you fried something.
I can't quite make out what it was you did from your description (I'm sure it makes perfect sense to you with the hardware in front of you), but the symptoms do sound somewhat fatal.
What actually happened depends very much on the Arduino you have - if it's a genuine one or a cheap Chinese clone. Either way the USB circuitry seems to not be functioning. Whether that is because the USB chip (varies depending on if it's a real Arduino [ATMega16U2] or a clone [CH340G]) or one of the voltage regulators is unknown.
You should power the board up normally and test the voltages at the 5V and 3.3V pins. Also if a component is still getting hot you should note which component it is, and that will give more of a clue as to what went wrong.

Ok I did the way you told me to do. The 5V pin is showing 5,03V and 3.3V pin is showing 3.3V exactly and I have powered up board for almost 15 minutes and none of the components got heated up..but what I noticed is that when i press crystal(applying certain force) in arduino D16 000l2 the light in L led turns off. And it also happens when I put my fingers in the soldered portion of 13th pin and below that.

Precisely which Arduino do you have?

Arduino uno r3 and I dont know if it is orginal or clone..

Where did you buy it?

Ok I live in Nepal. I purchase in local market of my area..

Can you post a photograph of it?

yes sure but I dont see any option to upload the photos. Please can u guide me . I have just joined this forum

Go to edit your question, then insert a picture where the cursor is by clicking the picture icon (a square with two triangles and a dot in it - it's supposed to represent a picture of mountains).

Thank you sir . Here you go . I have uploaded the picture when the board is normally powered on

That looks like a fake (clone) Arduino to me. Subtle, and it took close inspection, but the telltale signs are there. The biggest giveaway is the use of the serif font the Chinese fab houses seem to default to where it should be sans-serif (e.g., the word Digital).

Have you tried the normal things of changing the USB cable, and plugging in to a different USB port?

Yaa I did all the possible things but none of these worked....I even changed the ic but the same problem exist..I dont know if I shud install a bootloader manually or not..although I was informed that the bootloader was pre installed

Changing the main IC won't fix it since the problem is with the USB interface and that's a separate chip entirely (the small square one next to the USB socket).

I get it ..If I recall that chip also got humongously hot at that moment. I guess its probably better if I get a new one. Thanks for your support

The chip may have survived but just the soldering may have melted and the chip is no longer attached to the board properly. Or the chip may be toast. As you say, buy a new board, it's simplest. With a counterfeit board like that you can never be sure that the components are particularly any good.

Yes thats definitely right..

You fried it you should ALWAYS double check connections before powering on your arduino but I do suggest doing a normal power up without any connections to see what happens

I did the normal connection but nothing happens. Neither heating effect nor any other. Just the L led and on led powers on . And I cant use Serial Port . The option is greyed. When I upload any code consider the blink code it tells the com port missing. Is there anything I can do with this board or purchasing a new one shall be better.

I would prefer you to buy a new original Arduino as it would be quite difficult to repair any hardware issues (which is your issue) which would include soldering replacing and etc° and would be even expensive to buy new parts.

I guess so..Thanks fotlr the recommendation and help

The ATmega328 on these boards is 5V tolerant on GPIOs so it depends on where exactly you connected the cable.
GND pins, for example, would've been fatal.

I connected the positive 5V coming from motor driver to 5V pin of arduino and GND for both motor driver and arduino was made common..Everything happened when I connected in 5V pin when I was supposed to connect in Vin pin of arduino

it feel sad to hear that you just fried it up. Every mistakes gives opportunity to learn tons of knowledge.
In this case you supplied 5v supply to 5v output pin. If you've seen the datasheet of  8-bit AVR Micro-controller ATmega328/P you'll know that it just possess VCC for 5v supply pin (input) neither an output 5v pin. Its the job of voltage regulator attached next to the power jack to supply 5V to provide the necessary juice to the chip. If you supplied 5v to GPIO output pin then you may or may not have burnt the chip but for sure you burnt the arduino board ,technically its power control system. So i think it'll be better buying a new board rather then fixing it.But i salute your attempts.

Thank you bro..I appreciate that. And I wont make such mistakes from next time


text:
How to know positive and negative in breadboard
I have this breadboard, and there is no indication on it about what is positive/negative on it.

In comparison, this other breadboard (pic from the internet) DOES have indications:

Can anyone give me a hint ?

Hint: there is no negative or positive.

@gre_gor like this https://www.pjrc.com/store/breadboard.jpg I want to wire two pins to ground on breadboard

@Williams You could do that as usually as you would with a printed or marked board.

It doesn't matter. You could label them yourself with a red and blue permanent marker.

Also from my experience, your breadboard has side rails wider apart than the other breadboard and a power supply intended for a breadboard won't fit.

Here;s the rub:  Don't forget what you have chosen.  Wiring power backwards is hard on some components.  I make a point of always using the same color of wires for power to everything, and as long as the same colors are on the same rails I don't need to look at breadboard markings.  Have fun!

btw, I have used those power supplies for breadboards.  Be wary.  Their QC is not good.  I don't use them any more.

You decide which rails are positive and which are negative when you connect them to the + an - from your power supply or battery.
A breadboard isn't polarised per se. It's just a bunch of cross-connections inside a perforated plastic case. No active or passive components inside.
Some manufacturers may choose to paint indications regarding where to connect the positive and negative rails, but those are just a guideline. Ultimately it's your choice, you're free to connect + and - wherever you want in the breadboard rails.

so If I wire GND of battery to first row, do I need to plug other wires which need to be GND besides to that wire in a same row ?

Yes indeed. Moreover, if you find it convenient to use a row in the opposite side of the breadboard as GND too, just connect it via wire to the first GND row and boom, you've got another GND row. As simple and easy as that.

As gre_gor said. A simple breadboard contains of rows and columns of connections but sometimes for convenience manufacturer marks or prints Positive and Negative symbol along the row as they are usually used to power a circuit

Connections in the two strips along the edge running top to bottom in your image are connected (in the way you have the image placed) top to bottom.  So, all pins are connected to each other in each of those rows.  Within the inner secions, the connections are (in your image) across from one side to the other.
You decide how you want the power supply cable to be connected to your breadboard,  just becasue there's no indicators means that they simply haven't drawn any coloured lines on the breadboard.  You can draw red and black lines on however you wish.


text:
How to keep a specific bit set all the time for bit masking I2C operations?
I've been working on I2C and I learned how to initialize, send and receive with I2C communication protocol.
Next, I wanted to run the LCD1602 I2C adapter. But the module has a different bit masking, it turns out that I have to keep a specific bit set so I can control the remaining 7-bits, because otherwise I can't control the upper 4-bits if this bit is 0.
So, I put the 8-bit variable for the bit masking operations in the global section and initialize it with uint8_T bitmasking = 0x08; but it's volatile. I used static keyword, but the bit is not constant.
So what's the solution?
Regards,

'static' just avoids reinitialization and is used for local vars in timed interrupts for example.
volatile is another keyword you should not be using without thinking about it and does not appear to be useful for your case. See https://stackoverflow.com/questions/4592762/difference-between-const-const-volatile for more information
The appropiate keyword would be const, which tells the compiler this var mustn't be changed.
But I suspect there is another problem with your code, which will make the compiler throw an error as soon as you use const in the declaration.
I assume you are not using the variable correctly. You are meant to use a bitwise OR | in order to set the required bit along your actual data.
So do it like this:
data_byte |= bitmasking;
write8(data_byte);

Well, after thinking about it, I don't know, I don't think it's what I want because it may change anytime.

wtf? what may change at any time?

Sorry that method works fine. I figured out another method which is to initialize the variable in the global region with that bit set. Regards,


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

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


text:
Is it any way to connect ESP8266 to wifi faster?
I'm uploading this sketch to try connecting ESP to internet. However, most of the times I've ran it it takes a very long time to connect, a lot of times I've had to break the process because it seems it goes to nowhere. Few times it has connected in less than a minute. Is it any alternative to boost the connection?
Also, when I reset the module, it writes to the terminal 3 strange characters, and freezes without even starting to execute its sketch. Do you mind me asking how to solve that?
Regards!
#include <ESP8266WiFi.h>

const char red[] = "CDT10";
const char pass[] = "G7ZSY74Cs";
unsigned long muestra = 0;

void setup() {
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  WiFi.begin(red,pass);
  while (WiFi.status() != WL_CONNECTED){
    Serial.print(".");
    delay(1000);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: "); Serial.println(WiFi.localIP());
  Serial.print("Chip ID: "); Serial.println(ESP.getChipId());
}

void loop() {
  delay(5000);
  muestra = millis();
  Serial.println(muestra);
}

Which board are you using?

Right now, ESP-01.

is the bandwidth ok once it connects?

I have also experienced the inability to connect sometimes. I wait a certain amount of time for it to connect then do a ESP.reset() if it fails.
As for the boot problem it sounds like you are keeping GPIO0 low so it goes back into programming mode. Hold it high and it will run your program instead.

It worked! I forgot to hold high the GPIO0. Now it is running right. Thanks!