text:
Wiring VCNL 4000 Proximity Sensor
I was looking for wiring the VCNL 4000 Proximity Sensor.
I found this one http://bildr.org/2012/11/vcnl4000-arduino/
but there is used a sensor on a red board, which has other pins like mine (which has a blue board) see http://www.adafruit.com/products/466?&main_page=product_info&products_id=466
as I see SCL,DSA,GRND on both
the red has IR+ which is connected to the 5V . mine (blue one) has VIN. Is this meant to be the same and should it be connected to the 5V ?
Any hints?
I tried the following wiring but the following call does not finish.
3,3V TO 3,3V POWER
SCL TO SCL (Last pin on the digital side)
SDA to SDA (Beside SCL)
GND TO GND on the Analog side
Vin to 5V
 readVCNLByte(0x81); is called

i used the example code from adafruiut

There seems to be a big difference between the Sparkfun and the Adafruit breakouts:

Sparkfun breadkout needs 3.3V and 5V power as inputs as shown in their wiring circuit (in the first link you mentioned)
Adafruit breakout needs only 5V as input but has a 3.3V regulator on it that provides the 3.3V to all its internal circuits that need it; it also has a 3.3V pin which is an output not an input as for the Sparkfun

Hence your wiring is wrong. The expected wiring is described in Adafruit sample sketch:
// Example sketch for talking to the VCNL4000 i2c proximity/light sensor
// Written by Adafruit! Public domain.
// To use: Connect VCC to 3.3-5V (5V is best if it is available), GND to
//         ground, SCL to i2c clock (on classic arduinos, Analog 5), SDA
//         to i2c data (on classic arduinos Analog 4). The 3.3v pin is
//         an ouptut if you need 3.3V
// This sensor is 5V compliant so you can use it with 3.3 or 5V micros

In comments, VCC should read as Vin on the breakout.
Note that the comments mention SDA and SCL pins on A4 and A5 respectively, this is correct on Arduino UNO, but your wiring on the 2 leftmost pins of the digital pin header is also correct, as these pins are now replicated there on UNO and Leonardo. On Leonardo, the real pins for SDA/SCL are pins 2 and 3. If you don't have a UNO or Leonardo though, you should check where SDA and SCL can be found (that's generally described on Arduino Product page for your board).
Although wiring SDA/SCL on these 2 replicate pins is correct, I would rather recommend using A4 and A5 instead, so that you don't get the illusion that you can both use SDA/SCL and A4/A5 for something else at the same time.
This circuit uses I2C which means you should normally add pullup resistors to SDA and SCL wires; however, it seems that the Adafruit breakout already integrates them, so no problem here.
To sum up, and provided that you have a UNO or Leonardo, your wiring is correct except that you should remove the wire between both 3.3V pins.
This is shown below for UNO (I used the real pins for SDA and SCL so that you don't use them for something else later):

Arduino UNO 5V  ---> Breakout Vin
Arduino UNO GND ---> Breakout GND
Arduino UNO A4  ---> Breakout SDA
Arduino UNO A5  ---> Breakout SCL
Breakout 3.3V left unconnected

For Leonardo it would be:

Arduino Leonardo 5V  ---> Breakout Vin
Arduino Leonardo GND ---> Breakout GND
Arduino Leonardo D2  ---> Breakout SDA
Arduino Leonardo D3  ---> Breakout SCL
Breakout 3.3V left unconnected

I show you both UNO and Leonardo since you did not mention which board you use.


text:
Arduino power consumption issues
I'm working on an Arduino project involving an UNO.
I'm powering a 20x4 LCD screen and I am using all the ports on the Arduino, to the last.
All but four of them are pulled high at any given time, so by the time I'm done with pulling them all up the screen is going dim when powering via USB.
So I tried powering via an external 9V 600mA adapter, but that makes the Arduino overheat and eventually shut down.
I then tried another, 12V 500mA adapter, and that one doesn't even get my UNO to the end of the setup function, and it reboots repeatedly.
Anyone got good advice? Ideas?

Stop trying to burn out the MCU.

It's worth adding a schematic / daigram of what's connected. It sounds like you're trying to draw too much current from the outputs, normally an LCD shouldn't draw much current unless you're also using the backlight?

Use a 5V usb power supply, which allows you to bypass the voltage regulator, which is overheating.

Maybe an inadvertent short path somewhere - this should not happen. Schematic and/or photos helpful.

Is it a 0.6 mA or A? That's a huge difference! If it's 0.6 mA that's not nearly enough to power an Arduino with a LCD. I assume that's a typo.

The official arduino uno schematic uses a NPC1117 voltage regulator. This is a linear one. This means that if you put 12V on it, and if your system requises 0.5A, you Will leak 0.5A on the 12V, and, if there is 5V on the output, 12V on the input, there is a 7V drop on the regulator, 7V * 0.5A = 3.5W that turns into heat.
To avoid overheating, the solution isn't to increase the input voltage, but to decrease it. If you have a 6.2V power supply, this will minimize overheating. At least 6.2V are required for the NPC1117 to provide a stable 5V.
An other option is to use a USB 5V power supply with an output current greater than 0.5A. This is often used with smartphones. This allows to bypass the NPC1117, but the power supply shall be exactly 5V (where exactly stands for less than 10% of over or undervoltage).
Also, please note:

Arduino does not recommend bypass[ing the] Vin supply to directly supply 5V rail on the board as it will damage the NPC1117. See the first two line on page # 3 from the document link below. http://media.digikey.com/pdf/Data%20Sheets/Arduino%20PDFs/ArduinoEthernet.pdf
  You can either do the soldering and remove NPC1117 chip before you apply 5V directly onto the board or find a higher current capability power supply with the output voltage between 7v-12V.

Go with Jacen's second option. If you need any decent power, it's much better to skip the regulator on the arduino and just send it 5 volts directly, and since there are tons of USB power supplies out there, it's easy to find one.

source: Stack Exchange

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

sort: votes


text:
About arduino serial communication
I've used the arduino uno with the python serial library months ago and some packets got lost in the way. I've been searching about serial communication for arduino and I've been thinking that I could use some parity systems and other things to guarantee that my packets will arrive. First of all, if I use the parity system of the arduino's serial library, how good it will be? I need to send packets like "this button was touched", but ALL packets must arrive, so if some packet fails, I need to send it again.
How to make it possible? I'm thinking about using the parity system of the arduino's library, but I don't think if it's gonna work well.
Can somebody point me some good text about it?

You seem to be freely intermixing three extremely distinct concepts - Arduino "serial" which tends to mean UART-style asynchronous, "packets" a concept for which the previous serial has no inherent support, and then a rather random i2c tag, which is something else entirely (a shared synchronous signalling scheme).  Step one is going to be to sort out what specifically and exactly you are asking about.

Also note that on direct connections such as you likely have, failure is extremely infrequent - if you are seeing it, then likely you either have software which does not service the channel frequently enough to avoid missing data, or else extreme electrical noise.  While protocol-level integrity can be useful (especially where misoperation has real consequences), in a scheme that shouldn't be failing you should spend some time trying to understand why it is.

What baud rate are you using?

There is no way to guarantee that all packets will arrive. The best you can do is to have the receiving system acknowledge receipt of all packets, with enough data within to verify the correctness of the packets.
UART parity is not a good method to verify correctness since it can only detect single-bit errors within a byte; two bit errors will verify correctly, and of course the entire byte may get dropped before it can even get to the receiver.
RFC 916, "RELIABLE ASYNCHRONOUS TRANSFER PROTOCOL (RATP)", describes a TCP/IP-like method of sending data reliably over an asynchronous medium. It's more wordy than just sending a byte containing status changes, but if you need reliability then you need more than that.

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


text:
Light LED when 2 others are disconnected
I need to make circuit in which orange LED will light only when yellow and red are disconnected. When one of buttons is pushed orange LED should turn off.
See my attempt at it below.
I am new to electronics so your help is very appreciated.

EDIT:
After many atemps I managed to build this circuit as on left side of schematic (tested on live breadboard)

but my primary goal is to make this work with RGB LED. I took Common Anode RGB LED for this and build circuit on right side of schematic. I do not have such RGB LED to test it live so I ask you to review if that schematic will work as it has few changes to one with 3 LED's. Thank you
SOLUTION:
Thanks to Bruce's help my circuit now works.
3 separate LEDs emulate common anode RGB LED (as I do not have one to test circuit)
Q2 is BC 560B transistor with CBE type pinout

CODE:
void setup() {
  pinMode(2,INPUT);
  pinMode(4,INPUT);
  Serial.begin(9600);
  digitalWrite(2,HIGH);
  digitalWrite(4,HIGH);
}

void loop() {
  Serial.println(digitalRead(2));
  Serial.println(digitalRead(4));
}

I'm a newbie too, but are you planning on using an Arduino by any chance?

Yes I plan to use Arduino and using Arduino is easy way for that. But need this circuit because I need to have about 20 circuits like that and this make use of 60 arduino I/O's which I want to use for some other things than light this LED

By being disconnected, I'm assuming that you mean the buttons for the red and yellow LED's are not pressed down?

yes, when button is pressed LED is ON, when not pressed LED is OFF, when both(red, yellow) LED's are OFF orange LED should turn ON

I haven't done any of this myself, but I think you could use a MOSFET and hook up all the orange LED's to the drain pin. Have the Arduino read buttonState (google this). Then if the buttonState is LOW, meaning disconnected, have the Arduino digitalWrite HIGH to the gate of the MOSFET controlling the orange LED. If the buttonState is LOW, have the Arduino digitalWrite LOW to the gate. Just a general idea, although I'm sure there are better ways to do this.

I want to make this circuit without using Arduino. Using only electronic parts but I do not know which and how to connect that circuit.

I have edited my question with more details

I'd just use DPDT buttons instead.

I'm finding this statement self-contradictory: "orange LED will light only when yellow and red are disconnected. When one of buttons is pushed orange LED should turn off." "yellow and red" suggests I'd need to be pressing either both, or none (do the buttons disconnect when pressed? Or do they connect when pressed?), but then you say the orange LED goes off when just one button is pressed. Please clarify what you actually mean.

A truth table of every possible state, along with a clear description of exactly what the buttons should do (turn on or turn off the associated LEDs?) would help a lot.

You want the green LED to be on only when the red and blue LEDs are both off. In other words, you want the voltage on the green LED to be LOW only when the voltages on the red and blue LEDs are both HIGH. That is a logical NAND function.
Your right-hand circuit with the RGB LED won't work because the transistor's collector is connected to the wrong place - it's shorting out the battery! Another problem is that the Arduino can only switch to Ground or +5V, so it can't replace a 'floating' switch.
You need a configuration that produces a logical NAND function. Your left-hand circuit is doing it, but won't work with a common anode RGB LED. So swap the transistor to a PNP  type, and add a couple of resistors to switch it on when either input goes low, like this:-

To clarify my goal for RGB LED ... when buttons are open (not pushed) Green LED should be OFF, when one of buttons are closed (pushed) certain LED (red or blue) should be ON and green should turn OFF

So when both buttons are open the green LED should be OFF, and when either button is closed the green LED should also be OFF. When should the green LED be ON?

my bad english .... sorry Bruce ... correct "when buttons are open (not pushed) Green LED should be ON"

I have bought PNP transistor CTBC 560B (lowest voltage they had in store) and your circuit does not work with it. when I remove this transistor D3 (on your schematics) turns ONO. When I return it to circuit D3 turns OFF. I used R1,R2,R3 220ohm and R4,R5 10k ohm. Is it problem with resistors or with this transistor?

"when I remove this transistor D3 (on your schematics) turns OFF". If the transistor is removed the LED should be ON. If the transistor stays on when the switches are open then either it's connected the wrong way around, or noise is getting to its base through the wiring. You can put a 10k resistor from base to emitter to ensure that it turns off (this should not be problem when the switches are replaced with an Arduino, as R4 and R5 will be pulled high).

this is my breadboard and schematics based on your example: http://i.imgur.com/QYzJe9z.png http://i.imgur.com/7tt6VYs.png - my later goal is to replace switches with limit stop switches and read on arduino INs state of limit stop circuits (blue, red LEDs), green LED is indicator which is supposed to work without arduino connection.

BC560B connections are 1. Collector, 2. Base, 3. Emitter.

"my later goal is to replace switches with limit stop switches and read on arduino INs state of limit stop circuits". Enable pullups on Arduino inputs and it should be fine.

YAY it works :D thank you Bruce very much. you mean connecting after switch to arduino IN instead of GND?

Thanks Bruce again after some trial & error I managed to read state in arduino from this circuit. Your help was priceless.


text:
WiFi UDP.endPacket() continuously fails
I am attempting to send data from my Arduino to my computer using the WiFi shield.  However, my code is erroring out on UDP.endPacket(), and I do not understand why.  Here is my code:
#include <WiFi.h>
#include <WiFiUDP.h>

int status = WL_IDLE_STATUS;
char ssid[] = "NETGEAR31"; //  your network SSID (name)
char pass[] = "oddearth926";    // your network password (use for WPA, or use as key for WEP)

char  ReplyBuffer[] = "acknowledged";       // a string to send back

WiFiUDP Udp;

void setup()
{
  //Initialize serial and wait for port to open:
  Serial.begin(9600);

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD)
  {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }
  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED)
  {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
  }
  Serial.println("Connected to wifi");
  printWifiStatus();
  Serial.println("\nStarting connection to server...");
  if(!Udp.begin(8765))
  {
    Serial.println(F("failed"));
  }

  // if you get a connection, report back via serial:
}

