text:
Using ESP8266 core for Arduino
I am working on a wireless sensor network project, in which data is collected at a central node using nRF24 modules and the RFNetwork.h library.
I want to post that to the internet using the famous ESP8266 module, which works fine when used as standalone and programmed with Arduino IDE. But the problem is how to transfer my data from Arduino to the ESP8266 as it only has one serial that is already used to program it?
I have tried to use a nRF24 module that uses SPI with an ESP-12 as it has an SPI header, but it didn't work out and I can't figure out the problem. Is there a way to use ESP core libraries like esp8266wifi.h, wifiClient.h, webserver.h etc., just like we can use the esp8266.h library that uses AT commands to communicate to ESP from an Arduino like in a master-slave manner?

Maybe another solution is to link your ESP to one of your Arduino (or a new one, with an NRF24). If you have an ESP-1 you can use serial transmission with AT commands. For ESP-12, it must be possible too, through SPI as you mentioned.

Several solutions:

Are your SPI components 5V or 3.3V parts? The ESP8266 is 3.3V only, and is NOT 5V-tolerant; you may have already fried it.
In most cases that I've had problems with SPI with the ESP8266 (in particular, the Adafruit 8266-12E HUZZAH board), they went away when I drastically lowered the SPI speed to 8000000.
Once you've programmed the 8266, and assuming you don't use Serial for debugging output, it's free to use to communicate with the world. Again, be careful about signal levels -- the 8266 is NOT 5V-tolerant, and most arduinos have 5V signals. So either use a 3.3V arduino-like part (my favorite is the Teensy 3.2 for larger projects, and the Adafruit Trinket for smaller ones), or use a level converter. If you need debugging output, you can still use Serial1 for output only (and don't forget to change its bit rate -- by default it's something crazy like 74380bps).
Run the 8266 as another SPI slave and have the Arduino write to it. Or come up with your own serial protocol! Again, careful about signal levels.
You can use a different version of the 8266 (or another wifi chip), one that's already meant to be used with the Arduino. Sparkfun and Adafruit have several, as do a lot of other vendors.

I'd still suggest that you try to work out the SPI problems and stick to the 8266.
Also, don't forget that neither serial nor SPI guarantees data integrity. Always use a CRC to make sure your data were transferred correctly, and have some provision for retransmissions if you can't afford to just ignore corrupted data.
/ji

actually, according to several articles I've read, the ESP8266 is 5V tolerant on GPIO - of course, that's input, if the connected component requires 5v input signals, then you're out of luck

(It sounds like you have already used the esp8266 so I hope this background isn't too simple, but I'm not sure from your question where you're stuck.)
The ESP8266 modules are programmable. They are (usually) delivered with an application program installed that uses the manufacturer-defined set of "AT<something>" commands to operate it as a WiFi station or access point. There are code libraries for Arduinos or other computers to set it up and use it that way.
You can use its one serial port for either job - communicating to its current application program (interpreter, or your own custom program), much as you do an Arduino's port.
You can program your entire application on the chip and operate its WiFi radios directly, just as the AT-command interpreter does. You'll need the specs for programming the radios though; the AT-interpreter does that for you. Once you've loaded an application program of your own, it replaces the interpreter. To put it back to as-delivered, with the AT-command interpreter running in it, you'll need to re-upload the interpreter (which of course will replace anything else you've loaded).

Seems like you have several options:

1. Find a nRF24 library that works on ESP with the "arduino core" or port one yourself.
2. Implement your own Arduino-to-ESP protocol, using Serial (SoftwareSerial if needed), I2C or whatever.
3. Flash the ESP with the standard AT commands firmware and command it from the Arduino.

IMO, option 1 is best (you would ditch the Arduino completely), but may require significant effort.
Option 2 is academically better than option 3, as it will skip the hassle of dealing with AT commands on the Arduino side and will eventually be more efficient in terms of data bandwith between the Arduino and the ESP. In practice, it probably won't matter.
Option 3 might be the easiest - as much as I dislike the AT commands, they work and you won't have to program two devices constantly while developing your code.

So, in short, if you can go with Option 1 - please do so :)
If not - quickly asses which one will be easier / better for you - option 2 or option 3 and just go with it. Both will work, and are relatively easy to achieve.

...but the problem is how to transfer my data from Arduino to the
  ESP8266 as it only has one serial that is already used to program it.

After you flash a new firmware serial port becomes free so you can use it for whatever you like.
ESP8266 has two serial ports, not only one (although you can use only TX pin from the second one as RX is connected to SPI bus of the flash).
You can use any free GPIOs for software serial communication.

You can find the details about ESP8266's serial porth here, here, here and here.

authors: พงศธร พักวัง


text:
How is it possible that my skin temperature is so constant?

Here's the code
#include <OneWire.h>

int DS18S20_Pin = 3; //DS18S20 Signal pin on digital 3
unsigned long startTime = 0;
#define MEASURE_PERIOD 250
//Temperature chip i/o
OneWire ds(DS18S20_Pin);  // on digital pin 3

void setup() {
  Serial.begin(115200);
}

void loop() {
  if((millis() - startTime) >= MEASURE_PERIOD)
    {
        startTime += MEASURE_PERIOD;
        float temperature = getTemp();
        Serial.println(temperature);
    } //just here to slow down the output so it is easier to read

}

