text:
Arduino Due ( Atmel Microcontroller) IC Heat up and led goes off
I was connecting L293d Motor Driver IC with an Arduino Due Board. May be due to wrong connections, but when I made the grounds common, the Arduino LED goes off and Atmel IC heats up. When I reconnect my Due board with my PC anytime, the LED turns on and slowly dims to off and Atmel IC fries up.
I wanted to repair it. What should I do?
I have checked the input voltage of the AMS1117 3.3V regular IC as 3.8 V, while the output is 2.2 V. If I externally give 5 volt at input again, the input voltages drops. The regulator is loading.
I thought of replacing the regular IC?
Will that work?
Also I externally powered the Board with 3.3V by its pin labeled "3.3V" . The LEDs glow on and did not go off. But the Atmel Microcontroller IC becomes very hot.
What should I do?

Trash it and get a working board.

Motor driver boards exist to allow an MCU to control a motor without having to supply its power. If you try to power motors from the Arduino as well, they draw too much current and things get hot or damaged.
The 3.3v pin is only for supplying modest amounts of current at 3.3v from a 5v Arduino. You can not back-power the board with it. I don't know what happens if you try, but I bet it isn't good...

Supplying 3.3V to the board and trying to draw from the 5V connection will damage the voltage regulator. Since the ATmega16U2 on the board draws from 5V, well...

I have disconnected the motor driver and when i give USB power. Led glows for short period of time and then turns off. At the same time MCU heats up. and i am unable to upload any code in it. Does changing a regular will fix it up?

@MasoodSalik MCU heating up without anything connected to outputs means it's more or less destroyed. Something reached break down voltage and now it's permanently conductive.


text:
Problem building a smart shopping cart
I'm building a smart shopping cart with Arduino for my final year project.
The cart is supposed to be able to follow its user while shopping. I don't know of many feasible indoor positioning systems to use.
Proposed solution 1
I have recently seen some RF/ultrasonic positioning systems that make use of:

one ultrasound transmitter and one RF receiver, carried by the person,
and two ultrasound receivers and one RF transmitter carried by the robot.

The robots RF transmitter sends out a signal, which when received by the person's RF receiver, triggers the person's ultrasound transmitter to transmit a signal. This signal is received by the robot's two ultrasound receivers (with a distance, d between them), and the distance and angle to the target person can be calculated.
That sounds very feasible, but my question is, if the robot is in a crowded place, where the other people are also carrying ultrasound transmitters and RF receivers:

Will the RF signal meant for the owner of the robot be accidentally received by the RF receiver on another person, or is there some kind of unique ID shared between RF receiver/transmitter pairs that could prevent this problem, or maybe some kind of frequency hopping system, so there would be no mistaken identity.
How will the ultrasound receivers on the robot be sure that the received signal is from its matching ultrasound transmitter. Again, is there some kind of special ID systems employed by some ultrasonic transmitter/receivers.

Proposed solution 2
I have also read about this new device called Trackr, it makes use of bluetooth low energy to track objects based on their proximity to bluetooth enabled devices like smart phones.
Considering a scenario where various bluetooth devices (beacons) are placed at specific points in a room, and the target to be tracked is equipped with a bluetooth emitter/bluetooth chip/dongle.
When the target passes each of those beacons, the signal strength intensity is received and distance from the target is calculated.
I understand this concept, but have some questions:

When distance is calculated between beacon and target, what about the angle, how would the robot follow the target based on distance alone?
If this method is not accurate enough to be used in a crowded space, what other method can be used, I have checked out some indoor GPS devices and they are way to expensive (above $200).

Would a camera-based tracking system be better and how easy would it be for a non expert like me to implement.