void loop()
{
  IPAddress ip(10,0,0,5);
  int port = 8766;
    // send a reply, to the IP address and port that sent us the packet we received
    if(!Udp.beginPacket(ip, port))
    {
      Serial.println(F("Failed beginning packet"));
    }
    Udp.print(ReplyBuffer);

    if(!Udp.endPacket())
    {
      Serial.println(F("Failed ending packet"));
    }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

And here is the log:
Attempting to connect to SSID: NETGEAR31
Connected to wifi
SSID: NETGEAR31
IP Address: 10.0.0.34
signal strength (RSSI):-63 dBm

Starting connection to server...
Failed ending packet
Failed ending packet
Failed ending packet
Failed ending packet
Failed ending packet
Failed ending packet

It will continue to spit out "Failed ending packet" until I stop it.  Any ideas?

Fixed by updating firmware on Wifi Shield.


text:
Uploading Temperature data (DHT22) to Thingspeak with an ENC28J60
So, I've gotten my module working pretty well. It logs data from the DHT22 and sends it to a 192 address on my LAN. However, I'd like to log and graph the data.
I figured thingspeak is a decent platform for that. However, I have no experience doing so, and I'm not sure where to start. All the examples use the "official" arduino shield. I've only found ONE example bit of code, but it uses the Dallas One Wire temp module. Link
I'm in over my head, and have no idea how to switch from the One wire to the DHT22. Thanks for the help!
I'm using a clone arduino pro mini, 5V 16mhz, 328.
If there's a better platform than thingspeak, I'm open. All I want to do is graph and visualize the DHT22 sensor readings.

Try this:
/*
| Post temp. values from a DS18B20 to ThingSpeak using the Ethercard interface based on the
| ENC28J60 chip.
| Based on the Ethercard example from www.jeelabs.org
| Phil Grant Jan 2014
*/
#include <EtherCard.h>
// change these settings to match your own setup
#define APIKEY  "xxxxxxxxxxxxxxxx"

//DHT Setup
#include "DHT.h"
#define DHTPIN 2     // what pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);

// ethernet interface mac address, must be unique on the LAN
byte mymac[] = { 0xXX,0xXX,0xXX,0xXX,0xXX,0xXX };

char website[] PROGMEM = "api.thingspeak.com";

byte Ethernet::buffer[700];
uint32_t timer;
Stash stash;

void setup () {
  Serial.begin(57600);
    dht.begin(); //Initializate DHT
  Serial.println("\n[webClient]");

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);
  ether.printIp("DNS: ", ether.dnsip);

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");

  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());

  if (millis() > timer) {
    timer = millis() + 60000; //Transmit every minute
    delay(2000);  // Wait a few seconds between measurements.
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity(); // Read temperature as Celsius (the default)
  char h_buffer[10];
  String Hstring = dtostrf(h,0,5,h_buffer); //Convert Humidity value to String

  float t = dht.readTemperature(); // Read temperature as Fahrenheit (isFahrenheit = true)
  //float f = dht.readTemperature(true);
  char t_buffer[10];
  String Tstring = dtostrf(t,0,5,t_buffer); //Convert Temperature value to String

    byte sd = stash.create();
    stash.print("field1=");
    stash.println(Hstring);
    stash.print("&field2=");
    stash.println(Tstring);
    stash.save();

    // generate the header with payload - note that the stash size is used,
    // and that a "stash descriptor" is passed in as argument using "$H"
    Stash::prepare(PSTR("POST /update HTTP/1.1" "\r\n"
                        "Host: $F" "\r\n"
                        "Connection: close" "\r\n"
                        "X-THINGSPEAKAPIKEY: $F" "\r\n"
                        "Content-Type: application/x-www-form-urlencoded" "\r\n"
                        "Content-Length: $D" "\r\n"
                        "\r\n"
                        "$H"),
            website, PSTR(APIKEY), stash.size(), sd);

    // send the packet - this also releases all stash buffers once done
    ether.tcpSend();
  }
}


text:
Problem with while loops while detecting frequency of a signal
I just started to use the unusual part of Arduino language (avr) like interrupts, accessing registers, etc in Arduino IDE. I wrote a program to calculate the frequency of a digital signal using external interrupts.
The following code is to calculate timeperiod of a digital signal, the output of the color sensor (TCS3200) which depends on the color filter choosen via S2 and S3 pins, as in the code. That is, color sensor produces 50% duty cycle square pulses of frequency dependent on the power of the light incident on it. So when sensor faces red color, output signal's frequency in red color mode (by setting S2, S3 pins) is more than the frequency in blue and green modes. Thus we can detect the likeliness of the color which it faces w.r.t  R,G,B.
When this code is uploaded in the Arduino, it failed to print the values as expected in the serial monitor i.e. its stuck in while loops. But when Serial.print(e) statement in the while loops are uncommented, it is able to print the required time periods. I am unable to figure out the problem here, which is making Arduino to be inside the while loop when no statements are in it.
// INT0 interupt is used i.e. digital pin 2
int ti=0,tim=0,e=0,S2=4,S3=5;

void Interruptinit() //initializing interrupt INT0
{
  cli();
  EICRA =  0x02; //Control register
  EIMSK =  0x01; //Mask register
  sei();
}

void setup()
{
  pinMode(2,INPUT);
  digitalWrite(2,HIGH); //enabling pull up register
  pinMode(S2,OUTPUT);
  pinMode(S3,OUTPUT);
  Interruptinit();
  Serial.begin(9600);
}

ISR(INT0_vect)
{
  tim=micros()-ti;
  ti=micros();
  e++;
}

void loop()
{
  digitalWrite(S2,0); digitalWrite(S3,0); //switching over red filtered photodiodes
  e=0;
  while(e<2)
  //Serial.print(e) //waiting till interrupt is addressed 2 times
  ;
  Serial.print("red:");
  Serial.print(tim);

  digitalWrite(S2,0); digitalWrite(S3,1); //switching over blue filtered photodiodes
  e=0;
  while(e<2)
  //Serial.print(e)
  ;
  Serial.print(" blue:");
  Serial.print(tim);

  digitalWrite(S2,1); digitalWrite(S3,1); //switching over green filtered photodiodes
  e=0;
  while(e<2)
  //Serial.print(e)
  ;
  Serial.print(" green:");
  Serial.println(tim);

}

