text:
Interrupt crashes code when implemented
I've got a mini weather-station with a Davis Anemometer Vantage Pro that uses a reed switch to detect rotations. Using the rotations it then can convert to MPH. When using it alone, I have no problem measuring the wind speed. It measures the rotations over a 3 second period, and finds the average wind speed over those 3 seconds; however, when implemented into a group of code that also writes Temperature, Humidity, and Accelerometer data to an SD card, it crashes my code. For the sake of keeping this comment shorter, I am using code from http://cactus.io/hookups/weather/anemometer/davis/hookup-arduino-to-davis-anemometer-wind-speed, and am implementing into the code below. It's a big chunk, but the important stuff should be the ISR_rotation and enabling interrupts at the start of the loop.
// going to include all the libraries we need and definitions
#include "SD.h" //sd card
#include"SPI.h" //sd card
#include "SHT1x.h" //temp/humid
#include <Wire.h> //accelerometer
#include <Adafruit_MMA8451.h> //accelerometer
#include <Adafruit_Sensor.h> //accelerometer
#include <math.h> //for wind speed
//define pins and functions
#define dataPin 6 //data pin for temp/humid
#define sckPin 7 //serial clock for temp/humid
#define WindSensorPin (2) //pin for wind sensor
SHT1x th_sensor(dataPin, sckPin); //caling sht1x.h
Adafruit_MMA8451 mma = Adafruit_MMA8451(); //calling the accelerometer library

//WindSpeed stuff
volatile unsigned long Rotations; // cup rotation counter used in interrupt routine
volatile unsigned long ContactBounceTime=0; // Timer to avoid contact bounce in interrupt routine
float WindSpeed; // speed miles per hour

//SD card stuff
const int chipSelect = 10;
String dataString =""; // holds the data to be written to the SD card
File sensorData;

//Temp/Humid stuff
float humid; // humidity value
float temp_c; // temperature value

void setup(){
  // Open serial communications
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  pinMode(chipSelect, OUTPUT); //sd writing
  pinMode(WindSensorPin, INPUT); //wind data
  attachInterrupt(digitalPinToInterrupt(WindSensorPin), isr_rotation, FALLING);//""wind interrupt""

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
  // don't do anything more:
  return;
  }
  //accelerometer setup
  if (! mma.begin()) {
    Serial.println("Couldnt start");
    while (1);
  }
  Serial.println("MMA8451 found!");
  mma.setRange(MMA8451_RANGE_2_G);
  Serial.print("Range = "); Serial.print(2 << mma.getRange());
  Serial.println("G");
}

//
void loop(){
  //This interrupt portion is for incrementing Rotations
  Rotations = -22; // Set Rotations count to 0 ready for calculations
  //interrupts(); // Enables interrupts
  //delay (3000); // Wait 3 seconds to average
  //noInterrupts(); // Disable interrupts
  //convert to mp/h using the formula V=P(2.25/T) where T is the delay in seconds
  //V = P(2.25/3) = P * 0.75
  //WindSpeed = Rotations * 0.75;

  //read the temperature/humidity sensor
  humid=th_sensor.readHumidity();
  temp_c=th_sensor.retrieveTemperatureC();

  //read the 'raw' data in 14-bit counts for accelerometer
  //mma.x for x direction, mma.y for y direction, mma.z for z direction
  mma.read();
  //Convert 14 bit to SI units (m/s^2)
  sensors_event_t event;
  mma.getEvent(&event);
  delay(3000);
  WindSpeed = Rotations * 0.75;
  //read the wind speed data

  //build the data string
  dataString = String(temp_c) + "," + String(humid) + "," + String(event.acceleration.x) + "," + String(event.acceleration.y) + "," + String(event.acceleration.z);// + "," + String(WindSpeed); //to CSV
  saveData(); // save to SD card
  //for testing with serial monitor to see if we are obtaining correct values
  Serial.print("Temperature: ");
  Serial.print(temp_c);
  Serial.print(", Humidity: ");
  Serial.println(humid);
  Serial.print(" X: ");
  Serial.print(event.acceleration.x);
  Serial.print(" Y: ");
  Serial.print(event.acceleration.y);
  Serial.print(" Z: ");
  Serial.println(event.acceleration.z);
  Serial.print("Rotations: ");
  Serial.println(Rotations);
  delay(3000);
}

//
void saveData(){
if(SD.exists("data.csv")){ // check the card is still there
  // now append new data file
  sensorData = SD.open("data.csv", FILE_WRITE);
  Serial.println("Data written");
    if (sensorData){
    sensorData.println(dataString);
    sensorData.close(); // close the file
    }
  }
else{
  Serial.println("Error writing to file/Card removed");
  }
}

// This is the function that the interrupt calls to increment the rotation count
void isr_rotation () {
if ((millis() - ContactBounceTime) > 15 ) { // debounce the switch contact.
  Rotations++;
  ContactBounceTime = millis();
  }
}

When any wind information and interrupts are commented out, I have no problem at all with writing to SD card and getting the correct data from the accelerometer and sht10. I must be doing something wrong with the interrupt, but I'm not sure. I've read to not include any serial prints, delays, keep em short, etc. and it works alone. It crashes right after running the setup (before it can serial print any information), which makes me believe it's something with the interrupt. I've tried commenting out noInterrupts() and it returns trash data for rotations, so that's not usable. In case it's important, the memory usage is in the 60% range, so that shouldn't be relevant.
Thanks for any help or advice you have.
EDIT: After totally removing the interrupt() and noInterrupts() portion, I get trash data for rotations that changes depending on the debounce timing (higher debounce limit=fewer triggered rotations). I seem to get a constant Rotations range of 20-23 that does pretty accurately depict how many rotations I add (for example spinning 8 times gets me around 30). I also prettied it up the code a little bit.

I think the code besides measuring wind speed also uses interrupts. So if you are turning all of them off with noInterrupts() they cannot work either. Instead try to only disable the interrupt for Wind speed measurement

just an observation - indentation - you don't seem to want to write readable code

Your basic flaw is that you turn interrupts off (prior to commenting those lines out), and then attempt to use the SD card which almost certainly will want to use interrupts.
Your technique of turning interrupts on, and then doing a big delay, is not one I like. I comment on that sort of thing in my page about interrupts, in particular in reply #10. The essence of that reply is:

Timing an interval
I have seen example code suggesting you count things for a second by turning interrupts off for a second and then on again. I don't recommend this, because for one thing, you can't do serial prints if interrupts are off.
Example (not recommended):
volatile unsigned long events;
const unsigned long INTERVAL = 1000;  // 1 second

void eventISR ()
  {
  events++;
  }   // end of eventISR

void setup ()
  {
  Serial.begin(115200);
  attachInterrupt (digitalPinToInterrupt (2), eventISR, FALLING);
  }   // end of setup

void loop ()
  {
  events = 0;       // reset counter
  interrupts ();    // allow interrupts
  delay (INTERVAL); // wait desired time
  noInterrupts();   // stop interrupts

  Serial.print ("I counted ");
  Serial.println (events);
  }  // end of loop

(This is effectively what your code does).
That may work for simple situations, but turning interrupts off means that the Serial prints won't work until they are turned on again (which they may not be in a more complex sketch).
It is better to use the millis() result and just detect when the time limit is up.
Improved sketch:
volatile bool counting;
volatile unsigned long events;

unsigned long startTime;
const unsigned long INTERVAL = 1000;  // 1 second

void eventISR ()
  {
  if (counting)
    events++;
  }  // end of eventISR

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  attachInterrupt (digitalPinToInterrupt (2), eventISR, FALLING);
  }  // end of setup

void showResults ()
  {
  Serial.print ("I counted ");
  Serial.println (events);
  }  // end of showResults

void loop ()
  {
  if (counting)
    {
    // is time up?
    if (millis () - startTime < INTERVAL)
      return;
    counting = false;
    showResults ();
    }  // end of if

  noInterrupts ();
  events = 0;
  startTime = millis ();
  EIFR = bit (INTF0);  // clear flag for interrupt 0
  counting = true;
  interrupts ();
  }  // end of loop

In loop() here we wait for the interval (1 second in this case) to be up, otherwise we return, effectively doing nothing. You could of course do other things instead of just returning.
If the time is up we display the count.
If counting is not currently active (and presuming we want it to be active) we remember the start time, reset the counter to zero, and let it start counting up.
That code seemed to work OK up to 100 kHz, although the counts were getting a bit inaccurate. You can do more precise timings by using the hardware counters / timers. Details at my Timers and counters page.

Why are you clearing the interrupt flag in your loop code? I think, this is not needed here. I would also suggest, only attach the interrupt for the pin, when it is needed for measurement. After the measurement period is over the detachInterrupt() function disables only this particular interrupt without messing with the others interrupt sources.

Why? To avoid a spurious interrupt (event) which might have occurred before the timing recommenced.

the measurement period is over the detachInterrupt() function disables only this particular interrupt - feel free to post an alternative answer that shows how this might work.

Consider using one of the timers as a counter the the interrupts will not cause problems with the SD card.


text:
simultaneously read 16 hall sensor and maximum current allowed by Arduino
My question is about maximum current allowed by Arduino.
I know it's 200mA in Arduino and 40mA in every pin (lower in arduino mini). Just wondering if simultaneously read 16 hall sensor (than can be all activated at the same time) is too much.
My calculation is 200 / 16 = 12.5 mA máximum current I can drive to a pin from a sensor, but it's enough to read the sensor? Specs from 3144 hall sensor says it outputs 25mA when activated. Can I put a resistante between output's sensor and Arduino pin?
I'm planning to use Arduino mini and sensor hall 3144.
Sorry for my english, and thanks in advance!
p.s: The original idea was read all 64 sensors with one Arduino, but breaking it into several arduinos is easiest as my electronics knowledge is seriously limited :)

Which Arduino? Which hall effect sensor?

Arduino mini and 3144 hall sensor. I've edited the post, thanks for the appointment!

I know that i can reduce input current on each pin using resistors, but what is the minimum current to activate an Arduino digital pin?

I've seen people multiplex a grid of hall-effect sensors.

