text:
Problem with a function having a parameter with a default value
I've got a problem using a default value for a function parameter.
This code gives "'blink' was not declared in this scope":
void loop(void) {
  blink(12, 2, 1000);
}

void blink(const uint8_t led, int num, const uint16_t l = 12) {
  Serial.println(led);
  Serial.println(num);
  Serial.println(l);
}

but it works if I don't assign a default value to the "l" arg:
void blink(const uint8_t led, int num, const uint16_t l) {

or if I put the blink function before the loop:
void blink(const uint8_t led, int num, const uint16_t l = 12) {
  Serial.println(led);
  Serial.println(num);
  Serial.println(l);
}

void loop(void) {
  blink(12, 2, 1000);
}

only a function declaration can have a default parameter value. not the definition. so you have to add a forward declaration if you want to set default parameter values.

Confusing the code mangler that sits between your IDE code and the GCC code it generates is a sure way to get oddball errors.

It's just a failing of the Arduino build process to generate prototypes (function declarations) for functions that have default argument values.  There's otherwise nothing wrong with what you're doing.  Not in my opinion anyway.  The build process sometimes chokes on function or class templates as well.  The answer to these sorts of problems is probably that these features are not considered part of the Arduino "language".
Just a reminder: In C++ a function declaration needs to have been seen in order to generate a call to it.  A definition will serve as a declaration.  In either case, one must have been seen before the call site.  Generating declarations where needed is, perhaps, the greater part of what the Arduino build process does that can be said to make the Arduino "language" different from plain C++.
The following were generated by working out of /tmp/default-param with the "input" being default-param.ino, running:
arduino-cli -b arduino:avr:uno build --build-path /tmp/build

and inspecting /tmp/build/sketch/default-param.ino.cpp which I'm calling "output".  You can use the same process if you want to see exactly what the build process is doing to your code.
Non-default argument
This input:
void setup() {
    func(11);
}
void loop() {}
void func(int xyzzy) {}

generates:
#include <Arduino.h>
#line 1 "/tmp/default-param/default-param.ino"
#line 1 "/tmp/default-param/default-param.ino"
void setup();
#line 4 "/tmp/default-param/default-param.ino"
void loop();
#line 5 "/tmp/default-param/default-param.ino"
void func(int xyzzy);
#line 1 "/tmp/default-param/default-param.ino"
void setup() {
    func(11);
}
void loop() {}
void func(int xyzzy) {}

The build process has inserted a valid C++ function declaration prior to the call site, so the compiler is happy.
With default argument
But this input:
void setup() {
    func(11);
}
void loop() {}
void func(int xyzzy = 7) {}

generates:
#include <Arduino.h>
#line 1 "/tmp/default-param/default-param.ino"
#line 1 "/tmp/default-param/default-param.ino"
void setup();
#line 4 "/tmp/default-param/default-param.ino"
void loop();
#line 1 "/tmp/default-param/default-param.ino"
void setup() {
    func(11);
}
void loop() {}
void func(int xyzzy = 7) {}

No declaration prior to the call site this time, so the compiler is not happy with this generated code.
Build process
The build process is a rather ugly... process... that scrapes the output of the compiler and generated ctags to build include paths and to try to generate forward references for things.  Sometimes, it just gets it wrong.  I'm not sure what the exact error is in the build process, but it is probably just a failure to match the error caused by calling an undeclared function with its matching entry in the ctags.  You can try reading through the build process documentation to make sense of this.  Ultimately though, you may have to read the source to arduino-cli/arduino-builder to get to exact cause.
Non-.ino (and non-.pde) files more or less go through the build process unscathed.  So, if you really want default arguments, you can make use of and .h file for your function prototype/declaration and a .cpp file for its body and follow the normal rules of C++.
Using your own declaration
You can just make your own declaration for it.  Doing so makes it not detect an error on that line.
void func(int xyzzy = 7);

void setup() {
    func(11);
}
void loop() {}
void func(int xyzzy) {}

Output:
#include <Arduino.h>
#line 1 "/tmp/default-param/default-param.ino"
void func(int xyzzy = 7);

#line 3 "/tmp/default-param/default-param.ino"
void setup();
#line 6 "/tmp/default-param/default-param.ino"
void loop();
#line 7 "/tmp/default-param/default-param.ino"
void func(int xyzzy);
#line 3 "/tmp/default-param/default-param.ino"
void setup() {
    func(11);
}
void loop() {}
void func(int xyzzy) {}

As you can see it generates a proto type for whatever reason.  But not one that conflicts with your own.

It is probably better if you want to make use of default arguments to just use headers and .cpp file for those functions that have them so that you're not subject to changes in the ability of arudino-cli/arduino-builder to handle them.

Solution is buried in answer: "You can just make your own declaration for it". Suggestion: move to top, or add a TLDR at top.

Probably when I wrote this I took the "or if I put the blink function before the loop" to mean that they already had a solution and were wondering about why, so the TLDR is more of a why-TLDR "It's just a failing of the Arduino build process to generate prototypes" rather than a how-TLDR. They weren't explicit in asking so both are covered. If you're saying you found this helpful but didn't like reading as far, sure, I'll see if I can't address the how part sooner also.

If you use a function after you call it in the same file, you have to (or at least it is better) to add a so called 'forward declaration' before calling it. The best place is before the first function, and in your case it should look like:
void blink(const uint8_t led, int num, const uint16_t l);

You can omit the = 12 or not.

Normaly this is done by the Arduino IDE, and when I don't put a default value "blink" can be define after the "loop" function, without a 'forward declaration' before calling it.
I don't understand why this problem error exist only with default parameter.

The reason behind it probably can better be asked in StackOverflow.


text:
Why isn't ESP8266 connecting to wifi when calling yield()?
I'm experimenting with ESP8266 and I want it to cycle through various states: LED on/off, WiFi on/off and measure the connection time, deep sleep.
I wrote the following script, using millis() to define the time intervals. I cut away the previous parts of the code to have a minimum test case.
I read that ESP8266 has the watchdog automatically on, so I used yield() when spending time waiting, instead of using an empty while loop. I didn't use delay() because it block further execution of the code, and I tend to avoid it. I know it would reset the watchdog too.
#include <ESP8266WiFi.h>

const char* ssid = "wifi";
const char* password = "pass";

const int led = 2;

void setup(void){
  unsigned long refTime;

  pinMode(led, OUTPUT);
  Serial.begin(115200);
  digitalWrite(led, 1);

  refTime = millis();
// isssue from here
  while ((millis() - refTime) < 3000) { yield(); }
// to here

  Serial.println("Connecting...");
  refTime = millis();
  WiFi.begin(ssid, password);
  Serial.println("");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  // never gets here when "issue" code enabled
  Serial.println(millis() - refTime);
  digitalWrite(led, 0);
}

void loop(void){

}

If I use the yield(), then I never get a WiFi connection (well, it happened only once, actually).
Why is yield causing issues?

why not just delay() 3 seconds?

Because this way I can add some other code to the main loop and still get the blinking on time. I don't need it in this example, but I find it often useful. Still, why isn't it working? See also https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/using-the-arduino-addon

the code looks alright, but maybe try a delay(1) in the loop instead of yield()...

source: Stack Exchange

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

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

sort: votes


text:
Arduino with multiple buttons - will power be an issue?
I have a spare Arduino Uno lying around, which I figured I could attempt to turn into a game controller. First clear issue, that immediately popped up, was that there are not enough digital input pins on the board, but I think I can get around that by using analog pins with appropriate external resistors (is that actually a possibility?).
Another one, more severe, is that I'm not sure how I would need to go around wiring microswitch buttons with the board. Assuming they short the circuit when pushed (SPST), I could simply wire one contact to an input pin, set to INPUT_PULLUP mode, and connect the other to ground. However, since I know little about how such circuits work, I'm immediately in doubt about two things. Considering the board would be used as a controller, an external power source is out of question and I'd only want to rely on the USB power. Since I want to use plenty of buttons (up to fifteen), out of caution I'm worried that shorting this many input pins to the ground at once could overload the... regulator I think?
So my question is this: is it safe to use multiple, potentially simultaneously pressed, buttons connected to input pins on an Arduino Uno board, powered solely from a USB port? Additionally, just to be clear, is it normal to connect them all to a common ground on the board?

Is the game an Arduino game, or are you planning to control something else, like a PlayStation?

@Nick, I'd like it to be a "universal" USB controller. I found the UnoJoy project that ought to cover the basics of USB communication in my case; I'll figure out if I can further modify it once I get it running. Also, thanks for moving the question over, I wasn't initially sure which domain it's considered to be specific to.

In which case I endorse Ignacio's suggestion that you consider another Arduino, for example the Leonardo. I am using one to convert button presses into boilerplate for forums, described here.

You can use V-USB (Virtual USB) instead, try searching for that.

@Nick, ah right, Leonardo does have native USB support and more digital input pins available! Since I already have an Uno to spare, I'll proceed with this one for the time being, but will certainly consider buying a Leo for future projects of similar kind. Thanks!

was that there are not enough digital input pins what? why? how? I mean... You have 20 pins. If 2 are used for the serial communication, you still have 18 pins. Connect them in a matrix, and you have 81 possible buttons. Aren't 81 buttons enough for your controller? ;)

@frarugi87, if you consider analog pins, yes, that amounts to 18! However, when I first asked the question I wasn't sure if I can utilize analog pins for this purpose; I thought I'm limited to 12 digital pins available on an Uno, hence the question. I didn't think of wiring them into a matrix though; will have to find out how to do it to allow for a maximum number of simultaneously pressed buttons, but thanks a bunch for the suggestion!

@yakcyll Well, with 12 pins you can wire up to 36 buttons. And all of them can be simultaneously pushed (you just have to use a scanning frequency larger than the responsiveness you want). Anyway this is easily achieved since usually you want the buttons to respond within tens (even 50) of milliseconds and you can scan it at more than 10 times that frequency)