Watch the semicolon right after the //Serial.print, even if it's intentional, I wouldn't use it to keep the loop spinning, an empty brackets are much more readable

Whenever you modify non-local variables in an ISR, it's important that they are declared as volatile. This tells the compiler that the contents may change unexpectedly, ensuring it doesn't use out-of-date cached copies somewhere else. If you don't do this, the code can behave in unpredictable ways, such as outputting the wrong value under some circumstances.
Since the variables are bigger than 1 byte, it's also necessary to disable interrupts around non-ISR code which uses them (e.g. in loop()). This is because interrupts could be triggered at any time, potentially half way through an operation which reads/writes them.
You can use noInterrupts() and interrupts() to disable/enable interrupt handling.

The main problem here is that when while loops are accessing variable "e" here, to check whether e<2.... program's unable to come out of loop (ISR is not changing "e").. but when some code like "Serial.print(e)" is kept in while loop...i.e. it spent some time not accessing "e" to communicate serially, its able to come out of the loop. Actually this must not be a problem as when ISR are addressed the main stack remains as it is n returns where it left.

@Wupadrasta I suspect the ISR is executing correctly, but the while loop is simply operating on a different (cached) copy of e. Declaring it as volatile should solve that.

Thanks a lot... I learned about volatile qualifiers but didn't know where to use them.It worked... Thanq.


text:
Cheap 2-5mb memory to use with arduino
I'm looking for a storage solution for small files that would be moved into a small sensor running arduino-like processor.
Ideally the single memory unit would be cheap (in 1-10 cents range), but the memory can be very limited (several megabytes).
The closest I've got so far is small SD Memory card, but the smallest 4GB ones cost several dollars (at least bought in quantities < 100). Anything else I should be looking at?

1-10 cents for several megabytes? What is your volume going to be, tens of millions?