Also see some of the linked questions (in right sidebar, some of which are woefully short on facts, and some of which may be useful.

Is the user (shopper) allowed to wear things? For example, an IR transmitter? How big is the proposed area (shop)? Are there multiple aisles? For the demo are you basically getting the cart to follow someone around a room, or does it have to navigate aisles (or worse still, display cases or other shoppers)?

Also, can you install things in the "shop"? I presume the cart itself can have technology all over it.

yes, any of the above scenarios would be fine, i am not ruling out anything

I have a couple of ideas for you but know these are only suggestions. No hate please.
Have you tought of IR following?
IR is a almost unique signal that only you have. You can either use multiple IR sensors to determine where the emitter is or you can use the servo motor to do it as a radar. Note that you have to isolate each sensor so it knows where you are and it doesn't captures the wave from a different angle by accident.
Extra safety?
You can also incorporate an untrasonic distance sensor so that the cart doesn't bump into you or any one. Like you can say, if the distance is smaller then 12 inchs / 30 cm, stop the cart. It is practically an extra safety feature.

well, if the IR is the only signal that can send unique codes, what then do telecommucication companies use to transfer data

I just think that something like RF is a little too strong. You would want the beam to be concentrated into a small area with an isolated sensor that can detect at what angle of the cart you are. RF is too strong to do that and it is quite more expensive.

Try keeping it simple. I'd have the person wear and infrared transmitter. Then on the cart have an array of IR-receivers pointing in all directions. That way the cart knows which direction to go.
Next you need to get the distance to the target using e.g. an ultrasonic distance sensor.
Lastly you need to add some bumper sensor, so the cart known when it's running into an obstacle.
Your camera solution might also work, combined with OpenCV. But you can't run that on a measly Arduino.

thanks. but with the infrared transmitter, wouldnt the cart follow pretty much anyone who wears a similar infrared transmitter?

my major issue is how to match one person to one cart in a fairly crowed environment

You can have them send unique codes, similar to a remote control.

wow, really. Thanks thanks. So if i surround the cart with infrared receivers, wouldn't there be interference with each other, does it work with line of site. If so, does it mean i would need to cover the entire perimeter of the cart with receivers? Also is it only infrared transmitter/receivers that are capable of sending unique codes?

I'm going to get a bit ambitious here and suggest something along the lines of what the Vive virtual reality system uses. You can see from some of the photos on that site that the headset has lots of sensors on it. Judging by this article they detect signals from two base stations. I presume the base stations send IR beams (because radio would not be directional enough). The sensors on the headset are recessed a bit, which would shield them from anything but a line-of-sight beam from a base station.
The store
Now you don't need anything quite that sophisticated, but something like this might work. First, you have some IR transmitters located around the store, pointing in a criss-cross pattern, like this:

The green box is the cart and the bigger boxes the shelving. Now with sensors on the corners of the trolley, pointing in different directions, and with each transmitter sending a differently-coded IR beam, the trolley should be able to work out its position fairly accurately.
The trolley
By a process of exclusion (if you don't see a particular base station then you are not near it) and inclusion (if you do see a base station from a certain sensor then you can deduce a possible area you are in) you should be able to work out your position.
In this case we might expect that the bottom-left-diagonal sensor would be picking up signals from station 1003, and the bottom-right-diagonal sensor would be picking up signals from station 1004. Plus the forward sensor may be getting signals from station 1000 (depending on the range) and the rear sensor from station 1005.
The shopper
Now we also need to know where the shopper is. If you gave the shopper a vest or belt with sensors on it in a similar way (eg. front, back, diagonal) then similar calculations can work out where the shopper is. Let's assume that each shopper and each trolley are given a unique ID pair (that is, a trolley is associated with a vest). Effectively, each shopper would transmit, every second or so "shopper 5677 is at position x=543, y=666 in the store".
Now we can use radio transmission (from the shopper) to its paired trolley, to tell the trolley where its "owner" is. And assuming the trolley knows where it is, then it can work out if movement is required, and if so, in what direction.
Collision detection
In addition to the above, you would need some proximity sensors on the trolley (eg. ultrasonic) to stop the trolley from driving into other shoppers, display cases, its owner, etc.
Maze solving
The trolley could have software on it to solve the problem of reaching the shopper. For example, if its way is blocked for too long on the shortest path, it might take an alternative which would be to go to the end of the aisle, go down a different aisle, and then back to where its owner is.
Extra credit

You could make a button on the trolley you push when you are finished. The trolley could then "lead" you to the checkout with the shortest queue at it (or an empty checkout).
You could have some buttons on the trolley with major grocery types on it (eg. dairy food, bread, frozen foods). When pressed the trolley could lead you to the appropriate aisle.

Another solution, along the lines of your camera option, would be to seed the store with Kinect (or Kinect-like) camera systems.  These systems are already designed to track multiple people at once.
Using this method you don't need to equip the shopper with any device, which lowers logistics (how do I get that device back when the shopper exits the building) and tech support costs.
You might need to equip the carts with some kind of marker - I don't believe the Kinect systems are designed to track inanimate objects, but I could be wrong.
So challenges to overcome with this system would be:

How to track the carts?
Kinect doesn't have a very large focal distance so you will need some kind of system to hand shoppers off to the next Kinect when they pass out of range of the one currently tracking them.

source: Stack Exchange

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

sort: votes


text:
modbus slave ID setting
I have small problem in setting device ID for Mosbus slave arduino. Here is simple example
In Modus library; device ID being configure hardcode while program. This code works for Me.
Modbus slave(1,0,0);

Now I wanted to recognise 0-255 device ID , I am using 8:1 digital Multiplexer & DIP switch to select the port. I am reading status of digital pin & depend on status of 8 DIP pin i come to know whats device ID. Below function return device ID. I have checked Serial it returns value properly. If i assign the value to Device ID it wont work . Please let me know how can i solve this.
unsigned int ID_Check() {
      unsigned   int ID_value;
      for(int row=0;row<8;row++)
      {
        digitalWrite(SO_enable,array[row][0]);
        digitalWrite(S1_enable,array[row][1]);
        digitalWrite(S2_enable,array[row][2]);
        Status_Out[row]=digitalRead(Output_Read);

      }

  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5] + 64 * Status_Out[6] + 128 * Status_Out[7];
  return(ID_value);
}

Below is complete code.I tried to call function loop But it wont work
#include <ModbusRtu.h>
int SO_enable=5;
int S1_enable=4;
int S2_enable=3;
int Status_Out[8];
int Output_Read=2;
Modbus slave(ID_Check(),0,0); // this is slave @1 and RS-232 or USB-FTDI
int array[8][3]={
  {
    0,0,0    }
  ,
  {
    0,0,1    }
  ,
  {
    0,1,0    }
  ,
  {
    0,1,1    }
  ,
  {
    1,0,0    }
  ,
  {
    1,0,1    }
  ,
  {
    1,1,0    }
  ,
  {
    1,1,1    }

};

unsigned int ID_Check() {
  unsigned   int ID_value;
  for(int row=0;row<8;row++)
  {
    digitalWrite(SO_enable,array[row][0]);
    digitalWrite(S1_enable,array[row][1]);
    digitalWrite(S2_enable,array[row][2]);
    Status_Out[row]=digitalRead(Output_Read);

  }

  ID_value = 1 * Status_Out[0] + 2 * Status_Out[1] + 4 * Status_Out[2] + 8 * Status_Out[3] + 16 * Status_Out[4] + 32 * Status_Out[5] + 64 * Status_Out[6] + 128 * Status_Out[7];
  return(ID_value);
}

uint16_t au16data[16] =
{
  3, 1415, 9265, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1
};

void setup() {
  slave.begin( 9600 ); // baud-rate at 19200
  pinMode(SO_enable, OUTPUT) ;// pin can enable/disable using digital IO 7 of arduino
  pinMode(S1_enable, OUTPUT) ;// pin can enable/disable using digital IO 6 of arduino
  pinMode(S2_enable, OUTPUT) ;// pin can enable/disable using digital IO 5 of arduino
  pinMode(Output_Read,INPUT);
}

void loop() {
  slave.poll( au16data, 16 );
}

The other way i tried
void Modbus_Setup()
{
  Device_ID=ID_Check();
     delay(100);
    Modbus slave(Device_ID, 0, 0);
     slave.begin(9600);
  //slave.setID(Device_ID);

}

It looks like the problem may be initialisation order. In C/C++, global variables/objects are usually initialised in the order they are declared, and before any global functions run.
In your case, this means ID_Check() gets called before array is populated, and before setup() runs.
It looks like you need to make sure everything else is setup before your attempting to initialise the Modbus object. I'm not familiar with the library, but perhaps there's a way to set the device ID after it's been constructed (i.e. not in the constructor)?
If not, you could declare slave as a global pointer, and then instantiate it using new in setup().
As a side note, I'm guessing your Modbus_Setup() function didn't work because the slave object in there is completely separate from the slave object that's declared globally and used in loop().

can you show how can do it. How can declare slave as global pointer. As given in example ; if declare slave as globally & assign the device ID with No. code work. But my intension is to device id being update hw read

If i cant configure using mux & DIP switch . I need to configure manually. or i need to remember each device ID being used so to avois conflict.

I have tested their example code. When i declare slave globally. it will work. If i declare inside setup & assign slave ID . It wont work. How can assign my slave ID here.

@AMPS Declare it globally as Modbus *slave = 0. In setup(), instantiate it using slave = new Modbus(...). (That's standard C++. I'd recommend looking up a tutorial on pointers if you're not familiar with them.)

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


text:
How to Create a water screen with solenoid valve in arduino
I want to make a water screen. I will create character with solenoid valve. Sometimes sequential valve will pass to water, sometimes not pass.
And I will create some shape or character.
But I don't know how can I create this character with Arduino.
Do you have any good idea ? Can you help me ?

You can refer to this page for the generic actuation (iow Arduino board + relays shield + power supply for the valves), but that leaves one problem open: timing.
To draw something on a wall of water, you need to make sure that the water flows with a known, constant speed (unless your wall is very tall, I would ignore the effect of gravity, if the initial speed is high enough).
Maybe it can be achieved without this extra step, but to play it safe, I'd also add a pump that feeds all the valves.
This will ensure that you will have a known pressure/speed of the water, thus being able to calculate the timing of the valves.
You can use one of the relays to control also the pump.
Notice also that most likely an arduino UNO/Nano or equivalent will not be sufficient, as you will get relatively few lines.
An ArduinoMega2560 or DUE have far more GPIOs.


text:
On start servos rotates to 180 degree
I'm testing a servo using varspeedservo.h and it rotates to 180 degree on start and then rotates back to programmed position.
Here is the code:
#include <AFMotor.h>
#include <VarSpeedServo.h>
VarSpeedServo myServo;

void setup()
{
  myServo.attach(10);
}
void loop()
{
  myServo.slowmove(0, 30);
  delay(5000);
}

And what's your question?

It should not show such behavior. How can i fix it?

I suspect its finding its limits.  You could try setting the position to 0 before you attach (no idea if that will work)

I just tried it but not working. Seems this issue comes only when I'm using Varspeedservo.h.

could it be reversed, try setting it to 180 and see if it moves towards zero, if so just map it map(pos, 0,180,180,0) and success

I tried reversing but it works fine. Not moving back to 0 deg.

You will need to open up the VarSpeedServo library source code and read through it to understand how the library actually works with your sketch.
Consider that you have not setup an initial position before issuing your first "slow moving" command.  It may be by setting an initial position before assigning a pin to the servo, you may prevent any unexpected movement.
Try something (for your code) like "myServo.wirte(0,0)" where the first argument is the position and second is the speed.

I added myServo.write(0,0); before attaching and it's working fine. Thank you.


text:
Use TSL2561 and DS1307 RTC together
I want to use a TSL2561 light sensor and a DS1307 RTC and a couple of other sensors like DS18B20, AS3935, ML8511, MQ135, 433 mhz sender together with an Arduino.
However on Adafruit I read this today (Quote from Adafruit)

You may be wondering, how is it OK to connect a 3.3V chip like the
  TSL2561 to 5.0V data pins like the Arduino? Isn't that bad? Well, in
  this specific case its OK. I2c uses pullup lines to the 3.3V power
  pin, so the data is actually being sent at 3.3V. As long as all the
  sensors/device on the i2c bus are running on 3.3V power, we're fine.
  However, don't use a 5.0v powered i2c device (like the DS1307) with
  pullups at the same time as a 3.3V device like the TSL2561! If you
  want to use this sensor with a datalogger that uses the DS1307, remove
  any/all of the pullup resistors from the DS1307 SDA/SCL pins. The
  pullups built into the TSL2561 will then be active and keep the
  voltage at 3.3V which is safe for both the RTC and the sensor.

I don't really understand the meaning of this. What am I supposed to do? It tells me to remove the pullup lines on the RTC, but what are they and where can I find them? Are there any other sensors where I have to do this? If I don't remove the pullup lines, will I damage anything? Can someone clarify those things to me?

You can use the DS1307 itself just fine, but you are probably using a breakout board. These boards have (pull-up) resistors on it that will pull-up the I2C lines to 5v, while you only want 3.3v. What board (if any) are you using for the DS1307?

I am using a normal one you get from ebay for like 2 bucks

There is no "a normal one", as there are multiple version, each having different configurations of pull-up resistors.

I am using this one http://www.ebay.com/itm/2PCS-Arduino-I2C-RTC-DS1307-AT24C32-Real-Time-Clock-Module-For-AVR-ARM-PIC-SMD-/310526222928?hash=item484cce2250

You can use the DS1307 itself just fine, but you are probably using a breakout board. These boards have (pull-up) resistors on it that will pull-up the I2C lines to 5v, while you only want 3.3v. This will not damage the arduino, but could damage chips like the  TSL2561, that can only handle 3.3v.

On the board you indicated you are using, you need to remove R2 and R3
Other 5v sensor breakout might also have pull-ups to 5v. Easiest way to check, is to connect 5v and ground, and then measure the voltage on the SDA and SCL pins. If it's 5v, then it has pull-up resistors that need to be removed.

Thank yoh. How would I remove them? Just desolder them and leave a unconnected gap or bridge them? Also do I need to do this for other chips? How do I figure out if I have to remove resistors and where?

Desolder and leave open. The last two questions I've already answered.


text:
Use AS3935 with I2C?
Has someone experience with interfacing the AS3935 lightning sensor using I2C? I found a library but it only works with SPI as far as I can tell. I really don't want to give up 4 pins for SPI as I need those for other things. I2C would be great as I use a couple more sensors with I2C so no extra pins only for AS3935.

Please post a link to this library. And preferably to the AS3935. That way your question can be answered more readily.

Datasheet http://www1.futureelectronics.com/doc/AUSTRIAMICROSYSTEMS/AS3935.pdf

I've used other I2C devices with Arduino UNO (version 1.6 IDE); a word of advice: since AS3935 wants I2C repeated-start condition (Sr) to read device registers, you may need to patch the Wire library... see http://forum.arduino.cc/index.php?topic=137607.0 and https://github.com/helenarobotics/Arduino/commit/8aff39a229362e0167e5f48f6c15d02b39b0fbca -- Modification to file C:\Program Files (x86)\Arduino-1.6.0\hardware\arduino\avr\libraries\Wire\utility/twi.c  --- line 468      twi_stop();  // <---- comment out this line

Just use these functions to read/write AS3935 registers, replacing the SPI ones (_devAddr is the device address, usually 0x03) :
// read/write functions for I2C mode
uint8_t AS3935::_i2cRead(uint8_t addr)
{
    // send register number
    Wire.beginTransmission(_devAddr);
    Wire.write(addr);
    Wire.endTransmission(false); // <<<--- THE 'false' here is mandatory!

    // request register data
    Wire.requestFrom(_devAddr, (uint8_t)1);

    // read data
    return Wire.read();
}

void AS3935::_i2cWrite(uint8_t addr, uint8_t data)
{
    Wire.beginTransmission(_devAddr);
    Wire.write(addr);
    Wire.write(data);
    Wire.endTransmission();
}

The "trick" is to use Wire.endTransmission(false) inside the read routine; this avoid to send the stop bit, which is mandatory for AS3935 read operation.


text:
Overwritten EEPROM
I have a problem with the Teensy, its EEPROM and another Array.
My program contains two Arrays, the first one is a 128x4 long Array, the other one a 2560x2 double Array. The first Array is meant to be written to the EEPROM once a certain time (=number of loops) is reached. The other Array is meant to be written to an SD-Card or just the terminal, can't deiced yet.
My problem is that whenever I uncomment the save()-function the first 17 data-quadruples in the EEPROM get somehow overwritten by random data. Always the first 17 with would be the first 68 numbers or 272 byte.
I have tried renameing the save()-function, but the onlything that works for now is to comment the function in the loop()-function out so that it won't be called at all. I even have enough RAM left, the Arduino IDE tells me I am using about 73% of the RAM for variables.
Could it be that be creating more variables somewhere else the Teensy overwrites the Array for the EEPROM? But than again why doesn't that happen if I don't write into the everything-Array?
Thank you in advance for any help!
Greetings,
John
PS: Please excuse my not perfect English for it's not my native language.
//Includes
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <SPI.h>
#include <String.h>
#include <EEPROM.h>

elapsedMillis looptime = 0; //time for each loop in ms
int loopnumber = 0; //number of loops
elapsedMillis overalltime = 0; //overalltime in ms
const int iterationtime = 25; //time for each loop in ms

//EEPROM
//Deklarations
int nsd = 0; //counter for saving into eepromArray
const int maxArrayrows = 128; //Max number of row in eepromArray
int iArray = 0; //Number of used rows in eepromArray
long eepromArray[128][4]; //Array for EEPROM-storage
bool writtentoEEPROM = false;
double everything[2560][2]; //Big Araay with a pair of numbers of each loop

// Some more variables
double z, zpunkt, alpha, angle;

void setup() {
 // Just inititialing stuff, nothing to do with the Arrays
}

void loop() {
  //Calculating more stuff

  ++nsd;
  if (nsd >= 20) {
    WritetoArray();
  }

  save(loopnumber);

  ++loopnumber;

  looptime = 0;
}

//********************************************************
//
// Save Data in Array. If full write into EEPROM
//
// long: 4 byte
// Storeage needed for each quadruple: 4*4 byte = 16 byte
// EEPROM-size: 2 kibyte
// Max number of quadruples: 2048 byte / 16 byte = 128
// Quadrupels per second: 2
// Max time: 128 / 2 = 64 s
//
//********************************************************
void WritetoArray() {
  int scale = 10000;
  long zArray = (long)(scale * z);
  long zpunktArray = (long)(scale * zpunkt);
  long alphaArray = (long)(scale * alpha);
  long angleArray = (long)(scale * angle);
  if (iArray < maxArrayrows) {
    eepromArray[iArray][0] = zArray;
    eepromArray[iArray][1] = zpunktArray;
    eepromArray[iArray][2] = alphaArray;
    eepromArray[iArray][3] = angleArray;
    ++iArray;
  }
  else {
    if (writtentoEEPROM == false) {
      WritetoEEPROM();
      writtentoEEPROM = true;
    }
    while(true){
      for(int n = 0; n < 2560; ++n){
        Serial.printf("%f, %f\n", everything[n][0], everything[n][1]);
      }
      Serial.println("----------");
    }
  }
  nsd = 0;
}

//********************************************************
//
// Write Data to EEPROM
//
//********************************************************
void WritetoEEPROM() {
  byte data;
  int adress = 0;
  int  i = 0;
  while (adress < 2048) {
    for (int n = 0; n <= 3; ++n) {
      for (int a = 0; a <= 3; ++a) {
        data = (eepromArray[i][n] >> ((3 - a) * 8)) & 0x000000ff;
        EEPROM.write(adress + a, data);
      }
      adress = adress + 4;
    }
    ++i;
  }
}

//********************************************************
//
// Save data-pair for later usage
//
//********************************************************
void save(int l) {
  everything[l][0] = z;
  everything[l][1] = angle;
}

Are you never resetting loopnumber to 0 once it gets greater than 2559?

In your loop(), you increment repeatedly loopnumber without ever resetting it. You should at the very least replace
loopnumber++ ;

with
loopnumber = (loopnumber+1)%2560 ;

Otherwise, when loopnumber becomes >= 2560, your save() function will begin writing outside the 'everything' array and overwriting whatever is written in the adjacent positions of memory.

You mean loopnumber = (loopnumber+1)%2560. What you wrote is undefined behavior.

@Edgar Bonet : You seem to be right. I fixed the code accordingly.


text:
Problem in bootloading 328p using Arduino as ISP. Please help me in figuring out the problem.I have uploaded the verbose below
Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Uno"
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM8 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

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

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

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000 (retrying)

Reading | ################################################## | 100% 0.02s

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

avrdude done.  Thank you.

Error while burning bootloader.

I had the same problem yesterday. So look at the help offered to me and the solution.

it is wrong wiring

@Decapod So that's it? I have re checked the wiring numerous times.

Could you post a picture of your wiring?

@PeDro. It must be a wrong wiring or a bad contact in the wiring. Follow the arduino procedure carefully and verify the wiring again

there is great community called avrfreaks.net great with anything with AVR.
There is thread going with exactly same issue. follow it.
one quick thing try different 328p chip if it works mostly this one is bricked.
still want o experiment try changing crystal, fuse-bit , ISP , external clock generator.


text:
Why does an RGB LED between VCC and PWM work?
I'm an Arduino beginner and I recently bought a cheap starter kit on eBay. One of the lessons in the starter kit is an RGB LED controlled by 3 PWM output pins. However, the arrangement of the connections seems a bit funny to me:

To my surprise, it worked. I could see the three LEDs inside the plastic change colors. Why does this work? Do the PWM pins accept current whilst low? Is this a common arrangement? See the above link for the code provided in the lesson.

This is a common arrangement and is known as Common Anode, and the I/O pin is said to be sinking current.
To better understand what is happening here it's best to think of an I/O pin as a two-position switch:

When the I/O pin is HIGH point 1 is connected to point 2. When the I/O pin is LOW point 1 is connected to point 3.
So when HIGH the circuit is Vcc -> D1 -> R1 -> Vcc (or the other way around - I have done it that way because of the polarity of the LED), and no current can flow since it has nowhere that isn't at a lower potential than Vcc to flow to.
But when the I/O pin is LOW the circuit is now Vcc -> D1 -> R1 -> GND and so current can flow through it all to ground.  As a result the LED now lights up.
One thing you may have noticed now is that the operation is backwards.  Set the IO pin to LOW to turn the LED ON. That has the effect, as well, that PWM duty cycles are reversed.  analogWrite(ledPin, 0) will be full brightness and analogWrite(ledPin, 255) will be off.

Do the PWM pins accept current whilst low?

The pins sink current when low. And yes, that is commonly done. The pins are not "do nothing" at LOW, and "put 5V there" at HIGH. They are specifically designed to try to source (drive high) current when HIGH and sink (drive low) current when LOW.
To have pins (more or less) do nothing, you have to set them to INPUT mode. Then they try to neither source nor sink.
Caveat: if you enable the internal pull-ups they will try to weakly source current.

Is this a common arrangement?

It is quite common, depending on whether the device you are controlling is active high, or active low.

The RGB LED is common anode. This is why it is connected to VCC and the PWM pins pulls down to light resp LED.
A common cathode RGB LED would be connect to GND and the PWM pins would pull up to light
Cheers!


text:
How do you wire a ssr relay to a arduino nano
I am trying to wire a fss1-102z 5v ssr relay to my arduino nano but i cant get it to work here is my circuit. It stays stuck on and i cant get it to turn off.

Bluetooth control code
char val;         // variable to receive data from the serial port
int ledpin = 2;  // LED connected to pin 2 (on-board LED)

void setup()
{
  pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
  pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT

    Serial.begin(9600);       // start serial communication at 115200bps

}

void loop()

{
  if( Serial.available() )       // if data is available to read
  {
    ;
  }
  val = Serial.read();         // read it and store it in 'val'

  if( val == 'a' )               // if 'a' was received led 2 is switched off
  {
    digitalWrite(ledpin = 2, HIGH);    // turn Off pin 2
  }

  if( val == 'A' )               // if 'A' was received led 2 on
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
  }

  if( val == 'b' )               // if 'b' was received led 3 is switched off
  {
    digitalWrite(ledpin = 3, HIGH);    // turn Off pin 3
  }

  if( val == 'B' )               // if 'B' was received led 3 on
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
  } //else (ledpin = 3, LOW)        //set led pin 3 to low state

  if( val == 'C' )               // if 'C' was received led 2 on for 1 second
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
  }

  if( val == 'D' )               // if 'D' was received led 3 on for 1 second
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin, HIGH);      // turn Off pin 3
  }

  if( val == 'E' )               // if 'E' was received led 2 on for 5 seconds
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
    delay(5000);                     // wait 500 milli seconds
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
  }

  if( val == 'F' )               // if 'F' was received led 3 on for 5 seconds
  {
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 3
    delay(5000);                     // wait 500 milli seconds
    digitalWrite(ledpin, HIGH);       // turn Off pin 3
  }

  if( val == 'G' )               // if 'G' was received turn led pin 2 on for 500ms then switch off and turn on pin 3 for 500 mili seconds then off
  {
    digitalWrite(ledpin = 2, LOW);  // turn ON pin 2
    delay(500);                     // wait 500mili second
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
    digitalWrite(ledpin = 3, LOW);  // turn ON pin 2
    delay(500);                     // wait 500 mili second
    digitalWrite(ledpin, HIGH);      // turn Off pin 2
  }

  if( val == 'h' )               // if 'h' was received switch off all pins
  {
    digitalWrite(ledpin = 13, LOW);    // turn Off pin 13
    digitalWrite(ledpin = 2, HIGH);      // turn Off pin 2
    digitalWrite(ledpin = 3, HIGH);      // turn Off pin 3
}

  if( val == 'H' )               // if 'H' was received switch pin 2 on and off 1000 times

  for(int i = 0; i < 1000; i++)
  {
    digitalWrite(ledpin = 2, HIGH);  // turn ON pin 2
   delay (1000); //wait 1000 mili seconds
    digitalWrite(ledpin = 2, LOW);  // turn Off pin 2
   delay (1000); //wait 1000 mili seconds

  }

}