Most of your idea is sensible. Let's go over the sensible part first, and then we'll cover the bits that need work.
Using an internal pullup and shorting the input to ground is the correct way to approach this. Note that the pins will read HIGH when off and LOW when triggered this way.
Each pullup on an AVR is between 20kohm and 50kohm. This means that the current consumption if all 15 buttons are pressed is at most about \$15 \cdot {5 \text{V} \over 20\text{k}\Omega} = 3.75\text{mA}\$. This isn't enough for the USB connection to care about.
As for using the analog connections, A0 through A5 also have digital GPIO capability, which means that you would treat them exactly the same as you would the digital pins (A6 and A7 don't have digital GPIO unless you're running a ATmegaXX8PB with a special core).
And now the bad news.
The Arduino Uno is based on the ATmega328P, which does not have native USB capability. It communicates with the host through a serial connection via a USB-UART bridge. If you're using a real (or real-enough) Uno then that bridge is a ATmega16U2 which is a MCU that does have native USB capability, so it can be reprogrammed to interpret the serial stream from the '328P and talk USB to the host.
But if you aren't then you will either need to run a piece of software on the host that translates the serial stream to HID actions, or you will have to run a software USB stack on the '328P such as V-USB which will allow you to use Low-Speed USB 1.1 directly.
My recommendation is to see if you can get an Arduino or other AVR-based board that has an ATmegaXXU4 so that you can use Mouse and Keyboard directly instead of having to faff around with HID profiles and software USB. Unless that's your thing, of course.

Ignacio, it looks like this SE doesn't support maths symbols, unfortunately.

Aye, my board is supposed to be Uno R3-compatible and apparently does have an ATmega16U2 controller on-board to handle USB communication. If I understand you right, this means that I can program it, or find suitable firmware elsewhere, to have it present itself as a common HID device, instead of writing custom firmware for it, correct?

@yakcyll: Correct, although the buttons will still need to be handled by the '328P.

@NickGammon: Nor does it support CircuitLab. Some days I wonder how we even manage to get anything done :P

I wish those that migrate would take that into consideration. I have created schematics in the EE question editor and cut'n'pasted the markup in here and it works. I don't know if the schematics get purged if there's no record of them being used in EE though. Anyone know?

Yes, it is safe to connect multiple buttons to ground. The pull-up resistors have a fairly high value - about 10 kΩ and we know from Ohm's Law that
I = V / R = 5 V / 10k = 0.5 mA

per button. Your USB power is good for about 500 mA.
Welcome to StackExchange.

Transistor, it looks like this SE doesn't support maths symbols, unfortunately. ;)

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


text:
How to read/write variables persistenly on Arduino Due (no EEPROM/shield)?
I am relatively new to Arduino and I am currently writing some code to control a relay board. The on/off times are provided by the user at run-time and should be stored persistently (EEPROM or flash) in case of power-down.
On my Uno I worked with the EEPROMex library and that worked well. Now I have a Due which doesnt have any EEPROM and I am struggling how to store variables persistently. Specifically, I dont know how to access whatever I wrote to the flash memory previously. In the example below the content of test[] is obviously overwritten on every restart.
PROGMEM int test[] = {1, 2, 3, 123, 23};

void test()
{
  Serial.println((long)test);
  for (int i = 0; i < 5; i++)
  {
    Serial.println(test[i]++);
  }
}

I noticed that the address does not change during re-starts, so I I tried reading/writing beyond index 4. This out-of-bounds read/write worked, I guess since I am anyway not storing anything else. Interestingly even this memory which is out of the array is overwritten on power-up.
So: How do I store on unser input data (variables) persistenly on an Arduino due without using any shields?

You don't need a whole shield for EEPROM. Just 4 or 5 wires and an EEPROM DIP-chip.

I really hope that somebody knows differently, but I'm fairly sure that the answer is that you can't directly save runtime data back to the Arduino Due board.  I've looked into this myself and have only found answers saying "wire up an external EEPROM" or similar.  Whilst it seems that it should be technically possible to write into unused (or pre-reserved) areas of the program memory, I suspect that the CPU has to be put into a special mode to do this, which is very probably only possible from the bootloader when flashing a new program to it.
I've chosen to go with FRAM chips for data storage. Link to mine.  They are difficult to wire up - the only ones I found were in surface mount packages (although some hobby retailers sell them mounted to little boards with header pins), but they are very cheap, very durable (you can write to them a great number of times before they wear out), operate at high speeds and you can read/write single bytes from/to them.  Other storage chips often require you to write whole "pages" of data at a time which can mean reading in the existing data, modifying it, then writing it back.
Additional comments:
In your original question, you state that the contents of your PROGMEM located array must be restored on restarts.  I don't think this is the case.  That would suggest that the contents are stored elsewhere and code is in place to overwrite them, however it could be the case that they are copied into working RAM, which would mean that the PROGMEM macro is not actually doing anything on the Due - which may well be the case.
Modify your code to change one of the values of the array (within the bounds of the array!) and then print its value out again after changing it.  If the value printed has changed then this means that PROGMEM is not actually doing what it is supposed to do on the Due, which would be a real shame.

Adafruit sells FRAM on a breakout board which is a lot easier to deal with when everything else is thru-hole. Plus FRAM are crazy fast compared to EEPROM.

The SAM3X8E has also backup domain (several backed up registers, RTC), but its power supply is shorted to the main 3V3 rail on DUE board, so there is no easy way to add battery.

This library called DueFlashStorage was created by Sebnil and is in the Arduino Library Database Tool!
It basically takes the EEPROM functionality and applies it to the Flash storage on the DUE. The only drawback is that the flash memory gets erased every time you upload a new (or new version of a) sketch.
For my application that works but for other applications that might not be what you want!
Click here to go to the GitHub for it called DueFlashStorage

Without an external device you won't be able to store data permanently. So it might not be a full shield, but you'll have to add SOMETHING. Depending on how much data you need you might use components that have EEPROM as a side feature. For instance, as explained here, the DS1337 RTC module has 56 spare bytes of EEPROM^H^H^H^H^H^H Non-Volatile RAM available. I know, it sure isn't much, BUT it might be enough for your needs, depending on how much you need to store.
And of course it provides you with DateTime capabilities, wich could come in handy.
Aside from this, there are EEPROM chips mounted on a small board, with DIP switches to set the I2C address, which would be very discrete, and could store a large amount of data. See this one for instance.

Technically the DS1337 memory is not called EEPROM, but battery backed RAM. You can abuse the alarm sections to get an additional 7 bytes :-). I used this trick on the DS3231 which doesn't have any 'free memory'.

You're right. The datasheet says "56-byte, battery-backed, nonvolatile (NV) RAM for data storage". Neat trick you did abusing the alarm section ;-)


text:
How to save data in arduino when it's power goes off
I am doing a project 'arduino based switch operation'. Here the user needs to set a time to turn on relay and set time to turn it off. The problem is that I want to supply power to arduino using adapter connected to the ac supply (where the relay will also be connected). When the on time is set and if power goes off for some time then this system doesn't work. I want to save the data in arduino so that it will retain the data if power comes back.. So that my relay is operated on time..
How to do it guys???

See this answer https://arduino.stackexchange.com/a/72370/14490

Maybe I don't understand the question, but should the idea not be: the Arduino is always on, and the on and off time depends if the relay goes on/off... If you want the Arduino to be switched off too, you need at least some battery power and using sleep mode i.c.m. with an interrupt pin trigger set to some real time clock to be able to 'awake'  it.

It is unclear, if you want to power off the Arduino in regular operation, or if you just want to save the time settings in case of a power outage. Please make this clearer

Look up EEPROM. it is a memory that saves content even though power is off.
You can write data in EEPROM and when power comes back read it back.
there are safe ways to write in EEPROM without corrupting it.

Beside Georgi's answer, I would like to tell  you some details.
First :
a microcontroller can have a built-in EEPROM like the ATMega328 inside an Arduino UNO/Nano/mini, if not you would need to attach an external one, it can have may interfaces like SPI or IIC etc...
Second :
an EEPROM can hold only a specified amount of data, it can be 512byte like one on the ATMega328 microcontrollers, it can be only 64byte on others.
Third :
an EEPROM have addresses so for example in 8-bit EEPROM one address can hold only 8bits so values from (0-255) like on the ATMega328
Fourth : how to use it
In the beginning of your code you should first include the eeprom library
#include <EEPROM.h>

Then you would for example assign value "24" to one of the address on the EEPROM let's say address "1"
So you will use
EEPROM.write(1,24);

Of course you can power off you board and repower it again and that particular address will have the assigned 8-bit value "24".
To read back
EEPROM.read(24);

I hope that might help you or anyone else.
And as a side note an EEPROM have defined write and read cycles ~10000 maybe ~100000 after that amount it May not work.
Original documentation : here

You Can do that by using RTC (Real Time Clock Module ) in your project.

And how would you do that? "How do I get from New York to Trenton?" "You can drive." Hardly helpful.

Sure, hardly helpful. But similar to the question. The title question "How to save data in arduino when its power goes off" smells like EEPROM, additionally...


text:
Mass testing of Arduinos
I am using Arduino for an IoT class (40 students). I have set up a test program to check all sensors and actuators used in the class (we need to recycle for next semester). However, I would also like to check the Arduino's themselves (and also NodeMCU´s) in case some of the units have been broken. I have an idea of testing input/output of each pin to make sure its working - using LEDs and buttons, but if anyone has some ideas to improve testing, it would be great to hear from you.

Thank you all for your valuable input.  Unfortunately, I have to do the testing myself since students are working from home (Covid-19). So each student receives a package with all components and does the labs under online supervision.  That is why testing is important. I had the same class last summer with good results, but with brand new components.

Testing microcomputers is a very complicated task. In your case I would suggest writing some programs to do exactly what you are saying. Then let the students do the testing. When the class starts you have to teach them the basics, this will check the computers etc and also the test equipment on there benches. At the end of testing they will have knowledge of the basics they will need to continue with the class. You can also have the students do this at the end of the semester to get a head start on any problems.

A complete test would obviously be something fairly complex, and would
probably require building some sort of rig. You can, however, perform a
minimal test that checks for common failure modes, without connecting
any extra hardware.
I assume the pin I/O stages are the easiest thing to break. You can then
check that, when you read a pin that is set to OUTPUT, you get the
value that the pin is supposed to be outputting. You can leverage the
stray capacitances of floating pins to test them as inputs: the
capacitance should make the pin “remember” its previous output value for
some time, and that time should be really short if the internal pull-up
is enabled.
The following program tests pins 2–13 and A0–A5 of an Uno. It checks
that:

a pin set to OUPUT LOW reads LOW
a pin set to OUPUT HIGH reads HIGH
a pin switched from OUPUT HIGH to INPUT reads HIGH
a pin switched from OUPUT LOW to INPUT reads LOW
a pin switched from OUPUT LOW to INPUT_PULLUP reads LOW, then
switches to HIGH less than a microsecond later

