text:
How to map sensor analog output voltage
My sensor output voltage values ranges from 0.6 V - 3 V. How can I convert this voltage values to ppm in the range 0-1000? Upon exposure to CO gas: 0 ppm = 0.6 V , 500 ppm = 1.52 V and 1000 ppm = 3.01 V. Which means that the sensor cannot detect under 214 ppm (approx). Can you please help with mapping the sensor output values as ppm in the serial monitor? thnk u
// the setup routine runs once when you press reset:
    void setup() {
      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
    }

    // the loop routine runs over and over again forever:
    void loop() {
      // read the input on analog pin 0:
      int sensorValue = analogRead(A0);
      // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
      float voltage = sensorValue * (5.0 / 1023.0);

      // print out the value you read:
      Serial.println(voltage);

    }

What do you mean by "sensor cannot detect under 214 ppm"? Do you have the link to the sensor's data sheet? If you are using the MQ-7 sensor, are you using a standalone unit, or with a breakout board? Have you calibrated the sensor?

link if you have a look at the data sheet, they said the analog output voltage is from 0.6-3V and sensor range is 0-1000. According to that, the sensor cannot read anything below 200ppm (0.6=20% of 3V). And I have calibrated the sensor and its giving me 1.52V for 500pm and 3.01 for 1000ppm. How can I print the ppm values equivalent of output voltages?

Fyi:  The value can be between 0 and 1023 so you want to divide by 1024, not 1023.

On page 4 of the datasheet,

Left side value of detection range (zero point) is corresponding to left side value of voltage output range,but right side value of detection(max detection value) is not corresponding to the right side value of voltage output range.

Thus, 0ppm would correspond to 0.6V, for CO. And 1000ppm does not necessarily correspond to 3V.
Assuming that 500ppm = 1.52V was obtained from the "inspection report", you now have two reference points, (0, 0.6) and (500, 1.52).
Further below on the same page, a formula for N is given, which, points towards a linear response of Vo with respect to ppm. Thus, you can use the map() function to do the linear mapping from voltage to ppm.
Note that map() only works with integers, so instead of mapping voltage (0.6 - 1.52) to ppm, you should directly map the analogRead value (123 - 311) to ppm to get better accuracy. Other wise, implement your own mapping using floats.

So are suggesting that I use expression like this: ppm= map (voltage, 0.6, 3, 0, 1000)? Based on my code. Also with regards to the formula mention in pg.4, for example say my Vo=1.5V then if I do the math value of N=600ppm rather than 500ppm that I tested with. Can you please write down your version of mapping voltage to ppm?

No. Use map(voltage, 0.6, 1.52, 0, 500). But since map() uses integer math, better use map(sensorValue, 123, 311, 0, 500).
Note that 123 * (5.0 / 1023.0) = 0.6 and 311 * (5.0 / 1023.0) = 1.52.

Your mapping function is working. Thank you so much!!!

This Codes works for you :)
int SensorPin = A0;
int Readings;
int Min = 0;    // This is the Min reading of the sensor
int Max = 614; // This is the Max reading of the sensor
int Desired_Min = 0; // this is the desired number that you want converted with min reading of the sensor
int Desired_Max = 1000; // this is the desired number that you want converted with max reading of the sensor

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

void loop(){
  Readings = analogRead(SensorPin);
  Readings = map(Readings, Min , Max, Desired_Min, Desired_Max);
   Serial.println("Mapped Value:"+Readings);

}

I Strongly prefer you to note the min and max reading Value of your sensor with arduino and replace the 'Min' and 'Max' according to that in the programm....

In the main loop, sensorValue is assigned to store the raw analog value read from the potentiometer. Arduino has an analogRead range from 0 to 1023, and an analogWrite range only from 0 to 255, therefore the data from the potentiometer needs to be converted to fit into the smaller range before using it to dim the LED.
In order to convert this value, use a function called map():
outputValue = map(sensorValue, 0, 1023, 0, 255);

outputValue is assigned to equal the scaled value from the potentiometer. map() accepts five arguments: The value to be mapped, the low range and high values of the input data, and the low and high values for that data to be remapped to. In this case, the sensor data is mapped down from its original range of 0 to 1023 to 0 to 255.
The newly mapped sensor data is then output to the analogOutPin dimming or brightening the LED as the potentiometer is turned. Finally, both the raw and scaled sensor values are sent to the Arduino Software (IDE) serial monitor window, in a steady stream of data.
// These constants won't change. They're used to give names to the pins used:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the Serial Monitor:
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 2 milliseconds before the next loop for the analog-to-digital
  // converter to settle after the last reading:
  delay(2);
}

Few useful commands while mapping any analog output values:

map()
analogRead()
analogWrite()
serial()
AnalogInput - Use a potentiometer to control the blinking of an LED.
AnalogWriteMega - Fade 12 LEDs on and off, one by one, using an Arduino or Genuino Mega board.
Calibration - Define a maximum and minimum for expected analog sensor values.
/*
  Calibration

 Demonstrates one technique for calibrating sensor input. The sensor readings
  during the first five seconds of the sketch execution define the minimum and
  maximum of expected values attached to the sensor pin.

  The sensor minimum and maximum initial values may seem backwards. Initially,
  you set the minimum high and listen for anything lower, saving it as the new
  minimum. Likewise, you set the maximum low and listen for anything higher as
  the new maximum.

  The circuit:
  - analog sensor (potentiometer will do) attached to analog input 0
  - LED attached from digital pin 9 to ground

  created 29 Oct 2008
  by David A Mellis
  modified 30 Aug 2011
  by Tom Igoe

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Calibration
*/

// These constants won't change:
const int sensorPin = A0;    // pin that the sensor is attached to
const int ledPin = 9;        // pin that the LED is attached to

// variables:
int sensorValue = 0;         // the sensor value
int sensorMin = 1023;        // minimum sensor value
int sensorMax = 0;           // maximum sensor value

void setup() {
  // turn on LED to signal the start of the calibration period:
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);

  // calibrate during the first five seconds
  while (millis() < 5000) {
    sensorValue = analogRead(sensorPin);

    // record the maximum sensor value
    if (sensorValue > sensorMax) {
      sensorMax = sensorValue;
    }

    // record the minimum sensor value
    if (sensorValue < sensorMin) {
      sensorMin = sensorValue;
    }
  }

  // signal the end of the calibration period
  digitalWrite(13, LOW);
}

void loop() {
  // read the sensor:
  sensorValue = analogRead(sensorPin);

  // apply the calibration to the sensor reading
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);

  // in case the sensor value is outside the range seen during calibration
  sensorValue = constrain(sensorValue, 0, 255);

  // fade the LED using the calibrated value:
  analogWrite(ledPin, sensorValue);
}

Fading - Use an analog output (PWM pin) to fade an LED.
Smoothing - Smooth multiple readings of an analog input.


text:
Issues uploading to atmega324pb w/ adruino as ISP
I've been having some issues programming a new atmega324pb I have on a custom board. I set up an old adruino UNO as an ISP by uploading the ArduinoISP sketch, setting the programmer to "Arduino as ISP" and then using the "Upload using programmer" option but to no avail. Here is the verbose error message that the console logs:
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

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

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

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

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x000000 (retrying)

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

avrdude: Device signature = 0x000000 (retrying)

I think it might be an issue with Arduino possibly targeting a chip other than atmega324pb that I'm using, but I'm not sure. I don't know of any official arduino boards that utilize the 324pb. The main issue that I see is that avrdude can't find the device signature. I've see others mention it might be faulty wiring, but I made sure all connections are intact.

Welcome to Arduino Stack Exchange.  Please take the tour at https://arduino.stackexchange.com/Tour to get the most out of this site, and to see how to attract the most useful answers.

In case anyone was wondering, I solved the problem.
Unfortunately I wasn't able to figure out how to upload it using Arduino as ISP, but I was able to get it to work with an AVR Pocket Programmer from Sparkfun. If you decide to use this, check out this drivers guide. It will It'll save massive headache getting the usb device to be recognized.
IMPORTANT FOR ATMEGA324PB USERS!!!
The atmega324pb is apparently not a default microcontroller in avrdude. You need to add it to the toolchain manually. You can do this by following this blog:
https://hackaday.io/project/9313-uino-mini-super-atmega328pb/log/31003-easy-way-to-a-toolchain-for-the-atmega328pb
It is the same process to add any Microchip microcontroller to avrdude, so this guide will work for the atmega324pb (did it firsthand). From there, you can also add a custom entry to Arduino's boards.txt config file if you'd like to use the Arduino IDE for development. I didn't mind working the command line, but having it in Arduino definitely streamlines the proccess of compiling the .hex and uploading it in one go.
Here is the custom entry I added to Arduino's boards.txt file for the Atmega324pb. All the data was gathered from the datasheet:
####   ATmega324PB    ####
m324p.name=Atmega324pb
m324p.upload.via_ssh=true

m324p.vid.0=0x0424
m324p.pid.0=0x2740

m324p.upload.tool=avrdude
m324p.upload.protocol=usbtiny
m324p.upload.maximum_size=28672
m324p.upload.maximum_data_size=2560
m324p.upload.speed=57600
m324p.upload.disable_flushing=true
m324p.upload.use_1200bps_touch=true
m324p.upload.wait_for_upload_port=true

m324p.bootloader.tool=avrdude
m324p.bootloader.low_fuses=0x62
m324p.bootloader.high_fuses=0xD9
m324p.bootloader.extended_fuses=0x0f

m324p.build.mcu=atmega324pb
m324p.build.f_cpu=1000000L
m324p.build.vid=0x0424
m324p.build.pid=0x2740
m324p.build.usb_product="Arduino m324pb"
m324p.build.board=AVR_m324pb
m324p.build.core=arduino
m324p.build.variant=standard
m324p.build.extra_flags={build.usb_flags}

Note that I set the upload.tool to avrdude, and the upload.protocol to usbtiny since I was using the pocket AVR programmer.
IMPORTANT!!!  The high fuse bit in this config also is 0xD9, instead of the default 0x99. I changed one fuse bit to disable JTAG and regain access to GPIO pins. To my knowledge Arduino wasn't setting fuse bits when uploading with the programmer, but this is an important note to take. If you need to use GPIO pins that share JTAG functionality, run the avrdude command line to set the high fuse bit appropriately. (0xD9 for me).

source: Stack Exchange

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

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

sort: votes