float getTemp(){
  //returns the temperature from one DS18S20 in DEG Celsius

  byte data[12];
  byte addr[8];

  if ( !ds.search(addr)) {
      //no more sensors on chain, reset search
      ds.reset_search();
      return -1000;
  }

  if ( OneWire::crc8( addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return -1000;
  }

  if ( addr[0] != 0x10 && addr[0] != 0x28) {
      Serial.print("Device is not recognized");
      return -1000;
  }

  ds.reset();
  ds.select(addr);
  ds.write(0x44,1); // start conversion, with parasite power on at the end

  byte present = ds.reset();
  ds.select(addr);
  ds.write(0xBE); // Read Scratchpad

  for (int i = 0; i < 9; i++) { // we need 9 bytes
    data[i] = ds.read();
  }

  ds.reset_search();

  //byte MSB = data[1];
 // byte LSB = data[0];

  float tempRead = ((((int)data[1]) << 8) | data[0]); //using two's compliment
  float TemperatureSum = tempRead / 16;

  return TemperatureSum;

}

What are X and Y axes on graph?

X time, Y temperature

Y is standardized temperature

Examine your code closely.  It appears that you are partially implementing extended resolution calculations in this line of code:
  float TemperatureSum = tempRead / 16;

In the DS18S20 specifications the extended resolution equation used is:
 TEMPERATURE = TEMP_READ * 0.25 - ((COUNT_PER_C - COUNT_REMAIN) / (COUNT_PER_C))

Where COUNT_PER_C is a DS18S20 register containing a value of up to 16.  Maybe that is where 16 originated?
I believe what you want to do is divide the recovered value by 2.0 base on table 1 from the DS18S20 specifications:
  float TemperatureSum = tempRead / 2.0;

Don't forget the "." in case the compiler you are using decides to do integer math dripping the "float" part before assigning it to TemperatureSum.

I'm not sure I understood what you are suggesting. If i put 2.0 I have values like that:
165
164,5
165

The DS18S20 (https://datasheets.maximintegrated.com/en/ds/DS18S20.pdf) specification says the temperature is returned in degrees centigrade and is in 1/2 degree increments (table 1, page 6).  There might be other important details.  But you said you did not see enough change.  Dividing by 16 instead of 2 would explain that.

Your values do not make sense.  In your graph when you measure your skin temperature you get 0.96 C when you divide by 16.  But in your comment above when you divide by 2 you are getting 165 C  The value 0.96 * 16 is no where near 165 * 2. Carefully consider how you are posting so that we can find the problem faster...  Oh, I get it!  You're using commas as decimal points.  Still, that doesn't explain the 0.96.  But 96 * 16 ~= 165 * 2.

Also, consider the possibility the DS18S20 packaging is slow to respond and the possibility the DS18S20 is internally computing an average in an attempt to reduce noise and increase resolution.  In this (http://electronics.stackexchange.com/questions/186449/what-is-the-fastest-temperature-sensor) stackexchange answer a ti.com TO92 package temperature sensor response is show.  It appears to take 6 to 10 seconds to report the correct oil bath temperature.

0.96 is not the temperature. It's the standardized temperature: value/max(list of values)

Please explain the horizontal axes as well.  Is it time in milliseconds?

it shows seconds

Try using Dallas Temperature Control Library for DS18S20. (Click Here, Download Library). Its simple and easy to use, and it comes with examples.
Here is tutorial.
Hope it helps.

I'm curious why a person found this not useful

I didn't understand how can I put it at 12bits

source: Stack Exchange

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

sort: votes


text:
Connecting a motor to Arduino UNO Play breadboard
I am new to Arduino and have a small query. I am building a simple system that switches on a motor and switches it off after some time and repeats this in a loop.
The Arduino that I am using is a “DIY UNO Play Breadboard -ATMEGA328P with FT232 Breakout Board” (Rs. 825, or $12.38USD, from Mangalore).  The Arduino board is similar in size to a Nano but without USB.  The FT232 board has a USB B port on one end and serial pins on the other.

My query is whether I should connect the positive end of battery supply to the motor and then connect in series using a motor controller circuit to port 7 and connect the negative terminal to the gnd port.
Or do I need a separate voltage source for my Arduino, because this Arduino has no built in USB ports.
This is my code to switch on and switch off the motor:
int motorPin = 7;
   pinmode(motorPin,OUTPUT);
   digitalWrite(motorPin,HIGH); //turn motor on
   delay(500); //wait
   digitalWrite(motorPin,LOW); //turn motor off
   delay(500); //wait

Can you please specify operating voltage/current rating of your motor. and some info related to your motor controller circuit.

My motor is a 5V motor and this is the circuit that I want to build: http://www.instructables.com/files/orig/F5O/D77S/I0VOVRVX/F5OD77SI0VOVRVX.jpg

Using same Voltage supply to power Arduino Board and motor simultaneously is usually not a good practice.
So, what you can do is use separate batteries to power Arduino and motor as shown in image below

However you can also power arduino and motor from single power supply, but in this case you should first think of current ratting of your battery and current consumption of your Arduino (normally 500mA) and motor. As shown below,

Hope it help. Any question Comment below.

thanks for answering. Just another doubt, why can't I connect the positive terminal of the battery to the Vin Port.

oh, really sorry, did a mistake there. edited. you are right. you actually have to connect to vin which in voltage input port whereas 5V is a voltage output port.

Last doubt. Do I need to connect the negative terminal in the first diagram of the battery connected to motor to the gnd pin of the Arduino or will it work without the connection?

you have to. It wont work without that. What we are doing there is called common ground. All GNDs in your circuit must be connected.

You can use the same power supply for both if it can source enough current for both; USB ports usually can not. But what you must not do is try to supply motor current through the Arduino, from any power supply. You need the Arduino to control a transistor switch which manages the motor current.

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


text:
Matlab Arduino Multi Byte Read
I'm using Matlab to communicate with a custom AD7746 board through an Arduino UNO. The data sheet mentions that
"In continuous conversion mode, the address pointers’ autoincrementer should be used for reading a conversion result.
That means, the three data bytes should be read using one
multibyte read transaction rather than three separate single byte
transactions"
I'm not sure how I can go about implementing this using MATLAB's Arduino support package.
Would anyone have an Idea about this?

Show us what you've done so far. Have you read data from the sensor yet?

I think I figured it out.
Matlab's Arduino package has a "read" command which lets you read data from an I2C device and allows you to specify the number of bytes.
I'm just testing it to make sure that I got it right


text:
How to make Arduino to stop updating i2c data when meet a condition and wait until it receives another serial input from processing?
I am currently making a robot with Arduino Uno, D6T omron thermal sensor (i2c sensor) and some other sensors. My thermal sensor will always update the data in array form. It will display 4 data arrays every 1 second.
I wish to have my Arduino send out a string "found" over serial when it meet a condition, and thermal sensor will stop updating my data. Thermal sensor and Arduino will just have to wait until the user sends a selection, jump to the selected function, and thermal sensor will start updating data again after that. I am new to coding, any suggestion on how to make my arduino and sensor to wait? Thank you guys! =)
Attached below is my code. (Arduino Sketch):
#include <Wire.h>
#include <WireExt.h>

#define D6T_addr 0x0A
#define D6T_cmd 0x4C

int rbuf[35];
float tdata[16];
float t_PTAT;

const int S_DATATRANSFER = 0;
const int S_WAIT = 1;
const int S_STOPTRANSFER = 2;
const int S_CONFIRMATION = 3;
const int S_ALLSTOP = 4;

float left_sum, right_sum, center_sum;

//-----------------------------------------------------------------------------

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

}

void loop()
{

static int state = S_DATATRANSFER;

    switch(state)
    {

    case S_DATATRANSFER:
        //Calculate temp
        //serialprint temp
        int i;

        if (Serial.available() > 0)
        {
                      char inByte = Serial.read();
                      if (inByte == '1')
            {  //processing will send one byte to arduino if ready

                Wire.beginTransmission(D6T_addr);
                Wire.write(D6T_cmd);
                Wire.endTransmission();

            if (WireExt.beginReception(D6T_addr) >= 0)
                {
                    i = 0;
                    for (i = 0; i < 35; i++)
                    {
                        rbuf[i] = WireExt.get_byte();
                    }
                    WireExt.endReception();

                    t_PTAT = (rbuf[0]+(rbuf[1]<<8))*0.1;
                    for (i = 0; i < 16; i++)
                    {
                        tdata[i]=(rbuf[(i*2+2)]+(rbuf[(i*2+3)]<<8))*0.1;
                    }
                }

                right_sum= tdata[0]+ tdata[4] + tdata[8] + tdata[12];
                left_sum= tdata[3] + tdata[7] + tdata[11] + tdata[15];
                center_sum= tdata[5] + tdata[6] + tdata[9] + tdata[10];
                output_csv();

               }
                      }
        state = S_WAIT;
        break;

    case S_WAIT:
        if (center_sum > 35*4)
        {
        state = S_STOPTRANSFER;
        }
        else
        {
        state = S_DATATRANSFER;
        }
        break;

    case S_STOPTRANSFER:

        Serial.println("F");
                delay(300);

        state = S_CONFIRMATION;

        break;

    case S_CONFIRMATION:
        while (Serial.available())
        {
         char val = Serial.read();
            if (val == '2')
            {
                state = S_ALLSTOP;
            }
            else if (val == '3')
            {
                state = S_DATATRANSFER;
                }
                        else if (val == '1')
                        {
                                state = S_DATATRANSFER;
                        }
                }

        break;

        case S_ALLSTOP:

        break;

    }
}

void output_csv()
{
  for (int i = 0; i < 16; i++)
  {
    Serial.print(tdata[i]);
    if (i < 15)
    {
      Serial.print(",");
    }
    else
    {
      Serial.println();
    }
  }
}

Attached below is my code in processing:
import processing.serial.*;
import controlP5.*;
import javax.swing.JOptionPane.*;
import com.onlylemi.processing.android.capture.*;
ControlP5 cp5;
javax.swing.JOptionPane JOptionPane;

AndroidCamera ac;
PImage img;
Textlabel myTextlabelA, myTextlabelB;
boolean canStart = true;
boolean canInput = false;
boolean Start = false;
boolean Start_camera = false;
String typedText = "Comments: ";
PFont font;
String command = "";
String confirm;
String found;

PImage carImage;
float[] tdata = new float[17];
float tptat; // PTAT
String portName;
//int serialport = 0;

String buf;
float colourGreen; //change green in relation to temperature

int lbTemp = 25; //lowest relative temperature
int hbTemp = 35; //highest relative temperature
Serial myPort;  // Create object from Serial class

void setup() {
  size(1366,768);
  //background(#FFFFFF);
  background(ControlP5.BLACK);
  //println(Serial.list());
  //portName = Serial.list()[serialport];
  myPort = new Serial(this, "COM15", 9600);
  myPort.clear();
  cp5 = new ControlP5(this);
  ac = new AndroidCamera(720, 480, 30);
  ac.start();

  myTextlabelA = cp5.addTextlabel("label")
                    .setText("GUI of Alive Human Detection System.")
                    .setPosition(120,10)
                    .setColorValue(#FFFAF0)
                    .setFont(createFont("Georgia",20))
                    ;

  cp5.addButton("Start")
     .setPosition(115, 670)
     .setSize(100,30)
     ;

  cp5.addButton("Stop")
     .setPosition(375, 670)
     .setSize(100,30)
     ;
  cp5.addButton("Start Camera")
     .setPosition(799, 670)
     .setSize(100,30)
     ;
}

public void Start(int theValue) {
  println("Initialising...");
  println("Connected.");
  //start displaying
 // carImage = loadImage(".png");
  Start = !Start;
}

public void Stop(int theValue) {
  println("Shuting Down...");
  //finish = loadImage("robot.png");
  //image(finish,30,64);
  myPort.write(0x02);
  Start = !Start;
  //strokeWeight(0);
}

public void Start_camera(int theValue) {
  println("Initialising...");
  println("Connected.");
  //start displaying
 // carImage = loadImage(".png");
  Start_camera = !Start_camera;
}

void draw()
{
  //if (Start_camera){
  //img = ac.getCameraImage();
  //image(img, 610, 0);
  //}
  if (Start){

    myPort.write('1');
    delay(100);
    while (myPort.available() > 0) {
    delay(300);
    buf = myPort.readStringUntil('\n');
    if (buf.equals("F")){
    int dialogResult = JOptionPane.showConfirmDialog (null, "Human found? Please Confirm!!", "Alert!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    if(dialogResult == JOptionPane.YES_OPTION)
    {
    fill(255,0,0);
    rect(100,670,50,30);
    myPort.write('2');
    }
    else if(dialogResult == JOptionPane.NO_OPTION)
    {
    fill(0,255,0);
    rect(100,670,50,30);
    myPort.write('3');
    }
    }
    else{
    myPort.clear();
    tdata = float(split(buf, ','));
    for (int i = 0; i <16; i++) {
    colourGreen = map(tdata[i],lbTemp,hbTemp,255,0);
    fill (255,colourGreen,0);

      if (i == 0)
    { rect(450,64,150,150);}
      else if (i == 1)
    { rect(300,64,150,150);}
      else if (i == 2)
    { rect(150,64,150,150);}
      else if (i == 3)
    { rect(0,64,150,150);}
      else if (i == 4)
    { rect(450,214,150,150);}
      else if (i == 5)
    { rect(300,214,150,150);}
      else if (i == 6)
    { rect(150,214,150,150);}
      else if (i == 7)
    { rect(0,214,150,150);}
      else if (i == 8)
    { rect(450,364,150,150);}
      else if (i == 9)
    { rect(300,364,150,150);}
      else if (i == 10)
    { rect(150,364,150,150);}
      else if (i == 11)
    { rect(0,364,150,150);}
      else if (i == 12)
    { rect(450,514,150,150);}
      else if (i == 13)
    { rect(300,514,150,150);}
      else if (i == 14)
    { rect(150,514,150,150);}
      else if (i == 15)
    { rect(0,514,150,150); }

    if (tdata[i]<5) {fill(255);} else {fill(0);}
      if (i ==0)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]),525, 139);}
      else if (i == 1)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]),375, 139);
      }
      else if (i == 2)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 225, 139);
      }
      else if (i == 3)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]),75, 139);
      }
      else if (i == 4)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 525, 289);
      }
      else if (i == 5)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 375, 289);
      }
      else if (i == 6)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 225, 289);
      }
      else if (i == 7)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 75, 289);
      }
      else if (i == 8)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 525, 439);
      }
      else if (i == 9)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 375, 439);
      }
      else if (i == 10)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 225, 439);
      }
      else if (i == 11)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 75, 439);
      }
      else if (i == 12)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 525, 592);
      }
      else if (i == 13)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 375, 592);
      }
      else if (i == 14)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 225, 592);
      }
      else if (i == 15)
      {
      textAlign(CENTER, CENTER);
      textSize(20);
      text(str(tdata[i]), 75, 592);
      }
    }
    delay(350);
  }
    }
    }
}

Implement a state machine first in your code for each state:
1) Sending i2c data.
2) Not sending i2c data.
And identify the conditions necessary to switch states:
1 to 2 when condition meet.
2 to 1 when command received.
Then drop your code into the state machine's code.
Read about state machines here and here.

Thanks a lot for the tips! I shall go and try it out. @st2000

Hi there, I successfully asked my arduino and sensor to wait when it meet the condition by implementing FSM into my code. Thank you very much. However, I faced another problem here whereby my processing doesn't seems to read my string sending from Arduino when condition meet. My GUI in processing freeze when program jump into this state case S_STOPTRANSFER: . Any idea how to solve this? Latest coding is edited in the post. Thanks a lot in advance!