Pins 0 and 1 are not tested, as they are connected to the serial port.
On the other hand, if you can upload a sketch, you know those pins work
at least as RX/TX.
Note that the program uses direct port access, as the Arduino functions
for accessing the pins are too slow for this kind of tests. If all
works, the program prints “All tests passed.”. Otherwise specific error
messages are printed, followed by “Some tests failed.”
#include <avr/cpufunc.h>
#include <util/delay.h>

int failures = 0;

static void log_failure(char port_name, const char * reason)
{
    failures++;
    Serial.print("FAIL: Port ");
    Serial.print(port_name);
    Serial.print(", read ");
    Serial.println(reason);
}

static inline __attribute__((always_inline))
void test_port(const char port_name, uint8_t mask,
    volatile uint8_t *pin, volatile uint8_t *ddr, volatile uint8_t *port)
{
    *port = 0;
    *ddr = mask;   // OUTPUT LOW
    _NOP();
    if ((*pin & mask) != 0)
        log_failure(port_name, "OUTPUT LOW");
    *port = mask;  // OUTPUT HIGH
    _NOP();
    if ((*pin & mask) != mask)
        log_failure(port_name, "OUTPUT HIGH");
    *ddr = 0;      // INPUT_PULLUP
    *port = 0;     // INPUT -> HIGH
    _NOP();
    if ((*pin & mask) != mask)
        log_failure(port_name, "INPUT HIGH");
    *ddr = mask;   // OUTPUT LOW
    *ddr = 0;      // INPUT -> LOW
    _NOP();
    if ((*pin & mask) != 0)
        log_failure(port_name, "INPUT LOW");
    *port = mask;  // INPUT_PULLUP
    _NOP();
    uint8_t r1 = *pin;
    _delay_us(1);
    uint8_t r2 = *pin;
    if ((r1 & mask) != 0 || (r2 & mask) != mask)
        log_failure(port_name, "INPUT_PULLUP");
}

void setup()
{
    Serial.begin(9600);
    TIMSK0 &= ~_BV(TOIE0);  // disable timer interrupt

    test_port('B', 0x3f, &PINB, &DDRB, &PORTB);  // PB0..PB5
    test_port('C', 0x3f, &PINC, &DDRC, &PORTC);  // PC0..PC5
    test_port('D', 0xfc, &PIND, &DDRD, &PORTD);  // PD2..PD7

    if (failures == 0)
        Serial.println("All tests passed.");
    else
        Serial.println("Some tests failed.");
}

void loop(){}

As an extension, analog inputs could be tested in a manner similar to
test 5: if the analog sampling is done at the right time, you can
get a reading that is somewhere mid-range.

There are a number of open issues which need to be addressed in order to narrow the scope of this project to a manageable and reasonable effort.  For instance:

Which Arduino (board and processor) are you using?  Does the board power off a regulated USB 5 volt source?  Or does it use a regulator which needs testing?
How many GPIO pins are there? Will they be used to drive, sense or both?
Are there any Analog pins?  Do they need to be tested over a range or just a select voltage?
Are there any PWM outputs which need to be tested?

To simplify testing we might make some assumptions.  For example:

If the GPIO aspect of a pin works any PWM feature for that pin may be assumed functional.
If a given voltage at a Analog Input pin results in a reasonable analog to digital conversion then all other reasonable voltages will result in the expected analog to digital conversion.

For testing many UUTs (Units Under Test), it is almost always better to build a fixture.  This might be simple cables connected to another (carefully controlled) Arduino all the way to a bed-of-nails In Circuit Tester (ICT).
The "Make a Pogo Pin Test Jig" project at Adafruit addresses many of these concerns at a level that may be suitable to implement at the college level.

When I make a new (Uno-like) board, I test for shorts and opens with sketch that blinks each pin in sequence. @Gerben's suggestion to test the inputs as well makes a lot of sense for your application. Plus the basic ability to power up (working barrel-connector input & voltage regulator, working USB connector and USB communication) would another test I'd make. I'd probably boards that have a socketed chip for my future purchases (if you're not already).

I'd add a second Arduino to supply a HIGH and LOW signal to the Arduino being tested (to test the INPUT), and to verify that the tested Arduino can output HIGH and LOW. Testing inputs, outputs, and being able to upload you test sketch will catch the most common problems.
Testing the regulator would be my next thing, but that also depends on whether you're previous course was using the regulator.


text:
Power supply while using a shield
Sorry if this is a dumb question, I'm new to Arduinos. I'm planning to use a MOVI voice shield with SparkFun's RedBoard Turbo (3.3v). The RedBoard Turbo requires a power supply under 6VDC, but the MOVI website recommends a power supply of 9VDC to the Arduino, because the MOVI can't have its own power supply. Will this destroy my RedBoard? Or is this safe and just something you have to do when using shields? Thank you.
The product website says: "A 7V to 16V 500mA external power supply that powers MOVI™ through the Arduino board. The power consumption of both boards is just above what the USB port can provide. If you don't have already one, this 9V adapter from Adafruit will work perfectly."

You can add LDO in between the power supply to the before providing it SparkFun's RedBoard Turbo.

use instructions for Arduino Zero. http://www.audeme.com/uploads/4/3/9/9/43997575/movi_11usermanual111.pdf

Although I have not used either SparkFun's RedBoard Turbo or the MOVI voice shield, reading the specifications, which you can find on their respective web sites, it would appear that they have incompatible power requirements.
The SparkFun's RedBoard Turbo board web page says
The barrel jack connection on the RedBoard Turbo has a lower input voltage than most Arduino development boards. Make sure that you are using a power supply below 6V. Please be aware that the RedBoard Turbo is also a 3.3V device and not a 5V one like the original RedBoard.
Whilst the MOVI voice shield PDF manual (page 7) says
What you don’t see in Figure 1 is a power supply jack. MOVI is powered through the
Arduino board that needs to be powered using an external power supply. The external
power supply should provide between 7V and 16V and at least 500mA current. During tests
we usually used either 9V or 12V. Battery packs with this specification work as well.
So the one needs less than 6V whilst the other more than 7V. I don't know if you can break the power connection between the two boards and feed the MOVI from a separate supply (9V is very common in the Arduino world) or you may have to swap your SparkFun for an Arduino that runs on 5V and uses a 9V supply.
The gotcha is that Arduino boards, their clones and code compatible boards such as the ESP32 etc fall into 2 different groups, those that run on 3.3V and those that use 5V, and you must be very careful you don't over voltage the latter.
I haven't delved into the specifications further, but you will almost certainly find that the logic levels used by the two boards are also incompatible. One will be using 0 & 5V whilst the other 0 & 3.3V. Connecting a 5V logic output to a 3.3V logic input is not conducive to long life and happiness for the latter.

you understand it wrong. the answer is wrong. the shield takes 5 V from the 5 V pin of the board and the regulator on the board can provide it. the Uno has a different regulator and needs a different input voltage but provides same 5 V on 5 V pin. problem is if the external power supply can provide the necessary current and that doesn't depend on voltage

@Jraj If you compare the schematic of the original RedBoard
https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/RedBoard-V22.pdf
with that of the Turbo
https://cdn.sparkfun.com/assets/6/5/4/5/0/RedBoard_Turbo.pdf
There is no 5V regulator on the Turbo board, all it does is pass the 5V from the USB straight across to the 5V socket on the edge connector. There doesn't appear to be any connection between that and the rest of the board.
This query is about powering via the barrel connector.
The original board does have a 5V regulator and it is connected to the edge socket.

@Juraj Sorry, typo

@Juraj The MOVI manual clearly states that it takes its power from the Arduino and that it should be between 7V and 16V not 5V and Please note: MOVI cannot be powered through a USB power supply or the USB cable of the Arduino board as the voltage provided is less than 6V. So if the input supply to the RedBoard Turbo (<=6V) was passed to the MOVI it would not work.

does the shield have a power regulator and takes the power from Vin? I don't believe it.

@Juraj Have a look at the manual
https://www.audeme.com/downloads.html
and tell me what you think. Maybe I'm wrong, but my reading is that it takes the raw (9V say) power from an arduino and has it's own on board power conditioning circuits. If you look at the photograph of the MOVI there are some components that look suspiciously like a power supply (an inductor for example) near the power input pins. Unfortunately, unlike SparkFun) Arduinos do not provide a circuit diagram of the MOVI to confirm this.

it uses Vin, but it can be used with Arduino Zero, so it can be used with SparkFun's RedBoard Turbo

Let us continue this discussion in chat.


text:
Use Arduino IDE to program Bluetooth Bee standalone
Using Arduino IDE, how do I program the Bluetooth Bee Standalone?  I can't select that particular board from the list under Tools -> Board.  The closest I see is Arduino Fio.

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


text:
how to send data to Adafruit Bluefruit Feather (32u4) over bluetooth?
Sup yo.
I have my Adafruit Bluefruit Feather all wired up.  It's lovely.  I've got it responding to commands over the USB serial, activating an array of octocouplers.  It's terrific.  Here's the thing though.  I need to talk to it wirelessly.
I can only pair it (MacOS) the Adafruit Bluefruit LE Connect app.  It doesn't show up in my Bluetooth preference pane.
$ ls /dev/tty.*  shows /dev/tty.Bluetooth-Incoming-Port and the Arduino IDE can see it.  Unfortunately the word Incoming is right there in the middle of that port name.  Sending commands through the Arduino serial monitor doesn't seem to do anything.
The Bluefruit connect app appears to be able to send commands over something called UART but my board doesn't respond to the stuff that works over USB serial.
How do I talk to this board over Bluetooth?

The “UART” being referred to is the Nordic UART GATT Service. This is not a serial port or USB connection. It is a high level BLE protocol that simulates a serial port via the Bluetooth connection.
In order to connect to the device from your Mac you’ll need to write some C or Obj-C. I’ve done this for Windows, but not a Mac, so I’m afraid I can’t give you detailed instructions. However, the source code for the iOS Adafruit Bluefruit LE Connect app you’re using is open source and should be a good starting point.
Be warned of a few things though.

You’re going to have to learn a bit about the BLE protocols and standards. It’s not exactly for the faint of heart.
Apple throttles the speed/throughput of BLE for their iOS devices (as does Android) to protect battery life. I don’t know if they apply the same throttling to their laptops. You may not be able to achieve a satisfying data rate if you’re looking to create a high throughput “data pipe”.  With Win10 and the Bluefruit LE I was able to achieve 40 bytes every 30ms. You’ll likely be limited to 20 every ~30ms.
If you’re looking to just send some occasional text (maybe AT style) commands to the device via BLE though, you won’t come close to those limitations.