text:
ESP32 wifi module
I want to connect my arduino uno rev3 to wifi. The best option I found was esp8266. After searching about it I found that it is succeeded by esp32. But I am not able to find much information about it. So I just wanted to ask if esp32 module exists as a addon to arduino or is it a board on its own. It will be really helpful if somebody can send the link from where I can buy this module(and not the board) and how to connect it to arduino.

Its called an ESP32 not an EP32 that might help your searches.

it is a "board" on it's own, that some people use the integrated UART with, to make it talk to AVRs using factory AT firmware, but it can run it's own sketch. it will work fine for you and if running stand-alone, is actually a better option then the venerable 8266 in terms of un-interupted CPU, HTTPS, more RAM, etc.

ESP32 is not a replacement for the ESP8266.  There is quite a bit of info out there, but mostly in Chinese.  If you were to use an ESP32 to provide WIFI its like using a Formula 1 car as a mobility scooter (Rascal in American?) It will do the job, but its really not suitable.
You can buy ESP32 on eBay or AliExpress, but really you shouldn't for this task.  Stick with an ESP8266.
BTW People will mark this as off topic, because it isn't strictly Arduino related.

So you are saying that esp32 is a fullblown board and not just available as a module like esp8266 module?

ESP32's seem to be available in similar module packaging as ESP8266's.  It's not that one couldn't work, it's that it's not necessary and being newer means less support and more issues you can run into, fewer tutorials you can be confident will work unchanged, etc.

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


text:
Only 2 decimal places in printed float
There was a similar thread before but it didn't solve my problem. I had an issue with sending GPS data, which is float, and I couldn't receive the float with the same amount of significant figures as I was sending. I always received a number with 2 digits after a decimal point. So I started debugging and wrote this simple code just to check if floats work as intended:
#include <SoftwareSerial.h>
void setup() {
Serial.begin(9600);
}
void loop() {
float number1;
number1=1.45436;
Serial.print(number1);
delay(200);
}

And the serial monitor showed 1.45 as an output. How can increase the precision of the float I am saving in memory?

It is working , im m looking for adxl335 using as vibretion meter and balancer
Any one have code for ardiuno r3

By default, the Serial print function shows only 2 decimals, however I'm sure the float has the full (unrounded) value, even if it does not show it.
You can read about it in the official documentation here
With the following code you can use more decimals (fragment from the official documentation):
-Serial.println(1.23456, 0) gives "1"
-Serial.println(1.23456, 2) gives "1.23"
-Serial.println(1.23456, 4) gives "1.2346"

Also, probably the next link (PrintFloat) will help:
PrintFloat
It works roughly by iterating through the digits and printing them.

Arduino floats are not particularly accurate.  They have 6-7 significant digits, counting those on both sides of the decimal point.  For higher accuracy a double may be used.

Also note that the Arduino is not really good (i.e. fast) with floats/doubles.

@ChrisStratton Regarding the higher accuracy comment: On Arduino, a double is just another name for float. See: https://www.arduino.cc/reference/en/language/variables/data-types/float/ "Unlike other platforms, where you can get more precision by using a double (e.g. up to 15 digits), on the Arduino, double is the same size as float."

Also String() will do the same thing. It takes a second argument so if the number is a float or a double: String(floatVariable, 3) gives you 1.234.

By default, Serial.print() prints floats with two decimal digits.
float num = 7.875;
Serial.println(num, 4);

will print num with 4 decimal digits, thus: 7.8750.
The precision of float is not decreased in the way you think it decreases. See this answer for a better explanation.

Multiply your float by 10000 (or whatever number you wish), send it as an integer, and convert the received integer back to float.
Alternatively change the library or write your own.

Do you mean change serial library? Besides that, that's what I am doing(multiplying by something etc.). The problem is, it seems arduino does not save the numbers with the precision I give them to it. If what you suggested was to work, first arduino should be able to display the float correctly on the serial monitor. Am I wrong?


text:
Receiving Multiple data on Arduino Serial
I am writing a very simple code in Arduino Nano, in which I am reading data that I send on Serial. Here is the code snippet.
int incomingByte ;

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

void loop() {

    if (Serial.available() > 0) {

            incomingByte = Serial.read();

            Serial.print("I received: ");
            Serial.println(incomingByte);
    }

}
When I send 'A' , I receive the following output:
I received: 65
I received: 13
I received: 10
What is wrong with the working of Serial Port here?