According to its datasheet, the FSS1-102Z doesn't work with DC-voltage. Also the minimal voltage required is 50VAC. Here is the excerpt from the datasheet:

@jfpoilpret So when i hook it up to a 240v 80w pump it will work fine?

Yes, 240V AC will work with this SSR (just be careful). 80 Watts is around 0.4A, so well below the maximum 2A rating.

@jfpoilpret Should i put a diode on the input to stop current back-flow or is that only needed with coil relays?

It's Photo Isolated, so a diode isn't needed. Though I find it kind of strange that there is a coiled-relay, inside a solid state relay. Solid state generally means there are no moving parts. Most SSRs use triacs, I think.

so i can just wire it like in the image but to a 240v load?

Yes, the FSS1 has an input impedance of 470 Ohm, which will limit the current to 15mA max (well below the 40mA limit of the arduino). So you can just wire it directly to ground and a digital pin.

Is it really 5v relay?
Need your code.
Check your output is really 5v.

You do a lot of mistakes:
Int ledPin2=2;
Int ledPin3=3;
...
pinMode(ledPin2,OUTPUT);
pinMode(ledPin3,OUTPUT);
...
digitalWrite(ledPin2,HIGH);

I am on way now. I will edit and my answer when get back. Now correct your code
EDIT
You should improve your code... I edited it with switch cases. Also edit your comments because they are wrong!!! In the end there is Serial.printout states of pins. If you want uncomment them.
Here is the edited code:
char val;         // variable to receive data from the serial port
int ledpin2 = 2, ledpin3 = 3, ledpin13 = 13;  // LED connected to pin 2 (on-board LED)
bool status = true;