Since this sensor doesn't need to be driven directly from a pin, the maximum current for one pin is not important here. The hall sensor uses two of it's pins as supply voltage. The output pin is an Open-Collector pin. So it will be connected to GND trough a transistor depending on the magnetic field. If you use an external pullup resistor (as connection between OUTPUT and positive supply voltage), you get somewhat like a voltage divider. Since the hall sensor seems to behave as a switch, there will only be two possible states. When the magnetic field is low, the transistor doesn't let the current flow. The pullup resistor can pull the pin to the positive supply voltage (5V -> 1 as digital value). If the magnetic field is high enough, the transistor will open the connection to GND. Now a maximum of 25mA of current can flow throw it to GND. The voltage of the pin is now determined by the voltage divider the transistor and the pullup resistor build. You can calculate the virtual "resistance" of the transistor in this state with Ohm's law

R = U/I

(R is resistance, U is voltage and I is current) With 5V supply voltage and 25mA current you get a resistance of 200 Ohm. Since you just want to use the sensor as a switch, you only have to ensure, that the pin cannot be pulled to a significantly greater value than 0V. So grab a resistor, that is significantly higher than 200 Ohm and use it as pullup resistor. Keep in mind, that you always must use the pullup resistor with the supply voltage, that runs the Arduino. A higher voltage can fry the Arduinos components.
Then you connect this pin to a digital pin of the Arduino, which you configure as INPUT. In this state the pin has a high impedance, so that the current, that flows into it, is really small (it CAN source 25mA, but it does not have to. The current depends on your external circuit). So this isn't something you have to bother about.
This leaves us with the supply current, that the sensor needs to work. In the datasheet it says, that at a supply voltage of 8V the supply current is at maximum 9mA. For 16 sensors this gives us a total of 144mA, which is still comfortable inside the 200mA the Arduino can provide. So you should be able to drive all of them safely.
That said, if you want to add more components, that draw current, it might be better so source the current you need not over the Arduino but directly from your power source (if this is possible for you). Depending on the current you may need, it can also be good, to get an external voltage regulator (if your supply doesn't directly give you 5V), that can provide enough current.

So I only need to use a resistor to control the voltage from sensor to arduino , thank you Chrisl. It's complicated to calculate resistance value? I've read that typical are 10k ohm, but I guess it depends on voltage provided by external battery...

I'm a little confused with the resistor... If I have 9V as external supply, then I have to reduce this to 5V before carry this current to Arduino pin?

I edited my answer to make it clearer, what I meant. If you don't understand, what I wrote, you should read a tutorial or similar about switches and pullup/pulldown resistors. Maybe you can start here: [ https://learn.sparkfun.com/tutorials/pull-up-resistors ]

As Gerben mentioned in a comment, you could set up a matrix of the sensors.
Since the 3144 effectively is a switch to ground (when the magnet comes close it pulls the data line low) you would wire them up like a keypad matrix. I recently did an answer about a keypad matrix. If you wanted 64 sensors you would only need 16 Arduino pins (8 for the rows and 8 for the columns).
The keypad matrix I described already drives the rows low, so that is the right polarity for the sensors. You would just need a pull-up for the columns, say 10k. The sensor then just has to sink 5/10000 amps (0.5 mA) which is well within spec.
The supply voltage to the sensors can be provided independently of the Arduino (however 5V would be reasonable). Since the sensors apparently usually consume 4.4 mA, then 64 would consume 282 mA, which is probably quite reasonable to supply from the Arduino 5V pin.
The diodes mentioned in the keypad matrix answer are probably a sensible precaution if you are likely to have more than one sensor activated at once.

Hi Nick, it's a new approach for me that looks pretty good... I'll read your keypad matrix answer, thanks for your time!

Just one question about sensor matrix, it can manage several sensors activated at the same time?

(Answered by me: Yes, it can. You already specified at the end of the answer, that's the point for diodes)

source: Stack Exchange

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

sort: votes


text:
How to loop the result
int receive_pin = 2;

#define MAX 120
int value[MAX];
unsigned long time[MAX];
int changes;
int printed;

void setup() {
    Serial.begin(9600);
    pinMode(receive_pin, INPUT);

    changes = 0;
    printed = 0;
    attachInterrupt(2, change_handler, CHANGE);
    Serial.println("Receiver 433MHz setup");
}

void change_handler()
{
    if (changes >= MAX) return;
    value[changes] = digitalRead(receive_pin);
    time[changes] = micros();
    changes++;
}

void loop() {
  if (printed + 1 < changes) {
      Serial.println(time[printed+1] - time[printed]);
      printed++;
  }
}

Hi all
when i run this sketch after the result its stop and i close the serial monitor to run it again
my question how to make it run with out restart it

test the code with a button on pin 2

Without knowing what your goals are and what you expect this sketch to do, it is really hard to figure out how to help you. Please add more details, so what should this sketch do and what you want it to do. I think that Juraj's comment is right, but since the whole target of this setch seems to be to count the pulses, well, it seems strange that you don't know that you have to make a pulse on pin 2 to detect it...

atleast declare int changes to be volatile.

@frarugi87, based on the "Receiver 433MHz setup", I suspect that the source of the pulses is some other device

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


text:
Reading byte per byte from a txt file on SD Card without using the 512Bytes buffer
I am trying to read every sequenced-byte that is located on a txt file in the SD card. I have been reading quite a lot about the SPI and SD libraries, But I have found a lot of different information that makes me feel confused.

Is it really possible to read information byte per byte without buffering by default as usually happens when you use the SD or SDFat? Do you know a Library that makes it really possible?

Also, I found on the SDFile.cpp that is located in the src folder in the SD library, a part that mentions " // no buffering needed if n == 512 or user requests no buffering" How is it possible to request no buffering? I found the unbufferedread() function but I am afraid that this actually reads the number of bytes and not the information on the bytes (Is it possible?).
Do you know where may I found examples of this kind of low level functions for me to find out How may I use them  for the mentioned purpose. Or a library that would make my life easier in order to get the unbufferred read.
I want a continuous data sending into a DAC, that's why I am trying no to get the unbufferred in order to make all the data's sent as continuous as possible.

Sorry for making so many questions, I just started to use Arduino a couple of months ago  so I am not that familiarized with all the terms.
Thanks for your advise.

There are block sides transfers in SD specs. I'm not sure if there are also byte sized transfers. With SDHC and later, data on SD card is addressed in blocks, so you probably won't be able to just read a byte or two without transferring a whole block. I guess I'm saying "check the SD card specs".

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


text:
Is SRAM erased when putting Arduino into sleep_mode_pwr_down?
Question
In the interest of reducing power consumption, I am putting the Arduino into sleep mode between taking sensor readings. However, the data from readings are stored in arrays, and must not be erased when the device enters sleep mode.
For clarity, I am using sleep_mode_pwr_down, and triggering an interrupt using the Watchdog Timer on the ATMega328 chip. See this post for a description of the different sleep modes: What are (or how do I use) the power saving options of the Arduino to extend battery life?
It would be possible to address this issue by writing data to the EEPROM, however, I am unsure whether this is necessary. The question is whether putting the device into sleep_mode_pwr_down erases the dynamic memory?

Specs / Context:
Arduino Uno (ATMega328 chip)

If not, you could use an external SRAM chip - which will provide more RAM than ATmega328 gives anyway.  You can find them with a quick google search: e.g. SRAM 1Mbit.  Standby current is well below 10 uA.

Thanks @MichaelT, it appears from some prototyping I have just done that it is indeed the case that SRAM is not erased (based on dynamic memory within the system). I plan to test this further as this seems somewhat unexpected, but will update this post with any major developments.

Generally, Atmega sleep modes do not erase RAM. Their memory is static and as long as voltage (above 2.7V I believe) is applied, data is held.
However, this also depends on how you plan to wake up the device.
If it receives a RESET, RAM is cleared and program execution starts from the beginning.

If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU is then halted for four cycles in addition to the start-up time, executes the interrupt routine, and resumes execution from the instruction following SLEEP. The contents of the Register File and SRAM are unaltered when the device wakes up from sleep.

Check out the AVR's sleep modes to see which fits your application best and how to safely wake it up again

Note that, on reset, the RAM is erased by software (the libc startup code), not by hardware. You can put data in the “.noinit” section if you want to preserve it through a reset.

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


text:
NEED Help With Servo motor
I have just bought a MG90s tower pro servo for my school project and there is a problem. As soon as I connect my servo to the cnc shield or directly arduino, the whole arduino board turns off. I believe the motor is aking very high power. I even tried to power the motor with a 5v 2amps adapter, but still it turns off.I checked the resistance between the input wires and the wires to DC motor which was very high. As soon as I connected motor to external supply, there was a huge voltage drop. The voltage became almost negligible. DC motor was working fine alone. The servo hasn't even rotated for 1 degree. Please give me a quick solution as I am in a hurry for school deadline is coming. Should I buy a new servo or am I doing something wrong?
Please be quick.
Thank you.
Circuit diagram is below...]1
The code is below -
#include <Servo.h>

Servo name_servo;

int servo_position = 0;

void setup() {

name_servo.attach (9);

}

void loop() {

  for (servo_position = 0; servo_position <=180; servo_position +=1){

    name_servo.write(servo_position);
    delay(10);
  }

  for (servo_position=180; servo_position >= 0; servo_position -=1){

    name_servo.write(servo_position);
    delay(10);
  }
}

"Please give me a quick solution as I am in a hurry for school deadline is coming".  Don't ask questions like this on SE and expect people to be kind to you!  Please read the tour page.

This is not answerable. How have you connect anything? Please show a schematic. And please show your code.

The servo hasn't even rotated for 1 degree.

This is fine, until you apply a control signal nothing much should happen.

As soon as I connected motor to external supply, there was a huge voltage drop. The voltage became almost negligible. DC motor was working fine alone.

This is a problem; it sounds like your servo is shorted, busted, kaput, no good.

I found different sources, that state stall currents for this servo between 0.2A and 0.8A, so a 2A power source should be enough for one of these.
From your wiring diagram (which looks good) I guess, that the Arduino is provided with power by other means (maybe USB). If not, please try it that way. You can easily use a USB power bank or a externally driven USB hub, if you don't want to risk your PCs USB ports with a currently unknown error.
Your code is also ok (it's basically the sweep example code of the servo library).
So there are only 2 possible culprits left:

The servo: It might be damaged. I have seen some forum entries, that there are many cheap versions of this servo, which don't meet most quality standards. Depending on where you bought it, it might also been DOA (Dead On Arrival: broken, when it reached you). You should try to connect it with a capable power source (without any connection to an Arduino) and measure the current draw. If the current is too high (or the voltage again dips), disconnect it directly and throw it away.
The power source: You didn't write, what power source you used exactly. It might be the case, that it is broken, or that it does not provide the specified amount of current. Some power sources can break on a short (or on drawing too much current). You might have created a short while experimenting and broke it. Then you need a new power source.

Test the servo first, with a fresh power source.

Your conclusion is correct. The servo motor is asking a lot of current.
You need a power supply that is more than 2amps. Connect the grounds (the servo black wire to the Arduino GND). Don't let the current for the servo motor go through the Arduino board. Use wires for the servo motor that can handle high currents. Don't let the power for the servo motor go via a breadboard, because the small metal contacts of a breadboard are not for high currents.
Can you get a smaller servo motor?
Could there be something wrong with the 2 A power supply? Is it a certified and good quality power supply?
Tower Pro does not tell what the stall current of the MG90S is: www.towerpro.com.tw/product/mg90s-3/


text:
How to setup OpenCV with Arduino?
My question is how to do it (set it up), not if I can do it or with what Arduino.
I've previously setup OpenCV with Visual Studio 2015. It was a tough one, but I made it through. Now I want to set it up so that it would work with the Arduino and its IDE.
How should I proceed? Is there any specific things to do?
My setup:

Windows 7
Arduino IDE 1.8.1
OpenCV 3.1

Which Arduino? It's unlikely the AVR-based ones will have the resources to run this library. Not sure about the ARM-based units.

I wanted to use an Pro Mini, but I'll upgrade if necessary.

Not a chance. Maybe on a Raspberry Pi, but never an Arduino - unless it's one of these strange Intel things that are being marketed as Arduino these days. Basically you need an OS (Linux) to run OpenCV - something a real Arduino will never ever run.

If you are thinking of using OpenCV with a "normal" Arduino, such as the Uno or Mega, then think again. OpenCV runs on a computer - be that a desktop computer or an embedded computer. Basically you need an operating system; "normal" Arduinos don't have an operating system.
It may be possible to run OpenCV on an Arduino that runs Linux (some of the strange Intel things that are being marketed as Arduino do, as does the Yún), but in that case you will be writing a Linux application, not working in the Arduino IDE. You would need to treat it as a normal Linux computer and use the normal Linux tools for developing on it (note that OpenWRT that the Yún runs is tricky to develop for - the best way is to cross-compile on a real computer running Linux using the OpenWRT "Buildroot" system).

As some people said before, you just can't run OpenCV on Arduino.
but, you can use Arduino/Raspberry Pi to capture information and send it to a server for analysis. For example, Azure, Bluemix or your main computer.
In your case, I would use Raspberry Pi + camera to capture images/videos.
then, send it through Wi-Fi to a server. Then, on the server, process all images using OpenCV.


text:
Multiple I2C BREAKOUTS with pull-up resistors doesn't work [UPDATE]
[UPDATE] Now it works fine but the as soon as I add the GY-521 module (hardware not software), it starts sending me crapy info
Project uses:
Arduino Pro Mini as brain
FTDI as a programmer
GY-521 gyro/accel
MPL3115A2 baro/altimeter
DS3231 real time clock
Micro SD card adapter to datalog
The GY-521, MPL3115A2 and the DS3231 uses I2C and they are breakout boards so they include pull-up resistors on the board. Now the GY-521 and the MPL3115A2 works fine together but as soon as I add the DS3231, it all freezzes. My code is fine and I'm sure of that.
Now my theory is that all of those pull-up resistors caused some kind of problem in the circuit. I know that normal I2C require 4.7k ohm pull-up resistors. Now I BELIEVE that the GY-521 uses 4.7k pull-up resistors, the MPL3115A2 uses 10k pull-up resistors and the DS3231 also uses 10k pull-up resistors.
I don't know if this setup could work and I would like to know if I can add some external resistors to calm the whole I2C constellation a bit. Note that I do not want to sodder anything to the breakouts nor do I want to modify them.
Here is the code:
Tab1: MAIN
  //==================================================

#include <SPI.h>                        //include the SPI library
#include <SD.h>                         //include the SD card library
#include <Wire.h>                       //include I2C library
#include "I2Cdev.h"                     //include another I2C library
#include "Wire.h"                       //include another I2C library (yes, again)
#include "MPU6050_6Axis_MotionApps20.h" //include the MPU6050 library
#include "SparkFunMPL3115A2.h"          //include the MPL3115A2 library
#include <DS3231.h>                     //include the DS3231 library

//==================================================

#define testtest           //*** COMMENT THIS LINE BEFORE UPLOADING OFFICIAL CODE TO FINAL PROJECT ***

#define chipSelect 10      //pin for the CS/SS
#define led 2              //led and/or buzzer

volatile bool mpuInterrupt = false; //just one of those bools

bool ledState     = false; //state of the led and/or buzzer
bool dmpReady     = false; //state of the mpu6050

int yprInt[3];             //gyro data in a integer because the extra precision of the float is total bullshit
int altitude;              //altitude above takeoff point in meters
int altitudeCalibration;   //calibration for the altimeter
int temperature;           //temperature in degrees Celcius

float counter = 0;         //time counter, a somewhat internal clock that starts when the module starts dataloging

uint8_t mpuIntStatus;      //holds actual interrupt status byte from MPU
uint8_t devStatus;         //return status after each device operation (0 = success, !0 = error)
uint8_t fifoBuffer[64];    //FIFO storage buffer

uint16_t packetSize;       //expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;        //count of all bytes currently in FIFO

String day;                //day of the week
String ymd;                //date: year,month,day
String hms;                //time: hour,minute,second

MPU6050 mpu;               //MPU6050 object declaration as mpu
Quaternion q;              //quaternion container
VectorFloat gravity;       //gravity vector

MPL3115A2 myPressure;      //MPL3115A2 object declaration as myPressure
DS3231  rtc(SDA, SCL);     //DS3231 object declaration as rtc

//==================================================

void setup()
{
  generalSetup();

  gyroSetup();
  baroSetup();

  dataSetup();
}

//==================================================

void loop()
{
  gyro();      //read angles
  baro();      //read altitude and temperature
  timeClock(); //read day, date, time

  dataPrint();   //serial print the information

  dataLog();   //write data in sd card

  timer();     //time delay and led flash
}

Tab2: SETUP
//==================================================

void generalSetup()
{
  Serial.begin(115200); //start serial communication
  Wire.begin();         //start I2C communication
  rtc.begin();          //start DS3231

  pinMode(led, OUTPUT); //led or buzzer; used to easily find a lost device
}

//==================================================

void dmpDataReady() {
  mpuInterrupt = true;
}

void gyroSetup()
{
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  TWBR = 24;
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
  //while (!Serial);
  mpu.initialize();
  devStatus = mpu.dmpInitialize();
  mpu.setXGyroOffset(220);
  mpu.setYGyroOffset(76);
  mpu.setZGyroOffset(-85);
  mpu.setZAccelOffset(1788);

  if (devStatus == 0)
  {
    mpu.setDMPEnabled(true);
    attachInterrupt(0, dmpDataReady, RISING);
    mpuIntStatus = mpu.getIntStatus();
    dmpReady = true;
    packetSize = mpu.dmpGetFIFOPacketSize();
  }

  else
  {
    return;
  }
}

//==================================================

void baroSetup()
{
  myPressure.begin();             //start MPL3115A2 communication
  myPressure.setModeAltimeter();
  myPressure.setOversampleRate(7);
  myPressure.enableEventFlags();
  altitudeCalibration = myPressure.readAltitude(); //read altitude
}

//==================================================

void dataSetup()
{
  if (SD.begin());
}

//==================================================

Tab3: FUNCTIONS
//==================================================

void gyro()
{
  float yprFlo[3]; //gyro data in a float

  mpu.resetFIFO();
  mpuInterrupt = false;
  mpuIntStatus = mpu.getIntStatus();
  fifoCount = mpu.getFIFOCount();

  if (mpuIntStatus & 0x02)
  {
    while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
    mpu.getFIFOBytes(fifoBuffer, packetSize);
    fifoCount -= packetSize;
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetYawPitchRoll(yprFlo, &q, &gravity);

    for (int i = 0; i < 3; i++)
    {
      yprFlo[i] = yprFlo[i] * 180 / M_PI; //simplify the variable for serial printing and dataloging
    }

    for (int i = 0; i < 3; i++)
    {
      yprInt[i] = yprFlo[i]; //changing the variable from a float to a int
    }
  }
}

//==================================================

void baro()
{
  altitude = myPressure.readAltitude() - altitudeCalibration; //read altitude
  temperature = myPressure.readTemp();  //read temperature
}

//==================================================

void dataPrint() //serial print all the data
{
  Serial.print(day);
  Serial.print(" ");
  Serial.print(ymd);
  Serial.print(" -- ");
  Serial.print(hms);
  Serial.print(", ");
  Serial.print(counter);
  Serial.print(", ");
  Serial.print(yprInt[0]);
  Serial.print(", ");
  Serial.print(yprInt[1]);
  Serial.print(", ");
  Serial.print(yprInt[2]);
  Serial.print(", ");
  Serial.print(altitude);
  Serial.print(" ,");
  Serial.print(temperature);
  Serial.println();
}

//==================================================

void dataLog()//wirte all the data in a note file on the sd card
{
  if (altitude > 1) //if the device is higher then 1m, then we sstart recording everything
  {
    File dataFile = SD.open("datalog.txt", FILE_WRITE);

    if (dataFile)
    {
      dataFile.print(day);
      dataFile.print(" ");
      dataFile.print(ymd);
      dataFile.print(" -- ");
      dataFile.print(hms);
      dataFile.print(", ");
      dataFile.print(counter);
      dataFile.print(", ");
      dataFile.print(yprInt[0]);
      dataFile.print(", ");
      dataFile.print(yprInt[1]);
      dataFile.print(", ");
      dataFile.print(yprInt[2]);
      dataFile.print(", ");
      dataFile.print(altitude);
      dataFile.print(" ,");
      dataFile.print(temperature);
      dataFile.println();
      dataFile.close();
    }
  }
}

//==================================================

void timeClock()
{
  day = rtc.getDOWStr();
  ymd = rtc.getDateStr();
  hms = rtc.getTimeStr();
}

//==================================================

void timer()
{
  counter = counter + 0.5;

  #ifndef testtest
  ledState = !ledState;
  digitalWrite(led, ledState);
  #endif

  delay(500);
}

//==================================================

If the problem is a general one caused by pullup resistors, having one of the boards connected without trying to talk to it will still cause problems talking to the others.  You can also test the pullup theory by adding some additional ones in parallel - if it still works with one of the boards replaced by another set of 2.2K resistors, it's probably not a resistor problem. An address problem would not affect other devices with unique addresses. Strictly speaking different boards could have different susceptibility to excessively stiff bus pull-up from multiple resistors in parallel.

In your ISR function dmpDataReady you are setting mpuInterrupt = true; - that variable should be declared volatile.

as soon as I add the DS3231, it all freezzes - can you clarify something? Are you adding the hardware and it freezes, or are you changing the code and also adding the hardware?

Software doesn't change. I havent tested the volatile yet but I know that in the example sketch they did use a volatile for that one. That might be the problem. When I add the DS3231 in the sense of the hardware. The program runs the MPL3115A2 + GY-521 = FINE. MPL3115A2 + DS3231 = FINE. GY-521 + DS3231 = PROBLEM. This is speaking of hardware.

You can't properly perform the tests you claim to have without changing the software - leaving in software which tries to talk to a chip that isn't there will cause problems, at minimum a slowdown if there is a timeout implemented, but it isn't clear that there is, in which case the program may hang.

In fact the MPU-6050 on the GY521 and the DS3231 both use I2C address 0x68.  Had you looked at the source of the header files you included for each, this would have been apparent.
By consulting the data sheet for each chip you will likely find a way to either change the I2C address by changing a configuration pin, or else to potentially enable/disable the chip by changing one with a GPIO.  This will, however, likely require surgical modification of the carrier board.
You could also move whichever device you expect to access least to a distinct "soft" I2C bus bit-banged on other GPIO pins. No endorsment is implied, but the the first such library that came up in a web search was:
http://playground.arduino.cc/Main/SoftwareI2CLibrary
you can likely find other options for yourself, or can potentially create your own.
There are also other chips in the family of the MPU-6050 which speak SPI instead of or as well as I2C, however these tend to be more expensive.

When additional resistors are added in parallel, which is what is going on when you add new I2C devices to the I2C bus, the overall resistor is lowered. This could cause a problem with devices that cannot provide enough current with a low pull-up resistance. Hence, the device will not function well when the pull-up resistance is lower than a specific value. To fix the problem, I recommend removing all parallel pull-up resistors and just keep one at each line to achieve a good resistor value of approximately 4.7 k-ohms.

According to my calculations the total pull-up is:
1 / (1/10 + 1/10 + 1/4.7) = 2.423 k

As I show on my page about I2C a 2.2 k pull-up resistor gives a reasonably good signal:

Thus I don't think the resistors are the issue. And I don't see how adding more would "calm the whole I2C constellation a bit".

Alright, I'll have to test it again. Thanks!

I think there is a clash between the DS3231 and the GY-521. If I remove either of them, the code will work fine with the MPL3115A2. But if they run toghetter, with or without the MPL3115A2, the program will not have the predicted end result. If you want, I could include the code in an edit of my question.

Adding the code to your question would be helpful.

The code has been added!

The GY-521 has 2k2 or 10k pullups according to the Arduino Playground. http://playground.arduino.cc/Main/MPU-6050


text:
Assembly for loop repeating 2 times when it's only suppose to do it once
I'm programming an Arduino Nano so I belive that this question should be qualified for this SE.
I am trying to dim up an LED using a for loop in AVR assembly.
My problem is that the cycle is repeated twice before ending, while it is suppose to end after the first cycle.
A cycle is when the red_loop is repeated 256 times (to dim the led up). At that point, the value should overflow causing the variable to go back to 0. The code should stop there, but mysteriously, it does another cycle and then it stops.
Does anyone know why?
Here is my code :
.org 0x000

ldi r16, 0b111
out ddrb, r16

ldi r16, 0xff
out portb, r16

ldi r16, 0

; ff00 pin
; ff01 value
; ff02 led

ldi r16, 0b000
sts $ff00, r16

ldi r16, 0
sts $ff01, r16

red:
    ldi r16, 0b001
    sts $ff00, r16

red_loop:
    rcall pwm

    lds r16, $ff01
    inc r16
    sts $ff01, r16
    cpi r16, 0
    brne red_loop

end:
    rjmp end

pwm:
    ldi r24, 190

pwm_pre_loop:
    ldi r17, 0

pwm_loop:
    lds r16, $ff01
    cp r17, r16
    brge off

    cp r17, r16
    brlo on

pwm_loop_check:
    inc r17
    cpi r17, 0
    brne pwm_loop

    inc r24

    cpi r24, 0
    brne pwm_pre_loop

    ret

on:
    lds r16, $ff00

    sbrc r16, 0
    cbi portb, 0

    sbrc r16, 1
    cbi portb, 1

    sbrc r16, 2
    cbi portb, 2

    rjmp pwm_loop_check

off:
    lds r16, $ff00

    sbrc r16, 0
    sbi portb, 0

    sbrc r16, 1
    sbi portb, 1

    sbrc r16, 2
    sbi portb, 2

    rjmp pwm_loop_check

you did not say what cycle means, so i am assuming that it means red_loop ..... are you sure that the red_loop repeats only two times?.... i am not very familiar with avr assembly instructions, but it looks like the red_loop repeats a lot more than two times

AVR asembly is not Arduino

What kind of Arduino is that? Unless you have something like 64K of SRAM, $ff00 is going to be out of range.

I suggest re-writing this code in C and taking a look at the assembly output of the compiler as a reference. Also, it might be a good idea to feed this into a simulator. E.g. http://www.avr-asm-tutorial.net/avr_sim/index_en.html

@jsotola a cycle is when the red_loop is repeated 256 times. After that, the value will overflow which will cause the value to be 0. At that point. It should stop

@Juraj I am programming an Arduino Nano, so this question should be qualified for this site.

@EdgarBonet. surprisingly, I can write to $ff00 with no problem. Now that I think of it, it's a little weird that it's even possible...

The address will simply be "wrapping around" and higher bits being discarded.

SRAM starts at 0x100 - you should be using that as the base for your memory accesses.

To make things easier on yourself you should define your variables in a .DSEG so you don't have to worry about the addresses. (and don't forget to ensure your code is in a .CSEG...)

are you sure that red_loop runs twice? .... how are you determining that?

@jsotola red_loop actually runs 512 times (2 times 256). I only want it to run 256 times. I know it because I have a led that is connected to it and it is suppose to light up gradually once only. But instead, it lights up gradually once, then it goes to off and does it again. Then it stops.

things may not be as you think ..... maybe the LED cycles in 128 steps

The problem is that the register r17, which you use as a PWM timing
ramp, overflows twice every time you enter pwm_pre_loop:

when you increments it past 127, it overflows to −128
when you increment it past 255, it overflows to 0.

When using a counter the way you are using r17 here, you usually have
it overflow only once per cycle: either you consider it holds a signed
number which overflows from 127 to −128, or you consider it holds an
unsigned number which overflows from 255 to 0. I guess the latter is
more common. Your code is confused about that register's signedness:

The instruction brge (named “Branch if Greater or Equal (Signed)” in
the instruction set datasheet) tests the S (sign flag) bit of the
status register, which is useful for signed comparisons.
The instruction brlo (“Branch if Lower (Unsigned)”) tests the carry
flag, which is used for unsigned comparisons.

You should decide once on the signedness of the counter, and then use it
consistently. Since here unsigned makes more sense, you can just replace
brge by brsh (“Branch if Same or Higher (Unsigned)”).
Or better yet, remove the second test, which is redundant:
pwm_loop:
    lds r16, value
    cp r17, r16
    brsh off  ; if (r17 >= r16) goto off;
    rjmp on   ; else goto on;

Note by the way that you can name your RAM variables. And you can use
some of the other available registers instead of the RAM.


text:
Find RSSI of Mobile Device Without Connecting
I have a device in which a user connects their mobile device to an arduino uno via a HM-10 bluetooth transponder.  I want to be able to calculate the approximate distance between the user and the transponder by hopefully using the RSSI methodology:
 d = 10 ^ ((TxPower - RSSI) / 20)

My goal is for the user to send a connection request to the HM-10, the uno to then calculate the distance, and if greater than x meters away, reject the request.  I realize RSSI based distance is an estimate at best but that is fine for my purposes.
With that in mind, I have two questions:
1.) Is an HM-10 able to capture the RSSI strength of a mobile device to
    calculate distance?