You send a string "A"
However, to denote the end, a carriage line (code 13) + line feed (code 10) is sent.
So what is sent is actually an 'A' character followed by a return.
This way you also know when a new line starts
Just strip off the return (13,10) items if you do not need them.
If you do not want to send the return, try sending 'A' (which is the character A, and not the string A.
Update
You can ignore them by:
     if ((incomingByte != 10 && (incomingByte != 13))
     {
        Serial.print("I received: ");
        Serial.println(incomingByte);
     }

If you only want printable characters, check if you can use the isprint function (isprint function
so it should look like
    if (isprint(incomingByte))
    {
        Serial.print("I received: ");
        Serial.println(incomingByte);
    }

can you please tell me how to strip return (13, 10)?

I added it initially accidentally to the wrong answer, now added it to my own.

The line feed/carriage return is used to terminate the line, not the string. You can send the "A" all by itself (no delimiter); with a single cr or lf; or both (cr & lf).

nothing is wrong, it's to do with operator overloading and the print function trying to be helpful.
if you change this line:
int incomingByte ;

to this:
char incomingByte ;

it should display correctly
And the extra characters are because the software on the computer is sending line endings. these may be a linefeed with or without a carriage return. you could either just ignore them, or make use of them to create multi character commands (if you need them)

hi, thanks for your input , but when I change it to char I still receive following :I received: A
I received:
I received:

I don't want trailing carriage return and enter in my output, I simply need the character. How to trim ?

If you don't want any trailing carriage returns, just ignore them

@James Kent ... sorry for editing your answer (I moved it to my own answer). But still upvoted yours (for the inconvenience).

this is just because you are typing a letter i  the serial monitor ans in your code your are declaring it as a integer 'int' so you not need to worry about that just try the following code
int incomingByte ;

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

void loop() {

    if (Serial.available() > 0) {

            incomingByte = Serial.read();
            Serial.write(incomingByte);
    }
}

--------------------------------   OR    ---------------------------------------
char incomingByte ;

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

void loop() {

    if (Serial.available() > 0) {

            incomingByte = Serial.read();
            Serial.print(incomingByte);
    }
}

Both of the programs will work try that.......


text:
Arduino Leonardo(Atmega32u4) - Detecting if USB is connected to a computer?
The closest thing I can find is if(Serial) but that only returns true if there's a serial port open.
The function I want, ideally, should:
Return true if plugged into a computer
Return false if plugged into a USB power bank
Return false if not plugged in at all(Running off of its own lithium cell)

ADDEN of UDADDR is set if the '32U4 has been assigned a USB address by the host and the firmware wants to enable USB connectivity.
UDADDR & _BV(ADDEN)

Is there something similar for VBUS detection to get the (not)plugged in?

@Majenko: VBUS in USBSTA.

Stupid question, but where do I go from here? Is it as easy as (UDADDR & _BV(ADDEN)) != B00000000 ?

if (UDADDR & _BV(ADDEN)) ...

Works but there is a problem with battery powered equipment when you disconnect the USB cable. This still returns true and after an restart it returns false. How to fix this?

Rewrite the firmware to deconfigure USB when disconnected.

This willl wait for serial monitor to be opened if usb connected before proceeding:
if (UDADDR & _BV(ADDEN)){ while (!Serial);}


text:
Check to see that String only contains .csv style numbers
I'm looking to determine if an Arduino String contains any other character than those that would be in the [number],[number]'\r''\n'where [number] could be positive or negative.
I know I can run a for down the entire string and use if(isDigit([char]) || isWhitespace([char])||[char]=='-') however, I imagine there's a better way to do this.
Could I (for example) convert the String to an array of values and search the array for any value that doesn't correspond to the characters I'm looking for? Or is there a better way to check this out?

ardunio gives you .indexOf(), which saves you the inner loop and is probably faster than hand-coding it.

Ok, so I could say give me `String.indexOf([Regular expression for A-z and symbols]) and if I got an index back I could reject the string?

yes, except for the regexp part, you need to match explicit literals

If your string contains 2 comma separated integers, with carriage return, then you could convert the string to a C string, then use the sscanf function, using "%d,%d\n". The return value of the function will tell you if the numbers are not in the correct format.

There is a better way, which is called regular expressions (or regexp). However, afaik these are not supported by Arduino by default.
However, I'm sure you can find some 'generic C++' class that can handle them.
For that, it's best to check on StackOverflow.com probably.
After a short check, on the Arduino forum there is a library available for regexp:
library
It is created by Nick Gammon, so all credits are for him.


text:
How can I control the speed and direction of dc motor at the same time (through Bluetooth
I am working on a project of an arduino car it's simple really i know how to control the speed and direction using simple button but I was looking for an upgrade so I add a virtual joystick in my app now It can send 2 values first is the angle where the pointer of the joystick is which will be used to control the direction. And the distance between the center of the joystick and the pointer will be used to control the speed, problem is they are both int values how can I make the arduino differentiate between both values ? also they would be sent simultaneously over Bluetooth which might be a problem as well

look into "H bridge" modules or circuits.

Use delimiters to separate the two values you are sending over bluetooth.
Something like
"30,5\n"

instead of
"30\n"
"5\n"

On the Arduino side, read the the incoming string into a char array and add a \0 after the last read character to make it a C string. The use strtok() to parse the C string and atoi() or atof() to convert the parsed C strings to an int or float.
See this answer for more information about parsing a string.

I would say it would be the best way to use a H-bridge motor driver such as L293N. With it you can simply drive a DC motor both ways and even control it's speed.
Make the connection as shown on picture below, but connect wires of both motors to the same motor and PWM_SPEED_CTRL are channels connected to the Arduino. Don't forget to add relays between pins: 3-1, 6-2 and 11-1, 14-2, which would determine the turning direction.
If you don't understand certain thing, just ask and I'll try to reply ASAP.

thank you for your answer but that wasn't the point i was asking about . Still it's really helpful


text:
Convert int to char[]
I'm looking to convert an int value to a char array. currently I've found the following will return [number]
int num = [number]
str = String(num);
str.toCharArray(cstr,16);
Serial.println(cstr);

However, per Majenko's The Evils of Arduino Strings I feel like this code would make my Arduino's heap look like swiss cheese. Is there a better way to change an [int] into a char[n] array that avoids the String class?

itoa is the best route:
int num = 1234;
char cstr[16];
itoa(num, cstr, 10);
-> "1234"

You can read more about using it here.
If you want more control over the format of the number (and don't mind the increased PROGMEM usage) you can use sprintf (or the more secure snprintf) to format it:
sprintf(cstr, "%05d", num);
-> "01234"

Or with PROGMEM string constant:
sprintf_P(cstr, (PGM_P)F("%05d"), num);
-> "01234"

Or with more values:
sprintf_P(cstr, (PGM_P)F("%02d:%02d:%02d"), hours, minutes, seconds);
-> "03:23:11"

Nice, I'm looking to take an int value in seconds and convert to hr:min:sec before I strcat([c string],[time]) as I understand, I'll have to stick with itoa since I don't want it to go to serial?

sprintf is a good choice. I'll add an example.

Ok, that looks like it will work for me. how do you go about getting the (PGM_P)F("%02d:%02d:%02d"), section? (specifically the (PGM_P)F part)

The F is documented in the arduino PROGMEM docs. The PGM_P just changes the pointer to the right type for_P variant functions.

You can also use the PrintEX library to give you all the 'printf' capabilities without having to deal with string types.


text:
How do I prevent Arduino from running on startup?
I just uploaded a sketch to my Arduino Leonardo, which presses a key on the keyboard. The code was unfortunately bugged and now as soon as the Arduino is powered on, the key is being pressed.
When I try to upload a new sketch that fixes the issue, I am unable to do so as the Arduino is executing the sketch, preventing the new sketch from being uploaded.
How can I prevent the Arduino from executing the sketch once powered on? Pressing the reset button or wiring it in does not work...

Welcome to Arduino Stack Exchange.  Please take a moment to look at the tour at https://arduino.stackexchange.com/Tour to get the most out of this site.  Meanwhile, we're going to need more info in order to help with this question.  Start with posting the code.

I no longer have the code, it presses a key as soon as the code starts... I can't upload a new sketch because of the old code executing and pressing the key...

Yeah, you said that already.  Normally you have to press the reset button and hold it until just the right instant during upload.  It usually takes several attempts to hit it just right.  From now on, code a little delay in setup for projects like this to give yourself a chance.

Releasing the reset button at the right time as @Delta_G wrote should make it work. If you enable more output for the upload in the preferences, then you should release the reset button after the polling starts. If that fails, you could burn a new bootloader into the Leonardo to stop the current sketch, but then you need a programmer.

Does this answer your question? How to stop uno from running program when powered on?

The Leonardo should wait a couple of seconds after resetting to see if a new sketch arrives.

Power off the board completely (remove the USB cable).
Hold down the Reset button, and keep it held down (or, run a jumper wire from the RESET pin to the GND pin). This stops the problem sketch from starting.
Still holding down Reset, reconnect the USB cable.
Start uploading a sketch that does not have this problem (eg. Blink)
Once the IDE reports "Uploading" release the Reset button (or remove the jumper wire).

After 6 attempts, it finally worked. Thanks mate!!


text:
5V and Vin pins on Arduino
I am working on connecting two Arduino boards (Arduino Uno & Arduino Nano). I am trying to run a stepper motor  connected to Arduino Nano with two digital Pins on Arduino Uno to alter the direction of the stepper motor(BYJ48) connected to the arduino Nano.
While making connections I attached the pins as:
1] 5V  (UNO) -> 5V (NANO) & GND (UNO) -> GND (NANO)
2] 5V (UNO)  -> 5in (NANO) & GND (UNO) -> GND (NANO)
Both [1] & [2] worked fine initially but I kept the arduino powered and tried toggling the Vin with 5v. Nothing went wrong in the beginning but later fumes started coming out and I dont know the reason why?
Was that because I kept the power on while toggling between Vin & 5v ?
NOTE: besides the code and success in running the possible reason of fumes is much important here.

Why did you connect arduino's 5V and GND at all? What was the reason? And why did you use two arduinos to drive stepper motor?

task for me was to connect the two arduinos with just any two pins and try to communicate between two with the digital pins on ARDUINO UNO. I was trying to gather the ways how i can do that and i thought let just try with simply 5v->5v & GND -> GND like the way we do for I2C. I was just checking if that can be done or not.

Ah so, this is not the case at all... If you want to use I2C you need to use digital pins, not 5V or GND! You can read more there http://www.instructables.com/id/I2C-between-Arduinos/

GND is connected to keep the relative zero the same, but 5V is not used for sure.

thanks for the comment but i want to know how to communicate between the two arduinos of different types without using any protocols like I2C or SPI..? Can we do this..?

Yes, you can write your own protocol, but it is not an easy task and except of learning, no real reason to do that.

Note: You can try make up custom communication. But you have to use the pins you can actually control (write and read). 5V is not the case.

You can try software serial communication between the two boards. Any two digital pins of one board can be used as Rx and Tx, and make sure the roles of Rx and Tx are reversed on the other board. See the Software Serial library:
https://www.arduino.cc/en/Reference/SoftwareSerial


text:
DFRobot GPS init error [Arduino Uno, SIM808]
i have problem with initialization DFRobot SIM808 actually when i try to recieve gps data by SoftwareSerial only it does works (i mean examples based on sending and reading command to and from serial's), and recieve data but very long string of data and i need only Latitude and Longitude and i think using DFRobot will be the easiest way to extract the data i need. So the simple test program like this one is not working:
    /*
### Get GPS data
1. This example is used to test SIM808 GPS/GPRS/GSM Shield's reading GPS data.
2. Open the SIM808_GetGPS example or copy these code to your project
3. Download and dial the function switch to Arduino
4. open serial helper
4. Place it outside, waiting for a few minutes and then it will send GPS data to serial

create on 2016/09/23, version: 1.0
by jason

*/
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

#define PIN_TX    7
#define PIN_RX    8
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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

  //******** Initialize sim808 module *************
  while(!sim808.init()) {
      delay(1000);
      Serial.print("Sim808 init error\r\n");
  }

  //************* Turn on the GPS power************
  if( sim808.attachGPS())
      Serial.println("Open the GPS power success");
  else
      Serial.println("Open the GPS power failure");

}

void loop() {
   //************** Get GPS data *******************
   if (sim808.getGPS()) {
    Serial.print(sim808.GPSdata.year);
    Serial.print("/");
    Serial.print(sim808.GPSdata.month);
    Serial.print("/");
    Serial.print(sim808.GPSdata.day);
    Serial.print(" ");
    Serial.print(sim808.GPSdata.hour);
    Serial.print(":");
    Serial.print(sim808.GPSdata.minute);
    Serial.print(":");
    Serial.print(sim808.GPSdata.second);
    Serial.print(":");
    Serial.println(sim808.GPSdata.centisecond);
    Serial.print("latitude :");
    Serial.println(sim808.GPSdata.lat);
    Serial.print("longitude :");
    Serial.println(sim808.GPSdata.lon);
    Serial.print("speed_kph :");
    Serial.println(sim808.GPSdata.speed_kph);
    Serial.print("heading :");
    Serial.println(sim808.GPSdata.heading);
    Serial.println();

    //************* Turn off the GPS power ************
    sim808.detachGPS();
  }

}

SoftwareSerial accepts the pins in RX, TX order. You have them backwards. This may not  be the issue depending on your wiring, but it's the first thing I noticed.

yea some mistake in template but it is (7,8) anyways, same as in working example

I have the same issue were you able to resolve?

Nope, i just wrote my code instead using library :( . Resolving it would be still useful

I have tried to run the sim808 shield with the source code from above and also with the Dave's code. Without success. I have the external power supply, I switch between the different modes when uploading the code. I receive on the serial monitor either Sim808 init error
or GPS initializing. Do you have any suggestions where to start troubleshooting?

I had similar problems, couldn't even get a basic connection from Arduino - Shield. I guess the DF Robot GPRS library is broken.

@stevieb, well spotted about the TX&RX being the wrong way round in the DFR demo, but sadly that doesn't fix the problem.

@OnuralpArslan I have unprotected this question so you can answer it. Your original answer is here as a Community WiKi answer that you can copy and paste into your new answer.

{Original answer by Onuralp Arslan}
gps function of sim808 does not require sim card you only need 9v source with enough current and 1575.42 mHz gps antenna
use this code it will help
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#define PIN_RX 11
#define PIN_TX 10
SoftwareSerial mySerial(PIN_TX,PIN_RX);
DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

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

//************* Turn on the GPS power************
if( sim808.attachGPS())
Serial.println("Open the GPS power success");
else
Serial.println("Open the GPS power failure");

}

void loop() {
//************** Get GPS data *******************
if (sim808.getGPS()) {
Serial.print(sim808.GPSdata.year);
Serial.print("/");
Serial.print(sim808.GPSdata.month);
Serial.print("/");
Serial.print(sim808.GPSdata.day);
Serial.print(" ");
Serial.print(sim808.GPSdata.hour);
Serial.print(":");
Serial.print(sim808.GPSdata.minute);
Serial.print(":");
Serial.print(sim808.GPSdata.second);
Serial.print(":");
Serial.println(sim808.GPSdata.centisecond);

Serial.print("latitude :");
Serial.println(sim808.GPSdata.lat,6);

sim808.latitudeConverToDMS();
Serial.print("latitude :");
Serial.print(sim808.latDMS.degrees);
Serial.print("\^");
Serial.print(sim808.latDMS.minutes);
Serial.print("\'");
Serial.print(sim808.latDMS.seconeds,6);
Serial.println("\"");
Serial.print("longitude :");
Serial.println(sim808.GPSdata.lon,6);
sim808.LongitudeConverToDMS();
Serial.print("longitude :");
Serial.print(sim808.longDMS.degrees);
Serial.print("\^");
Serial.print(sim808.longDMS.minutes);
Serial.print("\'");
Serial.print(sim808.longDMS.seconeds,6);
Serial.println("\"");

Serial.print("speed_kph :");
Serial.println(sim808.GPSdata.speed_kph);
Serial.print("heading :");
Serial.println(sim808.GPSdata.heading);

//************* Turn off the GPS power ************
sim808.detachGPS();
}

}

try this, worked for me without sim card
connect rx of sim808 to arduino 11
tx to 10
and connect grounds of arduino and sim808

We had the same error in the code. But we managed to solve it! You have to insert the SIM CARD to work. We do not know why, but it works!


text:
Why is a delay(1) necessary before Wire.requestFrom?
I had a problem communicating an nodeMCU with an Arduino Pro Mini with I2C.
To find the culprit, I finally wrote an Echo Server in Arduino: it receives a byte and responds the same byte. In the nodeMCU I wrote a test program: it sends bytes to the Echo Server and verifies the response, in addition to any error conditions in the Wire methods.
Both processors are connected GND-GND, VCC-VCC, SDA-SDA and SCL-SCL. SDA and SCL have 10K pull-up resistors. Both are connected via USB to my PC, and I have two serial monitors to trace the execution.
In the tester program line 38 there is a delay(1). If you comment it out, some requestFrom() fails randomly with return value != 1, but the Echo Server still received the byte.
As ATmega328 included TWI in the silicon, I can't understand what is failing here and why delay(1) seems to solve the problem. What I'm missing here?
The tester program
/*
 * Echo Server Test
 * Send one byte to the Echo Server and read it back.
 * Do it for bytes from 0x01 to 0xDD
 */
#include <Wire.h>

#define SLAVE_ADDRESS  42
byte car = 1; // car to be send to the Echo Server.

void setup() {
    Serial.begin(9600);
  // We have a nodeMCU con I2C on pins D5 and D6.
    Wire.begin(D5, D6);
    delay(1000);
  Serial.println("");
    Serial.println(" Echo Server Tester");
    Serial.println("---------------------");
    Serial.println("###  Sent   Received");
    delay(1000);
}

/*
 * Send one byte in each loop().
 */
void loop() {
    byte status;

    if(car > 0) {
        do {
            Wire.beginTransmission(SLAVE_ADDRESS);
            int written = Wire.write(car);
            status = Wire.endTransmission();

            switch(status) {
            case 0:
        delay(1); // Comment this out and watch requestFrom() fails.
                if(Wire.requestFrom(SLAVE_ADDRESS, 1) == 1) {
                    byte r = Wire.read();
                    printChar(car, r);
                    car++;
                } else {
                    Serial.println("error in return");
                    status = 4;
                }

                break;

            case 1:
                Serial.println("Data too long");
                break;

            case 2:
                Serial.println("NACK on address");
                break;

            case 3:
                Serial.println("NACK on data");
                break;

            case 4:
                Serial.println("Some error");
                break;
            }
        }

        while(status != 0);
    }
}

/*
 * Utility: print in bytes sent and received
 */
void printChar(byte s, byte r) {
    Serial.print(s);
    Serial.print(" ");
    printBits(s);
    Serial.print(' ');
    printBits(r);

    if(r != s) {
    //  Mark invalid responses.
        Serial.print(" *");
    }

    Serial.println();
}

/*
 * Print a simple byte in binary
 */
void printBits(int car) {
    byte bit = 0x80;

    for(int i = 0; i < 8; i++) {
        int digit = car & bit;
        Serial.print(digit ? '1' : '0');
        bit >>= 1;
    }
}

The Echo Server program
/*
 * I2C Echo Server
 * Receive one byte from Master, echo the same byte to Master.
 */
#define MY_ADDRESS  42

#include <Wire.h>

volatile byte received;
volatile int count = 0;

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

  Wire.begin(MY_ADDRESS);
  Serial.println("--- Echo Server ---");

  Wire.onReceive(receiveCommand);
  Wire.onRequest(sendAnswer);
}

void loop() {
  static int lastCount = 0;

  if (count != lastCount) {
    Serial.print(lastCount + 1); Serial.print(" ");
    printChar(received);
    lastCount++;
  }
}

/*
 * Receive a byte from Master
 */
void receiveCommand(int howMany) {
  received = Wire.read();
  count++;
}

/*
 * Send a byte to Master
 */
void sendAnswer() {
  Wire.write(received);
}

/*
 * Utility print byte received/sent
 */
void printChar(byte car) {
  Serial.print("Char ");
  byte bit = 0x80;
  for (int i = 0; i < 8; i++) {
    byte digit = car & bit;
    Serial.print(digit ? '1' : '0');
    bit >>= 1;
  }
  Serial.println();
}

the TWI interface needs to wait a whole cycle before it requests again, otherwise the clock and buffer can get messed up.

THIS fixed my I2C problems, delay(1) I had not seen this mentioned anywhere previously, so thanks for the question and the answers as I have been going in circles why my first 2 reads worked but not my second read 2, although commenting out the first 2 reads then let the second 2 behave correctly. I will now find out the clock cycle and change delay(1) to a micros delay.

The 1 millisecond is not needed, try delayMicroseconds with 50 or maybe 20 µs.
The Arduino as a slave is totally different than for example a sensor. The Arduino as a slave uses a combination of hardware and software. The onRequest and onReceive functions are executed while the Arduino keeps the SCL line low. That is called clock pulse stretching.
With an Arduino Uno (ATmega328P microcontroller) connected to an Arduino Uno, this delay problem between a write and read on the I2C bus existed for a long time. A few years ago it was solved. It was a bug, a real bug. That delay is no longer needed.
There are still ways to make it unreliable, for example by disabling the interrupts for too long in the slave.
I read that is still exists with the Arduino Due. With the Due as a master and for example an ATmega328P (at 3.3V) as a slave, the Due still needs a delay.
The nodeMCU and the Raspberry Pi might still have some problems when an Arduino is used as a slave. The Arduino as a slave should at least run at 3.3V or a I2C level shifter should be used.
I don't know if the nodeMCU Wire library supports clock pulse stretching.
That delay might still be needed. Even then, I don't know how reliable the communication will be.
The Wire.endTransmission is the function that transmits the data (not the Wire.write). If that is followed too soon by a Wire.requestFrom and there is a bug in the Wire library, that can cause troubles.


text:
Use 5V pH sensor with 3.3V NodeMCU
I'm trying to use a pH probe with NodeMCU, the problem is that NodeMCU is 3.3V and the pH analog sensor requires 5V, at first I thought using the VIN pin but didn't work, then I used the VU pin from NodeMCU V3 (by Lolin) but it didn't give me the right values, like if it missed more power. Is there any other way? Or any esp8266 board which supports 5V into it's analog input?

Try and get a 5V ADC board that you can talk to over I2C and a 5v->3.3V logic level convertor for the I2C bus.

your divider was probably OK after all - some nodeMCU boards don't spit out 5v on VIN. There's not a ton of consistency on nodeMCU devboards but i've found the ones with CH340s to all be deficient in that regard, and all the CP2102s to be good, look for "amica" on the back, and avoid the ones that say "lolin". All the Wemos D1 minis i've tried (about 20 units in 3 variations) work and have 3.3ADCs and 5v VIN, as expected.

Depending on your specific sensor and power supply setup you have following options:

Change supply voltage
Most resistive sensors don't have to power anything and will function just fine when supplied with less than 5V. Study the datasheet and make test measurements to find out whether this is suitable.
Use a voltage divider
Supply the sensor with 5V and use a simple voltage divider before    connecting to your MCU and therefore measure 0-3.3V.
Interface another IC
Get a small external ADC that can handle 5V readings and may be interfaced by any serial protocol supported by your esp8266 (namely UART and I2C).

I would also recommend using an external ADC for example: link

The external ADC is imo the least favourable option as it needs more hardware work (maybe even different casing), MUCH more code and is generally less efficient.

@mistery Thanks for your answer! Well actually I already tried with a voltage divider, from 5V to 3.3V and worked but just in some cases; I'm using NodeMCU VU pin which supposedly gives 5V, but for example, when pH is lower, the sensor needs more power to give an accurate value, and when this happens NodeMCU stops getting those readings, let's say under 4.80 (in a scale of 0-14) it stops reading analog value changes, so I'm thinking probably NodeMCU can't really provide 5V.
My voltage divider is with 1K and 2K, I'm thinking to probably use a Wemos board, it has a 5V pin, what do you think?

I still don't know what exact board you have. my idea was to power the sensor from your power supply, not through the chip. You should really study the sensor's data sheet to get an idea of it's behaviour

The simplest method is just a voltage divider - just as if you were interfacing a 5V logic signal output with a 3.3V input. However it may not work.
A voltage divider will only really be of use if the output of the pH sensor is low impedance. If it's not then you will need a very high impedance voltage divider, and the analog input of the ESP8266 isn't high enough impedance to support a very high impedance voltage divider - it will skew the results horribly.
So you may need to buffer the output of the pH sensor through an op-amp first.
If you use a unity gain non-inverting buffer you can then use a voltage divider to reduce the output voltage.

simulate this circuit – Schematic created using CircuitLab
Alternatively, as others have suggested, use an external 5V ADC chip and logic level conversion to communicate with the ESP8266.

Old topic, but in case it shows up in searches, like the one I was just doing ... I run a 5v ultrasonic SR04 off a Lolin nodemcu, and if you connect to "VU" on the Lolin nodemcu, you will get 5v.

Tested here with a voltmeter and indeed VU gives 5V. Good one!

Part of the problem was also reading 5v from sensor

Have you guys checked the specification of the AiThinker's ESP-12s? There's a piece of description in its Chinese edition document that says if you are hooking up other devices which work in 5v, you have to use the Level converter circuit in between.

the question is about powering, not about Serial comunication


text:
Help What am I doing wrong? Matrix Led
I'm new and im trying out the Matrix LED
heres my code
#include <LedControl.h>

LedControl lc = LedControl(12, 11, 10, 1);

unsigned long delayime = 100;

void setup()
{
  lc.shutdown(0, false);
  lc.setIntensity(0, 8);
  lc.clearDisplay(0);
}

void writeArduinoOnMatrix()
{
  byte H[10] = {8, 8, B01100110, B01100110, B01100110, B01111110, B01111110, B01100110, B01100110, B01100110};
  byte E[10] = {8, 8, B01111110, B01111110, B01100000, B01111110, B01111110, B01100000, B01111110, B01111110};
  byte L[10] = {8, 8, B01100000, B01100000, B01100000, B01100000, B01100000, B01100000, B01111110, B01111110};
  byte O[10] = {8, 8, B01100000, B01100000, B01100000, B01100000, B01100000, B01100000, B01111110, B01111110};

  lc.setRow(0, 0, H[0]);
}

I keep on getting this error no matter what.
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.
Help What am I doing wrong?

Welcome to Arduino SE! Can you post the complete code, with thevoid loop{...} function? Also post the complete error as Michel has requested below.

Unfortunately I think you are missing the actual error message and have just copied the result.  I suspect if you scroll back up through the output it will say loop is missing.
All Arduino sketches (well almost all) have to have setup() and loop() functions.  The underlying 'stuff' will call setup() once and loop() repeatedly.
I hate global variables, but in this case I would be tempted to move those arrays out of the function and make the constant global values.  That way they will be in memory as the Arduino boots and you won't have to waste processor cycles setting them up.
It may be a silly question, but are you using the right hardware?  This might help check that http://playground.arduino.cc/Main/LedControl

ok, yes I'm using the right hardware and the code...

I am using the right hardware, screw the code i made a new one can u check it for me?
#include <LedControl.h>
int DIN = 12;
int CS = 11;
int CLK = 10;
byte H[8]= {(0x66,0x66,0x66,0x7e,0x7e,0x66,0x66,0x66)};
byte E[8]= {(0x7e,0x7e,0x60,0x7e,0x7e,0x60,0x7e,0x7e)};
byte L[8]= {(0x60,0x60,0x60,0x60,0x60,0x60,0x7e,0x7e)};
byte O[8]= {(0x7e,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0x7e)};
LedControl lc=LedControl(DIN,CLK,CS,0);
void setup() {
// put your setup code here, to run once:
lc.shutdown(0,false);
lc.setIntensity(0,15);
lc.clearDisplay(0);
}
Would this work?

A ld error normally means a link error, i.e. you call a function that is not defined.
Are you sure it is the complete error? That it does not show which function you miss?
Also, I notice:

function writeArduinoOnMatrix never seems to be called, or you didn't post the full code?
In writeArduinOnMatrix, you declare 4 arrays, but you use only one (H).
Typo in: unsigned long delayime = 100;  ... this should be delayTime

If the posted code is complete, then it is missing the loop() function, which might explain calling of an undefined function, as the rest of the runtime should call loop() after setup().


text:
(ESP8266) Check if a SSID is in range
I need to check if a given SSID is in range. Would be good if it didn't disconnect from the current wifi network that it's connected to, but it doesnt matter, i just need to see if a SSID is in range, whether it does disconnect or not.
It should be something like this:
if(WiFi.SSID(checkforthisSSID)) {
  //do something
}

Thanks.

Not so tough it is possible just try the bellow code :)
void loop() {
  Serial.println("scan start");

  // WiFi.scanNetworks will return the number of networks found
  CheckPossibility();
  }

 CheckPossibility(){
 int n = WiFi.scanNetworks();
  Serial.println("scan done");
  if (n == 0)
    Serial.println("no networks found");
  else
  {
    Serial.print(n);
    Serial.println(" networks found");
    for (int i = 0; i < n; ++i)
    {
      // Print SSID and RSSI for each network found
      if(WiFi.SSID(i) == "REPLACE THIS WITH YOUR SSID"){ //enter the ssid which you want to search
      Serial.println("The network you are looking for is available");
      }
    }
  }
  Serial.println("");

  // Wait a bit before scanning again
 // delay(5000);
}

Try to connect to an AP, Use scan networks example, then look if the SSID in in the response.
Did not try, the scan networks example has an "WiFi.disconnect()" before the scan() function.


text:
Connecting Arduino Wifi shield to Arduino Uno based Mcore board
I am trying to connect this mBot board to an external network, that's why I bought the arduino wifi shield.
I am connecting the wifi shield to the 6pins (5V MOSI GND RST SCK MISO) of the mCore.
Though when uploading any of the Wifi program example, the shield isn't even recognized.
(I've succesfully upgraded the firmware of the shield)
The thing is that I don't really understand how should I plug in the wifi shield on the mCore since I'm struggling to understand the datasheet of the mBot board.
Any advices ?
Regards,
Alex


text:
Reliably measuring the energy consumption of arduino running sketch
I would like to know if there is a programmatic way of measuring the energy consumption of a sketch or at least if this is possible via external devices.
My aim is to compare the energy consumption of two devices, connected to usb, running slightly modified versions of the same sketch e.g., one using crypto and one without using crypto.

Are you only interested in that, or do you really want to reduce power ? For example with a battery operated Arduino ? For a ATmega328P as a bare-bone Arduino, the actual code does not make the difference, but the sleep mode (there are a number of different sleep modes) does and of course how long the Arduino is busy between sleeping is important, and also the clock speed. Without sleep mode, it does not matter what code the Arduino is running.

use something like this one with time counters, or the simpler and cheaper spot-reading USB meters

@user35247 Not a duplicate.  Your link is about using an Arduino to measure the consumption of other things, this is about measuring the consumption of an Arduino.  Though as already pointed out, there's not much variation to measure until the software starts playing with hardware features beyond merely running code.

programmatic way of measuring t

Not sure what you meant by that but typically you can use a high side current sense amplifier to get a measurement of the current. Then adv a known voltage to get vcc. That known voltage could be the internal reference, if available
In some cases a resistor on vcc can be used to measure current, together with two dividers.


text:
Error running the code
The error I get is as follows:
F:\Josh\GIZDUINO PROJECT\Joshua\arduino-1.8.3\libraries\arduino-ledcube-master\examples\ledcube\ledcube.pde: In function 'void loop()':

ledcube:49: error: taking address of temporary array
         cube.createFrame((byte[]) {0,6, 1,6, 2,6}, 6, 80),
                                                         ^
ledcube:50: error: taking address of temporary array
         cube.createFrame((byte[]) {0,7, 1,7, 2,7}, 6, 70),
                                                         ^
ledcube:51: error: taking address of temporary array
         cube.createFrame((byte[]) {0,8, 1,8, 2,8}, 6, 60),
                                                         ^
ledcube:52: error: taking address of temporary array
         cube.createFrame((byte[]) {0,5, 1,5, 2,5}, 6, 50),
                                                         ^
ledcube:53: error: taking address of temporary array
         cube.createFrame((byte[]) {0,2, 1,2, 2,2}, 6, 40),
                                                         ^
ledcube:54: error: taking address of temporary array
         cube.createFrame((byte[]) {0,1, 1,1, 2,1}, 6, 30),
                                                         ^
ledcube:55: error: taking address of temporary array
         cube.createFrame((byte[]) {0,0, 1,0, 2,0}, 6, 20),
                                                         ^
ledcube:56: error: taking address of temporary array
         cube.createFrame((byte[]) {0,3, 1,3, 2,3}, 6, 10)
                                                         ^
F:\Josh\GIZDUINO PROJECT\Joshua\arduino-1.8.3\libraries\arduino-ledcube-master\examples\ledcube\ledcube.pde:115:38: warning: narrowing conversion of '(((int)cube.LedCube::getLevels()) + 1)' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
     byte planes[] = {cube.getLevels()+1,cube.getLevels(),cube.getLevels()*2,1};
                                      ^
F:\Josh\GIZDUINO PROJECT\Joshua\arduino-1.8.3\libraries\arduino-ledcube-master\examples\ledcube\ledcube.pde:115:74: warning: narrowing conversion of '(((int)cube.LedCube::getLevels()) * 2)' from 'int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]
     byte planes[] = {cube.getLevels()+1,cube.getLevels(),cube.getLevels()*2,1};
                                                                          ^

exit status 1
taking address of temporary array

Learn C syntax.

Welcome to Arduino Stack Exchange.  Please take the tour at https://arduino.stackexchange.com/Tour to see how to get the most out of this site.  You will see the difference between between how this works here and your question.  Perhaps you can edit this to make it answerable; but if not then you will be ready for next time.

Gizduino is garbage. The fact that they instruct you to install their hardware definitions to the IDE installation folder shows they lack the most basic understanding of Arduino. Send the board back for a refund.

Three remarks to your question.

Avoid using UPPERCASE as that is considered to be a typographical notation for shouting. See http://practicaltypography.com/all-caps.html
The compiler error is due to that you are using a temporary byte vector as parameter. You should declare the vector as a local or global variable and pass the reference. See https://stackoverflow.com/questions/42332229/how-to-pass-a-temporary-array or web-search for more info.
The compiler warning is due to an implicit conversion from int to byte. The conversion may result in a loss of precision thus the warning. You can use a type cast to avoid this. The type case will tell the compiler that you know what you are doing.

Cheers!

You have to declare your array by itself, with a name, like this:
void fcn(byte p[]) {
  Serial.print("p[1]=");
  Serial.println(p[1]);
}

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

  byte ar[] = {0, 6, 1, 6, 2, 6};
  fcn( ar);
  }

void loop() {
}

And the warning are for using a int where a byte is expected. It's just a warning. There is no problem as long the values are between 0 and 255.


text:
Call class B from Class A
I have two classes in my sketch that are independent of each other (a serial output and an LCD display) A simplified structure of my code is as follows:
class A
{
  public:
   int x;
   void afoo()
   {
     x=1;
   }
   void afoo2
   {
     x=ClassB.bfoo+1;
   }
};

A ClassA;

class B
{
  public:
    int y;
    void bfoo()
    {
      y=ClassA.afoo+2;
    }
};
B ClassB;

However, if I don't comment out  class afoo2 I get the following error:

exit status 1
'ClassB' was not declared in this scope

I'm guessing that this is because I haven't yet created B ClassB while class is being defined. Is there a way I can do what I'm intending here?

You can't see non-static member variables in a class like that.  The closest is to make it static, which means you get one and only one copy of the variable across all instances of your class:
class ClassB;
class ClassA {
    public:
        int x;
        void foo();

};
class ClassB {
    public:
        static int bfoo;
};

void ClassA::foo() {
    x = ClassB::bfoo + 1;
}

However I suspect that isn't what you want. I suspect you actually want to see the bfoo value stored in class instance B - so you need to tell you classA instance A what and where B is. To do that you will have to pass it when constructing or during some other setup phase.  If you want A to know B and B to know A you can't easily do it during construction, so you will have to do it at a later stage:
class ClassB;

class ClassA {
    public:
        ClassB *B;
        int fooa;
        void begin(ClassB *b) {
            B = b;
        }
        void foo();
};
class ClassB {
    public:
        ClassA *A;
        int foob;
        void begin(ClassA *a) {
            A = a;
        }
        void foo();
};

void ClassA::foo() {
    fooa = B->foob + 1;
}

void ClassB::foo() {
    foob = A->fooa + 1;
}

ClassA A;
ClassB B;

void setup() {
    A.begin(&B);
    B.begin(&A);
}

void loop() {

}

Ok, why do you have class ClassB; and class ClassA A at the beginning as well as before the setup?

class ClassB; means "ClassB exists, but I am going to define it later on." It allows ClassA to know about the type ClassB even though ClassB hasn't been defined in the file yet.

trying your sketch, I'm getting an error forward declaration of 'class ClassB'

Actually, the foo() functions can't be contained within the class structure as I have it - they have to be external to it so that it knows the structure of the classes before they are used.  I will edit a working sketch in,

What you are trying to do is call class A from B and vice versa.
What you could try, is remove one of the functions out of the class, possibly to a third class, so class A and B depend on a class C and not on each other.
However, if they are really depend, you can split up the files in header/implementation files.
Instead of using two classes directly, pass them as a parameter (reference).
Somewhat like this (not tested)
File A.h:
class A
{
  public:
   int x;
   void afoo();
   void afoo2(B& b);
};

File A.cpp:
#include "A.h"
#include "B.h"

void A::afoo()
{
  x=1;
}

void A::afoo2(B& b)
{
  x=b.bfoo+1;
}

file B.h:
class B
{
  public:
    int y;
    void bfoo(A& a);
}

file B.cpp:
#include "A.h"
#include "B.h"

B::void bfoo(A& a)
{
  y=a.afoo+2;
}

And your ino file you declare A and B.
#include "A.h"
#include "B.h"

A ClassA;
B ClassB;

ClassA.afoo(ClassB);
ClassB.bfoo(ClassA);


text:
FPC1020 + WeMos D1 Mini
I have a FPC1020am that work perfectly with arduino and a ESP8266 D1 Mini V2 NodeMcu 4MB Lua that can connect to server.
How can I connect the FPC1020 direcetly to ESP8266 D1 Mini to scan finger and send matched id to server?
here is my code and error:
#include <NewSoftSerial.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <FPC1020.h>

extern unsigned char l_ucFPID;
extern unsigned char rBuf[192];  //Receive return data
#define sw_serial_rx_pin 2 //  Connect this pin to TX on the FPC1020
#define sw_serial_tx_pin 3 //  Connect this pin to RX on the FPC1020

const char* ssid = "-------";
const char* password = "-------";

const char* host = "-------";
String url = "-------?id=";

NewSoftSerial swSerial(sw_serial_rx_pin, sw_serial_tx_pin); // Fingerprint serial (RX, TX)
FPC1020 Finger(&swSerial);

void setup() {
  Serial.begin(115200);
  Serial.print("connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  pinMode(4, INPUT);
}

void loop() {
  Serial.println("Please put your finger on the Sensor.");
  while(Serial.available()<=0);

  if( Finger.Search()){
    Serial.print("Success, your User ID is: ");
    url = "-------?id=" + l_ucFPID;
    Serial.println( l_ucFPID, DEC);

    WiFiClient client;
    if (!client.connect(host, 80)) {
      Serial.println("connection failed");
      return;
    }

    client.print(String("GET ") + url + " HTTP/1.1\r\n" +
                 "Host: " + host + "\r\n" +
                 "User-Agent: BuildFailureDetectorESP8266\r\n" +
                 "Connection: close\r\n\r\n");

    String line = "";
    while (client.connected()) {
      line = client.readString();
    }

    Serial.println(line);

  }
  else {
    Serial.println("Failed, please try again.");
  }
}

And the error is:
C:\Program Files (x86)\Arduino\libraries\NewSoftSerial\NewSoftSerial.cpp:41:27: fatal error: avr/interrupt.h: No such file or directory

 #include <avr/interrupt.h>
                           ^
compilation terminated.

exit status 1
Error compiling for board WeMos D1 R2 & mini.

We are not a free code writing service.

it's a serial device, hook it into the MCU's UART line, or use SoftwareSerail...

@dandavis the softwareSerial doesnt work on WeMos D1 Mini.. is there any other component that do this on WeMos D1 Mini?

i don't know where you got that idea, but i use SS all the time on d1minis...

@dandavis when i want to compile my code, I got this error: fatal error: SoftwareSerial.h: No such file or directory

@dandavis complete error:  fatal error: SoftwareSerial.h: No such file or directory
#include <SoftwareSerial.h>
                        ^

compilation terminated.
exit status 1
Error compiling for board WeMos D1 R2 & mini.

@mimskydo - That is user error, you haven't downloaded the Software Serial Library or you haven't placed it in the correct location.  Try reading the readme or IDE help on how to download 3rd party libraries.  This is why I said you should have included the error message when you asked this question on your other post, the problem would have been solved by now.

@CodeGorilla I update the question by adding code and error. Would u please take a look at it? I totally confused about it.. also I use "NewSoftSerial" instead of "SoftwareSerial" because of arduino website recomenation. tnx

NewSoftSerial is now in the Arduino core as SoftwareSerial. I doubt the old NewSoftSerial supports the ESP8266.

@mimskydo- avr = Arduino, so when you see avr in a path then it means it wants something just for the Arduino, not for the ESP.  You now need to find a version of software serial that works with the ESP.  OR you could add a hardware serial port http://www.nxp.com/products/signal-chain/bridges/single-uart-with-i2c-bus-spi-interface-64-bytes-of-transmit-and-receive-fifos-irda-sir-built-in-support:SC16IS740_750_760 ??

I have never tried this, but a D1 Mini has 2.5 serial ports.

The Tx and Rx pins are Serial0.
Digital pin 4 is TX1 - There appears to be no RX pin.
D7 and D8 are Rx2 and Tx2.

So rather than using SoftwareSerial or NewSoftwareSerial try using Serial2.  It might work.


text:
Restarting Arduino changes cursor position on OLED
I got an 16x2 OLED Display (DEP 16201-Y , compatible to the HD44780 controller) for my Arduino Uno and I got it to work in 4-bit Mode.
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup()
{
//lcd.clear();
   lcd.begin(16, 2);
   lcd.clear();
   lcd.setCursor(0,1);
   lcd.print("Hello there");
   delay(1000);
}

void loop()
{
   lcd.setCursor(0,1);
   lcd.print("Hello World");

   lcd.setCursor(0,0);
   lcd.print("ABCDEFGHIJKLM");

   delay(1800);

   lcd.clear();

}

I'm using the LiquidCrystal library as it is written for this controller.
The code is uploaded to the Arduino and now I power it via a normal power supply with 9V.
Then it is pure luck at which position the Text appears. Most of the times at the programmed position but sometimes the hole text is shifted to the right or to the left.
In read in the .cpp file and it says, that the display won't be reseted when the Arduino is reset, so I assume the problem lays there, but I don't know how to fix it.
Thanks!

I've indented your code (difficult to read & follow without it). Added missing ';' after the delay(1000) in setup(). Was that a copy/paste error or a bug?

I have had a similar module which has displayed similar problems - randomly the lines would swap over on a whim. The best I could get was to control the power to the module to give it a power cycle when needed. I gave up on it in the end, it seems to be an inherent problem with these displays.

@JRobert just a copy/paste error. Code works fine :) Thanks!

Same cause and solution as: https://arduino.stackexchange.com/questions/43080/oled-display-crashes-when-connecting-usb


text:
OLED display crashes when connecting USB
I got an 16x2 OLED Display (DEP 16201-Y , compatible to the HD44780 controller) for my Arduino Uno and I got it to work in 4-bit Mode, but just if the USB isn't connected and it is powered by a 9V power supply.
So my routine is:

Connect USB and power supply
Upload Code
--> Doesn't work
Disconnect USB and power supply
Just connect power supply
--> Works
Connect USB
--> Display crashes

So basically: If the arduino is connected via USB to my PC, with or without an additional power supply, the display won't work properly, it will crash or the Arduino even restarts itself. (some kind of memory error?)
I have no possible explanation for this..
Thanks for your help.
EDIT: I'm running Ubuntu Mate Kernel 4.4.0-43-generic 64bit
If I plug in the cabel without power, display works fine.
If I plug in the cabel with 5V, but the PC is shut down, the display works fine.
For the display to crash, the pc has to be running.
Test code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup()
{
    //lcd.clear();
    lcd.begin(16, 2);
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print("Hello there");
    delay(1000);
}

void loop()
{
    lcd.setCursor(0,1);
    lcd.print("Hello World");

    lcd.setCursor(0,0);
    lcd.print("ABCDEFGHIJKLM");

    delay(1800);

    lcd.clear();

}

And both Arduino and display are 5V. Good case!

Does this only happen if your PC is running? If yes: which OS are you using?

How do you uploaded your sketch in the first place? Do you have some service running that expect something to be connected via USB (like a smartphone sync ...)

When your computer boots, or when you plug the board in with it booted, most likely the serial port that gets created (/dev/ttyACM0) is opened by the process modem-manager. That will cause the Arduino to reset giving you the same results you see when you reset the board in other ways.
I have had no end of trouble in the same manner with a green version of the same screen. The best results I have had is to control the power to the display and power it up at every boot.  You can do it with a simple P-channel logic level MOSFET or PNP transistor:

simulate this circuit – Schematic created using CircuitLab
If you chose, say, D3 (as an example) as your control GPIO you would go:
void setup() {
    pinMode(3, OUTPUT);
    digitalWrite(3, LOW);
    delay(1000); // Give it time to settle after powering up
    ... rest of setup code ...
}

You can also then use it to save power (if you want to) by turning the display off - simply set the pin back to INPUT and it will be turned off by R1.

I'm using Linux Mint 17 & 18 for Arduino development and never have this kind of problem.

@LookAlterno Have you ever used one of these displays though? They are troublesome to say the least.

@LookAlterno also, have you ever noticed how, if you boot your computer with an Arduino plugged in, the Arduino will reset part way through the boot sequence? That's modem-manager.

No, I never. I'm using Linux, my uptime is in the order of months.

@LookAlterno So am I, but I like to sleep at night so I turn my computer off.

I had the same problem but solved it with with the following code:
The noDisplay(); display(); seems to reset the screen to the correct position.
void LCDInit()
{
  lcd.begin(DISPLAY_LINE_LENGHT, DISPLAY_LINES);
  // We need to do  this to reset the OLED display
  lcd.noDisplay();
  lcd.display();
  lcd.clear();
}


text:
Modified Mesh networking using nrf24l01
I am trying to make a mesh network of three nrf24l01 nodes in which all three are transceivers, such that all three are in a line. The modification I want to make is that if two end nodes are not able to communicate with each other as they fall short of range the signal must be sent via the middle node. How should I approach?

You can do it this way

Or just use a library that does it for you?

To be honest, I still have to receive my RF's... But I have a similar problem, meaning I also need to have them all to both receive and transmit.
I thought it was not possible, since in a 6-1 network, one is receiver, 6 are transmitting. With auto-ack messages can be returned.
Depending on the amount of messages being sent and latency you can let them talk when needed and hope there is not too much sending simultaneously (causing resends).
One solution you could use, is to put in the message a receiver ID. Suppose the 'geographic location' of your objects are
A   <---->   B  <----> C
Assume A wants to send to C, but it will not be received by C, C does not auto-ack, and A knows this. Know A can send the message to B, which can auto-ack, and B has to send it to C. Possibly the original source (A) has to be added to the message as well, if this is important for C to know.
Update: (in steps)
Suppose A wants to send a message m to C

A sends message m to C
C does not receive it, thus is does not send an ACK-message back to A
A gets a timeout
A knows that message m has not been sent to C (so it is out of range)
A sends the message m to B (adding 'A' as sender of the message if not already done)
B receives message m
B sends an ACK back to A
A knows message m has been sent to B
B sends message m (with A as sender) to C
C receives the package
C sends back a message to B
B needs to send a message to A that m has been sent successfully

Some generic remarks:
- This scheme is maybe not full-proof or can be optimized (like that A knows from now on it needs to send to B first to reach C).
- Also both B and C can be out of range, you want to resend it (later)?

Sorry Michel but I could not understand your logic clearly. Can you explain it to me as if i am a layman.

I updated my answer with some possible steps


text:
Advance arduino programming?
I have worked with basic arduino IDE for making robots and sensor based projects.Now I want to learn some advance arduino programming and try some complex Arduino projects.Can anyone help me with the links or related information..?

You could learn about what algorithms are if you want to delve into "advanced programming". If you believe yourself to be rather adept, then get into computational theory. Perhaps learn about finite state machines or object oriented programming but there aren't any readings for Arduino advancements. Just become a better programmer. Learn some Python. Learn how to program an Arduino with different programming languages.

get an ESP8266 to run some of your AVT sketches; the conversion will teach you a lot about the ardunio platform, and MCUs in general.

Here are 4 suggestions:

Especially for point 2 there are plenty of resources that are easy to find. Once you learn "Blink" sketch,you will realize there is a lot out there.

Don't use Arduino IDE

It lacks a lot of features which any serious programming IDE offers today. Visual Micro for Visual Studio and PlatformIO are two examples. More alternatives mentioned in the comments. These IDE which give you advance features like syntax highlighting, autocompletion, multifile projects, etc..

Start learning C/C++

Arduino programming is derived from C++ with some nice libraries to make it easier, specially on Embedded Systems. Instead of looking up and setting registers to change pin state Arduino libraries will make it easier for you.I have worked with complex projects on arduino and arduino libraries made it very easy to go. There is a lot more to learn in arduino.

Start learning electronics

Your advanced projects surely comes with advanced electronics. This is a whole other place where things might go beyond our understanding. I have spent hours and days debugging my codes. It will also help you find your way through the jungle of all the current "maker toys". There are different platforms, variety of boards and chips,people often spend a lot of time figuring out which one is suitable for our project.

Have a look at Arduino's "successors": ESP8266, ESP32

These Chinese chips are like Arduino on crack. They have onboard WiFi and higher clock frequencies (but are also a lot more capricious and don't have as much documentation as Arduino). Best part: You can program them just as easily as your Arduino Or you can try barebone programming (javascript)later. The newest one, the ESP32 is a dual-core chip with 240 MHz, WiFi and Bluetooth. Cost is around USD 2. It is available on Aliexpress.
There are also a lot of other chips/boards out there that I have not mentioned here. Above is AFAIK the most common.

1b.  Don't use Visual Micro and Visual Studio, the overhead isn't worth the benefits IMO.  Use Notepad++ as an external editor for the Arduino IDE.  It has all the features of Visual Studio 2017 + it has macros!  (Otherwise Grtschnk is spot on!)

I want something like Netbeans (clean and lean), with refactoring, integrated source control (Git), library managment, and local copies (not Internet) of all docs (pins, specs and API's). Free (as beer) and for Linux.

Try eclipse then. There's already a good plugin for that to support Arduino.

@Delta_G. I hate Eclipse so much. It is a big mess of add-on and plug-ins for this and that. It's not even an option for me.

I don't see how netbeans was any better.  They're just about equivalent to me.  I haven't had any issues with eclipse. I use it for Java, python, c++, Arduino, and I'm sure something else I'm not thinking of this early in the morning.  Either way, it was just a suggestion. You don't have to take it.


text:
NodeMCU NeoPixel
I am attempting to control a single NeoPixel with a NodeMCU, but I'm not having any luck.  Even just loading the default Adafruit NeoPixel library sketch yields unsuccessful results.  I've tested the exact same sketch on a regular Arduino with sucess.  I've got the data line hooked up to D5 on the NodeMCU board and here is my configuration of the Pixel in the sketch.
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, D5, NEO_GRB + NEO_KHZ800);

Any suggestions??

The  node mcu is an esp8xxx with 3.3V outputs.
The neopixel is an ws2812 led controller that normally uses 5V logic.
They cannot communicate. This is why it's failing.
Lower the voltage used for the neopixel so that 3.3V is within 70% of the neopixel VIN or use a logic level translator.

I added a logic shifter, but I'm still not getting any response from the Pixel.

Schematic please.

http://imgur.com/a/QTG1a

I had the same problem. It were resolved by initializing the pin as OUTPUT:
  pinMode(PIN, OUTPUT);
  pixels.begin(); // This initializes the NeoPixel library.

As I understand Arduino bootloader does it by itself but bootloader of ESP8266 does not.

I had the same issue on a LoLin NodeMCU board while it worked with the Amica NodeMCU board.
When powered via USB, the Amica board provided 5V on the Vin pin, but the LoLin board didn't. I had to use the VU pin instead and it worked.
I did not need a logic shifter. I used the D2 pin with a 220 Ohm resistor for the data.


text:
Understanding a PWM spec
I have to send a PWM signal to a controller module from an Arduino Uno. I'm not sure how to interpret the spec I've been given, and how to translate it into a PWM signal. The module is a Castle Creations Mamba Monster 2, if that helps.
The spec says the unit wants a 50Hz carrier, and the control is:
1500 microsec = idle
2000 usec = full forward
1000 usec = full reverse

I get that the period of the carrier is 20,000 usec but how does that relate to the control periods? Does it mean that for "idle" the PWM signal is high for 1500 usec and low for (20000 - 1500) usec?
Any help or insight is appreciated. Are there libraries that can deal with PWM in the given terms? Any good tutorials? I generally understand how PWM works, I just don't get the notation used here.

For a full 50Hz wave you have 1/50 seconds, or 20,000 microseconds, as you have already determined.
That is split into two portions - the ON period and the OFF period. With a 50% duty cycle the ON and OFF periods are equal - 10,000 microseconds each.
With a 25% duty cycle it is ON for 25% of the time (5,000 microseconds) and OFF for 75% of the time (15,000 microseconds).
Every time the ON and OFF must add up to 20,000 microseconds.
So for a 1,500 microsecond "idle" time that's 1,500 microseconds on, and (20,000 - 1,500) 18,500 microseconds off.
Or to see it as a duty cycle - 1,500 / 20,000 * 100 = 7.5% duty cycle.
With an 8-bit resolution that's a value of 19.2 (256 * 0.075), or the closest integer match of 19.

Thanks, so it's what I assumed. I'd just never seen it expressed in that way, rather as a duty cycle as you show..


text:
Sending POST request to HTTPS aws server using SIM900A
I have hooked up an SIM900A module to my Arduino UNO and I wanted to send a GET request to my aws server for which I have created a RESTful API, the problem is that when I send a request using AT commands I get 601 error code. But I am easily able to connect to https:// www.goolge.com and get the HTML page. I have seen some other links which are very much technical for me like https://stackoverflow.com/questions/39177095/unable-to-invoke-aws-api-gateway-get-url-with-gprs-connection and https://electronics.stackexchange.com/questions/266974/testing-a-connection-to-a-tcp-socket-through-sim5320a-cellular-module.
I want to know if SIM900A even support connections to HTTPS and if yes, how can I connect to my aws server. I kind of a noob in networking, so sorry if I cannot elaborate on details. I have read somewhere online that SIM900A only supports half https, I don't know what that means, any help/advice would be helpful.
AT commands I used
AT
AT+CGATT = 1
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","www"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+HTTPSSL=1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","https://www.google.gom"
AT+HTTPACTION=0
AT+HTTPREAD

Did you really mean to include a link to www.goolge.com? (which I've deliberately not made into a link here) Or did you mean to link to Google?

@SamGibson I did not mean to link to google, I mean I was able to connect to https google, I have removed the link.

https://stackoverflow.com/questions/15975051/error-httpaction0-601-0 also, edit your question to add your code. Also check a few more https and http sites, to see if there is a pattern.

@Paul I have tried and I am able to connect to all tried HTTP sites and few HTTPS sites, I have added the code, I want to know how to connect to an AWS server.

Have you tried issuing the command AT+HTTPSSL=? to make sure your device supports SSL. You can also try the command AT+HTTPSSL=1 to force SSL on if it isn't already. You can query the current mode with AT+HTTPSSL?

Maybe the websites support HTTP fallback, but Amazon AWS doesn't? Or it uses another more advanced certificate or encryption?

@SpeedOfSpin Yes I have used AT+HTTPSS=1 before sending the request

@Paul can you please elaborate, what you have said?

There are different types of SSL, maybe your device does not support what AWS is trying to give https://www.globalsign.com/en/ssl-information-center/types-of-ssl-certificate/ But that's more of a guess.

@Paul Thank you, the problem is that AWS can't accept the request in SSL send by SIM module, can you put the answer with your explanation and know how to configure AWS for accepting HTTP request.

I actually have no knowledge on configuring AWS, nor do I think that it's related to Arduino (you may find better explanations on the AWS support portal). If you've found the solution, you can also post it yourself, then please note the steps that worked for you, so that others can use this information once they find themselves in the same situation.

When you use https, you must not use:
AT+HTTPPARA="URL","https://www.google.gom"

You must use:
AT+HTTPPARA="URL","www.google.gom"


text:
Automotive Lighting Control Module
I am looking for an Arduino-based solution for an automotive lighting application.
System Requirements:

Able to Operate in Automotive (Interior) Environment (12 +/- 2V DC    Voltage)
Minimum 3 12 V DC Inputs (Preferably 6)
Minimum of 3 12 V DC Outputs capable of operating standard automotive-style
relays. (Preferably 6)
Compact/Condensed Form-Factor

Finding an Arduino that runs on a 12 V power supply is simple, but finding one that can handle 12 V I/Os has proven tricky.
Using a relay shield for the outputs is straightforward enough, and would be a safe way to step up the output voltage and current (although current is of little concern, given I'm only going to powering the coil in a relay). But what to do about the inputs? I don't want a transistor on each input - that would get quite tedious and large very quickly. Using relays on both sides would work, but most shields are setup to receive coil activation signals from the Arduino and as such also can't handle 12 V inputs, so using a relay shield to step-down from 12 V to 5 V also seems problematic.
Is there an all-in-one I/O solution that can step-down incoming voltages for the board and step-up output voltages on the other side?
What are my best options? I'd prefer not to have to custom-make a shield for such a basic I/O application...
Any and all help is greatly appreciated!

I think this post is 'on-topic', but you may have to look at ways of converting 10-14V -> 5V and that might be better posted on The Electrical Engineering forum, but don't mention the "A" word, otherwise they will fling you post over here faster than you car can do a 1/4 mile :)

I understand what you mean. Converting voltage isn't foreign to me (I'm a M.E.), but I'm surprised there is not already a shield that accommodates this sort of thing. Maybe something like this? http://ledsee.com/index.php/en/arduino-modules2013-02-16-10-32-17/1-x-arduino-fet-shield-detail

A Logic Level Converter can step-down incoming voltages for the Arduino inputs and may also work to drive the relay coils. Heres an example of a 4 channel board:
https://www.sparkfun.com/products/12009
and there are also 8 channel boards:
http://www.ebay.ca/itm/8-Channel-I2C-IIC-Logic-Level-Converter-Module-Bi-Directional-for-Arduino-MF-/172424799119?hash=item282551a38f:g:6Q0AAOSwo4pYPDwg.
The boards are small and use BSS138 MOSFETs, which, according to the data sheet: http://cdn.sparkfun.com/datasheets/BreakoutBoards/BSS138.pdf can handle a maximum of 0.22A continuous current and a Drain-Source Voltage of 50V. The SparkFun link has lots of information about these devices. Normally, you would use them to translate between 5V and 3.3V but I don't see why you couldn't power the "high voltage side" with the vehicles 12 - 14V and the "low voltage side" with 5V from the Arduino.

You could use a simple voltage divider on the inputs. It would take 2 resistors pre input.  That wouldn't be too huge.

I do not think a voltage divider would be sufficient for an automotive application given the likelihood of voltage fluctuations.

I see what you're saying.  But you could divide it down to 3.5 volts or maybe a little less and still rely on it reading HIGH.  So the overvoltages wouldn't get out of range as much.  You could also put a cap across to take out the big spikes.

That's a good point - what's the lower cut-off for "HIGH", just under 1V, right?

Depends on the chip.  For the 328 and the 2560 it's 0.6 * Vcc.  So right at 3V for something like an UNO at 5V.  I do know from much experience that the signal form any 3.3V device will reliably get you a HIGH.  The cutoff for LOW is 0.3*Vcc, so for an UNO at 5V that's about 1.5V.  Between 1.5V and 3.0V things aren't so well defined.

An easy solution would be to use a 10K resistor in series between the 12V input and the Arduino input. This reduces the current down to about 1mA. The zener diode in the microcontroller would then safely limit the voltage to 5V.

simulate this circuit – Schematic created using CircuitLab
Its the nice easy compact solution you are looking for.

There is no Zener in the microcontroller, but a diode from GDN to the pin, and another diode from the pin to Vcc.


text:
Can't find OV2640 module! pid: 254
I'm trying to follow this tutorial.
But I'm stuck in this error:
Can't find OV2640 module! pid: 254

I tried to contact the author of the program, but I have not had an answer yet.
I'm using the ArduCAM Mini module OV2640.
Has anyone ever been in this situation?

Thank you very much for your attention.
But the problem was in the dupont connection wires, as mentioned here!

If you look at line 762 of 'ArduCam_ESP8266_FileCapture.ino' you should see it is looking to read two bytes from the camera to check that the model number is either a '2641' or '2642'.
You are seeing the error because you are not getting those values back.  So between 761 and 762 insert some debug and print what you are getting back:
Serial.print ("vid = ");
Serial.println (vid);
Serial.print ("pid = ");
Serial.println (pid);

I guess you will either get 00 00 or a different valid (maybe) model number.  If you think its a valid model number add another condition to the if statement and see if it works.
Oh and don't forget to post the results, because I'm going to give it a chance too when I get time :)

Does it still happen if you power the cameras off and then on again. I was getting the same thing as there is a bug in one of the examples where the cameras are placed into deep sleep mode so when you reset the microcontroller or whatever you have the cameras can't be found because they are sleeping. I add the line
yourcam.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK);

to clear this state when intialising.


text:
Powering Sim808 + Arduino UNO
I am currently making a GPS tracker with UNO and SIM808 (this is the model.
It says The range of voltage of Lithium battery input power is 3.5 - 4.2V. for the module. I am aware that UNO needs 5V to power.
I want to make it compact as possible so it can be placed within the dashboard of a car or motorcycle.
How do I power both of this using just one battery holder?

Use an Arduino running at 8MHz - it can then run with anywhere from 2.8V to 5.5V reliably.

Can UNO running at 8MHz? Or should I buy another arduino? I heard there is a dissadvantage of running at 8MHz, which is slower. Do you have any links for the solid answer? I have been googling arround, but did not find the solid one. All discussions makes me confused.

No, buy a 3.3v pro mini. The only disadvantage of running slower is you are running slower.

One more thing, if I burn bootloader on UNO to 8 MHz and using 3.7v and 2A battery, will it damage the UNO? Because UNO can only hold 20 or 40 mA. If you put the answer, I will mark it

You will need to make hardware modifications for 8MHz. I.e., change the resonator for an 8MHz one.  And what do you mean the Arduino can only hold 20mA? That makes no sense whatsoever.


text:
Can I get the arduino to run ESP8266 code?
So I got this water flow sensor that measures the flow of water. I also got an ESP8266 module to help me make HTTP requests.
So as far as I know, one must set the board type to Generic ESP8266 and upload a sketch that the ESP8266 runs.
However, how can I write code in such a way that when the water flow goes over say 30 Litres, it makes a GET request to the Api that alerts the user? I am not able to use both the modules in one sketch. Any possible methods?

Can you add a link to the water flow sensor? What coms method does it use or is it have an analog output? Can you show us what you have tried so far? We aren't a code writing service.

@sa_leinad I added a link to the sensor. Majenko's answer was the one I was looking for. I've got what to do now.

why do you even need the uno?

I think you have a fundamental misunderstanding of what you are working with.
There are two ways of working with an ESP8266:

Directly program the ESP8266. This involves installing the ESP8266 boards package and uploading the code to the ESP8266. No Arduino is required (unless you want to use one as a USB to UART adaptor for the programming).
Use the ESP8266 as a serial peripheral to an Arduino. You program the Arduino, not the ESP8266, and no special software is needed (unless you want to use an ESP8266 library for Arduino). You send the ESP8266 AT commands to get it to do internet related operations. You are still working with an Arduino, so that is the board that should be selected.

It sounds like you are wanting to do (2) but are mistakenly trying to so (1).
Option 2 does rely on the ESP8266 having the AI Thinker AT firmware installed on the ESP8266, which most come preinstalled with. If you have uploaded code to your ESP8266 using the ESP8266 boards package that firmware will have been replaced with your code and you will need to put the original firmware back on. There's many tutorials on the web showing you how.
If you do want to program the ESP8266 directly then it's the ESP8266 that you need to program, not an Arduino. Everything will be done by the ESP8266 - the GET request, the water flow sampling, the decision making, etc. The Arduino will be relegated to your bits box where it will gather dust.


text:
Should BLK and GRN of Pro Mini be connected to upload sketch?
Is the following connector is valid for Arduino Pro Mini (no BLK and GRN)?

I was told to make a certain Arduino application, and got some Arduino Pro Mini  (ATmeag328 3.3V 8 MHz) with the connector above.
Everytime I tried to upload an example sketch 'Blink', the IDE complains (verbose enabled):
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x83
...
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x83

resp may differ (I saw 0x1f and 0x83)
But, according to the official document,  I think that I should use some FTDI thing, which has 6 pins including BLK and GRN.
I wonder whether I can use the existing 4-pin connector, or whether I must use 6-pin FTDI connector.

BLK and GRN sound like Wire colors and those may vary from product to product.  Look at what the function of the wires are and not the colors.

You need a DTR signal to connect to reset to enter the bootloader, of manually enter the bootloader at the right time by pressing the reset button.

Thank you for comments. I realized that BLK and GRN are not relevant in my case. After compiling, I press reset button manually, start upload, release the button, and upload succeeds. It's somewhat inconvenient. I need to get some board to do it automatically.

"After compiling, I press reset button manually" <-- That's due to missing DTR connection.   If your USB TTY adapter does not expose a jumper for DTR, you may be able to solder one on by tracing where the DTR pin is on your particular USB-TTY chip.

If you look at the picture in your link, you would see that BLK is ground (GND) and GRN is DTR, that is used to reset the board and enter the bootloader for programming.
As Majenko said, without DTR you will need to press the reset button at the right time, to enter the bootloader.


text:
How to merge 2 batteries socketof 6v each
i want to merge 2 batteries socket of 4 AA 1.5v batteries , how can combine them to have 12v ?

Connect the + of A to the - of B. The + of B and - of A are 12V.

Put them in serie. One red cable to another black cable. Glue the cases back to back.
Don't get confused by the clamps; I only used them for keeping things in place. Oh, my cases are for 3 batteries, but the procedure is aplicable to 4 batteries cases also.

Well , it makes some smoke

i was connecting red at black and other red at black then  i was measuring , i got some smoke:))

but i'm good now , ty

@RaduMihai - Please, for your own safety, step away from the electronics and find a website where you can learn some basics, before you injure yourself.