void setup()
{
  pinMode(ledpin2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
  pinMode(ledpin3, OUTPUT); // pin 3 (on-board LED) as OUTPUT
  pinMode(ledpin13, OUTPUT);
  Serial.begin(9600);       // start serial communication at 115200bps

}

void loop()

{
  if( Serial.available() )       // if data is available to read
  {
  val = Serial.read();         // read it and store it in 'val'
  switch (val){
    case 'a':
    digitalWrite(ledpin2, HIGH);    // turn ON pin 2
    status = true;
    break;

    case 'A':
    digitalWrite(ledpin2, LOW);
    status = true;
    break;

    case 'b':
    digitalWrite(ledpin3, HIGH);
    status = true;
    break;

    case 'B':
    digitalWrite(ledpin3, LOW);
    status = true;
    break;

    case 'C':
    digitalWrite(ledpin2, LOW);  // turn OFF pin 2
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin2, HIGH);      // turn ON pin 2
    status = true;
    break;

    case 'D':
    digitalWrite(ledpin3, LOW);  // turn OFF pin 3
    delay(1000);                     // wait 1 second
    digitalWrite(ledpin3, HIGH);      // turn ON pin 3
    status = true;
    break;

    case 'E':
    digitalWrite(ledpin2, LOW);       // turn OFF pin 2
    delay(5000);                      // wait 500 milli seconds
    digitalWrite(ledpin2, HIGH);      // turn ON pin 2
    status = true;
    break;

    case 'F':
    digitalWrite(ledpin3, LOW);  // turn ON pin 3
    delay(5000);                     // wait 500 milli seconds
    digitalWrite(ledpin3, HIGH);       // turn Off pin 3
    status = true;
    break;

    case 'G':
    digitalWrite(ledpin2, LOW);  // turn ON pin 2
    delay(500);                     // wait 500mili second
    digitalWrite(ledpin2, HIGH);      // turn Off pin 2
    digitalWrite(ledpin3, LOW);  // turn ON pin 2
    delay(500);                     // wait 500 mili second
    digitalWrite(ledpin3, HIGH);      // turn Off pin 2
    status = true;
    break;

    case 'h':
    digitalWrite(ledpin13, LOW);    // turn Off pin 13
    digitalWrite(ledpin2, HIGH);      // turn Off pin 2
    digitalWrite(ledpin3, HIGH);      // turn Off pin 3
    status = true;
    break;

    case 'H':
    for(int i = 0; i < 1000; i++)
  {
    digitalWrite(ledpin2, HIGH);  // turn ON pin 2
    delay (1000); //wait 1000 mili seconds
    digitalWrite(ledpin2, LOW);  // turn Off pin 2
    delay (1000); //wait 1000 mili seconds
  }
  status = true;
    break;
  }
  }

  /* Print out state of pin */
  /*
  if (status) {
   Serial.print("ledpin2 = ");
   Serial.print(bitRead(PORTD,2));
   Serial.print(" ,ledpin3 = ");
   Serial.print(bitRead(PORTD,3));
   Serial.print(" ,ledpin13 = ");
   Serial.println(bitRead(PORTD,7));
   status = false;
  }*/
}


text:
Negative value conversion for modbus slave
I have an analog sensor which reads values 0-5v, -75 degrees to 75 degrees. Now I have converted to +75 degrees and -75 degrees format depend on the voltage.
From 2.5v to 5v data is read properly (i.e 0-75 degree), but from 0-2.5v they are negative values -75 degree to 0. In the below image array holding register is reading 65493 and 65491 which are negative value. How do I make it readable format? Since my code is very big, only part of code is pasted.
#define ID   1

int Wind_Speed=30;
int Wind_Kmph=67;
signed int tracker_des_angle=-45;
signed int tracker_actual_pos=-43;
Modbus slave(ID, 0, 0);
boolean led;
int8_t state = 0;
unsigned long tempus;
// data array for modbus network sharing
uint16_t au16data[14];

void setup() {

  // start communication
  slave.begin( 9600 );
  rtcSetup();

  tempus = millis() + 100;
  digitalWrite(13, HIGH );
}

void loop() {
  // poll messages
  // blink led pin on each valid message
  state = slave.poll( au16data, 14);
  if (state > 4) {
    tempus = millis() + 50;
    digitalWrite(13, HIGH);
  }
  if (millis() > tempus) digitalWrite(13, LOW );
  calcTime();
  convertUTCtoLocal();

  au16data[0]=local_year;
  au16data[1]=local_month;
  au16data[2]=local_day;
  au16data[3]=wkDay;
  au16data[4]=local_h;
  au16data[5]=local_m;
  au16data[6]=local_s;
  au16data[7]=Wind_Speed;
  au16data[8]=Wind_Kmph;
  au16data[9]=tracker_des_angle;
  au16data[10]=tracker_actual_pos;

  au16data[11] = slave.getInCnt();
  au16data[12] = slave.getOutCnt();
  au16data[13] = slave.getErrCnt();
}

In arduino you have the map() http://arduino.cc/en/Reference/Map function, typically used to convert from ranges in analogReads. I miss in your code the place where you read your tracker_des_angle and how you convart it to your -+70º scale, can you post it please?

That looks like a problem in QModbus itself, or the way you use it. Check if you can setup these words as signed inside qmodbus.

@jfpoilpret i don't have those setting to convert it to readble format. I am thinking to check if no is negative multiply by -1. I know it wrong way. In hexadecimal , We can say if no is -ve subtract FF from No read.

The point is: can qmodbus display signed value? If not, then you cant do it with qmodbus. If yes, then how but this is qmodbus question not an arduino issue.

You could use a bit to store and display the sign and always send the absolute value in the register.


text:
How to connect Android phone to Arduino?
Is it possible to connect an Arduino to an Android Phone and use it for input/output?
Are connections possible over USB? Or do I need to have a wifi or Bluetooth shield?

Possible duplicate: https://arduino.stackexchange.com/questions/253/how-do-i-write-an-arduino-sketch-and-an-android-application-to-talk-to-each-othe/254

@FedericoFissore It's wondering not just USB, but also alternatives like wireless.

@AnnonomusPerson I see. To me it sounded more like a "can I use this or do I have to use that". Since the answer is "yes" for both, it's not as duplicate.

You bet it's possible. I used a pretty cheap bluetooth module that I got from Amazon, and wrote an app using the information on the official Android Developers page to connect to the Arduino. There are many guides online telling you how to hook up a module to the pins of the duino.
You can probably get a cheaper module if you look on eBay and don't care how long it takes to arrive, and I think there's at least one app on the Play store for controlling an Arduino if you can make it work for your purpose.
USB connections are probably possible, though I haven't done any of that.

Can you add a guide link and app link? I think "out there un the internet there are things" is not enough

I already had this answer typed up on another question so I thought I'd post it here to help you. I've replaced "tablet" with "phone" for easy reading.

You never mentioned your phone model... or Arduino model
There are some phones designed to work with USB flash drives and
  printers. This is called OTG (on the go.
You need:

A phone supporting OTG
An OTG adapter that fits into your phone's USB slot and is compatible
The Arduino Uno Communicator App
Arduino Uno (or clone) [Note: It says that it works with Atmega16U2 or Atmega8U2 programmed as a USB-to-serial converter so I would assume
  that that would cover a few boards more than the Uno.)

Another alternitive is to look into
  Bluetooth
  (Note: I just picked a random link but there are hundreds of similar
  BT adapters)

From my answer on a similar question

The Arduino ADK is meant for that. It combines an Arduino Mega with a USB host chip and port. If you don't want to buy a full Arduino, you can buy a USB host shield. Excellent tutorial for it here.
What those do is convert high speed USB signals to SPI, which is readable by a microcontroller. Android has libraries known as the Accessory Development Protocol, which can bridge communication from a phone to the USB and then to a microcontroller.

You can connect Android and Arduino with usb and use the easy tool App inventor 2 for android
Did you try this new application : https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo and full version : https://play.google.com/store/apps/details?id=bp.usbbridge.appinv
Find Videos about Explications : USB OTG Bridge Serial UART for APP Inventor 2 and ARDUBLOCK on youtube


text:
What is the execution context of the function registered via the Wire.onReceive() method?
I'm basically wondering if it's OK to Serial.write() or print in the function I register to be called when I2C data is received.  I can't seem to find the execution context or any warnings.
http://arduino.cc/en/Reference/WireOnReceive

Looking at twi.c in the Arduino libraries, it seems the callback function is called from within the I2C interrupt service routine (ISR). Any code in the call back will lengthen the ISR so it will have to be short. I don't think Serial.write will be too much of a problem; the TX interrupt will be delayed to the end of the I2C ISR which finishes straight after the callback and the Serial.write function is fairly short.
If you need to have a longer function run, you could instead have the callback store bytes in a ring buffer, then check for any available bytes in the main loop().. but this is what the Wire class helps with already.

Serial.write blocks if the serial buffer is full and waits for the buffer to have room before continuing. Conveniently, Serial.write checks to see if interrupts are disabled when it runs; If they are disabled, it runs the interrupt routines itself when a new character needs written to make space in the buffer, preventing lockup. In any case, if the buffer is full, printing on serial can take as long as it physically takes to output that many characters.

@BrettM thanks, I'll edit question with that (or edit it yourself and I will accept)


text:
How do I convert code between Arduino platforms?
What documentation is available regarding the differences between the different Arduino platforms?
For example, I have some code written for an Arduino Teensy that I would like to run on an Arduino Mega.
Is there documentation on the capabilities and equivalencies between each of the platforms?  e.g. memory, number of PWM outputs, etc?

The most detailed one seems to be Baldengineer's, but Arduino, SparkFun, and Adafruit have their own as well, although more limited.
As always, the best source for information about them is the datasheets for both the MCU(s) used as well as for the boards themselves.
And note that different macros are predefined for each MCU and feature (e.g. __AVR_ATmega328__ and __AVR_HAVE_MUL__); it is possible to test for their existence in order to customize behavior.


text:
how to use strstr() in serial communication?
I have a SIM900 module and Arduino, both are working fine. In my previous programs I have use strstr() command to find specific word from a string but they were constants and pre defined in the program but now I want to read serial communication from SIM900 and detect a specific word from it. But it is showing me

invalid conversion from 'char' to 'const char'

This is my program:
int x;
char sms;
char response;
char disp;
void setup()
{
  Serial.begin(2400);
}

void loop() {
  while(Serial.available() == 0);

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

    disp = sms;
    if (strstr(disp,"track")) //Comparing word entered with word stored in program
    {
      Serial.println("Found the  word!");
    }
  }
}