2.) Can it do so WITHOUT connecting first based on the
    initial request of the mobile device?

This seems to be an HM-10 question, not an Arduino question.  If you control the firmware on the HM-10, you could have it refuse (/ignore) the connection request.  But be aware that RSSI based distancing may be dissapointing, especially if you do not know the output power of the mobile.  Where people try to do it in the other direction, the beacons include their measured field strength in the advertising packet as an attempt at calibration.

What problem are you facing?
Usually, if I have a question, I try to google it myself, with reasonable results. I'll post an answer in which I'll try to help you though.

Do you have the bluetooth module working in the regular operating mode already? Tell us what you did, what worked and what didn't.

You have two questions, but what makes you think you can't find these out?
When you want to know what a device can do (and thus can't do) you should check the devices' datasheet. I believe it is this file.
Bluetooth (and gsm) devices often work by sending AT commands. For example: "AT+PIO" to set/query GPIO pins of the module.
You can send "AT+RSSI?" to get a response on the RSSI value.

Not everything can be mentioned in the datasheet though. If you can't find any sources on it, it's most likely not a feature.
The only way to add a "validation function" within the bluetooth connection code, would be to re-write the firmware of the device.
But, you could:

Connect (with everyone using the right pin)
Check their RSSI
Disconnect if it doesn't match your criteria

I'm not sure if this module can have multiple connections, I didn't really see a way to disconnect a single connection. If not, you could even toggle the power to the module to "disconnect" the client(s).


text:
Reading an MCP23S17 I/O expander port with the Arduino SPI library
I am trying to read an MCP23S17 I/O expander port B with the Arduino SPI library.
The following example is simple as possible, and I still can not get it to work.

The setup is an MCP23S17 I/O expander on a Teensy LC controller.
MCP23S17 port B pins are alternately grounded and energized.
I confirmed the pin voltages with a multi-meter.
Variable portBState is a bitwise reading of port B, and printed.
Expected output is:
10101010

Actual output is:
11111111

Sketch:
#include <SPI.h>

const uint8_t ADDR = 0x20;      //MCP23S17 address, all 3 ADDR pins are grounded
const uint8_t OPCODE_READ  = (ADDR << 1 | 0x01); //MCP23S17 read command

const uint8_t IODIRB = 0x01;
const uint8_t GPIOB  = 0x13;

uint8_t portBState = 0;                 //bit wise

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

    pinMode(SS, OUTPUT);                //configure controller's Slave Select pin to output
    digitalWrite(SS, HIGH);             //disable Slave Select
    SPI.begin();

    //IODIRB register is already configured to input by default

    SPI.beginTransaction(SPISettings (SPI_CLOCK_DIV8, MSBFIRST, SPI_MODE0));
    digitalWrite(SS, LOW);              //enable Slave Select
      SPI.transfer(OPCODE_READ);        //read command
      SPI.transfer(GPIOB);              //register address to read data from
      portBState = SPI.transfer(0);     //save the data (0 is dummy data to send)
    digitalWrite(SS, HIGH);             //disable Slave Select
    SPI.endTransaction();               //release the SPI bus

    Serial.println(portBState, BIN);    //should print 10101010
}