You can try to find some cheap SPI Flash chips out there. WinBound has one DIP8 of 8MB. The retailer price can be quite high ($2-$3) but I a, sure you can find much better prices in small quantities (http://www.findchips.com/).

You should clarify further what you are looking for, to do what and to use it from what system (voltage, I2C, SPI...)

When going for minimal cost it often works the other way around: see what you can get cheapest, then figure out how you can adapt your system to work with it.  But I'd probably do my proof-of-concept prototypes with SPI flash too (though in SMT packages).

@ChrisStratton That's exactly my question. I'm in a prototyping phase and the cost of memory is a biggest consideration that's why I'm looking aroudn for the options. I'm ready to create solution around it.

@IgnacioVazquez-Abrams Considering you can easilly get a 2GB micro SD card for ~ 2$  making a cost of mb at around 0.1 of a cent. I thought 10cents for 10mb doesn't seem that unreasonable. Feel free to correct me on that.

MicroSD cards are usually made in the tens of millions. But you wouldn't want to interface directly with the flash chip on it though.

So all you need is a micro SD of a few GB, a jeweler's saw, and a very steady hand.  By which I mean the cost is not a linear function of capacity

The reason that cost and capacity are not linear functions is that the cost of the package is a substantial part of the overall cost. You want to find a component that has the amount of memory that you need and that is produced in quantity.

Do the files need to be persistent across reboots – in other words, does it need to be non-volatile memory?

I assume that, if this is a cost sensitive item, you need a reliable supply of multiples (so looking for small SD cards on e-bay isn't a viable solution).
Does it need to be non-volatile storage? If it does't you may be able to find small 8-bit wide RAM chips at a pretty good price. If it needs to be non-volatile, you might look at individual flash chips. I found this one, an 8-bit by 512 KB Serial-SPI flash chip for £0.19 (about $0.28 US) in single units and £0.176 if you can by 100 at a time. I would expect DRAM chips and chips with a simpler interface to be less expensive (but you might end up spending more on interfacing the chips so it might end up as a wash).
If you're able to consider a variety of processor chips it might be worth looking for something that has adequate storage on chip. That might be the most cost effective way to get the space.

On ebay you can buy 2nd hand Nokia SD cards from old mobile phones which are 128MB or so and very cheap.

Even though interfacing with a SD card would ramp up the cost a ton...

How so?  Reliability is a pain, but most SD cards will talk something interoperable with SPI with moderately more software complexity than an SPI flash.

@ChrisStratton SD card readers cost at least $2-3, so it'd be just as easy to use a EEPROM chip. I don't know if the OP wants to be able to have a ton of "disposable" SD cards to use with one device or if he's just trying to minimize the overall cost...

@AnnonomusPenguin - No.  An SD card reader is useless with an Arduino (you talk SPI directly to the card), so the cost of one doesn't factor into to.  Sockets are cheap, and optional anyway, as if you don't intend to move the card to anything else you can just solder directly to it.

Good idea, but won't work in my case.


text:
Can I program Arduino with Python?
I know that I can program Arduino with python but is it possible to make every project, which can be completed by normal IDE?

How do you "know" that you can program an Arduino "with" Python?

possible duplicate of Programming an Arduino using Python, rather than C/C++

Do yourself a favor and learn C/C++. You won't regret it.

"You won't regret it" is a bit optimistic. Especially on those long, cold nights when the memory allocator in your templated class goes tits-up. You'll definitely regret it then. But it will still be the best choice for developing on the Arduino.

@IgnacioVazquez-Abrams we'll agree to disagree.

@PhilVallone: I was being facetious :P

@IgnacioVazquez-Abrams all good. I gave you +1

Python has a bigger memory footprint than c++ in general, and you will have a hard time figuring out the memory layout and allocation using Python

In addition to the existing question.. this question seems very open ended so I'm going to close it to prevent excessive discussion. Feel free to join the chat room for discussions: http://chat.stackexchange.com/rooms/8489/pin-13

I imagine you want to use python because you are already familiar with it, know your way around the syntax, etc. But I would advice against this line of thinking, because microcontrollers need a little more of "low-level" thinking (given the limited resources they generally have) and because of that, it's probably best if you learn some C/C++.
The arduino programming framework provides some not-so-low-level libraries and tools (like the arduino IDE itself) to make it easy for non-C programmers to learn C-like programming.
However, if you want to use python as a proof of concept or anything else, sorry about the misunderstanding! :)

The direct answer is almost certainly not.
There are some auspicious developments so that you might be able to adapt a specific open source Python package, but the resulting software would require a special Arduino board with an MCU chip with much more SRAM and a higher clock speed than we usually see on Arduino boards.
Discussion
I have looked several times and have never found anything.
I did find a "stripped down" implementation of a Python 3.3 interpreter called Micro Python. The software was developed hand in hand with MicroPy, an ARM-based single board computer (also described at the MicroPython website). MicroPy is closer to a Raspberry Pi or Beaglebone than an Arduino. However, the software environment is less complex because the MicroPy doesn't require a Linux-based or other operating system.
The base Micro Python package software package seems to require about 110KB of SRAM to boot up and expects a 1 MB SD chip with a boot record and MicroPython on it.
The Micro Python software was released under the MIT open source license so, in theory, a clever person could adapt it for the Arduino if they built a board with a really powerful chip SD socket.
Although the Micro Python/MicroPy package is very appealing, I don't think I would head down the path. I would rather be programming for hardware that is available from more than one source.
Another potential issue is that the Micro Python implementation uses a mark and sweep garbage collector which might tie up the processor for 4 msec at time. Depending on your application a 4 msec busy period might not be acceptable.

Not really, since python is an interpreted programming language.
If you are not new to the microcontrollers' world and have same experience, maybe this Board is you what you want. More powerful than Arduino and completely programble using Python 3.
Topic: Can I use Python to program Arduino?

The fact that Python is interpreted (or more accurately, byte-compiled for a VM) is not actually relevant. There are several Python VMs for AVR and ARM.

Not exactly. micro controllers, by virtue of not having an os, can only execute compiled code. Hence, using Python is not good as you'll run into a lot of runtime errors and stuff that can be figured out when compiling (exact memory allocation). C++ is better suited.

That's a silly thing to say. Not having an OS means that os and sys are less useful, but an allocator is by no means dependent on an OS. And assuming a working VM implementation, there's little to no reason why a Python program should be any more or less difficult to debug than a C++ application (other than the absence of e.g. debugWire, which can be emulated at a higher level regardless).

@prakharsingh95 Yes, they can only execute compiled code. The compiled code is the interpreter.

@AnnonomusPenguin, an interpreter is the main executing instance which executes Python code. Compiled code allows static scheduling, and memory management, interpreted code will have a harder time optimising. Python programs would need to be internally compiled to byte code , against pythons nature, or the program would need to an interpreter, like you said, which will kill performance. But of course, c++ here makes sense to me, but Python might be feasible.

@prakharsingh95 why would it have to be compiled to byte code? I see no reason, besides program space, to believe that it couldn't at least run a slow, stripped down version of Python from an SD card or EEPROM.

@AnnonomusPenguin, i confess, I don't know how much compromise using python makes, but to me, for tiny processors, nothing beats compile and optimized code. And compiled Python is very hard and probably never done, so people flash interpreters to execute Python, hence the overhead.

@prakharsingh95 speed is a very different thing than possibility. I've seen an AVR chip run Linux somewhere online! BTW it's already been done (kinda): https://micropython.org/

@AnnonomusPenguin yeah, I agree, it's possible, but just doesn't seem efficient to me :P

@prakharsingh95 that link has been already posted by me yesterday. But is not an Arduino board

@prakharsingh95: Python already is compiled to bytecode, so it is hardly "against Python's nature".

@IgnacioVazquez-Abrams Indeed, from this reference, Python is indeed compiled to bytecode, but then is still interpreted. I had meant Python is not compiled to machine code (hex code for Arduino). Like AnnonomusPenguin mentioned, the Python interpreter is loaded on the MCU, not the compiled machine code for the user program.


text:
Using MULTIPLE shields on Arduino Uno R3
I'm very new to using Arduino!  I'll be using Ocean Controls KTA 259 thermocouple multiplexing shield AND a Sparkfun microSD shield on my UNO--to log temperature data for a study I'm doing.  The KTA 259 has a library and the integral SD library should work for the SD shield.
Q1:  I believe they physically connect no problem, but how can I be sure there are no pin conflicts, disastrous or otherwise?  In other words--what conditions MUST I avoid using shields and multiple shields?
Q2:  Can (or must) a single data pin be used by both shields, eg from thermo as output to SD as input, or does Arduino juggle all that?
Q3:  Can (or must) a single function, eg CS, be mapped onto the same pin on BOTH shields, or do they have to be separate allowing Arduino to handle that?
Thank you; I appreciate the help!

You will have to consult a source like this one: http://shieldlist.org
There are no simple rules for which pin conflicts are OK and which ones are not, it all depends on the concrete protocol (i.e. I2C is designed for all bus participants to share lines, while in SPI, each participant needs their own select line, while the other lines are shared).
In your concrete case, both shields you want to use are addressed by SPI, which means D13 (SCK) and D12 (MISO) are shared between the shields by design, while they MUST have different slave select pins. In your case, the SS pin for the microSD shield is fixed as D8, while the one for the KTA shield seems to be selectable, so either D9 or D10 should be OK.
Peripherals generally don't have facilities to become an SPI master, so all data has to be transferred through the Arduino.

I have used these exact two shields myself and can confirm they definitely work together. I can find my datalogger code to confirm if desired.

Q1: If its a well established source of Arduino compatible boards you can be pretty confident (in my experience) that there are no design flaws regarding pin use.  A search on comments by other developers will also help confirm that for you further.
When you go to multiple shields you would need to look at fanout (driving more than one input from an output).  The reverse problem is even more of an issue: driving one input from several outputs.  In other words, an input on the Arduino would be connected to output pins on two shields providing different signals.
Q2: The answer relates to how I ended in Q1.  By avoiding the use of certain pins on a shield the conflicting inputs could be avoided.  The headers would simply pass through the signal.  I don't think there is any rule that a shield has to use or touch every pin.
Q3: I'm not quite sure what you are asking in this question.


text:
Washing machine controlled by Arduino for homebrewing
So, this question might sound a bit silly at first glance (no, I know, it sounds flat out insane), but not all that silly at second.
I have heard once about a guy who transformed some (presumably old-ish) washing machine into his own personal home-brewing apparatus. It is quite some idea if you think about it. Washing machine can easily solve most issues people have with homebrewing. It can carefully control and adjust temperature throughout the long and complicated process of brewing, it can stir, it can pump in fresh water.
Main question is, how to control washing machine to do what I want it to do.  Most automatic washing machines already have some controllers, but I don't see much chance in trying to simply reprogram them (Am I wrong?). Arduino seems like best choice for its simplicity and expandability. However I am still fairly new to Arduino and have trouble imagining how would connecting everything from washing machine (motor, pump, maybe water and temperature sensors) to Arduino actually look like.
So is it even possible? Are there any projects to "bounce of"? (I couldn't find any, but maybe I looked for wrong projects) Should I expect any major problems?

Sounds like you need a bunch of motor-rated relays.  Older machines used a clock motor and cams to close contacts; newer ones might have relays for some functions already.  It's possible you will find a known, reprogrammable micro inside, but you may also find an obscure or custom part.

There is an article by Atmel, talking exactly about this (not for homebrewing, though). They provide a link to a PDF file that describe in detail a project involving Arduino and a re-created washing machine.
Note that it seems to be some kind of Bachelor graduation project, and that the students seem to build an entire washing machine. They control the rotor using an Arduino, and even provide the code (and a brief history about washing machines..).
Apart from building the entire machine, there are two main directions here as I see it:

Manipulate the existing washing machine's control board using Arduino. The bad news are the it would require some reverse engineering of the existing controller, because, per my understanding (and I'm not an expert on the subject) there is no one standard and any manufacturer seems to use it's own propriety control board (similar to Microwaves or Dishwashers). The good news are that an expert could probably do it, either by dumping the controller memory and examining the hex code or by using JTag.
Another way to go here is interfacing the electrical hardware itself; see this instructable where the guy connected the Arduino in parallel to the start button, by thus allowing an alternative way to start.

As for a beginner, it would make more sense to go for the latter; in-parallel connection with an existing hardware button should be a fairly comprehensible task. Consider the hazards of working with a high voltage/power device such as washing machines. I must say that on first glance such a project doesn't seem fit a novice, but I would be the last one to hold an enthusiast's back. And if you know any, I would suggest asking supervision from someone with a strong EE background.


text:
Reading atomic radio clock
i have some data logging to do. And i want some what accurate time meaning accuracy has to be +/- 1 minute.
I have considered a RTC, but then i thought. When i was 10 i got a watch that kept time from this radio clock. And if it is possible 20 years ago to make a clock that updates automatically in such as small form factor, then i should be able to do it with my arduino today.
Does anyone know of a guide/solution with components where i can read this atomic radio clock?

So, the first consideration goes to the radio propagation aspect. Every country does things a little different with their radio clocks. And you might only have good signal a few times a day. For a nice overview, check out a solution for the German DCF77. If you're totally set on using a radio clock, time-nuts has discussed in the past ripping open a $10ish clock to get at the fun parts of a WWVB receiver, so that's one overview of the pool you're diving into.
For myself I've skipped past the terrestrial time keeping and went straight to GPS. Find a receiver that provides a pulse-per-second and attach that to an interrupt and process it alongside the timestamp; you can see how I've gone about that in both code and final product.
I think GPS is both easier and more precise than the alternatives, assuming you're above ground and can pick up satellites. I think of RTCs as something to tell me the day and the year, while GPS can tell me the second. But you could consider ripping the antenna out of a cheap bedside radio-controlled clock and using that to set an RTC, careful to consider whether you want a cheap RTC (DS1307) that drifts a minute per day or a slightly more expensive RTC (DS3231 or ISL1220) that drifts a minute per month. (Rough numbers of course.)

Ok great - You can pick time from gps signals! While not an answer to the question i asked it was a much better solution! This is what i like about stack.
*


text:
How to send Json to a webservice from pc/RPI with live data from Arduino(serial)
I'm making a project where my plan is to take sensor input from the Arduino, and then pass that info (by serial/usb connection) through either a laptop or a Raspberry Pi and convert it to Json and send it to a webservice in asp.net c#, where it gets stored in a database, and then the data can be shown on a website, so the visitor can see live data from the Arduino sensor on the site and also be able to see what the sensor measured yesterday, last month, or the average for a extended period of time, or a graph.
It might be easier to illustrate what I'm talking about:

The PC / RPI part is optional, it can be using either one.
There are a few options, as I see it, as to which methods could work. But I am unsure about how to implement them and what programs to use for it.
First one is to log data to a file on the PC/RPI and then have some shell script either listen for changes and then combine a Json string with the newly added info to the file and send it of to the webservice.
Second one is to somehow take the Serial data from the Arduino and have some shell script or program listen for any data coming from the Arduino and converting it to Json, and sending it of to the webservice. The pro's by this method would be omitting the extra "file-step", but it would make the system more vulnerable to any interruptions in the connection.
Does anyone have experience with doing something like this? Or maybe have an idea how I can do what I'm trying to do ? Or just a nudge in the right direction, as to which approach you think is best, or what programs I could/should use.
Any help is very much appreciated!
Best regards
Daniel

None of this is actually an Arduino problem; it merely has an Arduino as one of the cogs in the system.

No, and I never claimed it to be an Arduino problem, but its still related to Arduino. I'm not asking about the whole setup, just if someone knows how to handle the Serial input from the Arduino.

But that's the thing. You could just as easily say "serial input from the BBB" or "serial input from the DAQ board" and absolutely nothing would change.

Well, I would also need the system to go the other way, and turn on a motor driver shield, would that make it more Arduino related for your preferences?

It has nothing to do with my preferences. You have a very good question here, but I don't believe that it will get the attention it deserves on this site. However, if you move it to another site then the fact that you mention "Arduino" may bias people towards moving it back here even though it's not the important part. I honestly think you should post this on Stack Overflow but first obscure the Arduino with "embedded device", mentioning in passing that the device is an Arduino but that you're not actually asking for help with the Arduino (since serial transfer with it is a solved problem).

That's a very good point. I thought you we're just on a "smear campaign". The reason that I posted here, was that I was sure that there must be some Arduino people, that had tried something like this before. But you're right, it will get much more attention on the general forum. I'll try and go post it there, thanks for your help. :)

You might even explicitly say that the Arduino site concluded it was not an Arduino question.

I'm kind of tackling the same thing at the moment.
I have been using MQTT for a while for things like this. Including on an Netduino, an Arduino, and today a LEGO NXT.
But it is TCP based. I have been wanting to use serial, not TCP (ethernet) for a while, and when the need came for the NXT, it was time to write my own bridge to existing code.
I runs on the same host as the MQTT broker, but listens to a serial port, and mirrors the data to a TCP MQTT broker.
The code is turning out to be much simpler than I expected, I should have done this months ago.
Nxt Side
while (true)
{
    float x, y, z;
    DIMUreadGyroAxes(IMU, x, y, z);

    char json[128];
    sprintf(json, "PUBnxt/Gyro,{\"x\":%f,\"y\":%f,\"z\":%f}\n", x, y, z);
    nxtWriteRawHS(json, strlen(json), 0); // wireless serial over xbee
    wait1Msec(50);
}