There might a logic problem in your code.  I'm going to leave that up to you to find.  However, I will suggest you approach the problem in parts.  First, determine if you can send a found message to your "GUI".  Do this unconditionally when you start the Arduino.  If that does not work, perhaps your Arduino logic is good but your "GUI" can not understand the message.  If it does work, then, second, start eliminating some of the conditions in the Arduino code which prevents sending the message to the "GUI".  Perhaps the logic of one of the conditions is incorrect.

Thank you very much for all the suggestions given! It's working now! =D i found the mistake in my coding.
I should be using Serial.print to print my string in Arduino instead of Serial.println because Serial.println will return in \r\n instead of \n. Manually adding \n after my text in both Arduino and Processing coding.
In Arduino,
Serial.print("FOUND\n");
In Processing,
buf = myPort.readStringUntil('\n');     if (buf.equals("FOUND\n"))
Program in processing is now able to detect my string from Arduino. Thanks again! =)

Create a flow chart of the entire process you want to happen. Once you proof your flow chart to cover all possible functions, you can create the logic, control, and subroutines that are needed. If you have a good book on Arduino programming, and how I2C works, you will know that the I2c display will hold whatever data you wish until you change it. Also, you probably know that you can chain a whole bunch of I2c devices, no matter if they are displays, or anything else, so each device will hold its own data independent of the others. Any updating is under your control in programming. You might also look into using interrupts for some of your program control. Sensors don't push data, the processor reads the data, and your program is in control of how often and when the data is read, and what it does with the data.  The exception to your program being in control, is when you use interrupts. You should be storing the data so you will always have access to it for program examination and possible decision making. Lastly, to increase the abilities of your system, consider using one master Arduino, and several slave Arduino's. Some of the slaves, depending on what you want them to do, can be very small. Look at the tiny85. Some of the boards with the Tiny85 are the size of a postage stamp. I hope some of these suggestions are helpful to you.


text:
RF24L01+ VER01 with 10 pins
How can I connect this little ship to my Arduino? I can find alot of tutorials how to do it so, but all I find is 8 pins, mine includes 10 pins, and from what I could of understand from searching me myself, that there is 2 pins of VCC and 2 GRN pins.
So I would like to know how to connect this? Not necesserly Arduino, but can someone help me with the pins names at least so I can identify them.
Thanks.

This is also not correct for boards with original chip on it. This one is for WaveShare board :

There are some 10pin adapter boards floating around. See e.g.
nrf24l01 (8pin) + adapter board (10pin) oops?
Their pinout looks to be the following.


text:
Practicality of recording speech
Is it practical to record speech with the Leonardo?
I want to record speech via a MEMS microphone and stream it over a serial connection to a Raspberry Pi for speech-to-text processing.
This article states that the typical bitrate for recording voice podcasts is 64 kbps. The Arduino's analogRead() function has a maximum sample rate of typically 8,600 times/sec for a maximum bitrate of 8,600 samples/sec * 10 bits/sample = 86 kbps, so theoretically, it should be fast enough to record decent voice audio.
However, will the serial connection be fast enough to stream this much data? Theoretically, the Leonardo's serial connection can go up to 115,200 bps, but I've never reliably gotten it to go faster than 57,600 bps, which would mean the serial connection would a bottleneck that would prevent it from sending a continuous stream of 64 kbps, and therefore it would be impractical to record speech with the Arduino.
Am I wrong? Has anyone had success with voice recording while streaming it over serial?

@Greenonline, sorry, I've fixed the link.

On my page about the ADC converter I attempted to record a 4 kHz sine wave on the ATmega328P with the following code:
const byte adcPin = 0;  // A0

const int MAX_RESULTS = 256;

volatile int results [MAX_RESULTS];
volatile int resultNumber;

// ADC complete ISR
ISR (ADC_vect)
  {
  if (resultNumber >= MAX_RESULTS)
    ADCSRA = 0;  // turn off ADC
  else
    results [resultNumber++] = ADC;
  }  // end of ADC_vect

EMPTY_INTERRUPT (TIMER1_COMPB_vect);

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();

  // reset Timer 1
  TCCR1A = 0;
  TCCR1B = 0;
  TCNT1 = 0;
  TCCR1B = bit (CS11) | bit (WGM12);  // CTC, prescaler of 8
  TIMSK1 = bit (OCIE1B);  // WTF?
  OCR1A = 39;
  OCR1B = 39;   // 20 uS - sampling frequency 50 kHz

  ADCSRA =  bit (ADEN) | bit (ADIE) | bit (ADIF);   // turn ADC on, want interrupt on completion
  ADCSRA |= bit (ADPS2);  // Prescaler of 16
  ADMUX = bit (REFS0) | (adcPin & 7);
  ADCSRB = bit (ADTS0) | bit (ADTS2);  // Timer/Counter1 Compare Match B
  ADCSRA |= bit (ADATE);   // turn on automatic triggering

  // wait for buffer to fill
  while (resultNumber < MAX_RESULTS)
    { }

  for (int i = 0; i < MAX_RESULTS; i++)
    Serial.println (results [i]);

  }  // end of setup

void loop () { }

The code (rather inefficiently) sends the results in ASCII, like this:
378
710
899
992
966
827
609
367
159
38
35
147
350
593
817
965
1001
917
733
494
259
88
21
76
239
471
711
905
1001
977
839
620
376
164
39

This gave reasonable results:

Now the Leonardo is, of course, a different processor. However it is similar. The ADC on it should be capable of similar performance.

I should point out that this code records first, then sends the data. This is so the recording can keep up. A normal ADC conversion (if you don't change the ADC prescaler) takes 104 µs. To send 10 bits via serial at 115200 baud rate would take 173.6 µs because it would require two bytes per sample (unless you somehow compress each reading). If you could put up with 8-bit resolution (per sample) then you halve that, and can probably just stream the data out fast enough.

Do you really need to enable the TIMER1_COMPB interrupt? The doc of the ADC says the conversion is triggered by the rising edge of the interrupt flag, and the interrupt flag does not need the interrupt enable bit to work. Did I miss something?

You could be right. Try it without the interrupt. However the EMPTY_INTERRUPT probably just generates an RTI instruction.

I tried it with the interrupt disabled: it doesn't work. Seems there is an error either in the silicon or in the datasheet: “Note that an Interrupt Flag will be set even if the specific interrupt is disabled or the Global Interrupt Enable bit in SREG is cleared. A conversion can thus be triggered without causing an interrupt.” You may have noticed the inconsistency if I understand the comment next to setting TIMSK1. The empty interrupt is indeed just a reti, but the whole interrupt processing (save context, load address of vector, execute vector (jmp), reti) takes 11 cycles.

There's no traditional meaning to baud rate on a Leonardo.  Transmitting extra data over USB, at least in binary, is probably faster than doing logarythmic encoding as traditionally used for 8-bit telephone links.

I did some extra tests: my previous comment is wrong. What I missed is the conversion being triggered by a rising edge of the interrupt flag used as a trigger source. In order to have more than one such edge, the flag has to be cleared after it is set. This can be done automatically by enabling the interrupt: “OCF1B is automatically cleared when the Output Compare Match B Interrupt Vector is executed.” The other option is to clear the flag manually, e.g. by doing TIFR1 = _BV(OCF1B); inside ISR(ADC_vect).

You don't actually have to initialize your connection to 115,200 bps or 57,600 bps. You can use a custom baud rate of 65,000 bps.
One thing to keep in mind that, you can use any custom baud rate you want, as long as it's supported by the hardware. The Arduino IDE however only supports standard baud rates.
One more thing, as you are streaming data (kind of), you might also want to look into Arduino serial buffer sizes.

There's actually no (traditional) meaning to the baud rate setting on a Leonardo.


text:
Nrf24L01 with Arduino
When I wanted to test my Nrf24L01 I wanted to be sure of it working fine, so I used this code for an Arduino Uno:
#include <SPI.h>
#include <RF24.h>
#include "printf.h"
#define RF_CS 9
#define RF_CSN 7
RF24 radio(RF_CS, RF_CSN);
void setup() {
  Serial.begin(9600);
  printf_begin();
  radio.begin();
  radio.printDetails();
}
void loop() {
  radio.printDetails();
  delay(5000);

}

The thing is when I opened my Serial, I got this each 5 second:
STATUS       = 0xff RX_DR=1 TX_DS=1 MAX_RT=1 RX_P_NO=7 TX_FULL=1
RX_ADDR_P0-1     = 0x0000000000 0x0000000000
RX_ADDR_P2-5     = 0xff 0xff 0x00 0x00
TX_ADDR      = 0x0000000000
RX_PW_P0-6   = 0xff 0x00 0x00 0xff 0xff 0x00
EN_AA        = 0xff
EN_RXADDR    = 0xff
RF_CH        = 0xff
RF_SETUP     = 0xff
CONFIG       = 0xff
DYNPD/FEATURE    = 0xff 0x00
Data Rate    = 1MBPS
Model        = nRF24L01
CRC Length   = 16 bits
PA Power     = PA_MAX

Which apparently means that there must be something wrong with the connection, as far as I know .
noting that i have this Nrf24L01 with 10 pins, so i tried to attach it just like the following picture shows :

So I tried to plug it in with the Arduino just like this:

What was the mistake?

Voting to close as unanswerable, as the poster has admitted that the circuit does not match what is depicted but has failed to provide any information on what circuit they actually do have.  Questions abandoned in a form where they can neither be answered nor inform any similar problems merely clutter the site without being of use to anyone.

What is it that you are asking? I can't see a clear question.

I think problem lies in your Arduino sketch, specifically in this line:
#define RF_CSN 7

Now, you have set RF_CSN pin to pin#7 while actually, its connected to pin#9
To get this to working you, try changing above lines of code to:
#define RF_CSN 10

Hope it helps.

yes, true, that but I   just discovered that the pins aren't even like the http://i.stack.imgur.com/5epm9.jpg image shows, but indeed it's a whole different setup, so i managed to solve my problem, thnx for your help

@Medmalik - You should post your answer


text:
Compile `.hex` files on Linux
I build .hex files for Arduino. How can I do this in Linux? I use the Linux distro  Mint 17.2.
I need a program to make [.hex files] (in Linux).
Can anyone help me?

With the Arduino IDE of course.

What are you asking for? How to build .hex files on Linux? Or how to upload .hex files on Linux? Please clarify your question, because as it stands it is rather unclear and is likely to be closed.

@Majenko - I may be wrong, but looking at your edit, I would have said (as a non-native Brazilian Portugese speaker) that Necessito de um programa para fazer. should be translated as I need a program to make [.hex files], rather than I need to make a program.This may be the reason why the question seems a little unclear... :-)