void loop() { }

Why is the output not "10101010"?
The controller is Teensy LC (3.3 volts) on Arduino 1.6.7.
SPI library: https://www.arduino.cc/en/Reference/SPI
More links in the comments below (I don't have enough reputation points to post more links in the question).

Teensy LC pin out: https://www.pjrc.com/teensy/card6a_rev2.png

MCP23S17 datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf

It's working now.  Here is what was missing:
A yellow jumper from the micro-controller MOSI pin to the MCP23S17 SO pin.
So the read command can travel from micro-controller to MCP23S17.


text:
Sketch will not start with external power source
NOOB Question: when my Uno is connected to an external power source it will not start running the uploaded sketch. The Arduino web site says it's because the RX pin is not connected and then gets random data.
The site suggests grounding the RX pin using a resistor (granted it suggests a 10K and I used a smaller one ) or connecting it to the TX pin.
From Why doesn't my sketch start when I power up or reset the Arduino board?

Most likely because you are sending serial data to the board when it
  firsts turns on. During the first few seconds, the bootloader (a
  program pre-burned onto the chip on the board) listens for the
  computer to send it a new sketch to be uploaded to the board. After a
  few seconds without communication, the bootloader will time out and
  start the sketch that's already on the board. If you continue to send
  data to the bootloader, it will never time out and your sketch will
  never start. You'll either need to find a way to stop serial data from
  arriving for the first few seconds when the board powers (e.g. by
  enabling the chip that sends the data from within your setup()
  function) or burn your sketch onto the board with an external
  programmer, replacing the bootloader.

From Why doesn't my sketch start when I'm powering the board with an external power supply? (Arduino Diecimila or earlier)

Because the RX pin is unconnected, the bootloader on the board may be
  seeing garbage data coming in, meaning that it never times out and
  starts your sketch. Try tying the RX pin to ground with a 10K resistor
  (or connecting RX directly to the TX pin).

Both failed for me.
What should I do?

To upload your sketch, you have to connect your uno to your system using usb cable. After that you can use any ext. supply

I uploaded the sketch using the USB port connected to my computer. The sketch runs immediately after I upload it (the motor runs). Then I disconnected the USB port and connect a 9V batery to the barrel connector. The "power on light" on the UNO is on, but the sketch does not start.

Try uploading some other sketch like blinking led connected to 13 pin then connect your uno to 9v battery and check if led is blinking or not.!

Motors use large amount of current. A 9v battery can't provide that much current, so the motors won't run.

Gerben is right. The problem was the battery. Everything runs fine on a 9V power source connected to the outlet. So, my question is, what batery should I use? The projet is a small robot with 2 "yellow dc motors"

My BOEbot robot used 5 x AA batteries, and that worked. You need to be looking at substantially larger power. A LiPo battery might do for you, they come in a range of sizes.

Try to give power through ardino with ardino adapter..try

A 9V battery as a power supply it is not. I would venture to guess your 9V is dropping to below 6 volts. If you must use batteries use several single cell batteries in series such as AA as previously suggested. If you have a wall wart try that.

The problem was, as Gerben said, the battery was too weak to run the engine.

I also had a similar problem running with an external power supply.  In my case the sketch ran but totally incorrectly .  Conected RX to ground with a 10K Ohm resistor and solved the problem.
Thanks for the info!!  Others have spent a lot more time solving this problem than I did.

I will add my little drop of experience here...   So I am using a display tm1637, having CLK in 6 and DIO in 5. When connecting the Battery (12V 3s lipo 4000mA) to Vin, the arduino will freeze, even connected to the USB, will still freeze.
Short version, Moving DIO from 5 to 7 corrected the problem, now i have my device running from USB and or battery with no problem.
Long version: after 3 hours of trying different mods, including resistor to RX,TX, to GND, even removing the ch340 chip and connecting Rts and others to GND/VCC..  Nothing, so i decided to move the different devices from One nano to Other but testing after each connection. When the display was connected, the Nano will freeze while running on battery power. So... i moved DIO first to a different pin, and the device started working.  I know is a very particular case, but one more thing to try if you are like me, stock without knowing what to do.... moving some pins (maybe skipping 5?)...


text:
Precision voltmeter using Arduino
I am newbie, I need to measure precise voltage in range 0.00-0.80V, two digits precision.
The voltage will not be greater than 1V-1.2V.
I wonder if I need divider or not, I am sure that voltage won't rise above 1.2V.
Can I connect the point to measure directly to analog input, or I still need to use divider? Please explain why.

A divider is used to (as the name suggests) reduce a higher voltage to a lower voltage.  Using a divider on a small voltage will only make it smaller and harder to measure.
To get the most out of your measuring you need to have the reference voltage as close to the highest voltage you want to measure as possible.  The highest voltage that can be applied is not dependent on the reference voltage, but the supply voltage, and as 1.2V is way less than 5V (or 3.3V on a 3.3V board) you have no worries there.
So you need to change the reference voltage - the voltage that the ADC uses as its upper measurement voltage.  That's simple enough, since many of the Arduino boards include an internal 1.1V analog reference voltage generator that you can switch to (see: analogReference())
So when you have switched to the 1.1V analog reference the ADC is capable of measuring 0-1.1V in 1024 steps.  That's 1.1/1023=0.00107V per bit of precision.
The formula is:
V = ADC / 1023 * Vref

So a reading of 1 would give you 0.00107V - a reading of 2 would be 0.00215V, etc.  That's plenty of resolution to meet your 2 decimal places requirement.
One thing to note though is that the internal 1.1V reference isn't that stable or accurate (or not even there on some chips).  If you need better stability and accuracy then it could pay to use an external voltage reference chip.  These are like a linear voltage regulator but are far more accurate and stable (and can't provide lots of current).  Pick one that is greater than your upper measurement voltage but as close to it as you can get (so just above 0.8V) and feed the output into the external ARef pin and switch the analog reference to the EXTERNAL mode.
You could use a voltage divider on the external ARef pin to provide a low reference voltage, but the stability and accuracy will be no better (and probably worse) than the internal 1.1V voltage reference, so there really is no point.