There are two problems.
1) you are trying to have the Arduino's single UART talk to both the SIM900 and the PC.
2) disp needs to be an array of char's, as to compare for words phrases.
Try the following. It implements a 2nd Soft serial port to which you can connect the SIM900. Along with building an array char at a time.
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

char buffer[16];
#define buffer_size sizeof(buffer)/sizeof(buffer[0])
int8_t buffer_pos = 0;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("Serial to mySerial demo started");

  buffer_pos = 0;
}

void loop() {
  char inByte;
  while (mySerial.available()) {
    inByte = mySerial.read();
    while (buffer_pos >= buffer_size) {
      for (int8_t i = 0; i < buffer_size - 1; i++) { // if shift buff left if at end of buff
        buffer[i] = buffer[i + 1];
      }
      buffer_pos--;
    }
    buffer[buffer_pos++] = inByte;
    if (strcasestr(buffer, "track")) {
      buffer_pos = 0;
      Serial.println("TRACK FOUND!");
    } else {
      Serial.write(inByte);
    }
  }
}

mpflaga thanks for taking your time to help me but your solution didn't work,It's showing up "TRACK FOUND!" for anything I send(to whatever word I send),I tried to change "strcmp" to "strstr" but in this method it's not reading string completely to the end.it's showing unfinished data.I took the screenshots.http://s29.postimg.org/i0mrhzw13/image.png.I will also add code that I modified.

My modified code:http://freetexthost.com/mwez052ng4, My requirment is very simple ,I send sms to sim900 a specific code and arduino should receive this and search for that key word,If it finds that keyword it needs to print predefined text.

did you try "strcasestr" I see your picture is upper case

yes,I did still no use :(

I don't know what's wrong with above program,but I have made another program:here: http://freetexthost.com/rw6cdpf3m3 , Here is the output : http://s18.postimg.org/amcjzqfu1/Untitled.png, it basically reads serial data from sim900, I just need code to detect specific word from that text,for eg: "145" in that incoming data, since it is serial data not a const char,please help me

I have corrected my above code. There was a minor bug, missed buffer_pos--; in the rotate buffer left. Also changed to strcasestr. I don't have a SIM900 to test against, rather I validated against a more simpler code. It worked as expected. See GISTHUB strstrSerial.ino


text:
Arduino Hardware timer and interrupts issue
I recently started programming with Arduino and and currently I'm making a project to read RPM and Speed of my car using Arduino Uno. So far I got everything working but the speed value does not show properly. I have used one hardware counter and two interrupts in this project.

Timer 1 on pin 5 - Count pulses from car's ECU to calculate speed.
Int0 on pin 2 - Read ignition pulse to calculate RPM.
int1 on pin 3 - 5v in from headlight switch to control the brightness of the display (MAX729 7 seg 8 digit).

I can get the proper reading from RPM and also the brightness control is working properly. Here is my codes below.
    #include <LedControl.h>

// inputs: DIN pin, CLK pin, LOAD pin. number of chips
LedControl display = LedControl(12, 10, 11, 1);

//SPEEDO-----------------------------------------------------------
const int hardwareCounterPin = 5;
const int samplePeriod = 1000; //in milliseconds
const float pulsesPerMile = 4000; // this is pulses per mile for Toyota. Other cars are different.
const float convertMph = pulsesPerMile/3600;
unsigned int count;
float mph;
int kph;
int roundedKph;
int previousKph;
int prevCount;
//----------------------------------------------------------------

//RPM-------------------------------------------------------------
//Configuration for the Tachometer variables
const int sensorPin = 2;
const int sensorInterrupt = 0;
const int timeoutValue = 5;
volatile unsigned long lastPulseTime;
volatile unsigned long interval = 0;
volatile int timeoutCounter;
int rpm;
int rpmlast = 3000;
int rpm_interval = 3000;
//---------------------------------------------------------------

//Brightness control---------------------------------------------
int brightnessIndicator = 13;  //Light pin 13 led to show that brightness control is in action.
int brightnessIn = 3;  //Sensor in from headlight positive wire to control the brightness.
//---------------------------------------------------------------

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

  display.shutdown(0, false);  // turns on display
  display.setIntensity(0, 10); // 15 = brightest
  printTrueno(); //Print my car's name
  delay(3000);
  initToZero(); //Print all zeros before going to the loop

  TCCR1A = 0; //Configure hardware counter
  TCNT1 = 0;  // Reset hardware counter to zero

  //Config for the Tach
  pinMode(sensorPin, INPUT);
  attachInterrupt(sensorInterrupt, &sensorIsr, RISING);
  lastPulseTime = 0;
  timeoutCounter = 0;

  //Config for brightness control
  pinMode(brightnessIndicator, OUTPUT);  //LED output
  pinMode(brightnessIn,INPUT);  //Sensor in
  attachInterrupt(1, changeBrightness, CHANGE);  //Attach the 2nd interrupt
  changeBrightness();  //Check for head lights on or not.
}

void loop() {
  //SPEEDO-----------------------------------------------------------
  // This uses the hardware pulse counter on the Arduino.
  // Currently it collects samples for one second.
  bitSet(TCCR1B, CS12); // start counting pulses
  bitSet(TCCR1B, CS11); // Clock on rising edge
  delay(samplePeriod); // Allow pulse counter to collect for samplePeriod
  TCCR1B = 0; // stop counting
  count = TCNT1; // Store the hardware counter in a variable
  TCNT1 = 0;     // Reset hardware counter to zero
  mph = (count/convertMph)*10; // Convert pulse count into mph. 10x allows retaining 10th of mph resolution.
  kph = ((unsigned int) mph)*1.6; // Convert to kph and cast to integer.

  int x = kph / 10;
  int y = kph % 10;

  // Round to whole mile per hour
  if(y >= 5){
    roundedKph = x + 1;
  }
  else {
    roundedKph = x;
  }

  //If kph is less than 1 kph just show 0kph.
  //Readings of 0.9kph or lower are some what erratic and can
  //occasionally be triggered by electrical noise.
  //if(x == 0){
  if(x < 2){  // 1 was triggered by some noise signal.
    roundedKph = 0;
  }

  // Don't display kph readings that are more than 50 kph higher than the previous reading because it is probably a spurious reading.
  if(roundedKph < 181){
    if((roundedKph - previousKph) > 50) {
      Serial.println(previousKph);
      printNumber(previousKph, 0);
    }
    else {
      Serial.println(roundedKph);
      printNumber(roundedKph, 0);
    }
  }

  previousKph = roundedKph; // Set previousMph for use in next loop.
  //-----------------------------------------------------------------

  //RPM--------------------------------------------------------------
  if(rpm >= 0) {  //Remove the minus values

    //Let's keep this RPMr value under control, between 0 and 9999
    rpm = constrain (rpm, 0, 9999);

    //If the engine is not running, print 0
    if ((micros() - lastPulseTime) < 5e6 ) {
      rpm = rpm;
    }
    else {
      rpm = 0;
    }

    if (rpm < 250)
      rpm = 0;
    //Serial.println(rpm);
    printNumber(rpm, 1);
  }
  //-----------------------------------------------------------------
}

//Each time the interrupt receives a rising tach signal, it'll run this subroutine
void sensorIsr() {
  unsigned long now = micros();
  interval = now - lastPulseTime;
  if (interval > 5000){
     rpm = 61000000UL/(interval * 2);
     lastPulseTime = now;
  }
}

void changeBrightness() {
  int val = digitalRead(brightnessIn);  //Read the sensor value

  if(val == 1){  //If the headlights are on, pin goes HIGH.
    digitalWrite(brightnessIndicator, HIGH);   //turn the LED on
    display.setIntensity(0, 6); //Reduce the brightness.
  }
  else {
    digitalWrite(brightnessIndicator, LOW);    //turn the LED off
    display.setIntensity(0, 14);  //increase the brightness.
  }
}

void printNumber(int v, int flag) {
    int ones;
    int tens;
    int hundreds;
    int thousands;

    if (flag==0){
      ones = v%10;
      v = v/10;
      tens = v%10;
      v= v/10;
      hundreds = v;

      //Now print the number digit by digit
      if (hundreds>0)
        display.setDigit(0,0,(byte)hundreds,false);
      else
        display.setChar(0,0,' ',false);

      display.setDigit(0,1,(byte)tens,false);
      display.setDigit(0,2,(byte)ones,false);
    }
    else if (flag=1) {
      ones = v%10;
      v = v/10;
      tens = v%10;
      v = v/10;
      hundreds = v%10;
      v = v/10;
      thousands = v%10;

      //Now print the number digit by digit
      display.setDigit(0,4,(byte)thousands,false);
      display.setDigit(0,5,(byte)hundreds,false);
      display.setDigit(0,6,(byte)tens,false);
      display.setDigit(0,7,(byte)ones,false);
    }
}