@Greenonline Don't complain to me - complain to Google Translate ;)

@Majenko - ah, ok :-) Anyways, I've changed the meaning of the question, and it all makes a bit more sense now. I've voted to reopen.

You can download the Arduino IDE for Linux from the Arduino site.
As mentioned in Where are the hex files compiled by Arduino?, in the Arduino program: go to Arduino -> Preferences and then select Show verbose output during -> compilation.

Finally, when you are compiling, the program will show you lots of
  data. At the last lines, you will find the path to the .hex file
  (Every time the path changes!).

If you want to upload this .hex file to your ATmega328P (the micro controller inside Arduino Uno), avrdude can do that for you.
Here, are few useful links:

Setup Avrdude on Linux
Programming your chip
Choosing a Programmer
Uploading your .hex file

ok. But it not is my problem.
I have an .hex file and I need compiler this file to the arduino.

Upload? Compile seems strange. Please elaborate.

from what i understand of your question is that you have a .hex file and you want to upload it to your Arduino Board. Well, First you need to know which microcontroller is being used in your Arduino Board you can use AVRDUDE, as shown in this tutorial, you can upload that .hex file to your micro controller. (Arduino UNO have a ATMega328P)

Unfortunately, your answer and the link only shows how to install avrdude, but not how to use it to upload a .hex file.

Unfortunately, you did paid attention while visiting the given link. There was menu in which different section were listed. Anyways, I have edited my answer.

No problem... It turns out that you were correct anyway, as the true meaning of the question had got lost in translation. I have clarified the question.

How are you creating your .hex files? Where are they coming from? Are you cross compiling the .hex files on some other machine and then transferring them to the Linux box? What is your Arduino connected to, the Linux box, or some other machine? Why are you even bothering with the .hex files? Your question is a little unclear. As Mikael states in his comment, you do not need to compile the .hex files, they are already compiled, you merely need to upload them, which the Arduino IDE would do for you anyway...
As ARK points out in his answer, you may find the answers to the question Where are the hex files compiled by Arduino? useful, although it seems like you know where they are but you don't know how to upload them.
Why can you not just use the Arduino IDE, to write your sketch, and then allow it to automatically compile the sketch and upload the .hex file for you? That way you do not need to manually play with the .hex file. Maybe I am missing something.
Is the Arduino IDE bombing out and not uploading the sketch on to the Arduino board?

However, if you are merely asking, how can I upload a .hex file to an Arduino, in Linux without using the Arduino IDE, then you would use avrdude. Taking the answer from How do I upload a hex file firmware to a target board without using the arduino IDE?
avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/build8135728863211847829.tmp/sketch_may21b.cpp.hex:i

or alternatively, taking the answer from Uploading Arduino hex file using avrdude
avrdude -U flash:w:[put-hex-file-path-here]:i -C avrdude.conf -v -p atmega328 -b 115200 -c stk500v2 -P [put-device-path-here]


text:
Can I prevent the Stepper library from holding the motor?
I'm using the Stepper library to control a single stepper motor. When the Arduino is not running the motor it is holding the motor shaft in place. For my application, this is very wasteful and puts unnecessary strain on the motor.
Is the Stepper library supposed to do this or is something else up with my circuit? Can this behavior be overridden?

use disable output class in  accelstepper library.
http://www.airspayce.com/mikem/arduino/AccelStepper/

Stepper library has nothing to do with this. What holds your motor are those GNDs or 0 Volts applied to control pins of your Stepper motor.
What you are looking for is UL2003A. The way ULN2003A works is solution to your problem.
Assuming your stepper is unipolar, Here is a complete tutorial on how to use Stepper motor with UNL2003A.

The ability to release all the stepping motor coils depend on the hardware and software used. For example, the Adafruit.com hardware and software has this function to release all the stepping motor coils.  Investigate their approach and determine if you can contribute to the library you are using by porting this feature.  Also investigate if this feature is not (serendipitously) already part of the library you are using.  For instance, it is not unreasonable to expect the library you are using to return Atmel pins to a passive input state (which, depending on the hardware, may release the stepper) when you destroy the instance of the stepper library class.

//for all pins used for controlling stepper motor assign all of them LOW

#include<Stepper.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 10, 11,12,13);

void setup() {
  myStepper.setSpeed(30);

Serial.begin(9600);
}

void loop(){

 Serial.println("clockwise");
  myStepper.step(stepsPerRevolution*5);
  delay(300);
digitalWrite(10,LOW);
  digitalWrite(11,LOW);
digitalWrite(12,LOW);
digitalWrite(13,LOW);

}

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


text:
Connecting arduino and EV3 using I2C
I'm trying to connect arduino uno and ev3 by using this guide (http://www.dexterindustries.com/howto/connecting-ev3-arduino/),
everything works perfectly but when i tried to use analogRead block to display data from arduino it just displays  i2c address of my arduino.

Post your code and setup. What is the 'analogRead block'?


text:
Avoiding float math to speed up arduino
I read and heard that the floating point math is much slower than int math.
And I saw a converting process in here floath math to integer math
So I want to to convert my floating math calculations to integer math.
Here is the code that include floating math:
float sensval, lpf, lps;
float sensinitial; // used to store the initial sensor data
float x, y, z;
int heigh;
int dA;

void setup() {

  runSensor();
  sensval = readSensorData();
  sensinitial = sensval; // Setting the initial data
  lpf = lps = sensval;
}

void loop() {
  sensval =  readSensorData();
  heigh = (float)44330 * (1 - pow(((float) sensval/sensinitial), 0.190295));
  lpf = lpf + (sensval - lpf) * 0.1;
  lps = lps+ (sensval - lps) * 0.05;
  x = (lps - lpf) * 50;
  y = x+ (z - y) * 0.1;
  z = constrain(y, -500, 500);
  dA += z * 100 + 2000;
}

readSensorData(); returns 7 decimals maximum(752.4543 for example)
There is pow calculation too.
So how can I convert floath math to int math?
Any optimization code are welcome.

The general idea is that you look at your calculations and decided how many binary places (binary equivalent of decimal places) you need in your calculations, or at different stages of the calculations, and do your calculations in an order and/or with a word length that will avoid overflows. You will be using integer data types thoughout your calculations, mentally keeping track of the binary point at each stage of the calculation. Search for Fixed Point Arithmetic to find a lot of information.

overflow is not problem, ı just want to convert my floating point calculations to integer calculations to speed up arduino little bit.

Have you actually noticed that it is running too slow? Don't try and optimize without a benchmark handy.

What you are asking for is not simple, especially since you have this
power function that can be hard to approximate.
First, you have to figure out the range and the required precision of
each of the floating point numbers you are manipulating. You wrote that
readSensorData() returns 7 decimals. If by that you mean that you
require a relative accuracy of 10−7, then I predict it will
be extremely hard to optimize this as a fixed point calculation. If
you can live with a much lower relative accuracy (say, around
10−3 or 10−4), then it may be worth trying
something.
I would start by writing the expression of height as
height = f(sensval/sensinitial-1)

where
f(x) = 44330 * (1 - pow(1+x, 0.190295))

I would expect sensval and sensinitial to be close to one another,
which would imply that x is small. At this point you should try to
estimate the likely range for x, because the feasibility of what
follows strongly depends on it. Next step is to approximate f() by a
polynomial. A simple Taylor
expansion gives:
f(x) ≈ -x*(8435.78-x*(3415.25-x*2060.2))

You may start by trying this, just to see if it looks kind of OK or
completely hopeless. You will notice that the above approximation is
great when |x| is tiny, but it very quickly degrades as |x|
increases. This is why you don't use Taylor expansions in real
approximations, I showed it to you only to give you an idea of the
feasibility of a polynomial approximation.
To do better than Taylor, you must specify the range of x, then you
can scale that range to [−1, 1] and expand on the basis of the
Chebyshev
polynomials. And
then you could fine-tune to get the optimal
polynomial, but
it's likely to be only marginally better than the Chebyshev expansion.
If all this works with a reasonable polynomial degree (say, no more than
5), then you can start converting to integer math. If it doesn't, you
may try a different type of approximation, like interpolating over
tabulated values. If the problem is the range of x being too large,
you may instead write the power function as
ab = 2b × log2a
and write polynomial approximations to the base-2 exponential and
logarithm (the polynomials only needs to cover one octave). If you try a
rational fraction approximation, beware that divisions are slow on the
AVR platform.
If all the above looks like too complex, or too much work, then just get
a faster CPU, or try to live with your program being slow.

Since you are dealing with fractions, you can use fixed point arithmetic. For example, you can use unsigned short _Accum for readSensorData() if you only need 8 bits for the fraction part. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf tells you about fixed point types in c.

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


text:
Arduino Leonardo runs unusually hot
I have a genuine (purchased from Adafruit) Arduino Leonardo that I have had for 2 years and I have not had any issues with. However, I have always noticed that it seems to be running suspiciously hot for a low power microcontroller, sometimes even too hot to comfortably touch. I measured the temperature today with an infrared thermometer at 121 degrees Fahrenheit (~49C). Based on observations by feeling the board, the 32U4 seems to be what is getting hot and everything else is cool to the touch. This happens when it is powered over USB as well as through the power jack. The chip gets hot even when nothing is connected to the I/O or power pins. The board is entirely working and does not appear visibly damaged. I am a bit worried about this as I may use this board in a project where it will be inside in enclosure and running for long periods of time. Any ideas why this is happening and if this normal?

Mine is getting hot as well. A genuine Leonardo too. I'm using Ethernet Shield and an RFM69HCW radio.

I think I solved mine, I was using 12v supply, I changed it to another one using 7v. It's normal now.

My Leonardo, which I leave on all the time, is not hot. The CPU chip feels at room temperature as far as I can tell. If you were powering something from it, maybe you are drawing too much current. If it gets hot just sitting there doing nothing, and with nothing connected, something is wrong.
Maybe you damaged it in the past? Maybe hooked up some LEDs without current-limiting resistors? If not, it sounds like a faulty device to me.