PC side
 void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
        SerialPort p = sender as SerialPort;
        while (p.BytesToRead > 0)
        {
            string line;
            try
            {
                line = p.ReadLine();
            }
            catch (IOException)
            {
                throw;  // +++timeout
            }
            // parse it, it should be CMDtopic[,payload]
            if (line.Substring(0, 3).Equals("PUB"))
            {
                int commaIdx = line.IndexOf(',', 3);
                string topic = line.Substring(3, commaIdx - 3);
                string payload = line.Substring(commaIdx + 1);
                Console.WriteLine("{3}: {0}, publish topic({1}) payload({2})", p.PortName, topic, payload, DateTime.Now.ToLongTimeString());
                Mqtt.Publish(topic, System.Text.Encoding.UTF8.GetBytes(payload));

            }
            else if (line.Substring(0, 3).Equals("SUB"))
            {
                string topic = line.Substring(3);
                Console.WriteLine("{0}, subscribe topic({1})", p.PortName, topic);
                throw new NotImplementedException("MQTT Subscribe not implemented yet");
            }
            else
            {
                //Debugger.Break();   // ignore it, framing error
                Console.WriteLine("{0}, Data dropped", p.PortName);
            }
        }
    }

You might also want to look at data.sparkfun.com. A similar, complete concept, already existing.


text:
Fade LED strip using proximity and map() function
I'm using a sonar sensor to detect proximity, and need to control the brightness of an LED strip in direct relationship to the distance detected. For example, as someone moves toward the sonar, the strip needs to dim.
I'm using map() to do it now crudely but it's way too abrupt and I'm not sure how best to achieve the effect I'm looking for. Ideally, as the person moves toward the light, it very smoothly fades out in relationship to the person's movement/pace.
Initial thoughts / questions:
-- Can I use a more refined number type to set the LED brightness other than int?
-- Do I need to do something more complex where I detect the delta in the person's movement and use the loop to fade the LED from one value to another? Seems complicated...
Any help / ideas on this would be much appreciated! Existing code is below if it helps.
Claudia
//variables needed to store values
long pulse, inches, cm;

//LED VARIABLES
int frontPin = 6;    // front strip connected to PWN pin 5
long interval = 8000; // interval at which to do something (milliseconds)
int val;

void setup() {
  //This opens up a serial connection to shoot the results back to the PC console
  pinMode(frontPin, OUTPUT);
  pinMode(pwPin, INPUT);
  Serial.begin(9600);
}

void loop() {
    //Used to read in the pulse that is being sent by the MaxSonar device.
  //Pulse Width representation with a scale factor of 147 uS per Inch.

  pulse = pulseIn(pwPin, HIGH);
  //147uS per inch
  inches = pulse/147;
  //change inches to centimetres
  cm = inches * 2.54;

  if (inches < 36){
    detect();
  }
}

void detect(){
  Serial.print(inches);
  Serial.print("in, ");
  Serial.println();

  val = inches;
  val = map(val, 6, 36, 0, 255);

  analogWrite(frontPin, val);
  Serial.print("mapped value is ");
  Serial.print(val);

  delay(500);

}

The biggest problem is that by forcing the code to use integral inches you've restricted it to 31 discrete values. And since the brightness response of a PWMed LED is non-linear you effectively have very large steps in brightness when the LED is dim.
pulseIn() has much more flexibility with regards to its range so use the raw value directly instead of converting it to "pretty" values.
val = map(pulse, ..., ..., 0, 255);

I agree about the step size, however sub-inch measurement may not be a full solution.  Non-linear mapping may be needed.  Something in the time domain, which ramps the level up or down one step at a time (with delay) to seek a function of the current distance or recent average thereof might or might not also help.

Thanks Ignacio!! I gave it a shot and it needs a little tweaking but gets me closer. However, to Chris' point, it still seems a little abrupt as it shifts. Chris - any tips on approach to what you're talking about? I think that's where I probably need to go...

@claudybee: Implement a lookup table using one of the formulas in the linked question. Don't be afraid to use more than 256 values if it ends up working better.


text:
How to send data to sim900 only once in loop()
I am trying to communicate with a client(PC) from my arduino (set up as a server with a sim900 module connected via UART). I have successfully got it to register its IP address with a dynamic DNS provider (no-ip.com) and set up a TCP server using the AT+CIPSERVER command for the sim900. All this is done in setup(). After that in loop() it waits for a client to connect. The moment a client connects the problem arises. The code is:-
void loop()
{
  while(Serial.available() <= 0);
  int x=0;
  char server_recv_string[30];
  while(Serial.available()>0)
  {
    server_recv_string[x] =  Serial.read();
    delay(10);
  }
  Serial.println(server_recv_string);
  sendATcommand2("AT+CIPSEND",">","ERROR",1000);
  sendATcommand2("I hear you\x1A","SEND OK","ERROR",5000);
  while(Serial.available()>0)  // I dropped this in to clear out the input buffer.
  {                            // Doesn't help
    Serial.read();
    delay(10);
  }
  Serial.flush();
}

The sendATcommand2 is a function as given below. I don't think that has any fault in it because it seems to work fine for all the other commands in setup. However this is the code:-
int8_t sendATcommand2(char* ATcommand, char* expected_answer1,
    char* expected_answer2, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '\0', 100);    // Initialize the string

    delay(100);

    while( Serial.available() > 0) Serial.read();    // Clean the input buffer

    Serial.println(ATcommand);    // Send the AT command

    x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        // if there are data in the UART input buffer, reads it and checks for the answer
        if(Serial.available() != 0 && x < 100){
            response[x] = Serial.read();
            x++;
            // check if the desired answer 1  is in the response of the module
            if (strstr(response, expected_answer1) != NULL)
            {
                answer = 1;
            }
            // check if the desired answer 2 is in the response of the module
            else if (strstr(response, expected_answer2) != NULL)
            {
                answer = 2;
            }
        }
    }
    // Waits for the asnwer with time out
    while((answer == 0) && ((millis() - previous) < timeout));

    return answer;
}

The when I monitor it on the serial terminal I get infinite sends to my client. Its like this:
 AT+CIPSEND
 I hear you

 AT+CIPSEND
 I hear you

 AT+CIPSEND
 I hear you

 AT+CIPSEND
 I hear you

 // And on and on and on.

Any idea why this is happening? If you guys need any more information, please do tell me.
Thanks
Taz

I don't see what your problem is really, canyou explainfurther what you would expect from your code?

You can use a boolean variable to decide if you are going to execute the send command. You can set the variable to true in the setup and to false after the command is executed.
If you introduce the send call inside an if (your boolean variable == true), it will only be executed in one loop iteration.
You can execute it again anytime you like setting the variable to true at any moment.

Thanks! Unfortunately that itself didnt help me. For some reason even when I add a flag, the flag sets over and over again when serial.available() is greater than zero. Couldn't figure out why. So i combined setting the flag and after finishing all my tasks forcefully cleared the input buffer with Serial.end() and Serial.begin(9600). I guess this isn't neat but it works for now. I'll investigate further though.


text:
Reading keyboard input
I'm using Serial.read(); to read keyboard input from the serial monitor.
It only sends the characters after hitting enter or clicking the "send" button.
Is there a way to read keyboard input without having to use "enter"?

Not with the Serial Monitor built into the Arduino IDE. It is possible to use an external terminal program with buffering disabled though.


text:
How can I increase resolution for current sensor?
I purchased a ACS711 Hall effect-based linear current sensor (http://www.pololu.com/product/2197) and when i read the input it's basically always the same. After doing some research I think it's because there is only a 10bit AD converter and since the current is only changing a little bit it's not enough to catch the change. For my situation I'm pulling around 40-90ma idle and when the motor turns on it jumps up so I want this sensor to see that but it only jumps up to about 120ma. Any tips on how to fix this? Maybe a different sensor? Can I use an amplifier to boost the analog signal?

You definitely want a different sensor for this. Your current sensor isn't sensitive enough for the current application.

Are you sensing the right line? Because, a motor using only 30-80mA doesn't sound right?

If you have a transistor, simply amplify the voltage. This allows you set different reference voltages

@Jasmine yeah. I typically have to use 2A adapters for motors. Check that out.

In default configuration, the Arduino's ADC has a range of 0v-Vcc (5v or 3.3v depending on the model). If you are sure your input voltages will always be way lower than Vcc, spreading the ADC's resolution over that range is a waste of accuracy. What you need to do is to properly configure your analog reference voltage.
Basically, this is a way of telling your Arduino "instead of spreading your ADC's bits over a range of 0v to Vcc, just cram all that accuracy between 0v and [refVoltage]."
So:

Measure the highest analog output your sensor will give.
Setup a voltage divider to output a little more than that
Connect the voltage divider's output to the AREF pin
in setup(), declare analogReference(EXTERNAL);

And that's basically it. As noted, in this specific case you'd probably be better off buying another sensor altogether. However, you won't always have that luxury, and knowing how to set the analog voltage reference always comes in handy.

The problem with this is that the sensor produces voltage offsets from Vcc/2, so your ADC has to support voltages of 0 to about Vcc/2 - ie: you can get only about a resolution gain of 2.  To do better you need differential inputs rather than single ended (eg: having the ADC 0-1024 counts span 2.2v - 2.7v if Vcc=5V).  That could be done with op amps, or using a different Arduino.  I guess I'll write up the latter, since it takes a bit more explaining.

First, let's look at where you are now.  The sensor you have reports current changes at 110mV per amp.
That means 40mA => 4.4mv, 90mA => 9.9mv, and 120mA => 13.2mv -- all very small voltages and small changes in voltage.
Let's work backward, tho.  A 5V Arduino in typical ADC mode has a resolution of about 5 mV (5 V / 1024 counts), whilea 3.3V Arduino would have a resolution of about 3.3 mv).  Divide those step sizes by 0.11V/A sensitivity and you'll see that a different of 1 count on the ADC will represent about 45ma (5V Vcc) or 30 ma (3.3V Vcc).  But there is always inaccuracy and noise, so it's going to be hard to reliably distinguish between 90mA and 120 mA (using your figures).
You can improve that somewhat by switching to a sensor with higher sensitivity (and lower maximum range) like https://www.pololu.com/product/1185 which improves the sensitivity to 185 mV per amp.  The step size of the ADC converters would translate to about 26 mA (@5V) or 17.5 mA (@3.3V).  That's still pretty tight.
You might be able to manage with the more sensitive sensor and a 3.3V Arduino - if you use capacitors to filter out the electrical noise on the sensor to ADC input, and you average multiple readings in your code to further smooth the values.  But it would be marginal.
So you need to amplify the sensor.  Yes, you could do that with an external amplifier, like an op Amp.  A transistor is more difficult because you need it to stay fairly linear which gets trickier, and you may need more than one stage - so an op amp is easier.
There's another tricky factor - you need to compare the voltage from the sensor to some reference - Vcc/2 for your sensor, and 2.5V for the more sensitive one.  The current is proportional to the difference between the sensor reading and that reference (the current going one way for sensor output above reference, the other way for sensor output below reference).
I'll mention another option - you could use an Arduino Mega or Leonardo.  These chips offer the option of differential inputs (one pin goes to the signal, and one to the reference), and they have built in selectable amplifiers with up to 200x amplification.  That should give you plenty of resolution, without needing to use external active analog circuitry.
You will still need to filter the sensor output to smooth spikes from the motor (current spikes translated to voltage spikes by the sensor).  You may need to also filter the Arduino Aref input with a cap.
Suppose you were to use an Arduino Mega or Leonard with the sensor you have.  You'd want a Vcc/2 reference, which could simply be two identical resistors (say 10K ohm) between Vcc and Ground as a voltage divider (and maybe a cap to ground for filtering).  You would still probably need to calibrate by finding the ADC value for no current as your reference and subtract that from the reading you get when current is flowing.


text:
How to protect sensors used on atheletes?
I'm working on a project were we are trying to attach accelerometers to soccer players and capture various aspects of movement data.  Breadboarded circuits are coming along nicely and I'm now looking for how to best protect sensors we can mount on players.  (All wire at the moment unfortunately - BT next.)
Although I can find ways to protect the sensor for sensor damaging impact (we are essentially interested in player impacts with the ball or ground) there are other aspects of protection I'm not sure about.  Any recommendations on how to protect from moisture without increasing bulk too much, minimizing cushioning which could affect the data and of course avoid adding anything that could injure the player?  I have come across other examples of movement studies, but they have been by musicians or other situations that do not include outdoor weather and sweaty bodies.

Just make it, so it's easy to repair. Thing will break, no matter what, at those conditions. Just make sure the players aren't electrocuted :-)