I think the problem is between Timer1 and first interrupt. Can someone please help me to solve this?
Thank you very much.

Have you tried to reduce the program to the smallest amount of code that either works or has the bug, and nothing extra. For example "the speed value does not show properly" is still in the code, but everything else removed. Please answer Will's question first.

Try swapping count = TCNT1; and TCCR1B = 0;. It could be that stopping the counter also resets TCNT1.

@Will - Lets say my current speed is 25kmph. But I'm seeing incorrect random values like 31, 35, 45, 40, etc... Sometimes after every 5-6 seconds I get the correct reading 25kmph. But my RPM values are showing correctly 99% of the time.

@gbulmer When I run these two parts of codes separately (RPM and Speedo), they work without any problems and give me the correct values. But when I merge them together, the speedo value becomes incorrect.

Is the speedo value correct when the value is Serial.print(...) only, and everything using display is removed? I am suspicious about display using a timer or effecting interrupts.

Delete lines from your code until you have it work again then add the last line in again. Simulate inputs with numbers ect... Its very hard to help you like this

I think you made a mistake in the program design.  You have things backwards, and your tach interrupts are messing with program flow because they are happening too fast.
The tachometer runs 0~100 rev/sec.  Send the pulses to the counter and, twice a second, multiply the count by 120 and display the RPM.  You only care what the RPM is to the nearest hundred, anyway, right?
You get an ECU pulse every ~0.4m traveled.  Record the interval (x ms) between pulses in your interrupt routine.  0.4m/x ms * 1 km/1000 m * 3,600,000 ms/hr = ~1448/x km/hr.  Do the (expensive) division, using the last interval recorded, twice a second when you update the RPM.
Now your interrupt routine is getting called every 12ms, tops, instead of 8ms typical.  And, your main loop is running at a steady 500 ms.

else if (flag=1) {

should be
else if (flag==1) {

What else would flag be anyway? Why not just use "else"?

 // Don't display kph readings that are more than 50 kph higher than the previous reading because it is probably a spurious reading.
  if(roundedKph < 181){
    if((roundedKph - previousKph) > 50) {
      Serial.println(previousKph);
      printNumber(previousKph, 0);
    }
    else {
      Serial.println(roundedKph);
      printNumber(roundedKph, 0);
    }
  }

  previousKph = roundedKph; // Set previousMph for use in next loop.

In the code above you admit roundedKph might be wrong, but use it anyway for next time around the loop. That means next time around you will discard a correct reading.

   //If the engine is not running, print 0
    if ((micros() - lastPulseTime) < 5e6 ) {
      rpm = rpm;
    }

What does that achieve?

int rpm;

That should be volatile.


text:
4-digit 7 Segment LED displaying numbers in the wrong order
I am a novice Arduino programmer and am currently having trouble with a SH5461AS 4-digit/7-segment LED when using it with an Arduino Uno. I have struggled to find an accurate datasheet/tutorial of any kind for this particular model (It is the LED without the colons in between digits 2 and 3) but I believe I have it figured out.
I currently have it going through a HC595 shift register but when I removed the register and connected the LED directly to the board the problem remained. My code below is with the shift register; I am displaying it this way because it is simpler to view and I thought it would make it easier to debug.
I can display a single digit at a time correctly. However, when I try to display 2+ digits at one time, they are in the incorrect order.
For example, I can count 1-9 on the first digit, then 1-9 on the 2nd digit, and so on and everything displays correctly (other digits are off). But as soon as I try to display multiple digits they are in the wrong order. So if I try to display 12__ with the last 2 digits off, 21__ is displayed with the last two digits off. If I try to display 23, 32 is displayed. If I try to display 1234, 4123 is displayed.
I am at a loss because the code seems like it should be simple.
const int DATA = 0;
const int LATCH = 1;
const int CLOCK = 2;

const int DIGIT_ONE = 3;
const int DIGIT_TWO = 4;
const int DIGIT_THREE = 5;
const int DIGIT_FOUR = 6;

//digits[0-9] corresponds to the patterns for numbers 0 -> 9.
//Add 1 to the digits[X] to turn on the dot.
byte digits[] = {B11111100, B00011000, B01101110, B00111110, B10011010, B10110110, B11110010, B00011100, B11111110, B10111110};

void setup() {
  pinMode(DATA, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(LATCH, OUTPUT);

  pinMode(DIGIT_ONE, OUTPUT);
  pinMode(DIGIT_TWO, OUTPUT);
  pinMode(DIGIT_THREE, OUTPUT);
  pinMode(DIGIT_FOUR, OUTPUT);

  digitalWrite(DIGIT_ONE, HIGH);
  digitalWrite(DIGIT_TWO, HIGH);
  digitalWrite(DIGIT_THREE, HIGH);
  digitalWrite(DIGIT_FOUR, HIGH);
}

void loop() {
  writeDigit(DIGIT_TWO, 2);
  writeDigit(DIGIT_THREE, 3);
}

/*
 * Write a digit to the 4-digit 7-segment LED
 * - digitPin corresponding to the pin on the LED to light up the correct digit.
 * - number 0-9 to display on the LED
 */
void writeDigit(int digitPin, int number) {
  digitalWrite(digitPin, LOW);

  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);
  digitalWrite(LATCH, HIGH);

  digitalWrite(digitPin, HIGH);
}

So in this instance, I am expecting 23 but 32 is displaying instead.
I am also having trouble with some bleeding (I don't know what the correct term is) where some segments are very faintly glowing even though I am not doing it intentionally. This is a much smaller issue, however, than digits randomly in the wrong order.
If it would help, I can try to post the circuit diagram as well.

Here is a datasheet I found that seems a better macth for your display model (that's the datasheet for a display that I use):
http://www.play-zone.ch/en/fileuploader/download/download/?d=1&file=custom%2Fupload%2FFile-1356269320.pdf
This is the datasheet I directly got from my local supplier.
According to what you say, the problem does not seem to be a wiring problem.
It looks more like a timing issue:
void writeDigit(int digitPin, int number) {
  digitalWrite(digitPin, LOW);

  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);
  digitalWrite(LATCH, HIGH);

  digitalWrite(digitPin, HIGH);
}

The first issue when you call writeDigit() is that it forces the cathod low BEFORE having set the shift register, so the digit will first show the current register value, i.e. the one from the previous call to writeDigit().
Then it pushes the new value for the segments on the shift register, that will be fast but not as fast as two consecutive calls to loop().
If we try to roll and expand the loop() call in your example that will be:
// First call: writeDigit(DIGIT_TWO, 2)
  digitalWrite(DIGIT_TWO, LOW);
  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[2]);
  digitalWrite(LATCH, HIGH);
  digitalWrite(DIGIT_TWO, HIGH);

// Second call: writeDigit(DIGIT_THREE, 3)
  digitalWrite(DIGIT_THREE, LOW);
  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[3]);
  digitalWrite(LATCH, HIGH);
  digitalWrite(DIGIT_THREE, HIGH);

The calls to loop() and writeDigit() are negligible in terms of timing here.
In the sequence above, most of the time is spent in:
  shiftOut(DATA, CLOCK, LSBFIRST, digits[2]);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[3]);

So that means your function will:

show the previous value on the new digit for t1 us
show the new value of the new digit for t2 us

with t1 >> t2, hence your eyes will see the opposite of your intent!
To fix that issue you definitely need to introduce some delay to reverse what your eyes will see:
void writeDigit(int digitPin, int number) {
  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, LSBFIRST, digits[number]);
  digitalWrite(LATCH, HIGH);
  digitalWrite(digitPin, LOW);
  delayMicroseconds(100);
  digitalWrite(digitPin, HIGH);
}

In the code above:

no digit shows while the shift register is set
the requested digit shows immediately after the shift registry has been written and lacthed, and for a duration of 100us, which will be much longer than the rest of the time.

That code should also get rid of the "bleeding" you observed.

Excellent, detailed answer; thank you! I will try that when I get home to see if it fixes it.