gosh thanks dude.  it sounds like a lot more trouble than it's worth.  i'm just going to do a salvage run to another project that can actually do a bluetooth serial.

It depends on what you need. If you just need to send & receive some text at a low rate, not much trouble at all. If you need a lot of throughput, then yeah... it’s a bit of a headache. You’ve got to remember that BLE stands for Bluetooth Low Energy. It’s designed to conserve battery life.

First you should do some research on just what Bluetooth LE is.  First and foremost, what it is not, is a serial port.
In fact the BLE specification has no concept of serial ports, not like the old Bluetooth 2.x SPP specification.
Yes, you can use it like a serial port, but the point I am making is there is no GATT profile for serial data transfer. Every module manufacturer has their own way of doing it, so it's down to your application to implement that method (usually using libraries provided by the manufacturer). You can't present BLE as a serial port (COM3, /dev/rfcomm0 etc).
Sure, you could write a daemon that connects the MFG's custom method to a PTY and make it look more like a serial port (and such a thing may already exist in the community for some devices), but it will only ever work with that device and never any other device. There is no serial - there is only serial emulation and it's specific to the device. If it were standard no doubt someone would write a driver for it - like SPP of Bluetooth 2.x. But with GATT you just don't get that standard facility.
BLE is intended for sending short packets of data back and forth using minimal power. Many manufacturers have chosen to create a profile that can be used in a similar way to a serial port (in that you send data through a virtual "pipe"), however you require special software to interface with it. And, since there is no standard, and manufacturers just don't talk to each other, the software is specific to the device you are talking to.
If you are directly programming a BLE chip itself with your own firmware there is nothing to stop you from implementing your own protocol for serial data transfer and writing an application, driver, daemon, whatever, for communicating with that custom firmware. The same thing stands though: whoever wants to use it will require your specific application to communicate with it.
The only people who want to use BLE for serial are people like us. Everyone else (that's 99.999% of the market) uses it for what it is intended - connecting sensors and HID devices to mobile phones etc. That's why all the GATT profiles are for such things as heart rate, blood sugar levels, cycle speed, etc.
So no. You can't use it like a serial port. It's not a serial port. The only foolproof way (and the way to which I have resorted in the past) is to create a USB dongle that exposes a CDC/ACM interface to the computer, and contains a BLE module that is capable of communicating directly with a similar BLE module through its own proprietary profile (the one I use has a "transparent UART" mode when two modules are paired together). The MCU in the dongle then forwards data between the computer and the BLE module.

@RubberDuck I think you misunderstood what I was saying there. Yes, you can use it like a serial port, but the point I am making is there is no GATT profile for serial data transfer. Every module manufacturer has their own way of doing it, so it's down to your application to implement that method (usually using libraries provided by the manufacturer). You can't present BLE as a serial port (COM3, /dev/rfcomm0 etc). Sure, you could write a daemon that connects the MFG's custom method to a PTY and make it look more like a serial port, but it will only ever work with that device and never ...

... any other device. There is no serial - there is only serial emulation and it's specific to the device. If it were standard no doubt someone would write a driver for it - like SPP of Bluetooth 2.x. But with GATT you just don't get that standard facility.

Only works with Nordic though. Like I said, it's manufacturer specific as there is no standard.

lol thanks for the involved answer.  it sounds like this board is just not the right board here.


text:
unable to install usbserial driver for GPRS shield with mac air vs. 10.9
Despite all my efforts and web crawling I can not install the necessary driver to connect my Arduino uno R3 to the GPRS shield from seeedstudio. I have attempted downloading the VCP driver from http://www.ftdichip.com/Drivers/VCP.htm
I have tried the solution offered here https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/mac for Yosemite and beyond through the AppleUSBFTDI driver as well as the solution offered by FTDI's script. Any help will be greatly appreciated. Please let me know if I can provide any more information.

Shields do not require PC/Mac drivers.

in order to use the GPRS shield you must be able to connect through the /dev/tty.usbserial#### port which requires a driver.

No.  The USB serial connection is provided by the Arduino, not the shield, and the naming pattern for an Uno on OSX will not be tty.usbserial### but rather something else (tty.usbmodem### perhaps?).  IIRC an Uno does not require a driver on OSX though older/unofficial FTDI based boards do.

The USB serial connection is provided by the Arduino, not the shield, and the naming pattern for an Uno on OSX will not be tty.usbserial### but rather something else (tty.usbmodem### perhaps?).
If I recall correctly, an Uno does not require a driver on OSX though older/unofficial FTDI based boards (as well as unofficial boards based on yet other fixed function chips) do require drivers.
(On Linux it is typically /dev/ttyUSB# for fixed function and /dev/ttyACM# for an Uno, both using kernel module drivers shipped with most distributions.  On Windows they are all COM# and drivers are typically required)


text:
Arduino in Eclipse IDE: How to add SPI library (core library already added)?
I want to use eclipse for arduino programming, so I followed the guides to set up a static project for the arduino core library. Then I added the library file (.a) and the .h and .cpp files to my new project in the settings.
So far, so good.
But now I am trying to add the SPI library to my project without success (I only have the .h and .cpp files, no .a)!
My sample code
#include <Arduino.h>
#include <SPI.h>

int main(void) {
    init();
    pinMode(13, OUTPUT);
    for (;;) {
        digitalWrite(13,1);
        SPI.setBitOrder(0);
    }
}

The pinMode and digitalWrite parts work, but with the SPI method I get an error:
05:33:26 **** Build of configuration Debug for project ArduinoTestProject ****
make all
Building file: ../main.cpp
Invoking: AVR C++ Compiler
avr-g++ -I/home/fabio/Workspace/arduinoLIB/SPI -I/home/fabio/Workspace/arduinoCORE -Wall -g2 -gstabs -Os -ffunction-sections -fdata-sections -fno-exceptions -mmcu=atmega328p -DF_CPU=16000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o "main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: ArduinoTestProject.elf
Invoking: AVR C++ Linker
avr-gcc -s -Os -o"ArduinoTestProject.elf"  ./main.o   -l"arduinoUNO" -l"m" -lm -Wl,-Map,ArduinoTestProject.map,--cref -mrelax -Wl,--gc-sections -L/home/fabio/Workspace/arduinoCORE/lib -mmcu=atmega328p; avr-nm -C -n "ArduinoTestProject.elf" >ArduinoTestProject.symbol
./main.o: In function `main':
../main.cpp:38: undefined reference to `SPIClass::setBitOrder(unsigned char)'
collect2: error: ld returned 1 exit status
avr-nm: 'ArduinoTestProject.elf': No such file
make: *** [ArduinoTestProject.elf] Error 1

05:33:26 Build Finished (took 72ms)

Does anyone see the problem?

Did you tell it to build and link against the .cpp file?

i did not intentionally... I just set configuration values.
How do you tell it to?

Upon makefile and console output analysis I have noticed, that I actually didn't include the library file to be compiled, so the linker doesn't find the object files and exits!

Does that mean the issue is solved?

Not really... But I'm not working in it right now. Should I remove the question or leave it open if I find some time again to work on it?

As far as I understand you are using eclipse CDT directly. (I mean you are not using an "arduino eclipse plugin" that does the stuff below for you)
The first thing to understand is that a arduino library is not treated as a library when compiling a arduino sketch.
In other words in the Arduino IDE, a arduino library is compiled like standard source code just like your .ino files.
As such there is no SPI.a file created during the compilation process.
In CDT you can have both options (with or  without .a file) but the Arduino IDE way is the easiest, by far.
So lets first assume you want to compile the "Arduino way" aka without SPI.a.
What you need to do is simply drag and drop the files in your project. If you want to drop in a subfolder (like libraries/SPI) you will need to add those folders to your include path.
That is all there is to it.
If you want to treat the library as a real library (saying you want a SPI.a) the best thing I can think of is to create a new library project for each sketch-project . Drag and drop the SPI code in that project (like above) and make your project dependent on the library project. There are probably some include path issues but the .a file should be found and included in the build
Note that the second approach makes that you will need a SPI project for each and every (arduino) board you have. If you want to use project defines it is even more difficult.
I would strongly advise to start your arduino eclipse development with my arduino eclipse plugin because it is simply easier. Later you can evolve to the full freedom of CDT.
If you want to drag and drop folders instead of the .h and .cpp files you will have to add exclusion rules to your include path. This because otherwise all the examples of the library will be in your project making you have multiple setup and loop functions.

You assume correctly: I was using only CDT with avr-eclipse. Weird that i have never heard of this eclipse plugin before...? Anyway you answered my question: it is not easy to create static libraries (.a) to link directly to the main code. This was my intention, as I didn't want to drag and drop files into each single project.

Thanks for accepting my answer. I don't know why you haven't heard of my plugin. It has been around for quite some time. I guess I'm bad at marketing ;-)


text:
Why I am connecting positive wire in the circuit?
I have constructed a simple fade in and fade out circuit similar to given on this website https://roboindia.com/tutorials/arduino-analog-output-led-fade Now I am connecting a wire from 5V power pins to +ve side line, but i don't know why I am doing this because when I remove this wire or connect it to 3.5V pin the led is still running fine. Also as side lines are connected horizontally there is no other further connection given to the +ve wire. Can you tell me why I am joining the wire?

You should include the diagram in the questions, so that people can see which wire you're talking about without following the links.

This is indeed not needed. As you can see in the diagram, the horizontal line which you connected the 5 V pin to.
The horizontal line of holes just above the red horizontal line) are connected. However, since it only connected to the 5V pin of the Arduino, the all pins on that horizontal line have 5 V, but since there is nothing connected to it (thus no closed circuit), the effect is zero.
The reason why the connection is made (the wire from Arduino to 5V), is that it is 'default' to connect both GND and 5V (or 3.3V) as a starting point. It is easy to forget later and than no current will flow when you connect something to the +5 V horizontal line of pins.
Btw, the 3.5 V pin you mention, is 3.3 V, not 3.5 V.


text:
RGB LED circuit problem
I have written the following code for RGB LED:-
const int RED =11;
const int GREEN = 10;
const int BLUE= 9;
void setup() {
  pinMode(RED,OUTPUT);
  pinMode(GREEN,OUTPUT);
  pinMode(BLUE,OUTPUT);
}

void loop() {
  analogWrite(RED,0);
  analogWrite(GREEN,255);
  analogWrite(BLUE,0);
  delay(1000);
}

Now according to my understanding if I run the above code then only  pin named GREEN i.e. 10th pin will give me current not 9, 11th pin. But when I upload the code and run it I see that 9 and 11 pin are giving me current not 10th pin as it is supposed to. Is there a problem in my code? I have checked my circuits are correct. To check current I took jumper wire that was connected to one of my colour and tried inserting it's other end at pins(9, 10 or 11) of Arduino board. If there is current bulb will glow. For above code the bulb was glowing when I inserted the wire at 9 and 11th pin.

Can we check that your circuit is correct too?

How do you know, that the other pins output a voltage? And what type of RGB LED do you have? Common anode or common cathode?

What do you mean by “give me current”. You are controlling voltage, not current.

@chrisl I took jumper wire that was connected to one of my colour and tried inserting it's other end at pins. If there is current bulb will glow. It's common anode

A common anode RGB LED can be sketched in a schematic like this:

simulate this circuit – Schematic created using CircuitLab
The positive voltage has to be applied to the top, for all the LEDs together. To light the LEDs up, you have to sink the current on the other end, meaning providing ground level at the bottom of that schematic at the corresponding pins. The current will then flow from your 5V pin, through the LEDs into the Arduinos pin.
That means, that analogWrite(pin, 0) will turn the LED on that pin ON and analogWrite(pin, 255) will turn the LED OFF. The logic is inverted here, because the Arduinos output pin is on the other side of the LED.
So your circuit and code work perfectly, you just didn't expect the inverted logic.

Note: The pins of the Arduino can only source/draw a certain amount of current (20mA continuously, 40mA at maximum) without getting damaged. A single, not too strong RGB LED should be OK, but as soon, as you want to drive more LEDs, you should consider using a driver circuit (for example simple transistors). That way the output pins don't have to provide the LEDs current, but only the current to control the transistor.


text:
NaN for reading from AM2302 from Arduino Uno
I want to read sensor values from 4x AM2302 to an Arduino UNO, and then pass those values for data logging to Raspberry Pi via Serial communication over USB cable.  The sensors are installed at 4x locations in an indoor plant growing system at difficult to access locations.  In the same script is a program that runs HVAC fans and a water pump using timers and relays.  The problem I encounter is that after working for several readings, eventually the AM2302 fails to read and continuously sends NaN value.  If I intervene and power down/repower up, and also reupload the script, then the AM2302 begin reading again, but only for a few readings then fail again.
In the sample read-out table below, the 4x AM2302 sensor read-outs are sensor 1 : (HA01 - humidity, TA01 - temp) sensor 2 : (HA02, TA02) etc..
There is another read-out CT01 which is a DS18B20, which also fails after some-time and reports a value "no more address" which is reported as -127C by the Dallas Library.
I setup a breadboard and ran the same script with 2x AM2302 and no DS18B20 attached and was unable to replicate the problem.
I have chosen to use json string as a way to pass the readings from Arduino to Raspberry Pi, and notice that sometimes the string gets corrupted - in particular the date timestamp.
I would appreciate any help / tips on diagnostics ideas to pinpoint the issue.
Code for Arduino and Raspberry Pi is available on GitHub.
https://github.com/footprintzero/plantlab

Updated info 2019/05/21 18:42
  I re-ran the program with a modified script and so far the sensors are continuously sending a reading (AM2302).This modified script version has the HVAC control timers with the relays commented out in HVAC.ino at line 97. So its only reading the sensors and not controlling the relays.
// timer_mainloop();

I guess that HVAC.ino is the sketch you are talking about. Without having read all the code (since it is a lot of code): You very often use the String class to construct the json data string. This will cause heap fragmentation and may be the reason for your problem (Though I'm not sure). You should avoid using String, especially in a project, that should run for a long time continuesly. Use char buffers with a constant length instead.

Thanks for having a look! The String class is one of the suspicions I have.


text:
ESP8266 does not detect WiFi networks
I have an ESP8266-12E, I used it previously and it worked fine (approx 2 years ago)
I can't seem to get it to detect WiFi networks or appear as an Access Point
I can upload the blink sketch and the onboard LED will work correctly and the serial monitor will show output from the ESP8266, but there appears to be no WiFi functionality
I have tried using previous versions of the ESP core board definition via the Arduino board manager
I have tried using an external power supply (wall plug) rather than the powering from a USB port
I have tried erasing the flash using esptool.py
I have checked that the WiFi router I am trying to connect to is operating at 2.4Ghz (also there are other WiFi networks around and I set up a second router to make sure)
I have tried connecting to the Access Point using the SSID (with and without a password) despite it not appearing
I have tried getting it to connect to an Access Point even though none are found
Is there something I am missing or should I order a new module?
Any other suggestions please!
Output when uploading a sketch
    esptool.py v2.6
    Serial port /dev/cu.SLAB_USBtoUART
    Connecting........_
    Chip is ESP8266EX
    Features: WiFi
    MAC: a0:20:a6:12:51:46
    Uploading stub...
    Running stub...
    Stub running...
    Erasing flash (this may take a while)...
    Chip erase completed successfully in 9.0s
    Hard resetting via RTS pin...
    esptool.py v2.6
    Serial port /dev/cu.SLAB_USBtoUART
    Connecting........_
    Chip is ESP8266EX
    Features: WiFi
    MAC: a0:20:a6:12:54:54
    Uploading stub...
    Running stub...
    Stub running...
    Configuring flash size...
    Auto-detected Flash size: 4MB
    Compressed 293920 bytes to 210833...

    Writing at 0x00000000... (7 %)
    Writing at 0x00004000... (15 %)
    Writing at 0x00008000... (23 %)
    Writing at 0x0000c000... (30 %)
    Writing at 0x00010000... (38 %)
    Writing at 0x00014000... (46 %)
    Writing at 0x00018000... (53 %)
    Writing at 0x0001c000... (61 %)
    Writing at 0x00020000... (69 %)
    Writing at 0x00024000... (76 %)
    Writing at 0x00028000... (84 %)
    Writing at 0x0002c000... (92 %)
    Writing at 0x00030000... (100 %)
    Wrote 293920 bytes (210833 compressed) at 0x00000000 in 18.6 seconds (effective 126.4 kbit/s)...
    Hash of data verified.

    Leaving...
    Hard resetting via RTS pin...

try the AT firmware

I tried downloading the default firmware from nodemcu-build.com and flashed it. Is this the one you mean?

Lua firmware? no. and does it work

I got an output saying the version of the Lua firmware and it could not init but I didn't try any AT commands... trying to find the AT firmware currently

https://www.espressif.com/en/support/download/at?keys=&field_type_tid%5B%5D=14 use 1.6.2. instructions: https://www.espressif.com/sites/default/files/documentation/4a-esp8266_at_instruction_set_en.pdf chapter 1.2.2.


text:
Best way of storing extra data for Arduino project
I am an arduino beginner and I am trying to make a speed camera alert system, it would start beeping if I am above the speed limit and getting close to the speed camera. There is this website where I can get all the data I need, coordinates, direction and speed limit of every 36000 speed cams in my country.
I would need some extra memory space to be able to store all this data, would an eeprom chip do the job? and would it be able to keep up with a for loop going through all those 36000 speed cam locations to check if i am close to it and above the speed limit?
Edit: since going through all those locations on a loop would be a lot for the processor to handle, someone recommended the creation of a temp file that would narrow that list down by direction, and when that direction changed it would recalculate that temp file. This is what I came up with:
void setup() {
  int tempDirection = gpsDirection;
  writeTempFile();
}

void loop() {
  //this will recalculate the temp file when the gpsDirection changes
  if(gpsDirection > tempDirection +5 || gpsDirection < tempDirection -5){
    tempDirection = gpsDirection;
    writeTempFile();
  }

  for(temp file){
    if(distance <= 100 && speed > speedlimit){
      //start beeping
    }
  }
}

void writeTempFile(){
  //this will write a temp file with every cam with a direction that's similar the gps direction
  for(each line of the file){
    if(gpsDirection + 10 > camDirection || gpsDirection - 10 < camDirection ){
      add cam to temp file;
    }
  }
}

SD card and ordered data

EEPROM would works. SD is probably easier to keep up-to-date, and about the same price.

EEPROM writes are limited to about 100k cycles.  They are for permanent or semi-permanent data (like your absolute speed threshhold - 120kmh, for example).
You should not store your speed camera base here.
Get a MicroSD adapter and save your data there.  Looping thru 36000 speed trap locations is going to put a toll on your processor and memory.  I recommend that you determine a binding box (+/- 2 degrees, for example) and save a temp file with only those traps inside the box.  recheck every time your position changes a full degree (N/S or E/W).
Notice: in some countries, Brazil for example, distributing information regarding speed trap locations is illegal (obstruction of justice).

I edited my post adding some code based on that binding box idea of yours to improve the processing. Would you give me your thoughts on it?

Been working wih GPS applications since 1995:i wouldnt work with direction, youd have to go into more complex calculations, which will eat your clock.You could store them by latitude (file21S.txt, file22S.txt, file23S.txt,...) and, depending on the lat you are on, you open the specific file.  Or you could have smaller files with latLon (file22S51W.txt, file22S52W.txt, file21S51W.txt and so on)


text:
Wemos D1 is not triggering Relay
Update: I realized my relay module was 12V and the current leaving the digitalpin from my Wemos D1R1 is only 3.3V. I bought a 5V relay module that I read in some articles that it could work, but it didn't.
My new question is: is there an easy and simple way to amplify the voltage leaving the D5 pin so it could control the 12V or the 5V relay module? I tried using and logic level converter from 3.3V to 5V but had no success. Ideas?

I am having issues with a simple project using Wemos D1 and a relay board. I followed a tutorial that was supposed to work out fine (https://www.instructables.com/id/Control-a-Lamp-With-ESP8266-and-a-Relay/), but for some reason I still don't know it is not working.
I read that it could be that the D5 pin has not enough energy to trigger the relay and change its state. So I tried using a logic level converter and still it didn't work.
I am attaching the image of my board/connections and also the logic level converter (https://br.banggood.com/3_3V-5V-TTL-Bi-directional-Logic-Level-Converter-For-Arduino-p-949438.html), plus my code below.

void setup() {
  // put your setup code here, to run once:
    Serial.begin(115200);

}

void loop() {
  digitalWrite(5, HIGH);
  Serial.println("HIGH");
  delay(3000);
  digitalWrite(5, LOW);
  Serial.println("LOW");
  delay(3000);
}

Does anyone have any idea of what could be happening? And how to make it work?

I can't quite see the text under the red wire connected to the Wemos D1. Does it say 5V? I'm asking because the relay requires 12VDC to operate.

yep. its 5V. I think I'll try with 12V and get back here if it still doesnt work

D5 is not io 5. use D5 in code

Still no success. Just got a 12V 2A powersource and still it doesnt trigger the delay. Also changed 5 to D5 in the code, and nothing happened.

try connecting the signal pin of the relay right to ground and vcc; do either of them actuate?

No. I tried putting it on the gnd and vcc coming from the 12V power supply and it works. I need to provide also 12V to the pin, apparently.


text:
How can I measure the point of contact between two wires?
I'm not sure the best way to ask this question, so I'll try to explain what I'm looking for, and roughly what I think is involved.
I want to measure the point of contact between two wires. This seems like it could be a resistance measurement, but I wasn't sure if that was the best way to go as it seems like the amount of change would be too small to measure.
Specifically I have two wires (more likely some sort of conductive ribbon) on a glove. One wire runs along the index finger, and the other is at the tip of the thumb. When someone touches their thumb to their finger, I want a value that indicates approximately where they touched.
For example, if they touch the tip of their finger to their thumb the value would be 1. If they touched their thumb to their first knuckle, then the value would be 0.75. And so forth. With a touch between two "points" producing a value in between.
Ideally someone could slide their thumb down their finger and produce a slowly changing value from 1 to 0.
Is resistance the way to go for this? It seems like there could a lot of other variables (surface area of contract, humidity, etc) that could dramatically change the resistance. Is there a better method?
Update: Because of some overzealous votes to close and confusion, this will be using the Arduino platform (maybe an ESP32, if that matters) once I figure out what sort of sensors and systems to work with.

Will you be using an Arduino in your project?

the index finger resistive strip and a contact on the tip of the thumb could act as a potentiometer .... one end of strip connected to Vcc ... other end connected to ground ... read the voltage on the thumb contact

voting to close because the question is not about Arduino

@VE7JRO Yes, this will be using Arduino platform, that is why I am posting it here. I can go add the words Arduino to the post if that makes you feel better.

@Jstola A restive strip sounds like exactly what I need. I'm assuming that works with Arduino (since we are on an Arduino site) but I guess I need to ask since you didn't say so explicitly.

You don't want wire, or wire braid. The resistance is too low and is very hard to determine accurately. Instead you want nichrome wire. Then just use it with a resistor of similar resistance to the maximum resistance of a touch as if it were a potentiometer.

@Majenko I figured the resistance would be too low. Looking into Nichrome wire and other resistive wire now. Thanks!

@VE7JRO Thanks for shutting down my first post here. Really makes me feel welcome to the community. I can just delete it and take my attention elsewhere. Clearly this isn't a site welcoming to new users. Thanks for making that clear before I waste more or my time participating in the community.

@Jim McKeeth - I'm sorry you feel that way. Unfortunately, your question is off-topic for the Arduino SE network. Please have a look at this page about General Electronics: arduino.stackexchange.com/help/on-topic "If your question is about making electronics or other electricity questions not related to Arduino, try Electrical Engineering". "If knowledge of Arduino would improve a question, it's on topic."

@Jim McKeeth - Your question only has a peripheral relationship to Arduino (if you decide to use one), is mainly about general electronics, and if you substitute a different type of micro controller (Rasberry Pi for example), the question is essentially the same.

@ve7jro I clarified my question immediately after I was asked if it was Arduino related. I see now sensor recommendations for use with Arduino are off topic. Seems very narrow-minded. I used to participate a lot in Stack Overflow before the culture got toxic. I see the toxic culture is all over the network. No thanks.

you could try 4 terminal sensing.
I have not used it myself, but the basic idea is to try to normalise for some of the external factors you mention.
As for the Arduino, the analog to digital converters have 10 bits of precision. This means you will get 1023 distinct values as the input voltage varies betwee 0 and Vmax (+5 or +3.3 depending upon the actual device). So that is fairly precise, usually you just use the value from the analog read - but you can convert to a value between 0 and 1 by dividing:
    int analogInt = analogRead(<your port here- e.g. A0>);
    double analogFloat = analogInt / 1023.0

Which begs the question, did you try using a 2 wire system? Assuming just 1000 data points, and a finger being, say, 5cm in length; that's roughly 1 point per .05 mm. I know it won't work out exactly like that, but that is my point - it is likely to be a rough estimate anyway due to the size of a finger at the touch point.

I didn't try the 2 wire system yet. I wasn't sure if it would work, and wanted to do a little research first. The 4 terminal sensing sounds interesting too.

Thanks for taking the time to answer my question. Because it has been put on hold, it is most likely going to just end up in a black hole on here and eventually be deleted.

:-( hopefully my reply helped you even if this topic is unwelcome here

It is helpful. Thanks!


text:
How to start a dendrometry dimension build (Dimensions of Trees) for research?
I am looking to build a device that can measure the dendrometry fluctuations of trees (etc). I essentially want to build this https://publiclab.org/notes/kinasmith/09-09-2016/dendrometers to a t but I don't know where to start. I have admittedly pretty limited knowledge of arduino/microcontrollers and microcontroller kits and sensors.

The tension meter from that link does not measure the circumfence. I measures the force from displacing a small part of the string. Do you really want to measure the circumfence?

I don't care about the actual circumference measurements, but I do need to wrap the string around a circular object and measure tension changes. What sort of device would I use to get started or what should I read up on?

I don't really understand the whole setup, but you can build a tension meter like in the link yourself by using a load cell

I am attempting to measure dendrometry dimensions of trees if that helps and want to do a setup like this but I am a beginner at this https://blog.adafruit.com/2016/10/25/using-circuits-sensors-to-study-dendrometry-dimensions-of-trees-in-alaska-citizenscience/

edited question for clarity

design and contruction of any sensor is not related to arduino

try using a sewing tape measure for the sensor band ... sewing tape measure is usually made of fiberglass or something similar and does not stretch .... you can determine its suitability by using it to measure the circumference of a tree at intervals ... if found suitable, then proceed with the construction of the sensor itself

The measuring principle, that is describe in that link, is quite cool and simple.
The string is wrapped around the tree. One end is connected to a fixed point (here the casing of the sensor). The other end is connected to a spring, which in turn is again connected to a fixed point. As the tree get's bigger, it will pull at the string. At the first side of the string nothing happens (because it is a fixed point). But the end with the spring will move according to the force of the tree. Force and displacement have a linear relationship for a spring (as long as you don't overload it): F = k*x with the force F, the spring constant k and the displacement x.
The displacement of the springs end can be measured with a linear potentiometer. That is just a simple strip of resistive material with a glider, which can be set to any position at the strip. It will create a voltage divider, giving you an analog voltage depending on the position (most potentiometers are linear, but there are also others). Connect both ends of the potentiometer to Vcc (supply voltage) and ground respectively and the glider to an analog pin of the Arduino. Then you can measure the voltage with analogRead().
As jsotola mentioned in his comment: Be sure to use a string, that will not stretch too much, as this will make your measurement less precise.

thanks @chrisl, this is starting to make sense to me. The only part that i'm not understanding is why the spring is necessary and how to actually set up the potentiometer to measure the displacement of the spring.

get a string and a rubber band (spring) and a couple of small nails and try it out on a tree .... attach the string to the tree and then put your hand under  the string to simulate tree trunk expansion ... see how the end of the string moves .... now try it without the rubber band

Would you use a gliding potentiometer or a Softpot? Forgive me if this is the same thing, I may be confused here.


text:
Help combining digital and analog code in arduino programming
So I'm making a device that does 3 things,

Measures frequency of an audio signal through a microphone
Checks whether there is a weight placed on a pressure pad (my pressure sensor works through the resistance of the material changing when a weight is placed on it)
Measure ambient room temperature

I have coded each individual section and tested them individually to find them work great, here are the sketches.
Frequency sketch :
// runs every time thru the loop
  setInputState();

  // count every transision HIGH<->LOW
  if (inputState != lastInputState) {
    count++;
    lastInputState = inputState;
  }

  if (millis() - previousCountMillis >= countMillis) {
    previousCountMillis += countMillis;

    // show Hz on Serial too if available
    Serial.print(count);
    Serial.println(" Hz");
    ledtest = count;
    // reset to zero for the next half second's sample
    count = 0L;
  }
  if (ledtest >= 400 && ledtest <= 850){
    digitalWrite(A2, HIGH);
  }
  else if (ledtest < 400 || ledtest > 850){
    digitalWrite(A2, LOW);
  }
}

Here is the pressure sensor sketch
int Vin = 5;
float Vout = 0;
float raw1 = 0;

int R1 = 770;

int R2old1 = 0;

int R2new1 = 0;

int R2avg1 = 0;

int pressurelog = 0;

void setup() {
  pinMode(A0, INPUT);             //Receive pressure voltage
  pinMode(A1, OUTPUT);            //Red led, PRESSURE PAD
}

void loop() {
  raw1 = analogRead(A0);
  Vout = raw1*5/1024;
  R2old1 = Vout*R1/(Vin-Vout);

  raw1 = analogRead(A0);
  Vout = raw1*5/1024;
  R2new1 = Vout*R1/(Vin-Vout);

  R2avg1 = (R2new1+R2old1)/2;

  Serial.print("Resistance: ");
  Serial.println(R2avg1);

  if (R2avg1 >= 1000){
    digitalWrite(A1, LOW);
    pressurelog = 0;
  }
  else if (R2avg1 <= 1000){
    digitalWrite(A1, HIGH);
    pressurelog = 1;
  }
}

here is the temperature code
float raw = 0;
float tempC = 0;
float tempF = 0;

void setup() {
  pinMode(A5, INPUT);
  pinMode(A1, OUTPUT);
  Serial.begin(9600);
}

void loop() {
 raw = analogRead(A5) * 0.004882814;
 tempC = (raw - 0.5) * 100.0;
 tempF = (180.0/100.0)*tempC + 32.0;

 Serial.print("temp: ");
 Serial.println(tempF);
 delay(1000);
}

I coupled the "void loop" of all three and defined everything and ran the code to give a peculiar output. It does the temp and pressure reporting just fine but seems to constantly skip the frequency measurement. It seems to like doing the pressure and temperature measurement like 50 times then do an audio measurement which doesn't make sense as it should do it sequentially.
I TRIED:

adding a delay between the frequency measurement and the other two. This didn't work as now the audio measurement work, as it relies on the millis () function
adding the 3 components in 3 different functions and calling them sequentially. This results in the exact same stupid output.

Does anyone have an idea or solution?
Combined code:

int Vin = 5;
float Vout = 0;
float raw1 = 0;

int R1 = 770;

int R2old1 = 0;

int R2new1 = 0;

int R2avg1 = 0;

int pressurelog = 0;

const byte inputPin = 2;

boolean inputState = false;
boolean lastInputState = false;
long count = 0L;
int ledtest = 0L;

unsigned long previousCountMillis = millis();
const long countMillis = 500L;

void setInputState() {
  inputState = digitalRead(inputPin);
}

int crylog = 0;

float raw = 0;
float tempC = 0;
float tempF = 0;

int templog = 0;

void setup() {
  pinMode(inputPin, INPUT);       //Receive microphone data
  pinMode(A0, INPUT);             //Receive pressure voltage
  pinMode(A1, OUTPUT);            //Red led, PRESSURE PAD
  pinMode(A2, OUTPUT);            //Blue led, FREQUENCY/CRYING
  pinMode(A3, OUTPUT);            //Green led, TEMPERATURE
  pinMode(A4, OUTPUT);            //Red led, MAX WARNING
  Serial.begin(115200);
}

void loop() {
  Serial.println("HI");
  Cryometer();
  delay(2);
  Serial.println("YO");
  Pressure();
  Temperature();

  // WARNING SETUP
  if (pressurelog == 1 && templog == 1){
    digitalWrite(A4, HIGH);
  }
  else {
    digitalWrite(A4, LOW);
  }
}

void Pressure() {
  raw1 = analogRead(A0);
  Vout = raw1*5/1024;
  R2old1 = Vout*R1/(Vin-Vout);

  raw1 = analogRead(A0);
  Vout = raw1*5/1024;
  R2new1 = Vout*R1/(Vin-Vout);

  R2avg1 = (R2new1+R2old1)/2;

  Serial.print("Resistance: ");
  Serial.println(R2avg1);

  if (R2avg1 >= 1000){
    digitalWrite(A1, LOW);
    pressurelog = 0;
  }
  else if (R2avg1 <= 1000){
    digitalWrite(A1, HIGH);
    pressurelog = 1;
  }
}

void Cryometer(){
  // runs every time thru the loop
  setInputState();

  // count every transision HIGH<->LOW
  if (inputState != lastInputState) {
    count++;
    lastInputState = inputState;
  }

  if (millis() - previousCountMillis >= countMillis) {
    previousCountMillis += countMillis;

    // show Hz on Serial too if available
    Serial.print("Frequency: ");
    Serial.print(count);
    Serial.println(" Hz");
    ledtest = count;
    // reset to zero for the next half second's sample
    count = 0L;
  }
  if (ledtest >= 400 && ledtest <= 850){
    digitalWrite(A2, HIGH);
    crylog = 1;
  }
  else if (ledtest < 400 || ledtest > 850){
    digitalWrite(A2, LOW);
    crylog = 0;
  }
}

void Temperature() {
   raw = analogRead(A5) * 0.004882814;
   tempC = (raw - 0.5) * 100.0;
   tempF = (180.0/100.0)*tempC + 32.0;

   Serial.print("Temperature (F): ");
   Serial.println(tempF);
   Serial.println();

  if (tempF >= 75 && ledtest <= 50){
    digitalWrite(A3, HIGH);
    templog = 1;
  }
  else if (ledtest < 50 || ledtest > 75){
    digitalWrite(A3, LOW);
    templog = 0;
  }
}

So post your combined code. You also need to combine the setup() functions and make sure you don't have any pin conflicts (hardware) or naming conflicts with your variable names (software)

Sorry forgot the combined code, but to answer to rest of your post; I have done all of that and made sure it should run perfect, it seems to execute the frequency analysis perfectly but for some reason just doesn't want to do it with every cycle of doing pressure&temp.

Your approach is globally sound. However, the code that measures the
input frequency is very time sensitive. Thus, you have to make sure this
piece of code is never delayed by anything else. This means that
everything in your sketch should be fast and non-blocking.
I see a few instances of blocking behaviour you should get rid of: the
call to delay() and the serial prints. The first is particularly
useless, so just remove it. Printing to the serial port is fine as long
as you do not try to print too much. If you try to print at every loop
iteration, you end up filling the output buffer. From there on every
print becomes a blocking call: the serial library has to wait for the
port to send out the data, until there is enough room in the buffer for
what you want to send. The solution is to throttle down the output rate
by only printing once in a while. You have done this brilliantly in the
frequency-meter code:
if (millis() - previousCountMillis >= countMillis) {
  previousCountMillis += countMillis;
  Serial.print("Frequency: ");
  Serial.print(count);
  Serial.println(" Hz");
  // ...
}

Now you just have to apply the same technique to every instance of
Serial.print() and Serial.println(). Well, maybe the "HI" "YO" could
just be removed instead...
Once you remove these blocking behaviors from your sketch, it will
probably run fast enough for the frequency counting to perform
correctly. There is still something you may want to optimize though: the
computations in Pressure() are horribly inefficient, especially
considering that you have an 8-bit CPU with no hardware floating point
support. If you need to average, I suggest you average the analog
readings rather than computed resistances. Also note that computing the
voltage at the analog pin is completely useless:
void Pressure() {
    int raw = analogRead(A0) + analogRead(A0);
    float R = (float) R1 * raw / (2048 - raw);
    // ...
}

You may even replace float by long if you don't need a resolution
better than 1 Ω.


text:
why arduino can not write to server?
i write a code for Arduino + SIM800 for connecting to server.
but it don't work!
SerialGsm.println("AT+CIPSEND=63\r\n");
delay( 1000 );
receive_message();
SerialGsm.print( "GET http://sasasas.ir.ir/hadi/signal.php?value=10" );
delay( 10000 );
receive_message();

all thing is true but "GET" can not retrun "OK".
it is arduino response:

AT
OK
Call Ready
SMS Ready
AT+CSTT="mtnirancell"
OK
AT+CIICR
OK
AT+CIFSR
100.65.157.141
AT+CIPSTART="TCP","sasasas.ir",80
OK
CONNECT OK
AT+CIPSEND=63

GET http://sasasas.ir/hadi/signal.php?value=10

"get" dont have response.what is wrong in this code?

Learn the proper format of a GET request.

Firstly you only have half of the first line of a GET request. Secondly the half you do have is badly formatted.
A GET request does NOT look like this:
GET http://jalambadani.ir/hadi/signal.php?value=10

A GET request DOES look like this:
GET /hadi/signal.php?value=10 HTTP/1.1
Host: jalambadani.ir
Connection: close
[extra blank line]

If you don't send the correct data you can't expect to get any response back.  You should learn the basics of what you are trying to do instead of just throwing random text a a web server.

Here is a full transcript of a GET request to your URL:
$ telnet jalambadani.ir 80
Trying 185.211.56.148...
Connected to jalambadani.ir.
Escape character is '^]'.
GET /hadi/signal.php?value=10 HTTP/1.1
Host: jalambadani.ir
Connection: close

HTTP/1.1 200 OK
Date: Tue, 25 Jun 2019 22:47:07 GMT
Server: Apache/2
X-Powered-By: PHP/5.6.35
Upgrade: h2,h2c
Connection: Upgrade, close
Vary: User-Agent
Content-Length: 31
Content-Type: text/html; charset=UTF-8

New record created successfullyConnection closed by foreign host.

In code that would be:
SerialGsm.print("AT+CIPSEND=83\r\n");
delay(1000); // I hate that. Look for a proper OK instead.
SerialGsm.print("GET /hadi/signal.php?value=15 HTTP/1.1\r\n");
SerialGsm.print("Host: jalambadani.ir\r\n");
SerialGsm.print("Connection: close\r\n");
SerialGsm.print("\r\n);

thank you for your answer. i am electrical student and i don,t know about http...but i will try learn it.
i test your answer but it don,t work yet:|
"GET" don,t answer to me.@Majenko

PHP has nothing to do with it. You are talking in HTTP.

Did you try majenko's suggestion - which looks like it does work - running against your server - using telnet?? Once you see how that works translate that to your arduinon code. Don't reach for the final solution in the first attempt if it is too far away. Take it one step at a time. Copy majenko's telnet example -> learn the protocol. Then transfer the protocol to your app.

yes i use of majenko's suggestion.
  SerialGsm.print("AT+CIPSEND=50\r\n");
  delay( 3000 );
  receive_message();
  SerialGsm.print( "GET /hadi/signal.php?value=15 HTTP/1.1" );
  delay( 3000 );
  receive_message();

not work.

@hadisamani1996 What about the Host: and Connection: headers, along with the extra blank line? They are all part of the request. You have to send all the request.

i resolve it with your help@Majenko
i have 2 mistake.
first you saw and when i use of this line it solved.

SerialGsm.print( "GET /hadi/signal.php?value=150 HTTP/1.1\r\nHost: jalambadani.ir\r\n\r\n" );

two
next of " GET command " i use of a little delay.
i increase it a little and next solved my problem
thank you

Since Majenko helped you, you should accept his answer by clicking the little grey checkmark (tick mark) next to his answer.

nitpicking: why not println?

Depending on the system println could end with \n, \r or \r\n. Better to be explicit here.

HTTP specification requires \r\n. Arduino println() adds \r\n on all cores

@Juraj that can't be guaranteed. Certainly all cores should do it but there are so many written by so many different people with different skill sets that it can't be 100% guaranteed.

Print class is copied. there is nothing to change in println. if some core would change it, it would have an issue in the tracker immediately. basic examples of networking libraries would not work


text:
Logging data to SD card from software serial
I have an Arduino Uno and an Adafruit data logging shield and I have connected a digital pressure sensor that uses serial communication. The sensor requires a character to start transmitting data. I have managed to read the data using this code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8,9);

int depth;

void setup() {

    Serial.begin(9600);
    mySerial.begin(9600);
    mySerial.print("C");

}

void loop()
{

 if (mySerial.available()) {

   depth = mySerial.read();

 }

}

This returns the following:

C1000
  C1000
  C1000

where 1000 is the value.
I have written another code that logs data to the shield and tested with other sensors but I cannot log data from this sensor by modifying the above code and cannot find any relevant examples.
If I add something like this it does not return the same value.
logfile.println(depth);

Complete newbie in so any suggestions are welcome.
UPDATE

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

use the C as the line start indicator. if received char is 'C' then do a file.println(); example with output to Serial
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8,9);

void setup() {
    Serial.begin(9600);
    mySerial.begin(9600);
    mySerial.print("C");
}

void loop() {
 if (mySerial.available()) {
   char c = mySerial.read();
   if (c == 'C') {
     Serial.println();
   }
   Serial.write(c);
 }
}

But this code does not do anything different than the simple code. My problem is not that I am not reading the data or that I do not see the data printed in the serial monitor. I do receive all the data. The problem comes when I try to log the data. I think the data come in so fast from the serial, but when I add delays everything is messed up.

it prints completely different then the code in Question. did you try it?

Yes I tried it. It prints the same with a gap between its measurement. Also it uses a lot more of the dynamic variable. But it prints the same with a gap between each C1000

is it not what you want? every set on a new line?

No. I want to log the data to an SD card. When I use this code to log I get one number every second. I have added a screen shot in the original post. I want to get all the 4 numbers in one second and then the new 4 numbers in the next second.

you stil have println instead or write or you look at lines recorded before the change

I have completely removed the serial.println () after the if but it does not change anything

in my Answer you have a complete sketch. run it as it is. don't change anything

I have run it as it is. The update I have added in the original post is when I run this sketch. It still prints its byte in a different line. 6171 is one reading and the code returns it in 4 seconds and its number in a different line

do you have 9600 baud set in Serial Monitor?

does the device send data at 9600 baud?

yes to both questions. When I use the sketch I posted initially (at 9600) it returns the data in one line as expected continuously. I get this problem when I add any type of delay. For example when I log every 1 s, I get the problem I mentioned.

you can't add a delay. the device doesn't stop to send data, the serial buffer overflows and some part of he data will be lost

So how can I log this data? There is no way?

you could after the delay first read the buffer clean (read SERIAL_RX_BUFFER_SIZE count of bytes), the wait for C and read until next C


text:
Arduino UNO - Fluctuation of inputs and outputs

I have some pots (100K) on my Arduino board. When I raise the value of one those resistance other pots are being changed (Not too much but it's significant). I have no idea what's going on. I tried to use a capacitor at the beginning of the circuit but didn't work.
These fluctuations change the value of my sensors too. When I raise the value of something other quantities change.
I'm powering up my Arduino using a USB cable.
Any ideas?

Please show a wiring diagram

This is usually because there is only one ADC in the chip. That ADC is multiplexed between inputs. You should do multiple reads of each input. Discard the first few readings, and then take an average of a few readings.

@Majenko Don't you think it takes too much time to do? Besides I need other pins too. Of course, there may be no other choices!

This is expected if the resistances of the pots is above 10 kΩ. Is this the case in your circuit?

@EdgarBonet Yeap. It's 100K!!

You seem to be experiencing cross-talk between the analog channels. This
happens because all the channels are funneled by an analog multiplexer
into the same sample-and-hold capacitor. If the source resistance is too
high, then the capacitor does not have enough time to charge to
the voltage of every channel.
Here is what the datasheet of the ATmega328P says about the
issue:

The ADC is optimized for analog signals with an output impedance of
  approximately 10 kΩ or less. [...] The user is recommended to
  only use low impedance sources with slowly varying signals, since this
  minimizes the required charge transfer to the S/H capacitor.

The problem can be mitigated by reducing the source impedance using a
capacitor at every pot wiper, or by giving more time to the
sample-and-hold circuit: make many dummy readings before the one reading
you want to keep. The proper solution would of course be to replace the
pots with 10 kΩ pots.


text:
How do I write an Arduino program to an AVR chip without the Arduino bootloader?
Is it possible to write an Arduino program to an AVR chip that does not have teh Arduino bootloader installed?  What is the process to do so?

Step 1: Get yourself a programmer.
This can be anything from a USBasp to an Arduino programmed for ISP all the way to an AVR ONE!. Some can be used from the IDE, and some cannot.
Step 2: Set up the chip as expected from the entry in boards.txt and from the datasheet.
Add a crystal, decoupling caps, whatever. Don't connect power yet.
Step 3: Connect the programmer.
If using ISP, connect the ISP pins. If using JTAG, connect the JTAG pins. If using something else, see the programmer and chip documentation for connection details. You may want to connect power at this point for the next step.
Step 4: Program fuses.
Program the oscillator, BOR, CKDIV8, EESAVE fuses as desired/required. Fuse calculator.
Step 5: Compile the program and write it to the chip.
If using the IDE, select the programmer in Tools | Programmer and then hold shift when clicking the Upload button (or press Ctrl-Shift-U). If your programmer is not supported by the IDE then compile the program (Sketch | Verify/Compile or Ctrl-R), locate the temporary directory it has been built in, and use avrdude or your JTAG program to upload it to the programmer.
Step 6: There is no step 6. You're done.
I just wanted to see if you would read this far.

Step 7: Write a comment acknowledging the fact that you read step 6...

If there are no memory restrictions (too large program) which eliminates this option, I'd try to write the Arduino bootloader first and then continue normally. This has the advantage of simple reprogramming if required.


text:
Can I specify that analog pins be used for digital output?
http://arduino.cc/en/Reference/pinMode notes that

The analog input pins can be used as digital pins, referred to as A0, A1, etc.

Is it possible to configure these pins as digital output pins as well?

Yes.
http://arduino.cc/en/Tutorial/AnalogInputPins states

The analog pins can be used identically to the digital pins, using the aliases A0 (for analog input 0), A1, etc. For example, the code would look like this to set analog pin 0 to an output, and to set it HIGH:

pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH)

There are several caveats on that page regarding this.

Good clear answer and very informative link. (voted)

Wait. You answered your own question? Was this a teaching post, or did you find the answer through research after posting your question?

A combination.  I had thought I heard it was the case, but the pinMode documentation wasn't clear. When I found the AnalogInputPins page I thought it would be nice to tie those together.

One more detail: the ATMega 328P in some packages (not including DIP) can support A6 and A7 analog inputs.  While the UNO does not provide pinouts for these (ie: they are unconnected), many clone Arduino Pro Mini boards do.  And these two pins are Analog Inputs only, no Digital I/O functionality.  The other Analog Input pins are as you note also digital I/O compatible.


text:
Can the nRF24L01+ CE and CSN pins be attached to Arduino pins A0 and A1?
This documentation states that the CE and CSN pins can be specified.  Can I specify A0 and A1 as these pins?

Yes, you can. The mirf library is using the regular arduino functions pinMode and digitalWrite to manipulate the pins. So A0 and A1 should work as expected.
Please note that when you use SPI (which the NRF does), you have to use pin 10 (SS) as an OUTPUT (as to not put the AVR into SPI slave mode).

I'd suggest one would use RF24 (by TMRh20) library so that they are actually using a library that has a active developer who's fixing any library related bugs.


text:
Strange values from LSM303 Magnetometer
I am having problems with values i get from Pololu MinIMU-9 boards's magnetometer. I am using Arduino-micro and the arduino library from Pololu. The sensor on the board is 3 axis accelero- and magnetometer LSM303.
The problem is - the highest value always seems to be in vertical axis, not horisontal, as i would expect.
For example, here is the data i got when i put sensor flat on the table and made 360 clockwise turn in horizontal plane:
(values are X Y Z)
-6 102 -516
-11 103 -515
-11 103 -515
-21 102 -514
-31 109 -515
-40 114 -512
-57 116 -509
-57 116 -509
-77 111 -507
-93 109 -506
-104 106 -507
-104 106 -507
-114 99 -508
-126 88 -504
-131 74 -507
-142 52 -507
-142 52 -507
-151 31 -506
-150 4 -509
-147 -27 -513
-147 -27 -513
-133 -60 -513
-119 -80 -519
-112 -87 -517
-102 -97 -521
-102 -97 -521
-89 -101 -522
-77 -101 -524
-50 -104 -527
-50 -104 -527
-43 -105 -529
-14 -98 -532
2 -92 -535
23 -92 -535
23 -92 -535
36 -81 -534
66 -54 -534
76 -32 -531
76 -32 -531
76 -21 -532
78 -7 -531
85 10 -528
91 39 -524
91 39 -524
94 50 -524
91 63 -524
76 75 -525
76 75 -525
63 82 -526
47 93 -525
44 98 -522
44 98 -522
38 104 -521
26 110 -521
26 112 -518
21 116 -519
21 116 -519
18 116 -518
12 120 -517
11 120 -515
11 120 -515
8 120 -517
5 122 -515
-5 123 -514

Turning the sensor "upside down" and then rotating it in horisontal plane again gives similar results, only Z axis has positive 500+ value.
Shouldn't the magnetometer always point in the direction of the magnetic field - in X or Y direction?
I have tried this in different rooms and buildings and got the same results.
Rotating the sensor on other axes yields the same results - vertical axis has the largest (and constant) value.
For reference, here is the code i used to get the values.
#include <Wire.h>
#include <LSM303.h>
LSM303 compass;

void setup()
{
  Serial.begin(115200);
  Wire.begin();
  compass.init();
  compass.enableDefault();
}

void loop(){
  compass.readMag();
  Serial.print(compass.m.x);
  Serial.print(" ");
  Serial.print(compass.m.y);
  Serial.print(" ");
  Serial.print(compass.m.z);
  Serial.print("\n");
  delay(100);
}

The earth's magnetic field is not parallel with the ground. In some locations it can be pointing more down than across.
NOAA has a magnetic field calculator where you can enter you latitude and longitude. For example, I am located at approx  19deg S 147degE and the field is
North Comp    East Comp    Vertical Comp    Total magnitude
32,434.4 nT   4,280.6 nT   -36,035.1 nT     48,670.7 nT

So the downwards strength is more than the other two combined for my location. I'm guessing the calculator will also show a very strong down component for your location.
Some other things to be aware of are that the LSM303DLHC magnetometer can have quite large offsets, up to the equivalent of 2 earth magnetic fields, and therefore requires calibration. Also hard and soft iron distortions can affect the readings.
Edit: Please see my answer here for methods to calibrate the sensor.

Thenk you, this really seems to be the case here.
`Horisontal intesity: 15,210.5 nT
Vertical component: 49,455.8 nT`