The only way this is ever done is with some kind of product casing. You can buy pre-fab cases for electronic projects, but to get something really slick and appropriate for your purpose, you're gonna have to make something yourself. You might look into 3D printing.
Something like this might work: https://www.sparkfun.com/products/8601
For protection from salt-water, this product is worth a look: http://www.corrosionx.com/
There's some different products there, but I've seen a demo of that product, where we ran an entire RC airplane system, servos, motors, and receiver, UNDER WATER.

That looks like the kind of case I was thinking of for the data logger module.  The accelerometers should be smaller and I was thinking of trying a soft setting sealer to coast the sensor.  I think they are low power enough to not have problems with heat dissipation issues.  The 3D printing is an interesting idea - only been reading about that and seeing demos at shows.  Might be the time to try it out.

Or, just don't. The effect of sweat on electronics is often overestimated. Many electronics work underwater just fine. Covering it with shrink-tube or plain old packing tape might be enough. I've done that with sensitive components on RC float planes. You could also try "Corrosion-X" spray.

Good comment.  I have worked with sensors in the field for geophysics and we have had some weather problems from time to time.  I like your experience with simple solutions.  Watch the Red Green Show much? ;-)

No, but you're not the first person to ask that. I have a Youtube channel (jasmine2501) where I try to keep it simple. It's mostly about firearms and RC stuff, but there's a few Arduino vids up there too. I've been an engineer for a long time and seen a lot of waste when searching for "ideal" solutions when it wasn't needed. Good engineers recognize perfection, but great engineers recognize "good enough"


text:
Arduino RBBB - Device not accepting address
I recently purchases and make a Arduino RBBB with a BUB II from Modern Device. I ordered the package found HERE. I built everything according to the instructions, but when I connect it to my laptop (running Ubuntu 14.10), I get the following in dmesg
[63415.213391] usb 3-1: new full-speed USB device number 63 using xhci_hcd
[63415.381403] usb 3-1: device descriptor read/64, error -71
[63415.485225] xhci_hcd 0000:00:14.0: Setup ERROR: setup context command for slot 26.
[63415.485240] usb 3-1: hub failed to enable device, error -22
[63415.597236] usb 3-1: new full-speed USB device number 64 using xhci_hcd
[63415.709154] usb 3-1: device descriptor read/64, error -71
[63415.813102] xhci_hcd 0000:00:14.0: Setup ERROR: setup context command for slot 27.
[63415.813116] usb 3-1: hub failed to enable device, error -22
[63415.925108] usb 3-1: new full-speed USB device number 65 using xhci_hcd
[63415.925270] usb 3-1: Device not responding to setup address.
[63416.129120] usb 3-1: Device not responding to setup address.
[63416.332902] usb 3-1: device not accepting address 65, error -71
[63416.444973] usb 3-1: new full-speed USB device number 66 using xhci_hcd
[63416.445174] usb 3-1: Device not responding to setup address.
[63416.649008] usb 3-1: Device not responding to setup address.
[63416.852734] usb 3-1: device not accepting address 66, error -71
[63416.852813] usb usb3-port1: unable to enumerate USB device