I found the data sheet here:
https://www.sparkfun.com/datasheets/Components/LED/7-Segment/YSD-439AK2B-35.pdf.
It's a horrible bit of writing. Not at all clear.
It looks like it's multiplexed. You use pins 14, 16, 13, 3, 5, 11, 15, and 7 as the cathodes for the segments on a digit (ground the pins for the segments you want to light.) Pin 7 appears to be the decimal place for a given digit.
One of the pins 1, 2, 6, or 8 should be fed a +5V to light a particular digit.
The other pins control the colons and other dots on the display. Let's ignore those.
To light the display here's what I THINK you would do (I'm tired, and didn't study the data sheet that closely, so I may may be wrong here)
For pins 14, 16, 13, 3, 5, 11, 15, and 7: These are the cathodes for the segments in the current digit you are driving. Set the pins you want to light as digital outputs, LOW. Set the others as inputs, which will make them essentially open circuits. The selected pins will be grounded, and the ones set as inputs will not be connected to anything.
Pull pin 1 HIGH to light the selected segments in digit 1. Put it back low, set the segment pins, then pull pin 2 HIGH to light that digit. Repeat, pulling pins 6 and 8 high to light the selected segments in digits 3 and 4.
You'd have to cycle rapidly through the digits, lighting 1 at a time, in order to make them appear all lit at once.
Get that working first without using shift registers. (It will take 11 I/O lines to drive all 4 digits and their decimal places - 1 less if you don't care about the decimal place.)
I think that if your drive all the pins using a shift register then some of the unlit segments will be fed reverse voltage. (When set as an output, sending a LOW connects the output pin to ground, and setting it high drives it to 5V. With all the control pins driven from outputs of a shift register, the off segments will have 5 volts on them, and the off digit select pins will have ground on them.)

That datasheet does not match the OP descriprion, it has a : in the middle.

Yup. I assumed it was a variation on the same item.

It is much more than a simple variation: the one used by OP is common cathode, while yours is common anode!

@jfpoilpret, it sounds like you found the correct data sheet. Why not post either the correct data sheet or an assessment similar to mine based on the specs for the correct display.

Well I guess the OP already understood how to use his display, so it was not necessary IMO to detail further the specs. As I said in my answer the main problem is in the code not the wiring.

I don't have enough reputation to add a comment, but the datasheet link in @jfpoilpret is dead. This link has the datasheet from the same website.
Thanks.


text:
Memory Problems on Arduino Uno
I am doing a project using Arduino UNO, cc3000 WIFI chip, micro SD card shield, and a TTL serial camera in order to make a security system that will post a picture online (not enough processing power for video) when motion is detected on the camera.
Thankfully, the hardware works after a few shortcomings, but my program seems to be taking up 97% of the Flash storage.
Also, I am looking for a better way to transfer the image than saving it 32 bits at a time and then waiting about 10 sec so the HTTP request will send it to the server.
One thing I do know is that I have tested all the hardware and those functions are working. My problem is in the logic.
Any help appreciated! (Image is around 13KB and UNO only has 2kb of dynamic memory).
My full code is here: https://www.dropbox.com/s/arxa253mxwvqtg1/HomeProj.rtf?dl=0
void loop(void)
{
    cam.setMotionDetect(true);

    while (1) {
        if (cam.motionDetected()) {
            Serial.println("Motion!");

            cam.setMotionDetect(false);
            if (! cam.takePicture())
                Serial.println("Failed to snap!");
            else
                Serial.println("Picture taken!");

            uint16_t jpglen = cam.frameLength();
            Serial.print(jpglen, DEC);
            Serial.println(" byte image");

            char filename[13];
            strcpy(filename, "IMAGE00.JPG");
            for (int i = 0; i < 100; i++) {
                filename[5] = '0' + i/10;
                filename[6] = '0' + i%10;
                // create if does not exist, do not open existing, write, sync after write
                if (! SD.exists(filename)) {
                    break;
                }
            }

            File imgFile = SD.open(filename, FILE_WRITE);
            while(jpglen > 0) {
                uint8_t *buffer;
                uint8_t bytesToRead = min(32, jpglen);
                buffer = cam.readPicture(bytesToRead);
                imgFile.write(buffer, bytesToRead);

                //Send Request
                Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
                if (client.connected()) {
                    Serial.println("Connected!");
                    client.println("POST /upload HTTP/1.0");
                    client.println("From: Arduino");
                    client.println("Host: fierce-chamber-5675.herokuapp.com");
                    client.println("Content-Type: image/jpeg");
                    client.println("Content-Length: " + 32);
                    client.print("Connection: close");
                    client.println();
                    for(int i = 0; i < 32; i++) {
                        client.print(buffer[i], HEX);
                    }
                    client.println();
                } else {
                    Serial.println(F("Connection failed"));
                    return;
                }
                client.close();

                Serial.println(F("-------------------------------------"));
                jpglen -= bytesToRead;
            }
            imgFile.close();
            cam.resumeVideo();
            cam.setMotionDetect(true);
        }
    }
}


text:
RTC resets when power is off
I have a few RTC modules with a batteries. All of them have this same issue with my project.
They work fine when connected via USB. But if I disconnect the power then reconnect they reset to Jan 1 2000.
I've read several posts about similar problems. But, none seem to apply.
Here is my code:
#include <SFE_MicroOLED.h>  // Include the SFE_MicroOLED library
#include <SPI.h>
#include <SD.h>
#include "Wire.h"
#include <RTClib.h>
RTC_DS1307 RTC;
#define BUTTON_PIN       0 // Button
#define LONGPRESS_LEN    25  // Min nr of loops for a long press
#define DELAY            20  // Delay per loop in ms

enum { EV_NONE=0, EV_SHORTPRESS, EV_LONGPRESS };

boolean button_was_pressed; // previous state
int button_pressed_counter; // press running duration

byte zero = 0x00; //workaround for issue #527

char* modes[]={"Walk", "Bike", "Subway", "Train", "Bus", "X-Bus", "Waiting", "Other"};
byte mode=0;
int modeRead;

// Chip Select for SD
#define chipSelect 10

//MicroOLED oled(PIN_RESET, PIN_DC, PIN_CS);
MicroOLED oled(9, 8, 5); // SPI declaration

void setup()
{
    pinMode(BUTTON_PIN, INPUT);
    digitalWrite(BUTTON_PIN, HIGH); // pull-up
    Serial.begin(9600);
    button_was_pressed = false;
    button_pressed_counter = 0;

    SD.begin(chipSelect);

    Wire.begin();
    RTC.begin();
    //RTC.adjust(DateTime(__DATE__, __TIME__));

    oled.begin();    // Initialize the OLED
    oled.clear(PAGE);     // Clear the screen
    oled.setFontType(1);  // Set font to type 0
    oled.setCursor(0, 0); // Set cursor to top-left
    oled.println(F("co'mute"));
    oled.display();  // Display what's in the buffer
}

int handle_button()
{
    int event;
    int button_now_pressed = !digitalRead(BUTTON_PIN); // pin low -> pressed

    if (!button_now_pressed && button_was_pressed) {
        if (button_pressed_counter < LONGPRESS_LEN)
            event = EV_SHORTPRESS;
        else
            event = EV_LONGPRESS;
    }
    else
        event = EV_NONE;

    if (button_now_pressed)
        ++button_pressed_counter;
    else
        button_pressed_counter = 0;

    button_was_pressed = button_now_pressed;
    return event;
}

void printDate ()
{
    oled.clear(PAGE);     // Clear the screen
    oled.setFontType(0);  // Set font to type 0
    oled.setCursor(0, 0); // Set cursor to top-left

    DateTime now = RTC.now();

    oled.print(now.year(), DEC);
    oled.print('/');
    oled.print(now.month(), DEC);
    oled.print('/');
    oled.print(now.day(), DEC);
    oled.print(' ');
    oled.print(now.hour(), DEC);
    oled.print(':');
    if (now.minute()<10) {
        oled.print("0");
    }
    oled.print(now.minute(), DEC);
    oled.print(':');
    if (now.second()<10) {
        oled.print("0");
    }
    oled.print(now.second(), DEC);
    oled.println();
    oled.setFontType(1);  // Set font to type 0
    oled.println(modes[mode]);
    oled.display();   // Display what's in the buffer (splashscreen)
}

void writeFile()
{
    File dataFile = SD.open("datalog.txt", FILE_WRITE);
    // If the file is available, write to it:
    if (dataFile) {
        DateTime now = RTC.now();
        //print the date EG   3/1/11 23:59:59
        dataFile.print(now.year(), DEC);
        dataFile.print('/');
        dataFile.print(now.month(), DEC);
        dataFile.print('/');
        dataFile.print(now.day(), DEC);

        printDate ();
        oled.print("*SAVED*");
        oled.display();
        delay(3000);
    }
}

void loop()          // run over and over again
{
    // handle button
    boolean event = handle_button();

    // do other things
    switch (event) {
        case EV_NONE:
        oled.print(".");
        break;

        case EV_SHORTPRESS:
        oled.print("S");
        //modeRead = analogRead(0);    // read the value from the sensor
        writeFile();
        break;

        case EV_LONGPRESS:
        oled.print("L");
        break;
    }

    static int counter = 0;
    if ((++counter & 0X016) == 0) {
        printDate ();
    }
    modeRead = analogRead(A0);    // read the value from the sensor
    delay(DELAY);

    int c=1020/(sizeof(modes)/sizeof(modes[0]));
    for (int i = 0; i < c; i++) {
        if (i*c < modeRead && (i+1)*c < modeRead) {
            mode = i;
        }
    }
}

In this diagram the "pressure sensor" is really a OLED that operates via MOSI and MISO.

Have you checked the voltage of the RTC battery?

Yes. I've also tried multiple RTC modules that I know work in other projects.

Initial value should be 1 jan 2000, not 2002, according to the datasheet.

Wow!  Spaghetti!  Is your ruler broken or something?!

byte zero = 0x00; //workaround for issue #527 - oh, aye.

yeah it's jan 2000 not 2002

Your schematic doesn't match your code.  Weirdness involving S1 shorting D0 to ground, MOSI/MISO/CLK on A1/A2/A3 vs D11/D12/D13, Code says D10 is chip select for SD board, while schematic shows D7 ... Uh... The RTCLib library will expect to use the chips TWI (I2C) pins (D11/D12/D13), which you're not hooked to.  That would explain the constant zero results from the RTC.

best schematic ever! tnks for share

First off, you should simplify your circuit to only keep the RTC and check if the problem is still here. Also, it would be useful if you could provide the exact reference of the RTC breakout(s) you use, or event just a picture. I am not sure all breakouts include a battery cell to keep time running when chip is not powered.

The RTC board has a battery holder and requires the button battery to be fitted in order to retain the time and date value. As shown in the Datasheet, this battery is for the RTC chip only.

The Adafruit board requires a CR1220 button battery.

The Adafruit webpage mentions the following:

Note: This product does not come with a CR1220 coin cell battery.

(Providing that it works when the Arduino is powered up) It sounds as if the battery for the RTC is either:

not present
not connected (not inserted correctly or not making proper connection)
inserted upside down
a track on the PCB is broken or shorted
the battery is flat

The battery should be inserted so that the flat + side is UP. I suggest that you use a DMM to measure the RTC battery voltage at the RTC IC. Place your +ve probe on pin 3 of the IC and the -ve probe on pin 4. It should read slightly above 3.0 Volts.
I also recommend that you disconnect all of the other periferals so that you just have the RCT connected to the Arduino. Then use a known working program such as the one in the Adafruit tutorial to verify that your RTC is working correctly. You should be able to disconnect the USB and then reconnect it and find that the RTC is still holding the correct time.
RTC DS1307 Datasheet
Adafruit RTC Product
Adafruit RTC Tutorial


text:
Arduino as ISP - program is being uploaded on Arduino, not breadboard
I am following this tutorial, and have wired Arduino using this diagram:

This is what it looks like:

These options are selected in Arduino IDE:

This is the program I'm uploading:
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(9, OUTPUT);
  digitalWrite(9, HIGH);
}

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