Great answer, Majenko! Just to add to it, see my post about ADC conversion on the Arduino - in particular the part about setting up reference voltages. That link takes you to the post about the TL431 voltage reference chip.

Majenko, do you have any documentation or rationale for your claim that “the internal 1.1V reference isn't that stable or accurate” ?  Per spec sheet, the 1.1V reference is an “internal bandgap reference... through an internal amplifier” which does not suggest  instabiliry or inaccuracy.

@jwpat7 Well, table 29-11 lists the voltage as between 1.0 and 1.2 with a typical of 1.1. That's a variance of as much as 20% in the actual voltage, and no practical way of measuring it. When you're working with voltages as low as 0.8V max that variance can have a big effect on your readings.

@jwpat7 Also you might like to take a look at figure 31-318 which shows the variation in bandgap voltage at different levels of Vcc and different temperatures.


text:
DHT 11 sensors and i2c LCD to Wemos Wifi not Working
Its my first time make arduino project. I make wemos d1  project using DHT11 temperature sensor and LCD 20x4 with i2c. The temperature data will display in LCD and sending to the bot telegram. For sending to the bot telegram it works, but why the data cannot display to the LCD? When I tried common charachter like "Hello World!" in the LCD it works. Can you help me? What should I do? Thanks before.
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3, POSITIVE);
#define DHTPIN D14
#define DHTTYPE DHT11

byte degree[8] = {
  0b00110,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

DHT dht(D14, DHT11);

void setup() {
  lcd.createChar(0, degree);
  Serial.begin(115200);
  Serial.println("DHT11 test!");
  lcd.begin (20, 4);
  dht.begin();
}

void loop() {
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  lcd.setCursor(0, 0);
  lcd.print("Humi : ");
  lcd.print(h);
  lcd.print(" %");

  lcd.setCursor(0, 1);
  lcd.print("Temp : ");
  lcd.print(t);
  lcd.print(" C");
}

what you should do is to give us more information. so far, all you have said is that your project does not work. you posted no circuit diagram and no code, so it is impossible to even guess what the problem might be.

Will you show us your code please, or is it "top secret"?

please add the code to your question and delete these comments ... i do not think that anyone will be able to read your code in comments

I've been add my code at my question. thank you very well

Please define "not working". Does nothing at all get displayed?

Does nothing at all

We would expect at least that Humi :  would be displayed, so this is nothing to do with your DHT11 sensor. Unless ... try putting in a debugging print after getting the sensor data. Like: Serial.println (h);

Ya, I've tried to see is that any problems with DHT11 sensor by serial monitor, the sensor works good. But when I connect it to the lcd, it doesnt work. it's confusing. Anyway, thank you for the response,

what is D14? Wemos doesn't have pin D14

what is LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3, POSITIVE)? I can't find such a constructor.

D14 is a SDA pin in wemos, and LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7,3, POSITIVE) is lcd initiation based on i2c library.

Does wemos cannot display temperature data in the lcd? I think it should be fine but why still error. For i2c wire I connect VCC to 5V, GND to GND, SDA pin to D4 and SCL pin to D3.

Oh I see, I cannot connect DHT11 to the D14 pin, because it is used for SDA(D14/SDA/D4). when I move to the pin D2, it works. Thank you every one. Sorry if I make mistake because it is my first project.

@ChoirinNisa, it is not D4, only io 4. D4 is io 2. I formulated an answer, for future readers. You could accept it.