text:
Confusion with ATmega328P and 3.3V/8MHz
Firstly, I have tried to set the bootloader to be 8MHz internal oscillator.
I have tried the board setup from here - https://github.com/oshlab/Breadboard-Arduino.
And also the breadboard-1-6-x.zip setup from here - http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard.
Burning the bootloader in both cases seems to work, with fuse settings of -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m (using Arduino IDE 1.6.7):
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: 1 bytes of efuse verified
...
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: 1 bytes of hfuse verified
...
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: 1 bytes of lfuse verified

When I try and run the test sketch (below) at these voltages:

3.3V it fails (tried multiple 3.3V sources, all fail).
4.23V (3xAA rechargeable batteries) it works.
4.8V (3xAA alkaline batteries) it works.
5V it works.

To try and determine if it was my power sources or the bootloader that was the problem I uploaded this test sketch on my ATmega328P, an Arduino Nano (all Nanos are 16MHz?) and a 16MHz Arduino Pro to see if the red LED (with 100 Ohm resistor for ATmega328P) lights up in about the same time. This test sketch also does not work at 3.3V, and must be run at 5V to work.
(edit) When running this test sketch at 3.3V I see no 3.3V logic level on any output pin with my multimeter.  When running at 4.23, 4.28, 5V I see this logic level on all output pins.
(update) When connecting the +ve of the LED directly to 3.3V, the LED lights up.  So the 3.3V source has enough power to light the LED directly.
So I assumed that because my ATmega328P circuit has no crystal in it (and the Nano and Pro Mini are 16MHz), these loops would execute in different amounts of time?  But no, the loops do execute at the same speed (3 and a bit seconds) - so is my Nano/Pro Mini underclocked, or my ATmega still running at 16MHz but without a crystal??  Rather confused.
Thanks.
(update) I tried a second ATmega328P, same problem.
(code edited to use 14 output pins)
void setup() {
  for (int p=0; p<14; p++) pinMode(p, OUTPUT);
}

void loop() {
  // waste some time.
  int y = 0;
  for (int i = 0; i < 11; i++) {
    for (int j = 0; j < 11; j++) {
      for (int k = 0; k < 101; k++) {
        y+=analogRead(A0);
      }
    }
  }
  for (int p=0; p<14; p++) digitalWrite(p, y % 2);
  for (int p=0; p<14; p++) digitalWrite(p, HIGH);
  delay(1000);
  for (int p=0; p<14; p++) digitalWrite(p, !(y % 2));
  for (int p=0; p<14; p++) digitalWrite(p, LOW);
  delay(1000);
}

It was a brownout fuse problem.
Changing boards.txt from:
atmega328bb.bootloader.extended_fuses=0x05
to
atmega328bb.bootloader.extended_fuses=0x02
solved it for me (*).
The chip and red LED now work at 3.01V  (1xAA alkaline and 1xAA rechargeable) and 3.19V (2xAA alkaline).
(*) not sure why I had to invert the bits (0000 0010=0x02 versus 0000 0101=0x05) when compared to the tables below.

Calculating those fuses by hand is error prone - I've already lost an AtMel chip to getting it wrong. http://www.engbedded.com/fusecalc/ will do the hard work for you.

Yeah, thanks for the warning.  Any idea why the default BOD value of 0x05 doesn't work for me and 0x02 does?  Seems as though I have to flip the bits.  If I set to 0x07 that also works (presumably BOD disabled, but bits not flipped!)

I don't know. This is for efuse? Can you read it back?

If you are using an LED to indicate that your sketch is running, then that may be the problem.
For example, if you have a fairly average red LED, it might have a forward voltage of 2.0v @ 20ma (refer to your spec sheet for your particular LED). Putting these values into the LED calculator, it would tell you that you need a 150 ohm resistor. You might have tested this, and seen the LED light up.
Then, if you drop the voltage to 3.3v, your LED might be either very dim, or (more likely!) not light up at all. Putting 3.3v into the same web page, it shows you need a smaller resistor, 68 ohm, for the same LED.
P.S. - I just noticed your paragraph about the green LED - a "true green" LED might have a voltage drop of 3.3v, which means for 5v you would need a 100 ohm resistor (as described in your paragraph); for a 3.3v supply you would need a 1 ohm resistor instead. This is pretty certainly your problem

Thanks for your answer. I've swapped from green to red and see the same issue.  I've also updated the sketch (qn edited) to use 14 digital pins (0..13) and don't see a 3.3V level on any of those pins, but I will see 5V.