It is repeatable every time I insert. lsusb does not register it. I have read that I should switch out the cable, but it is brand new (and I don't have another to test with. I was wondering if there is something evidently wrong with my circuitry. I posted pictures

Have you tried another port? Another computer? Another serial adapter?

I tried another computer and switching USB ports on my laptop, same error. I don't have another BUB II, but tomorrow, I am going to go to a lab on campus to use the oscilloscope to check the BUB II I/O. I will also try another cable.

I fixed it. Here is how I did it.
First, I tried connecting just the BUB II to via the USB. Same error, thus I ruled out the Arduino RBBB as the source. I then decided that perhaps it was the voltage jumpers (black things on the pins sticking out in the first picture). After removing them, it works under dmesg, yielding the below.
[  214.044563] ftdi_sio 3-1:1.0: FTDI USB Serial Device converter detected
[  214.044687] usb 3-1: Detected FT232RL
[  214.044696] usb 3-1: Number of endpoints 2
[  214.044704] usb 3-1: Endpoint 1 MaxPacketSize 64
[  214.044712] usb 3-1: Endpoint 2 MaxPacketSize 64
[  214.044718] usb 3-1: Setting MaxPacketSize 64
[  214.045209] usb 3-1: FTDI USB Serial Device converter now attached to ttyUSB0

Thus I wanted to put them back on so I wouldn't lose them. I proceeded to try various combinations till it worked. Ultimately, I ended with 5V for VOUT and VL for LGLV. If that is a bad idea, someone please comment, but it works.
May this help someone else.

Since you fixed it, I upvoted it. It would be good to accept your own answer too, so this becomes the "accepted" answer to your issue.


text:
Error: Function not declared in the scope
I want to make a timer library. The cpp file I have written is:
#include "avr/interrupt.h"
#include "Arduino.h"

#include "AllTimer.h"

AllTimer::AllTimer()
{}

void AllTimer::dofun(void)
{
    TIFR1 |= _BV(OCF1A);
    TCCR1B = 0X00;
    digitalWrite(13,!digitalRead(13));
}

void AllTimer::setTimer(void)
{
    TCNT1 = 0x0BDC;
    TCCR1A = 0x00;
    TCCR1B = 0x00;
    TCCR1B |= (1<<CS12) && (1<<CS10);
    TIMSK1 |= (1<<TOIE1);
    sei();
}

ISR (TIMER1_OVF_vect)
{
    dofun();
}

And the header file:
#ifndef AllTimer_h
#define AllTimer_h

class AllTimer{
public:
    AllTimer();
    void setTimer(void);

private:
    void dofun(void);
};

#endif

While compiling the file i am getting the following error:
sketch_jan05a.cpp: In function ‘void __vector_13()’:
sketch_jan05a.cpp:34:9: error: ‘dofun’ was not declared in this scope

You know its time to go home when you make this mistake. readTouchscreenParamsGeneric in header vs readTouchScreenParamsGeneric in cpp. Generates the same error message. Doing a search all, case-insensitive, led me to believe I had made no typos.... when in doubt, also turn on case-sensitive search.

Answering here because I do not have enough rep to comment.
At each iteration, the value in the timer counter must be reloaded.
Either the ISR or dofun are responsible to reload TCNT1.

Because in the call:
 dofun();

you should put from which class you are calling that function.
In your case:
AllTimer::dofun();

in that case your function must be declared as static method.
EDIT:
Thanks to the comment:
I'm not pretty sure if your code reflects what you want to do. Because you can create your timer after defining the class:
Alltimer mytimer;

and call the method as a normal function (it must be declared as public):
ISR (TIMER1_OVF_vect)
{
    mytimer.dofun();
}

But it is hard to say since I m not sure what you want to do.

That will work only if dofun() is modified to be a static method. It must also be made public:.

dofun() is currently declared as a private member function, meaning you can't call it directly. It can only be called internally by an instance of the AllTimer class.
It looks like you probably want to declare it as a public static function instead. To do that, remove the private specifier from the class declaration, and put static before the function declaration. Your header should look something like this:
class AllTimer
{
public:
    AllTimer();
    void setTimer(void);
    static void dofun(void);
};

You will then need to change the ISR to include the class name in the call:
ISR (TIMER1_OVF_vect)
{
    AllTimer::dofun();
}

How do i define dofun in cpp file?

@user3929110 The existing definition should be fine.

The code compiled well but the timer isn't working. The LED is remaining ON only.


text:
what is fastest allowable serial baudrate?
what is the fastest serial read the Mega can do?
begin.Serial1(1024000) is accepted for compiling, but reading jibberish
any suggestions on a faster device?

The divisors should give you 1 Mbps even.  However, on that board it is not just the Mega2560 which needs to do this - the 8u2/16u2 USB-serial and its firmware has to manage it as well.  Fortunately, you have similar Atmel parts on both ends of that very short link, so customization should be possible (you could ignore the host request and simply set both dividers to 0).  But your software has to keep up, too.  You may want to look at a different architecture where the application processor itself speaks USB, leonardo-style.

Why do you need "the fastest serial baudrate"? This is to communicate with what device exactly?

Sorry, my mistake - looks like you are using a different UART than the one proxied to USB.

device is a FANUC CNC Serial encoder...1024000 baudrate is fixed, but only need to output request strobe, then capture 77 bits serial input into buffer, then ignore while running rest of program to decipher what was read, when done arduino generates clock pulse to send another 77 bit word... I have it triggered via the request strobe falling edge interrupt to read input, but havent figured out how to save this into a buffer (i'm kinda new to this stuff) or if its even possible...

The Arduino Mega 2560 runs at 16 MHz. There are online calculators making this easy, as the calculation is not a straight and simple formula.
http://wormfood.net/avrbaudcalc.php
which shows using 16 MHz

Baud Rate
UBRR(dec)
UBRR(hex)
% of error

300
3332
0x0D04
0.0

600
1666
0x0682
0.0

1200
832
0x0340
0.0

2400
416
0x01A0
0.0

4800
207
0x00CF
0.2

9600
103
0x0067
0.2

14400
68
0x0044
0.6

19200
51
0x0033
0.2

28800
34
0x0022
0.8

38400
25
0x0019
0.2

57600
16
0x0010
2.1 - Barely OK

76800
12
0x000C
0.2 - GOOD

115200
8
0x0008
3.7 - BAD

230400
3
0x0003
7.8 - BAD

250000
3
0x0003
0.0

Where it is noticeable that the Mega's Arduino boot loader uses
mega.menu.cpu.atmega2560.upload.speed=115200

which is above the acceptable 1% error rate.
While it is possible to support different baud rates than stated above, it is not advisable, as the above values are the standard values. Values in between are very atypical and likely not trustworthy on the corresponding other side of the connection.
As I see your above example is 1024000, it is also worth noting that HardwareSerial.cpp implements a method to convert the requested baud rate to configuration of the USART, and I would not necessarily trust it for non-standard baud rates, especially on older version of the Arduino IDE. You may want to try the latest 1.5.8+ and verify the rate.

This is interesting. Why does the default Arduino bootloader use a baudrate with such a high error rate?

It depends mainly on CPU frequency, see USART/Baud rate settings in datasheet. For example at 16MHz it might go up to 2Mbps. But you need also consider error in baudrate which is important if communication with "3rd party" device.

If you have both MCU under control you can also consider USART in SPI mode with sync clock.

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


text:
communicating with arduino over serial via terminal
I'm attempting to write data over a serial line to the arduino, however I don't want to use the arduino IDE but rather use the command line.
In order to do this I have the following commands:
$stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
$echo s123 > /dev/ttyACM0

The code on the receiving end checks whatever or not the input is s123 and if it is starts blinking. I have tested this using the arduino IDE and it worked, however this did not work.
The sketch looks like this:
    void loop(){
     if(Serial.available()==4){
       byte b1,b2,b3,b4;
      b1=Serial.read();
      b2=Serial.read();
      b3=Serial.read();
      b4=Serial.read();
        if(b1=='s'){
               digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
               delay(1000);               // wait for a second
               digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
               delay(1000);               // wait for a second
               digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
               Serial.println("the cow has landed");
          }
     }

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

the output of
stty -F /dev/ttyACM0 -a

was :
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 0; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts
ignbrk -brkint -ignpar -parmrk inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl noflsh -xcase -tostop -echoprt -echoctl -echoke

Thank you

can you post the sketch?

I have added the sketch

Could you post the output of stty -F /dev/ttyACM0 -a after your own stty command? That could help see some potential config issues.

I have added the output

Your code doesn't seem to have any way of getting back in sync if that is ever lost.  And it may be that you inadvertently reset the arduino when you configure/open the serial port.  If you start talking too soon thereafter, (as echo would) the first character(s) might be lost while in reset, leaving your sketch and host program out of sync.  Try putting a "Hello World" in your setup()

If you made a sketch to endlessly print something, could you see it when you read from /dev/ttyACM0?

if(Serial.available()==4) is bad code. Unless there are exactly 4 characters it will do nothing. At the least it should be >=4 but you really need to work out what you want it to do. Even if it worked it would print 1 line then do nothing.

This was fixed this morning after a reboot and upgrade command, still don't know which one of these fixed it but it seems to work now.
Ah figured it out we were using the 0 and 1 rx gates to communicate over serial rather then usb and as the used power supply turned out to be only 5V rather then 9-12V it didn't quite work as intended.

This is not a solution, as your program remains faulty.  At best you are momentarily lucking out - which is actually bad luck, because when a system is faulty, it's more helpful when it will cooperate by failing while you are paying attention to fixing it, and not some other time.


text:
collecting & visualizing sensor data - best approach?
I'm working on a kite-related project where I'm using Arduino + accelerometer to track data while a kite is in the air. I am struggling a little with the best approach - help on the following questions / issues would be a huge help:
-- how best to grab data only while the kite is in the air? just detect with numbers, use a switch? other ideas?
-- how best to collect the data and transfer to computer for visualization (likely with processing but looking at other options). i'm using this project in workshops with kids in low-income neighborhoods in brazil, so will have limited resources. a laptop will be available -but use of mobile also ideal.
Thank you!
Claudia

Since it's battery powered, you probably want to have a power switch anyways. Also, wouldn't it be interesting the detect the preparations and launch from the data visualization? Like; here it is lying on the ground; here is the person walking with it; here is where it's thrown up; etc.

YES! that's a nice idea - to visualize the full experience. thanks for the input!

Several possibilities; Both at little cost, but since you have an accelerometer, I know your budget is not 0.
1) use a shield with an SD card on the arduino to log the information to a file on the SD card.  Open it later from a laptop or PC.  Hopefully it will have enough room to store data that you can ignore later for pre-flight, post-flight time.  If not, simply add some fixed delay to the start of your program (loop 5 times; wait 1 minute;)
2) some form of remote, like an XBee, or even a wireless WiFi Shield. The setup can be complicated but that would be ideal for real time visualization on a laptop at the flying site.
3) probably the easiest/least expensive - a cheap bluetooth transmitter.

eBay
This method would allow a bluetooth mobile to collect and visualize the data. This device connects to the serial lines on an arduino, (pin 0&1) and standard Serial.Write() function can be used.  Any terminal program for your mobile will be able to receive the data. You could also get fancy and write your own if you want to visualize it. You may be able to find something already existing, like this