Constant D14 is for Wemos D1 and other esp8266 dev boards mapped in arduino core to esp8266 io pin 4. Pin 4 is used as I2C SDA pin. The LCD uses I2C so pin 4 (D14) can't be used for the sensor.
from pins_arduino.h for Wemos D1 R1:
#define PIN_WIRE_SDA (4)
#define PIN_WIRE_SCL (5)

static const uint8_t D14  = 4;
static const uint8_t D15  = 5;

The origin of this confusing esp8266 io pin to Dx constants mapping is the big Wemos D1. There are esp8266 pins mapped to standard Uno pinout.


text:
Arduino Nano joystick x2 / potentiometer
will i be able to connect up all these parts to an arduino Nano
i noticed i will need to connect to the nanos v5 to the 2 joysticks and potentiometer slider if i share the voltage will it still function as intended

Parts
x1 = USB Arduino Nano V3.0 ATMEGA328P CH340G 5V 16M Micro-Controller Arduino
x2 = 3D Analog Joystick for Sony PSP 1000 Consol
+5v (possible 10kOhm resistance)
x1 = Electronic slider 10K potentiometer Slider Module for Arduino
Voltage: 3.3V or 5V / Resistance: 10K

Yes, this should work. The potentiometer slider will source about 5mA and each joystick axis about 50mA. In total this gives you 205mA. Here it is important, that your power source can provide enough current. If you are using an USB port from your computer, this would result in 500mA maximum that can be drawn from the bus. Since this is shared with the Arduino you can externally use about 400mA
For more information about current ratings refer to this question
EDIT: Since your previous resistance values were not correct, I edit my answer.
When all potentiometers have 10kOhm resistance (and this seems to be more likely the right values), each one draws about 5mA from the 5V pin (You can calculate this with Ohm's Law U = R * I, which gives you I = U / R. So you have to divide the voltage by the resistance.). So you aren't getting anywhere near the problematic currents. These potentiometers are designed this way. They don't want to draw a high amount of power, but only setting a certain voltage to the output pin.

I suspect the 100R pots are somewhat erroneously labelled. Especially as the slider certainly is incorrectly labelled.

ohh i could not find the joystick specs on that front this is my first project
this was listed as the slider i thought the 10k ment 10,000 did i get that wrong
Voltage: 3.3V or 5V
Port: Analog
Resistance: 10K

10k does mean 10,000 - but your schematic shows 1k for the slider and a mere 100R for the pots, which are almost certainly more likely to be around 10k or higher.

updated the image and info related to the parts still trying to find more info regarding the Analog Joystick Sony PSP 1000

The only way to be sure is to measure they resistance. But I also found a joystick, that is labeled as PSP on ebay. They claim to have 10kOhm resistance: Ebay

thanks for that been looking everywhere for some more info related to joystick


text:
Send Bluetooth Data to Android App (HC 05)
I'm struggling to send data strictly from my arduino UNO to an android app using bluetooth module HC 05. I am able to send/receive using 1) the serial monitor in arduino IDE and 2) Bluetooth Chat android app (a sample project in Android Studio). But when I use software serial using pins 3,2 instead of TX/RX on my UNO, the Bluetooth Chat app cannot connect to my HC 05. I think I'm missing something important.
My end goal is not to send messages like a chat. It will be a very simple flag-based system where, for example, an event occurs on my arduino which causes it to transmit character 'h' through bluetooth, which is then received by my android app. In android receive: if 'h' is read by bluetooth, doSomething(). I don't need to send anything from my android app to the arduino right now, but that would be nice to know.
I just thought I could test my bluetooth functionality with this Bluetooth Chat sample app. Now, that seems like a poor place to start.
Any suggestions are appreciated.

what do you mean by strictly? it has no meaning in the sentence that you used. ... you could have used the word joyfully and it would be just as meaningless. ... i am not trying to be snarky, i am just questioning the meaning of the word

one thing you need to do when developing hardware and developing code, you need to clearly identify the problem. ... your problem is cannot connect to my HC 05 when I use software serial using pins 3,2 ... your question should be about that, everything else that you mentioned is just a distraction from the real problem

@jsotola The serial monitor on my PC receives android messages fine. As far as I know about this, and I don't know much since I just began this android/arduino communication endeavor, the issue seems to be strictly transmission from arduino to android. Obviously the issue could be android reception. Sorry I'm spotty on the description of my issue. I'm experienced with serial communication but new to bluetooth. I suppose I could use some advice on where to start.

Another thing. People seem to be using a software serial abstraction to accomplish what I'm trying to do. But I don't understand why one would use a software serial and not tx/rx 0 and 1.


text:
Specific values not showing when using a numeric keypad
I have attached a 3x4 keypad to my Arduino Leonardo as an input method. Whenever I press the buttons, the majority of the keys work but specific ones don't. Here's my code, I've set it up to beep a piezo buzzer when it gets a keypress.
#include <Keypad.h>

int buzzerPin = 0;
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};
byte rowPins[ROWS] = {12, 13, 8, 10}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 7, 9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup(){
    Serial.begin(9600);
    pinMode(buzzerPin, OUTPUT); //Set buzzerPin as output
    keypad.addEventListener(keypadEvent); //Add an event listener for the KeyPad
}

void loop(){
    char key = keypad.getKey();
}

void keypadEvent(KeypadEvent eKey) {
        // When the KeyPad will be pressed, the results will appear on the serial monitor.
        switch (keypad.getState()) {
        case PRESSED:
                Serial.print("Enter: ");
                Serial.println(eKey);
                beep(10);
                delay(10);
                break;
        }
}

void beep(unsigned char delayms) { //creating function
    tone(buzzerPin, 2000); //Setting pin to high
    delay(delayms); //Delaying
    noTone(buzzerPin); //Setting pin to LOW
    delay(delayms); //Delaying
}

I based my rows/columns off of this pin-out: https://www.jaycar.com.au/12-key-numeric-keypad/p/SP0770,
but I later found out some of the columns had to be swapped :P
Here's a diagram of what's happening:

The keys in red do not work.
I wouldn't have posted this on stack exchange but it looks like an oddly specific pattern, and no matter what I changed, it didn't work.
(And yes, that is the exact keypad I bought from Jaycar)
Edit: I forgot to mention that I was using a prototype shield to plug the keypad into, but all pins are confirmed working on that.

If either row #2 or column #2 is used it does not work, unless both are used. Have you exchanged/mixed row #2 and column #2 somehow? There must be some logic in it. Can you disconnect the keypad and test every button with a multimeter? Please tell which arduino pins are connected to which keypad pins.

One more question: is it a cheap clone board? Because row #2 is connected to pin 13. The official arduino leonardo has a extra logic chip, so pin 13 can be used as a input without problem. Try to use another pin for row #2. Update your question with the extra information.

Agree w/@Jot, row #2 is swapped w/column #2.  Try changing your code to read "byte rowPins[ROWS] = {12, 7, 8, 10}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 13, 9}; //connect to the column pinouts of the keypad" to see if a code change can clear up the problem.

are you sure that 5 actually works?

Right so I've figured it out now (thanks to you guys), it turns out that yes in fact row 2 and column 2 were swapped around. I also forgot to mention that this was a prototype shield I was plugging the pins into, but thanks everyone for the quick and useful replies. In terms of marking this question as answered, I'm fairly new to this... Do I just quote one of you above in my answer button? Or do I requrie a moderator or something?

When @Jot sees this they will likely post their response as an answer and you can then select it as the answer.

A row against a row does not work, or a column against a colum.
That means there is a logical explanation. Row #2 is swapped with column #2.
Button 5 does work, because that still has a row against a column (but then the other way around).


text:
Communication with sensor KMX63 in I2C
I trying to use a new sensor the KMX63 with a Arduino Uno board, my sensor is on a evaluation board made by kionix.
For the connexion il linked as follows:
| Pin Uno | Pin evaluation board |
| A5 | 5 |
| A4 | 7 |
| 3.3 | 1 |
| GND | 8 |
Here the schematic of the evaluation board:

I found a technical note from the constructor that advice to do some steps after the power up of the sensor to insure it's well functioning I wrote a code following it:
#include <Wire.h>
#include "KMX62.h"

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

  Serial.println(F("Starting"));

  byte error=7;
  byte id=0;
  byte command=0;
  delay(60);
  Wire.beginTransmission(KMX62_I2C_ADD_2);
  Wire.write(0x7F);
  Serial.println(F("Write 0x7F"));
  Wire.write(0x00);
  Serial.println(F("Write 0x00"));
  delay(100);
  error=Wire.endTransmission();
  Serial.print(F("retour 1 : "));
  Serial.println(error);
  if( error==0 ){
    Wire.beginTransmission(KMX62_I2C_ADD_2);
    Wire.write(CNTL2);
    Wire.write(0x00);
    error=Wire.endTransmission();
    if( error==0 ){
      Wire.beginTransmission(KMX62_I2C_ADD_2);
      Wire.write(CNTL1);
      Wire.write(0x80);
      error=Wire.endTransmission();
      if(error==0){
        delay(5);
        Wire.beginTransmission(KMX62_I2C_ADD_2);
        Wire.write(WHO_AM_I);
        Wire.endTransmission(false);
        Wire.requestFrom(KMX62_I2C_ADD_2,1);
        id=Wire.read();
        error=Wire.endTransmission();
        if(id==0x18||id==0x2D){
          Wire.beginTransmission(KMX62_I2C_ADD_2);
          Wire.write(COTR);
          Wire.endTransmission(false);
          Wire.requestFrom(KMX62_I2C_ADD_2,1);
          command=Wire.read();
          error=Wire.endTransmission();
          if(command==0x55){
            Serial.println(F("device ok"));
          }else{
            Serial.println(F("Issue with the sensor step e : need to be rebooted"));
          }
        }else{
          Serial.println(F("Issue with the sensor step d id=wrong : need to be rebooted"));
        }
      }else{
        if(error==2||error==3){
        Serial.println(F("Issue with the sensor step c : need to be rebooted"));
        }
      }
    }else{
      if(error==2||error==3){
        Serial.println(F("Issue with the sensor step b : need to be rebooted"));
      }
    }
  }
}

void loop(){

}

but i have an issue the steps , the program seem to freeze when i try to write into the register 0x7F.
I don't get any trace that i should have after the wire.endtransmission().
Here the trace i obtain :
09:56:35.477 -> Starting
09:56:35.511 -> Write 0x7F
09:56:35.511 -> Write 0x00