If you are powering your circuit off a cell battery, you might find that your battery cannot supply enough current. To test this, use a multimeter to measure the voltage of the battery, while your circuit is connected (and possibly, or possibly not, running). If the voltage drops below 2.7v (as defined by your fuses - use the AtMel Fuse Calculator page to see what your fuses mean), your chip will shut down, causing the voltage to rise back, turning the chip back on, and round it goes.The battery may even take a while to recover (I think last time this happened to me, it took about 10 seconds -I thought I'd destroyed the battery).
This is fairly common issue with motors (which draw a lot of power), but depends on your exact battery, and the exact load.
If this happens, you might get away with using multiple batteries in parallel (connect all the + sides together, to the + side of your circuit; all the - sides together to the - side of your circuit). Most battery holders are in series, which means they boost the voltage instead; you will have to do your own wiring for this.

Thanks for your answer.  Given what I am seeing (no 3.3V logic levels at all), I am wondering if it's brownout detection or something.  The 328P seemingly won't get going at anything less than 4.8V (although I've not measured 3.3V-4.8V).  Also, I have no idea why the 328P runs the test sketch at the same speed at the Nano and Pro Mini.

Hy all,
I´m facing the same issue. Had an ATMEGA328P-PU with 8Mhz Oscillator on a breadboard that did not work with 3.3V (stabilized) as a supply. At 5V things work as expected.
Finally I got things running with extended fuses set to xxxxx110, which sets BOD to 1.8V. I coud verify that my ATMEGA328P-PU does not run with fuses set to xxxxx101 = 2,7V (max. 2.9V). The supply is about 3.4V and has blocking condensators, so it cannot be a supply issue.
Best regards, Eckehard


text:
Are there any detail examples of Si4463
Recently, I bought two Si4463 chips, but I don't know how to use them. It seems complex. I'd like to know if there are any examples of an Si4463 used with an Arduino?

try this

@ARK   I am just a beginner of Arduino, do you know detail course about how to use 4463 ?

@ARK   In your web, there are many things, in fact, I don't know what is suitable and how to use it .

QAPRS library also on si4436 - thr rado APRS frames beacon example

This seems to be the Chip used on the RFM24. Have a look on the RadioHead Library:
http://www.airspayce.com/mikem/arduino/RadioHead/classRH__RF24.html
I normally use the same libs for the RFM69 (Semtech SX1231) with my Whisper Node and works fine. I would expect the same for the RFM24.
Btw, getting a silicon and building the Radio can be quite complicated. You might would consider starting with a Dev Kit or an assembled module.
Also, I don't think HopeRF produces RFM24 anymore, can't find on their site (http://www.hoperf.com/rf_transceiver/). If you just need it for a single project and does not intent to build a product of that, might be better chose a different/more popular option. Will be easier to find support for it on the Internet.

I've looked at the data sheet for this and I think it is the wrong choice of device for a beginner.  Can I suggest that you start by looking at a relatively simple DPI interfaced device, such as a sensor or RTC.  This will teach you the basics of sending commands via the Wire library.  You might even get the hang of it just by looking at existing libraries.
I can't find a library, so you are going to need to write your own.  The library will need a begin function which initialises you class and a write and read function, which write and read from an address.
void begin(void);
uint8_t read(const uint8_t& address);
void write (const uint8_t& address, const uint8_t& bytesOfData, const uint8_t* pData);

You will need to flesh those functions out, but that's it.  If you want to make you library more useable read the datasheet and create wrapper functions for each of the registers that can be accessed.
// This instruction requires 10 buts spread over two bytes.
void writeFrequencyOffset (const uint8_t& highByte, const uint8_t& lowByte)
{
  write (0x73, lowByte);
  write (0x74, highByte);
}

The process of creating friendly wrappers is a tedious operations, just reading the data sheet and translating that into code.

The part in question is an SPI peripheral, not an I2C one, so the wire library does not apply.

The Si4463 IC from Silicon Labs is a great communication chip with very good sensitivity. However, its onboard MCU uses SPI as a communication interface to communicate with an external microcontroller.
In a module such as an HC-12, an STM8SF103F3 microcontroller which is programmed to act as an SPI to UART bridge. HC-12 modules lets you control all of the internal functionality of the Si4463, even using AT+ commands for things like adjusting baud rate and transmission power. Unfortunately, the code doing the SPI to UART bridging is proprietary, which leaves you at a disadvantage if you're trying to use the Si4463 chips to build a real product.
But perhaps, if you have purchased something like the RFM26W module, or you simply have a bare-bones Si4463 IC to work with, then you will need to communicate with it via the SPI pins. It must be noted that there is no standard Arduino library available for communicating with the Si4463's SPI pins.
Working with SPI pins can get a bit complicated as you're trying to sync the clockwork. If you want to get your hands dirty, then you could go ahead and have a look at the Si4463 datasheet and look at the SPI timing parameters on page 16.
Fortunately, there is a Si4463 library project on GitHub which you can look into and perhaps modify the code to fit your needs.
Here is the GitHub page for the Si4463 Arduino library made by zkemble:
https://github.com/zkemble/Si446x
Here is the blog post where he explains it in more detail:
http://blog.zakkemble.net/si4463-radio-library-avr-arduino/
Here is the documentation for the said library:
https://zkemble.github.io/Si446x/_si446x_8h.html


text:
Arduino micro window focus troubles
I'm currently attempting to use an Arduino Micro as a ducky USB for penetration testing, and currently when I attempt to open a command prompt (or any other window) the window loses focus which prevents me from typing anything in it. Here's my sample code:

#include <Keyboard.h>

void setup() {
  delay(5000); //Delay for testing
  Keyboard.begin();

  Keyboard.write(KEY_LEFT_GUI);
  delay(400);
  print(F("notepad"));
  enter();

  Keyboard.print("This is a test");
  enter();

  clear();
  Keyboard.end();
}

void print(const __FlashStringHelper *value) {
  Keyboard.print(value);
}

void clear() {
  Keyboard.releaseAll();
}

void enter() {
  Keyboard.write(KEY_RETURN);
  Keyboard.releaseAll();
}
void loop(){}

Any thoughts on what might be causing this? I'm testing it on windows 10 home (not sure if that matters).


text:
How to detect whether connected to computer
I built a keypad that can adjust volume, play, pause, skip tracks, and control the arrow and num keys. It has some backlighting under the keys. I'd like to turn this off when the computer is off. Additionally, whenever the computer is restarted the device must be unplugged and plugged back in or the operating system will not register keypresses. Is there a way I can tell if the computer is on or if the device is connected?

Which arduino are you using?

Is the device USB connected?  Also,  by “Is there a way I can tell if the computer is on or if the device is connected?”, do you mean a way that you yourself can tell, or the Arduino, or your PC, or some combination?

It's an arduino micro on the inside and is powered and communicates via microusb port. Also, the preferable solution is that the arduino itself can tell if the computer is on as currently it requires no helper software to be running on the host computer and works the same on windows and osx (haven't tested linux yet).

Try to look in your bios or OS if there is an option to turn off the USB ports when shut down. Otherwise you will need to do it yourself: If your PC has PS2 ports, you can sense the +5V there and check if it is powered off at shutdown; otherwise you will have to open the PC and find some place which turns on only when the PC is on (e.g. the IDE cables coming from the power supply). Then you will have to setup a usb port powered by that 5V or with a transistor controlled by that voltage. I think that this will solve also the reboot problems (since the board will be initialized again at boot)

What USB library are you using? LUFA? As to the unplugging, you could try adding some delay inside the setup function.

@frarugi87, I could configure the the ports to turn off when shutdown but then it is impossible to use the ports to power other devices when the power is off.  Surely I should be able to wire into the the middle two cables and listen for the ACK packets right?

@Gerben I am using the keyboard function here as well as a modified version of this library for control of media keys and volume.

@amoose136     What is the colour of the USB port you have the device plugged into, also are you powering down the PC or putting it into sleep?

@RSM The port is non colored (USB 2.0). The computer completely shuts off usually but I still use other ports to charge things like calculators and phones from time to time.

@amoose136 Hacking the USB protocol is not a really good idea, at least for me. Too much complicated.. If you can't selectively turn off the USB ports (one of my mother boards had three switches to enable the feature on different usb ports) then I'm afraid that the easiest solution would be to add another USB port powered by the internal IDE connectors...

I think you can use the function USBConnected() to see if the host is present/alive.

@Gerben I would imagine that function should do it but it's not clear to me how to access that function. If I just call USBConnected(); it will say "function not defined at this scope."


text:
Need to buy a new breadboard?
I'm new to Arduino and haven't done any education in electrical engineering before, so this might be a very dumb question.
I'm busy with a project to control two servo motors with Arduino. Now yesterday I connected the wires incorrectly to the breadboard, so the wires started smoldering. I didn't connect the resistor correctly, so I guess that might have been the problem.
Now I replaced the wiring, but it's not working and I don't know if the software might be the problem or the breadboard need to be replaced as well. I cannot see anything wrong with the breadboard, but it was warm so I don't know if it might be burned from the inside? The wiring of the servomotors seems to be okay, so I guess that I don't need to replace those I hope.
Any tips about how to check everything is still working?
Or might it be a good idea to buy an LED and add it to the breadboard to ensure it's okay?
EDIT:
I guess I found some code to check that the servomotors are still okay. Just add them directly to the Arduino and run some code: Sweep
One other question: one of the servomotors doesn't have a black, red and yellow cable but a red, brown and orange. How can I know which ones the same as yellow, red and black?

I didn't know you could buy just one LED...

I didn't connect the resistor right - Resistor? With servos? Can you share your schematic please? It sounds like you are doing something wrong.

How did you understand that it was the breadboard? usually a breadboard is a plastic cover and metal contacts; if something is broken, then probably it's the arduino or the servo,..

@Majenko http://cdn.instructables.com/FJJ/4RJK/HI3TRXOL/FJJ4RJKHI3TRXOL.MEDIUM.jpg

Ah right - just a base/gate resistor. That's OK then.

@frarugi87 Well the arduino is still functioning. I can upload and run software so that seems ok. I don't know OR the breadboard could be fried, that's my question, it's like you said a plastic cover so I cannot directly see or it's fried or not. So my question how can I determine or there's something wrong with the breadboard or not.

@ErikvandeVen usually if you can't understand if it is fried then it is not fried. When a breadboard "blows" the white plastic becomes black (and even then most of times it still works). To be sure, assemble your circuit, then check with a multimeter the resistance between each pin and the servo. I mean, touch the GND pin on the arduino and the GND pin on the servo and check that the resistance is low. Then do the same for the +5V and the signal..

Sorry to check your English, but when you say I don't know OR the breadboard and I cannot directly see or it's fried, do you mean if and not or, so that they should read as I don't know IF the breadboard and  I cannot directly see if it's fried - I only ask as I reviewed an edit to your question and swapped or for if as otherwise it didn't sound idiomatically correct.

haha I'm sorry. yes I meant if, my bad.

To answer your last question (for 99%):
red = +
brown = gnd
orange = pwm (speed)

To test: try measure resistance with multimeter, gnd and + should have the lowest resistance.
And to be save: buy a new breadboard, a bad partly melted breadboard, or pieces of solder spoiled, is a nightmare.
Otherwise you can test with a multimeter the resistance of your breadboard for columns (close to 0) and rows 1.

And if you want to be more sure, 99.99% of times the pinout is always the same, so if your cables are black-red-yellow and the other is brown-red-orange, then brown GND, red + and yellow PWM

You could check the connections of the breadboard, using a multimeter (set to continuity check) and wires in the breadboard holes, with the + and - leads, from the meter, at either end of each row/column of connections, following the diagram below:

It might be a bit tedious, but it should only take thirty minutes maximum, and would give you peace of mind as well as saving you four Euros...
If you say that it was working before and now is not, then maybe the breadboard is damaged. However, it is unlikely that the whole breadboard is... try moving your components to a different part of the breadboard.
The breadboard could possibly get warm, as servos can use a fair bit of current, and breadboards aren't really designed for power circuitry. You may be better off using an Arduino Servo shield and connecting the servos directly to that, rather than using the breadboard. Why are you using a breadboard - can you, as Majenko states, provide a schematic diagram?
Answering the last part of your question - Taking the graphics from my answer to Code to control servo with shield, to show the different colours for the four different connector types:
Futaba and Airtronics connectors

Hitec and JR Radio connectors have the same pin out:
.
This means that the red, brown and orange leads go to a JR Radios connector.

@ErikvandeVen - I have updated my answer a little, w.r.t. using the breadboard (component placement and heating)

Not all servo motors have the same color cables, that's the manufacturers choice, although they should be standardized. You can test them with a multi-meter, low resistance is usually ground, slightly higher one is usually is usually the power, the other will be the signal. Breadboards are generally cheap and if you suspect yours is not functioning properly, buy a new one. I have two of these and they work very well for $10. MPJA powered breadboard
Additionally, if you have a motor driver shield, they usually have a three pronged port for your servo cable to connect to. Try that as well.


text:
Detection of DS18B20, arduino Mega
I just bought a DS18B20 temperature sensor. I can't detect the device when i run this code :
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 10 on the Arduino
#define ONE_WIRE_BUS 10

// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
 }

 void loop(void)
{
  // call sensors.requestTemperatures() to issue a global temperature
 // request to all devices on the bus
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.println("DONE");

  Serial.print("Temperature for Device 1 is: ");
  Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
    // You can have more than one IC on the same bus.
    // 0 refers to the first IC on the wire

}

Here are my connections:

and output on Serial Terminal is:

      "Temperature for Device 1 is: -127.00 Requesting temperatures...DONE"

I also tried to detect the address of my device but with no success.
I am using an arduino Mega 2560, i have read in some forms that maybe it has something to do with Clock speed or something like that.

I appreciate your help.
I mainly followed this tutorial : http://www.hobbytronics.co.uk/ds18b20-arduino

In the Tutorial, which you are following, it says,

So we will use the 2 wire method. Simply connect both the GND and VDD
  pins to 0V (yes both)

and it shows:

but I think you are missing this step, because i can't see any connection like that here:

I still have the same result :/ I only get the -127 (I apologize for the mistake there was just that i was trying several tutorials and happened to leave that connection)

I attached VDD to GND and set it up so the 4K7 resistor was connecting the 5V to the data line - at first it didn't work, then I swapped it around as if the VDD and data lines from the sensor were switched - which it turned out they were.
Might be the case with your one.


text:
using enums in functions
Given the following enums
enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };
enum class CrossingZoneState: uint8_t {
    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state
    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor
    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear
};

Where RELAY_OFF = HIGH, HIGH is #define HIGH 0x1 which I assume is a C++/Arduino constant? because I didn't define it. And RELAY_ON = LOW, LOW is 0x0
in the following function I get the error that follows.
CrossingZoneState CheckEntrySensor(uint8_t esp) {
    //esp, short for entry sensor pin
    if (digitalRead(esp) == HIGH)
    {
        state = CrossingZoneState::CROSSINGZONE_CLEAR;
        return state;
    }
    else if (digitalRead(esp) == LOW)
    {
        state = CrossingZoneState::CROSSINGZONE_OCCUPIED;
        return state;
    }
    // if the digital read errs, return the current state so it re-runs
    return state;
};

boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState relayState)    {

    int testInt = 0;
    if (relayState == RelayState::RELAY_OFF)
    {
        testInt = 1;
    }
    digitalWrite(relayNumber, relayState);
    if (digitalRead(relayNumber) == testInt) {
        return true;
    };
    return false;
};

I tried having RelayState be an enum class as well but was getting similar type errors. Here is the error from VS2015 with the code shown above.

Compiling debug version of 'ModelRRXingStateMachine' for 'Arduino/Genuino Uno'
  ModelRRXingStateMachine.ino:11:55: error: 'RelayState' has not been declared
  :boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState relayState)
  ModelRRXingStateMachine.ino:2:1: error: 'CrossingZoneState' does not name a type
  :CrossingZoneState CheckEntrySensor(byte esp)
  Error compiling project sources

I'm not a professional programmer and am new to C++, usually writing in C# or VB.Net so I'm not sure what the compiler is looking for here, both enums are declared and one is declared with a type. Also, the VS code editor is showing no errors, the errors shown above show up in the error window when I try to build.

is this all in the .ino? the sketch preprocessor may be reordering the declarations and mucking things up.

I am using Visual Studio Professional 2015 and the Visual Micro add-in for Arduino, not the Arduino IDE

and yes, all this code is from the .ino file