In cases 2 & 3 you will need a way to xmit the data. I use MQTT. A protocol just for this, but it is TCP only. I also use it with JSON (eg Json for Arduino to manage the data.  You will need to find the same. Look at MQTT-SN as a possibility, or you can just write your own serialization protocol based around JSON without too much difficulty.

THANK YOU!! this is so much useful info - I'm going to look into all options but it seems like 1 or 3 would be the most light-weight which is a big consideration considering it's being attached to a small paper kite.


text:
Are there any KL03 "arduinos"?
I have been trying to find any Arduino or similar prototyping board that uses this MCU

http://www.pcmag.com/article2/0,2817,2453987,00.asp
But the smallest and more robust ones I have been able to find are Microduino and Espruino pico, none of which use this.
Are there any prototyping boards that use these?

I highly recommend searching the manufacturer's website: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KL03Z&fsrch=1&sr=1&pageNum=1

This development board uses a chip from the KL03 family:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KL03Z
However, as you can see, it uses the arduino uno form factor (like all their other freedom boards), so it's probably not what you were expecting with respect of size.
If you are looking for a dev board that you can prototype with (easy access to pins and all that) I doubt you can get anything significantly smaller than a teensy (https://www.pjrc.com/teensy/), which also uses a more powerful ARM M4 core. There has been quite a few kickstarters with tiny arduino-compatible boards, but I am not quite sure how many you can actually buy at the moment.


text:
Wiring Issues with Sparkfun Oled
I'm attempting to hook up an arduino uno with a Sparkfun Oled. I downloaded the example program and made these changes:
#define PIN_RESET 3  // Connect RST to pin 3
#define PIN_DC    4  // Connect DC to pin 4
#define PIN_CS    10 // Connect CS to pin 10
#define DC_JUMPER 0

I connected everything according to Sparfun's walkthrough. I also wired accordingly. However, I cannot seem to get the Oled to do, well, much of anything. I have tried switching the MOSI and MISO to see if that makes a difference, but it doesn't seem to have any effect.
I'm using:
pin 13 - clock (in the picture I was trying pin 8 for the clock but I have tried both)
pin 12 - MISO
pin 11 - MOSI
pin 10 - CS
pin 4 - DC
pin 3 - RESET
Can anyone tell me what's going wrong? I've tried to figure it out for a good long while now and I can't make the display do anything productive.
Thanks

Have you inspected the pins you soldered on for cold joints?

It looks almost like the wires are simply pushed through the holes of the OLED breakout board (i.e. not soldered at all). If that's the case then there's a good chance they aren't forming a reliable connection.

If I only want to test the oled without committing it to an actual application, is there any way I could do that without soldering?

(Old thread, but still.) This picture doesn't provide any useful information. Either draw a schematic or use something like Fritzing to create something legible!

Have you connected the GND pin from the UNO to the breadboard?  I can't hardly tell.  But it looks like you are also using 5V to power it?
How are you powering the UNO?  Is it just 3.3V?  I'm powering mine with a 5V but have level converters connected.
Mine:


text:
How to use 503 Thermistors for temperature?
I have a black Thermistor with the number 503 on it.
I know that I would need a 50k resistor as a voltage divider.
I don't get to convert the number I am getting. I get the number 340 when my house is at 64*F.
I bought a kit on Amazon and it came with it and there is no documentation.A test with multimeter has shown at 17*C I get 30k ohms.
This is how it is wired:
[Ground] -- [50k-resistor] -- | -- [(503)thermistor] --[Vcc (5v)]
                              |
                         Analog Pin 0

That's what happens when you get a random component from somewhere. Find one with a datasheet.

Can you please also post the code of your sketch?

I don't what to do with the value the code is just analogRead from pin 0

A very similar question was posted in the Arduino forums a few years ago: http://forum.arduino.cc/index.php?topic=4757.0

it was never answered

Have you measured the resistance of the thermistor, using a multimeter?

Ok I will measure and let you know the value

i get 30k ohms at 17*C

If you repeat that at another temperature, you can tell whether the device has a positive or negative  temperature coefficient (NTC decreases resistance with increasing temperature). That will help you identify the device and match it to a data sheet.

The rated resistance is the resistance at 25degC.

I found some code for a 10k thermistor and modified it for a 50k and cut out the code to display Celcius.  I found this on the Arduino playground posted by: Milan Malesevic and Zoran Stupic.
Origional code is found here: http://playground.arduino.cc/ComponentLib/Thermistor2
This is what I came up with and it returned the proper temp in F for a 503 Thermistor.
#include <math.h>
// enumerating 3 major temperature scales
enum {
  T_KELVIN=0,
  T_CELSIUS,
  T_FAHRENHEIT
};

#define EPISCO_K164_10k 4300.0f,298.15f,50000.0f  // B,T0,R0

float Temperature(int AnalogInputNumber,int OutputUnit,float B,float T0,float R0,float R_Balance)
{
  float R,T;

//  R=1024.0f*R_Balance/float(analogRead(AnalogInputNumber)))-R_Balance;
  R=R_Balance*(1024.0f/float(analogRead(AnalogInputNumber))-1);

  T=1.0f/(1.0f/T0+(1.0f/B)*log(R/R0));

  switch(OutputUnit) {
    case T_CELSIUS :
      T-=273.15f;
    break;
    case T_FAHRENHEIT :
      T=9.0f*(T-273.15f)/5.0f+32.0f;
    break;
    default:
    break;
  };

  return T;
}

//example of use #2
// using numbers instead of episco k164 definition
// this time reading from analog input 2
// getting result in fahrenheit

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

void loop() {

 Serial.println("********");
 Serial.println("Temp");
 Serial.println(Temperature(2,T_FAHRENHEIT,4300.0f,298.15f,50000.0f,10000.0f));
 Serial.println("********");
 Serial.println(" ");

 delay(500);
}

Good luck!!!!

I should mention that to get an accurate reading you will need to measure the 10k resistor and use its actual value in the line below. Mine measured 9.95k so below I replaced the 10000 with 9950.
Serial.println(Temperature(2,T_FAHRENHEIT,4300.0f,298.15f,50000.0f,9950.0f));

First of, 503 means 50 x 10^3, ie 50K Ohm: that is the maximum resistance of this thermistor (the higher resistance occurs for lower temperatures). However, having just that without any precise reference may prove difficult to find a relevant datasheet that could help you calculate the temperature from the measured voltage.
I think what could work well is just simple calibration by establishing a mapping between
the value returned by analogRead() and the temperature measured by a real, good precision, thermometer.
Establighing the mapping for 2 extreme temperatures would provide a first approximation on computing any temperature from the read value.
However, such an approximation would not be very accurate because thermistors are not linear, ie their resitance don't vary linearly with temperature.
What you can try to do then, is to increase the number of mapped value<->temperature with regular intervals of temperatures; then you can use linear approximation between two consecutive mapped values, which would provide better results.
The difficulty here is to "produce" the temperatures for which you want to find the mapped value: if you can spend one year for that, then just let the chqanging seasons operate that for you :-) otherwise use what you can find at home: fridge, oven, fan, heater...

Here is a link to Jameco, one supplier of a 503 thermistor - it is a negative-coefficient thermistor. They have a link to a data-sheet for it. I can't say for sure that this is your device, but a simple experiment with your ohm-meter should confirm it.

If the anonymous downvoter would care to comment on what s/he thinks is inadequate about this answer, I'd like to know. Maybe someone - me included - would benefit from it.

I have downvoted your answer for a reason that seemed obvious to me: you are just posting a link to a datasheet, which you can even not for sure say that it is relevant for the OP. That does not answer the original question!

I just think that a commentto the question would have been enough. Orherwise, a further development on how to use the datasheet in the OP context would be needed.


text:
Bluetooth module discovered by computer and not smartphones
I've been playing with Groove Bluetooth Module (HM-11) and for some reason my computer can see it, but none of my cell phones can.
I've tried two Huawei P7 (BL 4.0 + BLE) as well as some Samsung Galaxy & some older sony with Bluetooth 2.0. None of the cell phones can see the device. Any ideas?

If I'm not wrong cellphones need an app to search for BLE devices instead of the regular bluetooth manager of your phone

Are you configuring the module as a slave? A phone will typically act as a master, so it will only see slave devices.

I did configure it as master. I'll try with slave.

Handoko you are right - in order to discover BLE device you need an application. Usual android search is different from BLE search.

One other thing to note, some phones, the iPhone at least, will not show Bluetooth devices that do not advertise profiles supported by the phone. For instance, the HC-05 only provides the SPP profile which the iPhone does not support, so an HC-05 will not show up when scanning for BT devices.


text:
Problem with hc-05 bluettoth module
I wrote a simple program for controlling an LED using mobile. So, I bought the HC-05 bluetooth module configured it and then connected it to  the arduino.
This is the code that I wrote for it.
int ledPin1=13;
int state;
int flag=0;

void setup()
{
    pinMode(ledPin1, OUTPUT);
    digitalWrite(0,HIGH);

    second:
    Serial.begin(9600);
}

void loop()
{
    if(Serial.available() >0)
    {
        state = Serial.read();
        flag=0;
    }
    if (state == '0')
    {
        digitalWrite(ledPin1, LOW);
        if(flag == 0){
            Serial.println("led off");
            flag=1;
        }
    }
    if (state == '1')
    {
        digitalWrite(ledPin1, HIGH);
        if(flag == 0){
            Serial.println("led on");
            flag=1;
        }
    }
}

Everything is working cool with the serial monitor. But, I'm not able to control it using my mobile. I gave an input 1 in serial monitor and if showed "led on". the same thing appears on the commanding interface of the app used in the mobile. So, the bluetooth is transmitting information from the arduino to mobile but I'm not able to send commands from the mobile and control the led. I tried using various apps like  Blueterm, Ardudroid etc but, the situation remains the same.
What am I doing wrong? Is there something wrong with the code?
I'm using Arduino Uno.

Your android app might be sending extra characters like "end of line", which will cause the return value of Serial.read() to be other than 1 or 0 after the first byte. Nevertheless, it looks like it should still turn on or off the LED as soon as it reads the first byte, and do nothing when it reads the following bytes. I have used the "hyperterminal rs232" app successfully to send single characters, maybe give that I try to see if it helps and ensure it is configured at the correct baud rate.
I would recommend to send back to the serial stream the characters read, to ensure they have been received correctly, so I would change this:
if(Serial.available() >0)
{
    state = Serial.read();
    flag=0;
}

to:
if(Serial.available() >0)
{
    state = Serial.read();
    Serial.print(state);
    flag=0;
}

Edit:
Just realised this in setup():
digitalWrite(0,HIGH);

You are setting the receive pin of the UART peripheral to hight, so that is probably why you are not reading data from your phone.

Why don't you try making another code.
If you want to use library, use #include <SoftwareSerial.h>
Do not use digitalWrite(0, HIGH) in void setup(){...}
Declare ledPin = 13;
Use only pinMode and Serial.begin(9600) in void setup()
In loop() do ask if (Serial.available()){...}


text:
When I open a COM port some pins on Arduino Uno goes low for about 2 seconds
I have no idea why this is happening, but after I open COM port to talk with my Arduino (I click "Open" in RealTerm), the state of some pins goes from high to low for about 2 seconds and then goes back to high. Here's my code:
void setup()
{
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH);
  Serial.begin(9600);
}

void loop()
{
}

In this case pin 5 will behave this way. I've checked it also for pin 6 and pin 8 and they behave in the same manner. I suppose more pins act like that. Why is this happening?

That's because opening the connection to the UNO will automatically trigger a reset of the ATmega chip, hence your sketch will be executed from scratch, ie setup() will be called again then loop().

@jfpoilpret you should put that as an answer!

What you see is expected: that's because opening the USB connection to the UNO will automatically trigger a reset of the ATmega chip of the board, hence your sketch will be executed from scratch, ie setup() will be called again then your loop() repeatedly.
Hence what you observe in detail:

open USB connection from PC
open USB connection on Arduino UNO
UNO USB chip (an ATmega16u2) triggers a RESET of the MCU (an ATmega328P-PU)
On reset, the MCU sets all pins to INPUT, i.e. high impedence, hence no voltage can be measured on any pin
Then the bootloader starts, performs some intialization and starts your sketch
Your sketch executes first setup(), so your pin is put in OUTPUT mode and set to HIGH: its voltage is thus measurable (5V)
your sketch loop() gets executed "forever" i.e.until a new reset or power supply disconnection

Indeed.  Worth noting though is that this reset-on-open is ultimately due to a configurable behavior of how the PC operating system's serial API manages the control lines - though this is usual default.  Additionally, it can be disabled at the arduino end by overpowering the reset capacitor with a stronger pullup.

What is the logic behind resetting upon connection? What exactly happens when I click "Open"?

That is because the bootloader must be started in order to check if connection was open in order to upload a new sketch. This is because USB can be used for both situations: upload a sketch, or just communicate with the running sketch.

The arduino is reseting because of the serial port initializing. If you want to avoid it, you can put a 120 ohm resistor between 5v and reset.
Source