i have use the I2C scanner to check if the sensor appear, i had to modify the scanner to add a delay before Wire.beginTransmission and the Wire.endTransmission to avoid the scanner to be freeze too at the first address tried. After the modification i did saw the sensor at the address it was mean to be.
here the trace for the I2C scanner :
Scanning...
I2C device found at address 0x0F  !
done

Anyone have an idea of why i can't write anything to my sensor without making my program freeze indefinitely each time ?
PS : After the advice of chrisl i rerunned all my programs on a arduino mini pro on 3.3V / 8Mhz and got the same result.

Can you explain the "delay(100)" before "Wire.endTransmission()"? You know that the "endTransmission" is actually the start of transmission.

Does the evaluation board run on 3.3V?

i didn't had understood that the transmission started only after the endTransmission. I have added the delay() because into the I2C scanner i had to add a delay(100) between the beginTransmission and endTransmission or the scanner was blocking at the address tryed

@chrisl i tryed with the both alimentation pin of the Uno the 3.3 and the 5V and got the same result

But the Uno will try to raise SDA and SCL to 5V, while the evaluation board would only raise it to 3.3V. So there will be a cross current. If you want to connect a 5V and a 3.3V device via I2C, you definitely need a level shifter.

And does that mean, that you power the evaluation board over the 3.3V pin of the Uno? You have to check, how much current the board needs. It might be too much for the 3.3V regulator on the Uno. Please check these things first and don't connect 5V to a 3.3V device, unless you really know, that it can tolerate that. You might destroy the device otherwise.

yes i powered the evaluation board with the 3.3V of the UNO, i juste do a supplement test with a mini pro 3.3V 8MHZ and i obtain the same result my program freeze but the scanner I2C does find the sensor I2C address : 0x0F

BW: What register is 0x7F? Could you add a link to the product spec you are using? The one I found did not have this register. This might be the issue. Could it be register 0x7A that you mean?

http://kionixfs.kionix.com/en/document/TN005-Power-On-Procedure.pdf
This is the technical note concerning the power on procedure for the sensor. It did looked strange for me when i read the address register 0x7F but i guessed it may be a register that we normally don't need to touch

Did you try the startup sequence from this https://github.com/ROHMUSDC/ROHM_SensorPlatform_Multi-Sensor-Shield/blob/master/Platform%20Code/Arduino_UNO_FirmwareExample/ROHM_SENSORSHLD1-EVK-101_10-20-2016/ROHM_SENSORSHLD1-EVK-101_TerminalDemo_11-10-2016/ROHM_SENSORSHLD1-EVK-101_TerminalDemo_11-10-2016.ino?

@MikaelPatel I didn't know that i try this startup sequence using the wire library but got the same result, programe seem locked with the first writing. Does the issue can come from the wire library ?

There are several hardware issues here before assuming it is software.

I finally found where the problem was, i had made a error on the reading of the schematic of the evaluation board. I thought that the pin J1-9 was already wired in intern but it was wrong. I wired it to the VCC output of my board and it work perfectly now.


text:
What is /dev/tty.usbserial-1420
I'm a complete newbie with Arduino. I've bought a couple of Nano clones from China. According to supplier description, it is Arduino Nano V3.0 ATMEGA328P ATMEGA328 CH340. Not sure why they list both 328 and 328P, but my struggle is to make it work anyway: IDE doesn't see it.
Power LED is on, L-LED is blinking regularly.
After some online reading, I conclude that the root cause may be in the USB-serial chip. My question is: if, when connecting this device to my Mac, I see a /dev/tty.usbserial-1420 device appearing, does it mean that the USB-serial interface actually works correctly? Or does it not, and I should continue trying with installing some extra drivers etc.?
I am on Macbook Pro 2015, Mac OS 10.14.3. Many thanks in advance.
The error I am getting in IDE is:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

Note: In a similar question the user didn't have the usbserial device in his /dev list.

Have you installed a CH340 driver for Mac OSX? https://arduino.stackexchange.com/a/17358/37523

The question was not how to solve the problem, but what is the device that I do see in /dev.

Also note that in the linked answer, the user didn't have the usbserial device. So presumably nothing at all was happening when connecting his Arduino. In my case, the usbserial device appears. So I don't see how this question is a duplicate.

What happens when you select /dev/tty.usbserial-1420 as your serial port in the IDE, then try to upload a sketch? Does it upload? If not, install the driver.

@VE7JRO, indeed, it didn't work, I installed the driver, it does work. That's why I am wondering what this device is.

These China clones are frequently shipped with no bootloader burned to the chip. There is a way to get it working but, you need a working Arduino or programmer to burn the bootloader. I have used an Arduino Uno to burn a bootloader on my nano. The Uno and nano were both purchased from the same seller, on the same order, from AliExpress. Here are the instructions that worked for me.
The instructions provide a link to download the Windows drivers so here’s a link to the macos drivers. CH341_MAC.ZIP (CH340 uses CH341 drivers)

This one does have the bootloader, and with the WCH driver, IDE works. I was only wondering what usbserial is, if it's not what is needed to "talk" to Arduino.


text:
DHT22 reading weird values
I just hooked up a DHT22 I had laying around in a parts drawer to test something and it is giving out some crazy wrong values, I am running the adafruit library's unified example and this is the output:
Resolution:   0.10%
------------------------------------
:   1
Unique ID:    -1
Max Value:    100.00%
Min Value:    0.00%
Resolution:   0.10%
------------------------------------
DHTxx Unified Sensor Example
------------------------------------
Temperature
Sensor:       DHT22
Driver Ver:   1
Unique ID:    -1
Max Value:    125.00 *C
Min Value:    -40.00 *C
Resolution:   0.10 *C
------------------------------------
------------------------------------
Humidity
Sensor:       DHT22
Driver Ver:   1
Unique ID:    -1
Max Value:    100.00%
Min Value:    0.00%
Resolution:   0.10%
------------------------------------
Temperature: 588.80 *C
Humidity: 998.40%
Temperature: 563.20 *C
Humidity: 1049.60%
Temperature: 563.20 *C
Humidity: 1024.00%
Temperature: 563.20 *C
Humidity: 1024.00%
Temperature: 563.20 *C
Humidity: 1024.00%

Had anyone seen behaviour like this before? of course my room isn't 600 *C or 1000% humidity XD
Its connected to an arduino UNO that I am pretty sure works fine.

Since the sensed  value exceed the max value, perhaps code error?

Arduino Mega:
"
Temperature: 716.80 *C
Humidity: 1024.00%
"
library fake :-(

Have you tried this with the standard libraries (AdaFruit_Sensor & DHT)?  Plus, it is helpful if you show the code you are using.


text:
Why does exit status 1 stray '\302' in program pop up around Serial.println ( "-> Second Service load");?
/*
 Controlling a servo position using a potentiometer (variable resistor)
 by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

 modified on 8 Nov 2013
 by Scott Fitzgerald
 http://www.arduino.cc/en/Tutorial/Knob
*/

#include <Wire.h>
#include "ds3231.h"
#include <Servo.h>
int potpin = 0; // Analog pin is used to connect the potentiometer
int val; // Variable to read the value from the analog pin
int pause = 800; // Delay in open feeders (feed amount)

Servo myservo;  // create servo object to control a servo

#define BUFF_MAX 256

// First Service
uint8_t wake_HOUR1 = 12;
uint8_t wake_MINUTE1 = 56;
uint8_t wake_SECOND1 = 0;

// Second Service
uint8_t wake_HOUR2 = 18;
uint8_t wake_MINUTE2 = 30;

// How often to update the information to the standard output (ms)
unsigned long prev = 5000, interval = 5000;

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo.write (0); // Set the position to 0

  Serial.begin (9600);
  Wire.begin ();
  DS3231_init (DS3231_INTCN);
  DS3231_clear_a1f ();
  DS3231_clear_a2f ();
  set_alarm ();
}