The IDE automatically puts forward declarations for methods at the top of the file, conveniently before any types you make get defined. The VS add-in might do it too so everything compiles the same. Moving the code to a separate .h file and including that file would stop it from reordering things if that were the problem.

The solution was to move the enum declarations to a header file, due to the fact this was a VM add-in issue which will be resolved once they've implemented arduino version 1.6.8.
Adding this code to a header file and removing it from the main file resolved the issues and the code builds and runs.
// ModelRRCrossing.h

#ifndef _MODELRRCROSSING_h
#define _MODELRRCROSSING_h

#if defined(ARDUINO) && ARDUINO >= 100
    #include "arduino.h"
#else
    #include "WProgram.h"
#endif
#pragma once
// Arduino Digital I/O pin numbers for MEGA
//note: digital pins 30-45
//MEGA is a MUST for this project
enum {
    Relay1 = 30, Relay2 = 31, Relay3 = 32, Relay4 = 33, Relay5 = 34, Relay6 = 35,
    Relay7 = 36, Relay8 = 37, Relay9 = 38, Relay10 = 39, Relay11 = 40,
    Relay12 = 41, Relay13 = 42, Relay14 = 43, Relay15 = 44, Relay16 = 45
};

enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };
enum class CrossingZoneState : uint8_t {
    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state
    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor
    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear
};

#endif

For one thing, you are using the variable state without defining it. Moreover, you have not declared the functions CheckEntrySensor() and throwRelayAndCheckStatus() . When you define a function without first declaring it, the arduino preprocessor builds its own declarations, but often does so in a defective way. This is one of the idiosyncracies of the arduino environment versus a plain C++ compiler.
The following compiles:
enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };
typedef enum RelayState RelayState_t ;

enum CrossingZoneState {
    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state
    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor
    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear
};
typedef enum CrossingZoneState CrossingZoneState_t ;

CrossingZoneState_t CheckEntrySensor(uint8_t esp) ;
boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState_t relayState) ;

CrossingZoneState_t CheckEntrySensor(uint8_t esp)
{
  CrossingZoneState_t state ;
    //esp, short for entry sensor pin
    if (digitalRead(esp) == HIGH)
    {
        state = /*CrossingZoneState_t::*/CROSSINGZONE_CLEAR;
        return state;
    }
    else if (digitalRead(esp) == LOW)
    {
        state = /*CrossingZoneState::*/CROSSINGZONE_OCCUPIED;
        return state;
    }
    // if the digital read errs, return the current state so it re-runs
    return state;
}

boolean throwRelayAndCheckStatus(uint8_t relayNumber, RelayState_t relayState)    {

    int testInt = 0;
    if (relayState == /*RelayState::*/RELAY_OFF)
    {
        testInt = 1;
    }
    digitalWrite(relayNumber, relayState);
    if (digitalRead(relayNumber) == testInt) {
        return true;
    };
    return false;
}

Or, if you want to avoid the use of typedef, you can use the following:
enum RelayState { RELAY_OFF = HIGH, RELAY_ON = LOW };
enum CrossingZoneState: uint8_t {
    CROSSINGZONE_CLEAR = 0, // no train in crossing area, also initialized state
    CROSSINGZONE_OCCUPIED = 1, // train detected by the entry sensor
    CROSSINGZONE_EXITING = 2  // train detected by the exit sensor, when sensor clears, state= Clear
};

enum CrossingZoneState CheckEntrySensor(uint8_t esp) ;
boolean throwRelayAndCheckStatus(uint8_t relayNumber, enum RelayState relayState) ;

enum CrossingZoneState CheckEntrySensor(uint8_t esp) {
    enum CrossingZoneState state ;
    //esp, short for entry sensor pin
    if (digitalRead(esp) == HIGH)
    {
        state = CROSSINGZONE_CLEAR;
        return state;
    }
    else if (digitalRead(esp) == LOW)
    {
        state = CROSSINGZONE_OCCUPIED;
        return state;
    }
    // if the digital read errs, return the current state so it re-runs
    return state;
}

boolean throwRelayAndCheckStatus(uint8_t relayNumber, enum RelayState relayState)    {

    int testInt = 0;
    if (relayState == RELAY_OFF)
    {
        testInt = 1;
    }
    digitalWrite(relayNumber, relayState);
    if (digitalRead(relayNumber) == testInt) {
        return true;
    };
    return false;
}

It is good that you are able to get the code to compile, but seems this is a Q&A site and a few months/years from now other inexperienced ones my become lazy(Ctrl+c Ctrl+v) and not gain any understanding about the cause or solution to there problems. Could you thus elaborate on why it compiled and also maybe mentions of general use of enums in this way.

Type def is a C structure and is not standard in C++11 and forward and is not recommended for enums any longer.

A lot of code compiles, that doesn't make it right or effective

@RSM: You are right.

a) In function CheckEntrySensor(), the variable state was used without being defined.

b) The functions were used without a declaration.

You can edit stuff like that into the answer

If you don't want to use typedef, you can omit the typedef declarations and replace all instances of xxx_t with enum xxx . I guess in C++11 it would be sufficient to use xxx (without enum), but, to my knowledge, arduino is NOT C++11.

@dinotom : true, the fact that some code compiles doesn't make it right or effective. However it is always better than code that does not compile at all, regardless of its writer's rep on SO.

@Alphonsos_Pangas...state is declared, just not shown in the snippets I posted, so that wasn't the issue. See my answer below as this was Visual Micro add-in specific issue, solved with their assistance.

authors: Владимир Шамов


text:
Programming problem I need both if else cases to work but only else loop is running
#include <SoftwareSerial.h>
#include <Servo.h>
Servo myservo1, myservo2, myservo3;

int bluetoothTx = 14;
int bluetoothRx = 15;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
myservo1.attach(9);

//Setup usb serial connection to computer
Serial.begin(9600);

//Setup Bluetooth serial connection to android
bluetooth.begin(9600);
 }

void loop()
  {
    if(bluetooth.available()>0)
     {
      if(bluetooth.available()>=4)
       {
        char buffer[4];
          for(int i=0;i<4;i++)
         {
          buffer[i]=bluetooth.read();
         }
       int incomingValue = atoi(buffer);

      if(incomingValue>=1000 && incomingValue<=1360)
        {
           unsigned int servopos = bluetooth.read();
           unsigned int servopos1 = bluetooth.read();
           unsigned int realservo = (servopos1 * 256) + servopos;

         if (realservo >= 1000 && realservo < 1360)
          {
              int servo1 = realservo;
              servo1 = map(servo1, 1000, 1360, 0, 360);
              myservo1.write(servo1);
              Serial.println("servo 1 ON");
           delay(10);
            }
           }
          }
         if(bluetooth.available()==2)
          {
            char inbit=bluetooth.read();
            if(inbit=='A'||inbit=='D');
           {
            char myval= bluetooth.read();
            if(myval== 'A')
            {
              myservo1.attach(9);
            }

             if(myval== 'D')
              {
               myservo1.detach();
              }
             }
            }
           }
          }

You need to add, what values you expect from bluetooth during one loop-call. Calling bluetooth.read() twice in an if may not be that what you want.

I think you are lacking a basic understanding of how serial works.

Also lacking a basic understanding of how to write an if statement.

Your new code is still a mess. Please provide an abstract algorithm of what should be done.

There are so many things wrong with that program I can't begin to sort it out.
Here's some of the most glaringly obvious errors:
if(bluetooth.read() >=0 && bluetooth.read() <=360)

Read a character. Check it's at least 0. Read a second character. Check it's less than 360.  Since characters are between 0 and 255 that will always succeed if there is one character of any form to read (if there is no characters to read you get -1).
else if(bluetooth.read()=='A'||'B'||'C'||'D'||'E'||'F');

Read another character and compare it to 'A'. This if is true if the character read is A. It also succeeds if B, or if C or if D, etc. That's not "if it's equal to C", just "if C". C is a character literal, so it's equivalent to a number. Any number that is not 0 is TRUE, therefore it's equivalent to:
if character is A or TRUE or TRUE or TRUE...

Which of course is just true, so it will always succeed regardless.
char myval= bluetooth.read();
if(myval== 'A')

Read yet another character from bluetooth (I sure hope there are enough there...) then compare it to a list of characters that are the same as you looked at above. You're comparing a new character this time, not the one you compared with the list a few lines beforehand.

Would the changes I made do any help?. I want my code to execute first if loop if the bluetooth sends a value between 1000 and 1360 and second if loop if it sends character A or D.@Majenko

Well, no. Because you can never read a character that is greater than 255 since such a thing doesn't exist. You need to read some tutorials on using serial on the Arduino.

What if I add a buffer?Can I then send values more than 255?and then compare value in the buffer@Majenko

There are a number of ways of transferring data using serial. Simplest is with an ASCII representation. Then yes, read characters into a buffer and use something like atoi to convert that buffer into a number.

Could you check this code please?@Majenko

Please read this: https://hackingmajenkoblog.wordpress.com/2016/02/01/reading-serial-on-the-arduino/


text:
Arduino continually resets when connected to external power supply, but not USB
I'm working on a seemingly simple Arduino project which plays a sound and flashes an LED when provoked by some trigger.
The problem:
When powered by an external power supply, the Arduino continually resets after playing ~1/4 seconds of audio. When powered from USB, it works fine (however the LED, being powered from the external power supply, of course does not work here).
Wiring diagram:

Parts list:

Arduino Pro Mini 5V
Adafruit MAX98306 3.7W amplifier
Sparkfun FemtoBuck LED Driver
4 Ohm 3W speakers
3W LED

I am using a 9V 1A power supply. Again, when no speakers are connected, the Arduino and LED work as intended. It's only when a speaker is connected that the board resets over and over again. Playing roughly 1/4 of a second of audio and then resetting implies to me that there's insufficient current, however, the problem persists even after using a 2.5A power supply.
Things I have tried:

Increasing the power supply to 12V 2.5A
Desoldering the LED driver (even with the LED driver removed, the board still resets)
Checking continuity and staring at the wiring for long periods of time while scratching my head

Overall, I'm at a loss as to why it would work when powered via USB instead of through my external power supply.
What am I doing wrong? Any insights are greatly appreciated!

do you have a few capacitors you can add to the supply lines? 220~1000uF 25V?

I do, but I'm not knowledgeable enough about capacitors to understand what that would provide. Can you elaborate?

I'm having a similar issue and was wondering where you put the 5v regulator in the wiring diagram? Would it go between the external power supply and the arduino? Or just after the arduino?