When I upload it, it's uploaded on the Atmega on arduino board, not the one on breadboard. Both chips are ATMEGA328P.
I also tried to put 10μF capacitor between GND and RESET pins of the arduino board, which led to following errors:
Sketch uses 936 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avrdude -CC:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:C:\Users\Jakub\AppData\Local\Temp\arduino_build_319338/BlinkTestAtmega.ino.hex:i

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

         System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x12
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xe0
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

Note that I have a homemade ATTINY programmer shield for this arduino board and it works without problems.

Do you have a capacitor on the RESET pin of the Arduino? From you image I'm not sure. You need it for preventing the Arduino to reset and start the bootloader, when the serial port is opened

I tried to put 10uF and 22nF capacitors there. With 10uF, I get a bunch of avrdude: stk500_getsync() attempt 10 of 10: not in sync errors, the 22nF cap has no effect.

@Juraj I don't understand. Are you saying the tutorial I am following is wrong? When I select "Burn bootloader" it finishes without errors, but I don't know if it actually does anythinh.

@Juraj I am running arduino IDE, I don't know how to access output other than what's available in the IDE.

sorry. Use the "Upload using programmer" in Sketch menu to upload a sketch over ISP

after uploading the bootloader, you have to remove the chip from the arduino and wire the tx/rx lines from the arduino to your bread board chip. Its mentioned in the second part of the link you have provide. Did you do that..?

@Juraj Awesome, it works fine. The older versions of Arduino IDE used the same button to upload using ISP. It kinda made sense in my opinion. After all, I already selected Arduino as ISP.

Use the "Upload using programmer" in Sketch menu to upload a sketch over ISP

warning, it deletes the bootloader

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


text:
Where are the chip configurations stored in IDE 1.6.x? How to modify them?
With the new 1.6.x version of the Arduino IDE, obscurity of adding new chips has gained new level. It now seems you have to add HTTP links to some JSON files in single-line edit field in settings.
I did so and to add AtTiny to Arduino IDE, I used this JSON file: https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
I have AtTiny 13 however. It's same as the others, according to datasheet, but has different signature:
avrdude: Expected signature for ATtiny45 is 1E 92 06
         Double check chip, or use -F to override this check.
Wrong microcontroller found.  Did you select the right board from the Tools > Board menu?

I tried to search ATTiny45 and the signature over the files - no success.
What I need is to add the ATTiny13 to the list so that I can finally actually do some programming, instead of being completely helpless.

Possible duplicate of Adding Attiny to Arduino IDE - attiny\variants\platform.txt file missing

This doesn't answer the original question (which was how and where to modify the board configurations) but at least solves the immediate problem.
This repository contains working and maintained profiles for Attiny13: https://github.com/MCUdude/MicroCore

You are importing a json file provided by someone for free.
The best thing you can do is contribute by adding ATTiny13 to this repository.
To do so:
So go to github (create a account if you do not have one);
create a fork of the repository.
Add your ATTiny13 board to the boards.txt file.
mod the json file to contain a new version and the attiny13.
Test and if everything works fine
Create a pull request

I was asking how to do it on my local version. Imagine I wanted to add another chip when I have no internet connection...

If you do not have internet how are you going to get the toolchains?

If you have the toolchains; mod the boards.txt

So, here I am, several months after asking this question. Funny how useless answer has remained useless. Seriously, why should I have to wait for someone to accept my pull request? And this answer also doesn't cover how to actually add the signature in the file. You could really answer any question by telling the OP to do it himself.


text:
Solar Power Inside a Car
I plan on making an Arduino project for reminding a parent to take a child from a car. In order to power the project I though on using a solar panel. Since I can't rely on having solar power all the time I'll need to use rechargeable batteries and charge them with the solar panel.
The problem is that from reading about the subject it is clear that it can be dangerous as far as battery go up in flame in some cases, especially due to high heat.
My car can get into very high temperature when parked outside so this scenario is very likely to happen.
Can someone please direct me to reading materials about using solar power in a very safe way?

Is there a reason why you don't want to use the power source the car already has?

Well, the power source of the car mease run cables inside the car which is not ideal. Of course having battery explide is even less ideal :) Also the car give 24V if I'm not mistaking and I'll need to adjust for Ardino.

Most cars give 12V and Car to USB adapters are quite common, so that's now down to 5v.

Thanks, I'll consider that but it still leave running cables inside the car.

Just to clarify, its the batteries that are the problem, not the solar cell.  Could you put the batteries in a place that doesn't get hot, i.e. under the seats?  I have to be honest, I'm a bit confused as to the purpose of this system you are developing, do people really forget to remove their children from a car?

You right, the battaries are the problem but charge them seem to increase the chances of problems. Regarding the purpose, it turns out that people do forget their children, there has been few death cases in the past year. If I can reduce the chance of this happens to me it worth it.

If you would like to Charge batteries from solar you would Need more wiring, a charging System (over current shutdown, over Charge protection) and btw where do you install the solar? how does it get the sunlight? 12 Volts are running thougout the car, 12 also goes to reverse lights so you can Access probably from the floor. I don't know much about car wiring schemes.

Now that you say it I actually have car charger in the trunk so maybe running cables from there is not such a big-deal. Thanks

BTW how do you sense the child on the seat? which sensor do you have?

I plan to use one piezo sensor inside the child seat to detect when the child is in the seat and another piezo on the car body to detect when the car is on. If the car piezo is not detect anything and the child piezo detect something I'll sound some sound using another piezo buzzer.

Car Body? If the parent is calling, probably the engine will be off, it should be. Can engine can also be switched off at the time when stopping on Signal etc. There are no sensors already in seats? New cars have it.

Just an idea you might like to consider - I wonder if an inductive pad on (or in) the car seat would be a useful way to transfer power to the device without wires (and without solar panels.) It would require a bit of research on inductive chargers etc...

I'd just add some sensors to  both the drivers door, and the back door. If the parent opens it's door, but doesn't open the rear-door, it must have forgotten the child. I'd skip the solar panel, and make the system as battery efficient as possible. Depending on the sensors used, it's possible to get the system running on a couple of AA batteries for a year or more.

That's sound great. My question is if it's safe to leave batteries inside really hot car. I think my car can easily go ask high as 60 degrees C

Firstly, solar panels inside a car is pretty pointless. Solar panels need to be in direct sunlight to be effective. Having them inside a car means they're not going to be in direct sunlight, so they're not going to be able to generate anywhere near enough power - unless they are massive, in which case where is the child going to sit? Yes, you could put them on the roof, but that would be silly.
The whole concept of solar panels for this project is completely wrong.
The car has a big battery and an in-built generator. Use them. There is absolutely no reason for you to have your own batteries as well. Yes, you could charge your own batteries from the car's battery, but that just introduces extra losses and wastefulness.
The only possible benefit of having your own batteries is it will safeguard the car's battery when the engine isn't running. It would then be impossible for your project to flatten the car's battery. But if you design your project properly that wouldn't be a problem anyway.
Some things you seem to be missing with your project:

The car has power you can use. It's throughout the car. No need to provide your own external power source.
The car has an "accessory" signal that is only turned on when the ignition is on. It's used by things like the radio etc so that when you turn the car's ignition off the radio turns off. No need for vibration sensors or anything to know if the car is running, it can tell you directly.
Cars generally have "seat occupied" sensors in them that couple with the seatbelts to know if a passenger hasn't got their seatbelt on and warn the driver (in most jurisdictions it's the responsibility of the driver to ensure all passengers have their seatbelts on).

If you really must charge batteries there are certain safety aspects you really must take into account. Your charge circuit must be able to manage the battery charging 100% safely. You have mentioned heat, and that is a very very important thing to manage. A decent battery manager chip will include an input for a thermistor. That is used as one of the multiple methods of charge termination (there's dv/dt (change in voltage over time), dT/dt (change in temperature over time), etc). It also serves as an over-heat safety cutout. Ensure that the charge circuit you use not only provides a thermistor input but also has the ability to cut off charging in the case of an overheat situation.
You also need to consider over-voltage. A car's 12V supply isn't 12V. It can get as high as 16V sometimes, and noise from the ignition can cause regular spikes as high as 70V or more. Automotive electronics have to be able to withstand those spikes, and that means your charge circuit has to be able to withstand those spikes.  Buffering the 12V through a proper 5V (cigarette lighter USB charger) regulator will remove that noise and make your circuit easier to work with.
So you need to think more carefully about just what it is you want to achieve and how that is going to fit into an automotive situation.

Thank you for the detailed answer. One reason not to use the car power is that I need this device to work exactly when the card is off so I can't use the car power. Make sure this device doesn't drain the car battery is also very important. I'll read more about car electricity.

The car still has power when it is off. That is why you can turn the lights on without the engine running.

You right. I'm not familiar with car electricity so if I can solve this safely and reliably without messing with the car it will be better but I don't rule this out completely

Add a large (super) capacitor to it. So it will continue working for a while, after the engine is off. On the plus side, you now know when the engine is off, and that you should check to see if the driver is forgetting the precious cargo.


text:
Handling double (8 byte) in Arduino mega 2560?
I am receiving 8 bytes from serial.
I want to convert and save in double variable.
This is how i tried.
union u_data
    {
        byte b[4];
        double fval;
    } u;

double BytesToDouble (byte b8,byte b7,byte b6,byte b5,byte b4,byte b3,byte b2,byte b1)
{
    u.b[0] = b1;
    u.b[1] = b2;
    u.b[2] = b3;
    u.b[3] = b4;
    u.b[4] = b5;
    u.b[5] = b6;
    u.b[6] = b7;
    u.b[7] = b8;
 return u.fval;
}

But i am getting 0.00. Because here double size is 4 bytes.
Is there is any other way to do this?
Thanks

How is u.b[7] = b8; supposed to work on an array that is of size 4? How are you calling BytesToDouble?

In the Arduino there is no such thing as a double. A double is just another name for a float.
So you will have to either:

Manually interpret the double format data and calculate that into a float value, or
Send the value as some other format, such as float (32-bit), ASCII text, or (a selection of) integer values.

Since you can't actually use anything more than float, sending data with a higher resolution is pointless, so you are probably best off just sending it as a float.

avr-gcc doesn't support binary64. You can use 8 bytes to treat it as an opaque data type, but attempting to manipulate it beyond manually converting to/from binary32 will be naught but pain.