void loop()
{
   char buff [BUFF_MAX];
  unsigned long now = millis ();
  struct ts t;

  // Output through time (5000ms) The time and alarm clocks ustanovlennnye
  if ((now - prev> interval) && (Serial.available () <= 0)) {
    DS3231_get (& t);

    // Display current time
    snprintf (buff, BUFF_MAX, ".% d% 02d% 02d% 02d:.% 02d:% 02d", t.year,
             t.mon, t.mday, t.hour, t.min, t.sec);
    Serial.println (buff);

    // Display a1 debug info
    DS3231_get_a1 (& buff [0], 59);
    Serial.println (buff);
    DS3231_get_a2 (& buff [0], 59);
    Serial.println (buff);

    if (DS3231_triggered_a1 ()) {
      // INT has been pulled low
      Serial.println ( "-> First Service load");

  myservo.write(10);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there
  myservo.write(170);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there

      // Clear a1 alarm flag and let INT go into hi-z
      DS3231_clear_a1f ();
    }
    if (DS3231_triggered_a2 ()) {
      // INT has been pulled low
      Serial.println ( "-> Second Service load");

  myservo.write(10);                  // sets the servo position according to the scaled value
  delay(1000);                           // waits for the servo to get there
  myservo.write(170);                  // sets the servo position according to the scaled value
  delay(1000);
}

Indent your code with ordinary spaces, not with no-break spaces.

As Gerben notes, the stackoverflow question error: stray '\302' in program is about this issue.  Basically, your file contains one or more characters not valid in the current character set.  The character is either non-printing or a multi-byte unicode character.
How did the character get there? Some of the ways mentioned in the stackoverflow question are pressing ctrl-space or shift-space.
How to find the character and get rid of it?  You can look at output from hex-dumping the file, which will identify all characters definitively.  Or by trial and error you can delete and retype spaces in the region of the error.

I retyped my code on a new sketch and it uploaded successfully but i tried to change the times to see if my RTC code uploaded accurately instead of just successfully  I tried changing the numbers on wake hours and minutes and now i have a compiling error.

The error message will have a line number that points you to (or near) the line causing an error.  If the error is in one of the uint8_t wake_HOUR1 = 12; ... uint8_t wake_MINUTE2 = 30; lines, it probably is a simple typo, like an extra or missing character.  Each of those lines should be of the form uint8_t somevariablename=somevalue; where somevalue should be an integer, like 0, 1, ... 7, 8, 9, 10, 11 ... 59.  A value expressed as 08 or 09 instead of 8 or 9 would produce an error because 8 and 9 are not octal digits.  A missing semicolon or no space after uint8_t also is an error.


text:
Serial plotter isn't displaying my supplied data
I want to use serial plotter feature of Arduino by using DHT11 as humidity sensor at a time. But I'm getting problem as plotter is not loading by the code I have. Please help me what is the problem because of which serial plotter is not loading.
Here is the Code I wrote:-
#include <dht.h>
#define dht_apin0 A0 // Analog Pin sensor is connected to

dht DHT0;

void setup() {

  Serial.begin(9600);
  delay(500);//Delay to let system boot
  Serial.println("DHT11 Humidity Sensor\n");
  delay(1000);//Wait before accessing Sensor

}//end "setup()"

void loop(){
  //Start of Program

    DHT0.read11(dht_apin0);

    Serial.print("Current humidity = ");
    Serial.print(DHT0.humidity);
    Serial.print("%  ");

    delay(5000);//Wait 5 seconds before accessing sensor again.

  //Fastest should be once every two seconds.

}// end loop()

https://learn.adafruit.com/experimenters-guide-for-metro/circ08-using%20the%20arduino%20serial%20plotter

The serial plotter has no idea what to do with the text in front of the humidity value, or the % after it.

You can't send arbitrary information (percent signs, text etc) to the plotter. The plotter only understands numeric values. You have to separate these number values from each other with commas, then do a println in your last value:
Serial.print(percent);
Serial.print(F(","));
Serial.print(tankPercent(depth));
Serial.print(F(","));
Serial.print(litres);
Serial.print(F(","));
Serial.println(tankLitres(depth));

In your case, it'd be simply:
Serial.println(DHT0.humidity);

You can go a bit further if you want to switch between either serial output, or serial plotter. In one case, I just set a constant variable for graph or plain data, then have a function for each (my above Serial statements are actually within a function called displayGraph()). The data function would be something like you had originally, example:

void displayData(float depth, float percent, float litres){

  // water level depth (inches)

  Serial.print(F("current missing inches: "));
  Serial.println(mixtureDistance());

  // cubic inches

  Serial.print(F("total cubic inches: "));
  Serial.println(TANK_TOTAL_CUBIC_INCHES);

  Serial.print(F("current cubic inches: "));
  Serial.println(tankCurrentCubicInches(depth));

  // litres

  Serial.print(F("total litres: "));
  Serial.println(TANK_TOTAL_LITRES);

  // ... etc
}

I also have projects where I use a switch that if on, sets a flag to output in serial graph format, and if off, uses the serial data routine.
Then, in your sketch loop(), you'd do something like:
graph
  ? displayGraph(depth, percent, litres)
  : displayData(depth, percent, litres);

...or a bit more verbose rather than using the tertiary operator:
if (graph){
  displayGraph(...);
}
else {
  displayData(...);
}

Here's a Q&D serial plotter example of my displayGraph() function above. In the top-right corner of the image, the four colours represent the four pieces of data I'm sending in, in order:

In my case, those represent the exponential moving average of the percentage of how full a liquid tank is, the second is the raw data I'm building that average on, third is the exponential moving average of how many litres are remaining in the tank, and lastly, again, the raw data for that average.
The sharp movements are simply me slapping the tank to get some variable and unstable readings for example purposes.


text:
Reading an output analog pin with an input analog pin
I am having a hard time understanding why I can't read one analog pin's output with another analog pin. The docs state to put a delay in between, which I've done (I've tried up to one second with the same results). I've got this minimized code:
void setup() {
    Serial.begin(9600);
    pinMode(A0, INPUT);
    pinMode(A5, OUTPUT);
}

void loop() {
    for (int i=0; i<1024; i++){
      analogWrite(A5, i);
      delay(100);
      Serial.println(analogRead(A0));
    }
    Serial.println("done");
    delay(10000);
}

When it starts, it displays 6-9 for a few dozen iterations, then suddenly jumps to ~1018 and remains throughout the rest of the run.
A5 is connected directly to A0 via a 4" jumper cable. Nothing is connected to AREF. If I connect AREF to 5v, the output does not change but by a single digit. If I connect it to ground, it immediately outputs 1023.
I'm hoping this is a "do'h" moment here. Can someone please let me know what I'm not doing correctly?
Update: This is a legit Arduino Uno R3 board. When I connect A0 directly to 5v+, I get 1023 as expected as the output.

I do realize that PWM has a max value of 255, but updating the sketch changes nothing; the result is the same.

For a start, A5 is not a valid pin to do analogWrite to. On a Uno they are marked with the "~" symbol, and are pins: 3, 5, 6, 9, 10, 11.
Thus the code will treat it as a digitalWrite, and will write LOW up to 127 and HIGH after that. From the code in wiring_analog.c:
    case NOT_ON_TIMER:
    default:
        if (val < 128) {
            digitalWrite(pin, LOW);
        } else {
            digitalWrite(pin, HIGH);
        }

You are then just reading back (close to) 0 or 1023.

Second, PWM output is not what you can read back using analogRead. An analogRead reads a voltage level, whereas PWM output is just 0s and 1s interleaved at the PWM frequency, and with a width of the duty cycle.
See https://www.arduino.cc/en/Reference/AnalogWrite, in particular:

The analogWrite function has nothing to do with the analog pins or the analogRead function.

Third, writing 1023 to analogWrite is out of range. See the documentation from the page linked above:

Parameters
pin: the pin to write to.
value: the duty cycle: between 0 (always off) and 255 (always on).

You can see that the most you can write is 255 (not 1023).

References

More information about the ADC (analogRead) at my page about the ADC converter.
More information about PWM output at my page about timers.

This is a fantastic piece of feedback, and I realize that I need to do further research and testing. There has been an obvious disconnect between my understanding, and what's actually realistic. Thanks for this... after glancing at the board and with the understanding I have, it has put me in the proper direction of where to look and what to do.

I'm accepting this answer not because I've tested it, but because it is thorough and makes sense. I'm confident it'll prove true :)

I have to admit that I did not understand that A'n' pins were not necessarily analogWrite() capable. I totally overlooked that in everything I've done. It explains quite a bit. I think my Arduino experience will be much nicer moving forward with this new comprehension.

analogRead and analogWrite are confusingly named as they are not symmetrical. A better name for analogWrite might have been PWMwrite.

...that would have made one think, at minimum. Thanks Nick.

Can someone please let me know what I'm not doing correctly?

the analog (output) pins on those chips are not exactly analog: they are pwm output pins. as such, their output is either 0 or 1, nothing in between, with the chance of being 1 equal the duty cycle.
that kind of output can be a steady "analog" if you run it through a low pass filter - the simplest would be an rc filter where the r is in serial with the c.
so if you hook th epwm pin up to a rc filter and adc the output of that rc filter, you will get a real "analog".

Your program is correct and I suspect the error is in the hardware. Arduino uses its internal timer and creates a high frequency PWM on the corresponding pin upon a analogueWrite() is called. Here what we should notice is the DC switching in the appropriate pin is not noticeable in most cases. (If you give it to an LED you can adjust its brightness).
But what you have done now is not correct. Since there is no current flowing in the pin there will not be a analogue voltage actuality. It is 5V and 0V switching in a high frequency. Those are the values which the A0 pin will see.
So try fixing a capacitor between the pin and the ground. and a 1k resistor to create a slight current flow to stabilize the voltage. then let us know your readings.

simulate this circuit – Schematic created using CircuitLab

Thanks for this, but I believe the answer that states that I was incorrectly assuming that the A'N' pins were analogWrite() capable is correct. I definitely know I had current flow without need of a resistor, capacitor or other intermediaries. I made bold mis-assumptions as to what pins can do what.

This answer completely misses the issue. No, you do not need the pin to source current in order to have a well defined voltage. And your 1 µF capacitor can damage the output pin due to the inrush current.

@EdgarBonet Srry, it should be .1uf. So do you mean to use analogueRead() and read a PWM value insted of a real analogue voltage between 0v and 5v.

You wrote: “do you mean to use analogueRead() and read a PWM value [...]”. No, I mean what I wrote, nothing more.


text:
Arduino Yun used as Wi-Fi hotspot
I use for a project an Arduino Yun with Node.JS + socket.io to provide interactivity between a smartphone, driving through a webpage different devices.
I would like to enable this service for several smartphones at the same time. However I would like to work in the very same conditions that a (well configured) hotspot does:

I want to ensure that no user can see the other users on the network,
I want to have a limited number of connections on the Yun at the same time,
I want to force the different users when connected to the Wi-Fi to be routed to a captive portal on the first connection.

Does anyone know first if it is possible with an Arduino Yun (maybe some actions must be performed on a NodeJS virtual server as point 2). If yes, do you have a tutorial or any clues (do I have to use LuCi)?
Last question, in the same topic, I would like to use a fast granted access using NFC tag emulation to provide Wi-Fi credentials. Has anyone tried this with Arduino Yun and a shield?

Finally, here is how I did the job. In short, I separated the two topics of getting a trace of any user using socket.io and giving a limitations of the number of users.
First, my Arduino Yun is on a Ethernet network where a router, acting also as the internet gateway, is a dhcp server. My Arduino Yun have a static IP address in the subnet of this router (so it is not a dhclient). This can be set either by modifying the file /etc/init.d/network.
Including the lines:
config 'interface' 'wan'
        option 'proto' 'static'
        option 'ifname' 'your_interface_name'
        ipaddr xxx.xxx.xxx.xxx

or by using the LuCi interface.
For more information about the way to properly configure the network in OpenWRT, see Network configuration.
Then the router is set to authorize only few IP addresses.
The last step is to bridge the Wi-Fi and the Ethernet (WAN and LAN) keeping the configuration of the Ethernet interface. This can be done using the LuCi interface. Be careful of what interface configuration you keep. How to setup an OpenWRT router as a Wi-Fi bridge to an Ethernet router gives the way to do this.
Note that this can also be done using the Arduino Yun as a DHCP server if you don't want to be connected on a network.
In the end, any connections on the Arduino Wi-Fi will get its IP address in the authorized range (up to 16 users at the same time in my case) by the router/DHCP server through the bridge.
In socket.io, I took the id that is given to any connected client and the IP address to ensure that I have a same user.
About the NFC dynamic tag, I developed a NFC specific board with a dynamic tag in the Arduino Yun/Uno format and its library to push through the bridge between ATmega and Atheros any new Wi-Fi code or any webpage. I think it is outside of this scope so if you need anything about this I can give you in PM.
I finally get at the end a device:

Connected to an existing network and accessing the internet,
Serving the webpages I want using my node serve,
Able to push any information on any other devices on the network through my nodeJS server,
Enabling access to people to local or network content,
Serving some specific local information through the NFC shield.