@Josh it's best to ask a new question and reference this question instead of piggybacking off of another question. You'll get more eyeballs that way.

Most likely lack of current - lack of current able to be provided by the Mini. The audio is powered from the onboard regulator on the Mini, which has limited current capacity.
If too much current is drawn it will either get too hot and go into thermal shutdown until it cools down enough, or it will drop the output voltage, making things reset and crash.
Power the audio system from an external 5V regulator.

But why would the speakers work when the Arduino is powered via USB? The amplifier is still be powered by the Arduino regardless of what the Arduino is powered by.

Because when powered by USB you're not using the onboard regulator. You're providing 5V directly so the regulator isn't needed.

Ah, that clears it all up! Okay, I'm off to get a 5V regulator. Thank you!

I now have a 5V regulator in the circuit that I picked up from the local electronics supply place today and everything is working wonderfully. Thanks again!

your power supply may be faulty. try a another power supply which can supply more current and common the GND of arduino and power suply..it may have internal short circuit or lack of current.


text:
The most practical plug socket
I am starting some Arduino's projects with different sizes (very small based on Arduino Nano and bigger using Arduino Mega). These projects will be manipulated by students and they will connect and disconnect many times the wires. I will try to not use breadboard if I can. In order to develop very versatile projects, the idea will be to use very useful plug sockets. Currently I have no idea of which kinds of plug sockets I can use.
Do you have any idea about the existing plug sockets (from 2 to 6/8 wires) and which one it is preferable to use?
Complements:

Some shields and components I already have and want to use have sometimes some plugs sockets (similar to this) but sometimes only some classical pins
I want also to build my own shields by integrating plug sockets to the arduino or to another shield
Some parts will be also composed by small electrical circuit on which I want to integrate plug sockets aswell
I will also use LiPo batteries (for example this one which have a connector I can't buy currently because I don't know the reference)
Communications will be also achieved using SPI and I2C

Without knowing exactly what you are doing with these plugs and sockets, and what signals will be going down the wires, no one can say for sure. In some situations IDC connectors (like you used to have on older hard drives - or the smaller versions of them) could be ideal, but ribbon cable is ghastly for I2C or SPI. 9 Pin D connectors might be good, or they might be too bulky. There's just too many variables to be able to say "This is best".

Actually, I have also had similar considerations over a few educational projects. After many hours of strolling against the wind, I had to realize that probably there is nothing wrong with the plug-in breadboards and the readily available jumper wires. Actually, those are pretty easy to replace, inexpensive, and give the feeling of a full control of the connections, instead of using some yet another connection scheme and pinouts to learn.

@GeeBee It also has the advantage that they are actively learning the circuit, not just plugging together LEGO® bricks.

@Majenko, agreed! This is what I wanted to say, thanks for making this point very clear. I agree with you that lego bricks (e.g. lego wedo, lego NXT, littlebits) totally hide the electric connection aspect by using a much higher level of abstraction of "just put together". While this is great for preschool students since it hides a lots of complexity they are not interested in, it may not be a sufficient approach for an EE students course. It is much easier and inexpensive to let them blow up a few 1$ components for real than explaining all the underlying magic of connections for weeks.

@Majenko I have extended my initial post with more comments.

The problem with most of the connections you have linked to is they require specific crimped connections on the wires. The tool to do that crimping is specific to the connector, and can cost hundreds of pounds each.

@GeeBee I agree with you but in my case my students are not studying Electronical/Electrical fields but mechanical field. The purpose will not be to have electrical approach but use the electrical/electronical component to do some mechanical measurements using dedicated sensors. Moreover I want to minimize at the maximum the damages students can do by pluging and unpluging components.

@Majenko Even considering connectors presents on this shield: http://boutique.semageek.com/fr/280-grove-base-shield-v2.html?adw=1&gclid=Cj0KEQjwrte4BRD-oYi3y5_AhZ4BEiQAzIFxn5xRoul9Pb_uKKQ_Tahm-_D9FlSqx8guNvUjOANcEHgaAlzR8P8HAQ ?

Yes. Those are most likely JST. The last time I looked at a JST crimping tool the cost was in 3 figures.

@Majenko I see (real Tool http://goo.gl/4QqAIB , chinese version: http://fr.aliexpress.com/item/SN-28B-Pin-Crimping-Tool-2-0mm-2-54mm-3-96mm-18-28-AWG-Crimper-Dupont/32436828755.html?spm=2114.30011508.3.1.MUDVRu&ws_ab_test=searchweb201556_0,searchweb201602_1_10017_10005_10006_10034_10021_507_10022_10020_10018_10019,searchweb201603_7&btsid=603793c6-ff44-4d51-93d1-a3e6d5d2bce0 ). Maybe I have to find another solution or buy wires with plug sockets already fixed on it (and weld connectors on shields)

Ok, so more info from the OP:

non-electrical engineering students needs a prototyping platform
minimize possible damages, support hot plug-and-play
not too expensive

Dedicated connector
I suggest using standard subD9 connectors. Sensors shall have male pins, while the control board female socket (this makes very hard to do accidental short circuits on the control board). We were using these connectors in a daily basis in a lasershow system, and I was very statisfied. Inexpensive, easy to solder, works with a wide range of cables or separate wires.
In many cases, you can integrate the sensor into the housing of the connector. For example, an IR receiver, an accelerometer, etc. fits well.
You can use off-the-shelf serial cable extenders which makes it very versatile.
Since it is a D shaped connector, there is only one possible way to connect a sensor to the mainboard, and we're golden.
Dedicated connector light
NSL25 and NSG25 are my favorites:
http://www.soselectronic.hu/?str=371&artnum=4927&name=nsl-25-2-g
http://www.soselectronic.hu/?str=371&artnum=4934&name=-nsg-25-2
Although these are inexpensive wire to board connectors, it is very hard to misconnect them. Criping is a PITA, but you can purchase pre-crimped connectors with wires such as http://www.soselectronic.hu/?str=371&artnum=6175&name=-p-35003
One 3 wire female connector with wires costs about 50 USD cent.
Note though that in this case, the control board has the male connectors. By accidentally dropping a coin to the connector, or using a screwdriver, it is easy to run into short circuits. This leads us to the next plan...
Any inexpensive connector with proper electric protection
Probably the most inexpensive solution is to use standard headers and pins. Here you may also wish to buy ready made cables, than start crimping yourself:
http://www.soselectronic.hu/?str=371&artnum=6171&name=-p-2543
This however opens up a can of worms of misconnection:

connection by one or multiple pin off
connection in reverse direction
shorting the pins on the board

Against sorting, you shall have a multifuse on the power pins, say, 250mA. On each IO pin, you shall have a series resistor of 470 ohm, this ensures that no miswiring can destroy the Arduino.
On the sensor-side, things are a little more tricky. You need a shottky (or an equivalent P fet diode) to ensure that reverse polarity connection will not destroy your sensor. If the sensor has output pins, also use a series 470 ohm resistor.
Considering all the hassle, using a standard subD9 connector is a way easier:

it has enough dedicated pins for I2C, SPI, and a generic IO for dumb sensors
the pins can handle more current, and there are more pins you can connect in parallel to have enough power for small motors
it is impossible to misconnect (once all sensor sockets use identical wiring)

Don't forget ESD protection
In any case, it is a good idea to have some sort of ESD protection whenever you have connectors, and wires, and rough external world.
Have at least a TVS diode on the power pins (say, an 5.8V or 6V unidir TVS will do). On IO pins you can use a simple series resistor, or you can opt for a TVS.
During hot plug and play, it may happen that sensitive sensors get powered in a strange way. E.g. first 5V then the sensor output is getting connected, but no GND for a short moment. Some sensor may get damaged in this case. Use diodes to fix this.
For sensors requiring sudden current peaks (e.g. WIFI, or a motor), add at least 470uF/16V electrolyte capacitor right to the sensor end of the connector. This way once the sensor is connected to a long extension wire, you still have acceptable power to use in sudden current peaks.
Some sensors (e.g. IR receivers) are sensitive to power glitches. Consult their datasheet, use the suggested RC filtering network on the power pins.


text:
Arduino Digital Input. Trigger HIGH by 12V to 36V
I want to build a small circuit that will switch a LED on (for arguments sakes) when the cars ignition gets switched on. But I want to make it versatile so I can work with between 12V - 36V (Cars, Trucks, etc). What would be the best to read the Ignition status via the arduino. Know I have thought of an idea by working with voltage divider. Basically taking the principal of reading voltage Instructable Example and working from there. Any thoughts?

An Arduino seems a bit of overkill to just light an LED when the power is turned on...

Hi Majenko. My circuit will do more then just switch an LED on. Like I said (for arguments sake) I actually want to do a Vehicle Tracking unit but I must be able to to handle all voltage inputs between 12V - 36V

Even easier:

input - series 220 ohm resistor, and a 78L05 voltage regulator (check for maximum voltage). This allows you handling like 4..30V and get a solid "1" on digitalRead. (4V input makes like 3V output which is still logic high).

HAHAHA Gee Bee its you again. You always seem to come to my rescue. Tell me would something like this work 7805 SMD

Sure, it works up to 35V input out of the box, no series resistor. LM317HV works for much higher input voltage (you need two resistors to set up the output to 4.5Vish to get a stable 1 level).
These solutions are clear overkills - you could do this with series resistors, zeners, NPN transistor, etc. - but a voltage regulator is only one component to solder.

you can use transistor bias circuit, opto-couples circuits, op amp circuit or a simple relay circuit, to get 5V output signal when 12V-36V signal is triggered.


text:
Arduino uno simulation software for windows
Could anyone help me for a good free arduino uno simulation software for windows.Hope I get an answer.

See Can I program for Arduino without having a real board?

Autodesk offers a service called 123D Circuits which works in a web browser provided you have an Autodesk account. It allows you to construct (simple) virtual circuits and run code on a virtual Arduino Uno. Regrettably, it doesn't offer very much in the way of diagnostics tools, isn't open source, and won't work offline. The advantage of a service like this is that it requires no installation and is functional for simple setups with a few components. It can be found at 123d.circuits.io

Thank you for that but Could you suggest me anything offline.

Can you please expand your answer? There is no link to anything (not that we want link-only answers) and nothing explains what "works in browser" means.

123d.circuits.io is the web address. Works in browser means it works in a modern web browser like Google Chrome or Mozilla Firefox. The answer has been edited to reflect this.

Indeed. Currently this answer will be useless if the service goes down. Please add more detail to make the answer useful even without the link.