text:
LM35 readings are erratic
My son just did the Love-o-meter project in the Arduino Start Kit. However, the sensor readings of the LM35 temperature control vary widely. Below is a sample. What could be wrong?
Sensor Value: 217, Volts: 1.06, degrees C: 105.96
Sensor Value: 587, Volts: 2.87, degrees C: 286.62
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 320, Volts: 1.56, degrees C: 156.25
Sensor Value: 445, Volts: 2.17, degrees C: 217.29
Sensor Value: 141, Volts: 0.69, degrees C: 68.85
Sensor Value: 510, Volts: 2.49, degrees C: 249.02
Sensor Value: 247, Volts: 1.21, degrees C: 120.61
Sensor Value: 168, Volts: 0.82, degrees C: 82.03
Sensor Value: 595, Volts: 2.91, degrees C: 290.53
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 206, Volts: 1.01, degrees C: 100.59
Sensor Value: 606, Volts: 2.96, degrees C: 295.90
Sensor Value: 125, Volts: 0.61, degrees C: 61.04
Sensor Value: 290, Volts: 1.42, degrees C: 141.60
Sensor Value: 487, Volts: 2.38, degrees C: 237.79

Here's the code:
const int sensorPin = A0;
const float baselineTemp = 25.0;

void setup(){
  Serial.begin(9600); // open a serial port
  for(int pinNumber = 2; pinNumber<5; pinNumber++){
    pinMode(pinNumber,OUTPUT);
    digitalWrite(pinNumber, LOW);
  }
}

void loop(){
  int sensorVal = analogRead(sensorPin);
  Serial.print("Sensor Value: ");
  Serial.print(sensorVal);
  // convert the ADC reading to voltage
  float voltage = (sensorVal/1024.0) * 5.0;
  Serial.print(", Volts: ");
  Serial.print(voltage);
  Serial.print(", degrees C: ");
  // convert the voltage to temperature in degrees
  float temperature = (voltage) * 100;
  Serial.println(temperature);

  if(temperature < baselineTemp){
    digitalWrite(1, LOW);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+2 &&
    temperature < baselineTemp+4){
    digitalWrite(1, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+4 &&
    temperature < baselineTemp+6){
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
  }else if(temperature >= baselineTemp+6){
    digitalWrite(1, HIGH);
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
  }
  delay(1);
}

The GND is connected to the left most connector in the LM35, the A0 to the middle, and the power to the right most connector.

Maybe you mistyped the code? Didn't wire correctly? We need more information.

Either the person can't decide if they are in love or not, there is a problem with the power supply (is it a battery?), there is some dodgy wiring, you are reading the values too fast or there is a bad earth.  Is it possible to post your code and a photo of your setup?

A link to this project would help, or copy and paste the code.

Point 1 - Don't use D0 and D1 (the first two), because they are the Rx and Tx ports for the serial line, at best the it won't work.

I moved it to D3 to D5, but the sensor values are still the same, i.e. they vary wildly.

Looking at http://www.ti.com/lit/ds/symlink/lm35.pdf (page 3, LP package) and the way the sensor is facing in the picture, the pinout is 5V, Signal, GND, but you switched 5V and GND? (in this case of reverse polarity you have probably burned out your sensor already.)

I've had a look round and spotted this:
https://electronics.stackexchange.com/questions/117970/why-is-my-analog-temp-sensors-signal-so-unstable
In summary it says that the fault maybe that the Arduino's 5V isn't stable enough, so you need to decouple it.  For once it seems that running from batteries may have been a better idea.
I've also seen posts saying there should be a 500Ohm resistor between the Ground of the LM35 and Ground.  Apparently it says 499Ohm on the datasheet.
And as a final resort I saw said that the 'Data Direction Register' influenced the analog pins.  If it was set to digital output this could lead to unstable readings for the ADC.  Basically it implied you needed to set the analog pin's to pinMode (A0, output). But I really don't think this will work


text:
Motor not working when connected to motor driver shield?
My code is getting uploaded to arduino without problem but still my motor is not moving when i connect it to the motor driver shield. I am supplying 6V battery to the shield which is connected to dc motor at M2
What could be the problem?
Code:-
#include <AFMotor.h> //import your motor shield library

AF_DCMotor motor2(2,MOTOR12_2KHZ); // set up motors.
AF_DCMotor motor3(1, MOTOR34_1KHZ);

void setup() {
  Serial.begin(9600); // begin serial communitication
  Serial.println("Motor test!");
  motor2.setSpeed(105); //set the speed of the motors, between 0-255
  motor3.setSpeed(105);
}

void loop() {
   motor2.run(FORWARD);
   motor3.run(FORWARD);
  }

Do you have a picture of your setup?  You might also find this post on our Meta site helpful: How to ask a good question for Arduino Stack Exchange.

There is a large voltage drop to the motors. It is meant for 12v and (very) small 12v motors.

so it means if i supply 12v then it will work right? but the motor works with 5v also

The l293d outputs a voltage to a motor of 2.6v lower than the power supply. For 12v you need 12v motors.

When I power 12V to my motor shield for my 4 gear motor the arduino UNO is not turning on because of this my motors are not moving. What is the problem?

I cannot tell all of your connections from the photo, but I'm guessing you're supplying power to the Arduino through its power connector and also to the motors, both from the battery. The power connector on the Arduino is specified for 7-12v because the kind of voltage regulator it has needs that 2v difference to operate properly. You're kind of at the edge by supplying 6v, and when the motors come on, their current draw will cause the 6v battery voltage to drop somewhat. It probably drops below the regulator's ability to supply 5v from it, shutting down the Arduino.
Adding one more cell to your battery will give you 7.5v (5x1.5v) and will may be enough to run the Arduino and the motors. Two more cells would work even better. (Don't make the mistake of trying the small 9v batteries with snap-clips on top - their utterly incapable of supply the current your motors need).

cool, i will try to supply more power and see. thanks

source: Stack Exchange

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

sort: votes


text:
MPU9250 and ESP8266 are not working together with Arduino Uno
I am trying to send IMU sensor data via WiFi using ESP8266. Both MPU9250 and ESP8266 worked individually with 3.3 V when tested, but are not working when interfaced together. I am not sure what the problem is; it looks like the ESP8266 is getting connected to WiFi, but the IMU is having a problem.
First I connected the ESP and the IMU parallel with 3.3 V from the Arduino, but it did not work.
Then I connected the IMU separately with 5 V but still unsuccessful.
Connections of MPU9250

Connection of ESP8266

note:-
3.3 supply is common to esp and imu
reset is connected to ground
board selected in Arduino IDE is 'generic ESP8266'
code:
#include <ESP8266WiFi.h>
#define PubNub_BASE_CLIENT WiFiClient
#include <PubNub.h>
#define PUBNUB_DEFINE_STRSPN_AND_STRNCASECMP
#include "MPU9250.h"

const char *ssid =  "mym404";     // replace with your wifi ssid and wpa2 key
const char *pass =  "786110786";

const char * pubkey = "pub-c-4a9cdbca-5688-4939-a852-f63cf6743980";
const char * subkey = "sub-c-9b4067ae-1293-11e9-b4a6-026d6924b094";

const char * pubchannel = "demo_keyset";
const char * subchannel = "demo_keyset";

MPU9250 IMU(Wire,0x68);
int status;

void setup() {
    /* For debugging, set to speed of your choice */
    Serial.begin(115200);

       Serial.println("Connecting to ");
       Serial.println(ssid);

       WiFi.begin(ssid, pass);
       while (WiFi.status() != WL_CONNECTED)
          {
            delay(500);
            Serial.print(".");
          }
      Serial.println("");
      Serial.println("WiFi connected");

    /* Start the Pubnub library by giving it a publish and subscribe
       keys */
    PubNub.begin(pubkey, subkey);

    while(!Serial) {}

  // start communication with IMU
  status = IMU.begin();
  if (status < 0) {
    Serial.println("IMU initialization unsuccessful");
    Serial.println("Check IMU wiring or try cycling power");
    Serial.print("Status: ");
    Serial.println(status);
    while(1) {}
  }
}

void loop() {
    // read the sensor
  IMU.readSensor();
  // display the data
  Serial.print(IMU.getAccelX_mss(),6);
  Serial.print("\t");

    /* Publish message. You could use `auto` here... */
    PubNonSubClient *pclient = PubNub.publish(pubchannel, "String(IMU.getAccelX_mss())");
    if (!pclient) return;
    PublishCracker cheez;
    cheez.read_and_parse(pclient);
    /** You're mostly interested in `outcome()`, and,
        if it's "failed", then `description()`.
    */
    Serial.print("Outcome: "); Serial.print(cheez.outcome());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
    Serial.print("description: "); Serial.println(cheez.description());
    Serial.print("timestamp: "); Serial.println(cheez.timestamp());
    Serial.print("state: "); Serial.print(cheez.state());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
    pclient->stop();

    /* Wait for news. */
    PubSubClient *sclient = PubNub.subscribe(subchannel);
    if (!sclient) return; // error
    String msg;
    SubscribeCracker ritz(sclient);
    while (!ritz.finished()) {
        ritz.get(msg);
        if (msg.length() > 0) {
            Serial.print("Received: "); Serial.println(msg);
        }
    }
    sclient->stop();

    delay(1000);
}

I didn't get any error but here is the serial port message:-
.....
WiFi connected
IMU initialization unsuccessful
Check IMU wiring or try cycling power
Status: -1

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffdf0 end: 3fffffc0 offset: 01b0
3fffffa0:  3fffdad0 00000000 3ffeec60 40206dd0
3fffffb0:  feefeffe feefeffe 3ffe8538 4010150d
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,7)

What could be the problem here?

wires are connected like above

so you think that the esp8266 should be able to read the IMU wired to Uno? how?

I thought sensor readings will go to arduino, which will upload data to wifi through ESP8266. What should i do then? using node mcu?

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


text:
How to interface MPU9250 and NodeMcu?
I am trying to send MPU sensor data to Pubnub IOT platform but not able to do it since there is some unknown problem. There is no error in code but following issue pops up in com port:-

It looks like sensor reading needs to be in JSON Format but no sure how to do it. I Just need it in raw imu sensor reading for now so how do i get it.
Here is the code:
#include <ESP8266WiFi.h>
#define PubNub_BASE_CLIENT WiFiClient
#include <PubNub.h>
#define PUBNUB_DEFINE_STRSPN_AND_STRNCASECMP
#include "MPU9250.h"

const char *ssid =  "mym404";     // replace with your wifi ssid and wpa2 key
const char *pass =  "786110786";

const char * pubkey = "my key";
const char * subkey = "my key";

const char * pubchannel = "demo_keyset";
const char * subchannel = "demo_keyset";

MPU9250 IMU(Wire,0x68);
int status;

void setup() {
    /* For debugging, set to speed of your choice */
    Serial.begin(115200);

       Serial.println("Connecting to ");
       Serial.println(ssid);

       WiFi.begin(ssid, pass);
       while (WiFi.status() != WL_CONNECTED)
          {
            delay(500);
            Serial.print(".");
          }
      Serial.println("");
      Serial.println("WiFi connected");

    /* Start the Pubnub library by giving it a publish and subscribe
       keys */
    PubNub.begin(pubkey, subkey);

    while(!Serial) {}

  // start communication with IMU
  status = IMU.begin();
  if (status < 0) {
    Serial.println("IMU initialization unsuccessful");
    Serial.println("Check IMU wiring or try cycling power");
    Serial.print("Status: ");
    Serial.println(status);
    while(1) {}
  }
}

void loop() {
    // read the sensor
  IMU.readSensor();
  // display the data
  Serial.print(IMU.getAccelX_mss(),6);
  Serial.print("\t");

    /* Publish message. You could use `auto` here... */
    PubNonSubClient *pclient = PubNub.publish(pubchannel, "String(IMU.getAccelX_mss())");
    if (!pclient) return;
    PublishCracker cheez;
    cheez.read_and_parse(pclient);
    /** You're mostly interested in `outcome()`, and,
        if it's "failed", then `description()`.
    */
    Serial.print("Outcome: "); Serial.print(cheez.outcome());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.outcome()));
    Serial.print("description: "); Serial.println(cheez.description());
    Serial.print("timestamp: "); Serial.println(cheez.timestamp());
    Serial.print("state: "); Serial.print(cheez.state());
    Serial.print(' '); Serial.println(cheez.to_str(cheez.state()));
    pclient->stop();

    /* Wait for news. */
    PubSubClient *sclient = PubNub.subscribe(subchannel);
    if (!sclient) return; // error
    String msg;
    SubscribeCracker ritz(sclient);
    while (!ritz.finished()) {
        ritz.get(msg);
        if (msg.length() > 0) {
            Serial.print("Received: "); Serial.println(msg);
        }
    }
    sclient->stop();

    delay(1000);
}

What do you guys think?

I hope your pubkey and subkey aren't sensitive data

no, its just demo key. but will change it just in case.

The error you're reporting is coming from your call to PubNub.publish(). You could have diagnosed the problem by taking outputting and inspecting what you were passing to it.
Your line:
PubNonSubClient *pclient = PubNub.publish(pubchannel, "String(IMU.getAccelX_mss())");

is not going to work. You're sending the string "String(IMU.getAccelX_mss())" to PubNub rather than the value of IMU.getAccelX_mss() as a String. Take the quotes off it:
PubNonSubClient *pclient = PubNub.publish(pubchannel, String(IMU.getAccelX_mss()));

If for some reason the number has to be returned as a string, the code would look like:
PubNonSubClient *pclient = PubNub.publish(pubchannel, "\"" + String(IMU.getAccelX_mss()) + "\"");

I tried but it doesn't work. In Pubnub documentation its written to send that data in JSON format. eg - ""message"" . I know about uploading string but don't know about uploading data as a variable. You know how to upload variable as JSON.

You'll need ArduinoJson to make JSON easier - but if the data you are sending is very simple, then there's probably no need for ArduinoJson library - please add to the question the expected format of the data you are sending

I just need raw sensor reading for now

The answer I gave you sends the raw sensor reading to the server. You keep saying you need to send JSON. What should the JSON look like?

Expected format should be ""IMU.getAccelX_mss()"" .Just that imu.get needs to show an actual reading.

It's odd that a number should be returned as a string. I've updated the answer to publish a string instead of a number.


text:
Interfacing a stepper motor with arduino
I am having issues with interfacing my stepper motor, connected to a control board being this one
Due to some reason I am not able to move it, unless I remove the enable signal. I can change the direction either unless I manually change by either plug it or unplug it. If codewise change the state of the dir_pin,would the motor keep spinning in the same direction.
The control board need has a timing diagram, specifying when the en, and dir signal should be enabled.

the code I am using to interface it is as below:
stepper_motor.cpp:
#include "stepper_motor.h"

stepper_motor::stepper_motor()
{
  pinMode(BUILTIN_LED,OUTPUT);
  pinMode(step_pin,OUTPUT);
  pinMode(dir_pin,OUTPUT);
  pinMode(en_pin,OUTPUT);

  alive_bool = true;
  position_bool = false;
  step_count = 0;
}

void stepper_motor::alive()
{
  if(alive_bool == true)
  {
    digitalWrite(BUILTIN_LED,HIGH);
    alive_bool = false;
    delay(2000);
  }
  else if(alive_bool == false)
  {
    digitalWrite(BUILTIN_LED,LOW);
    alive_bool = true;
    delay(2000);
  }
}

void stepper_motor::step_pwm()
{

    digitalWrite(en_pin,HIGH);

    delay(0.005);

    digitalWrite(dir_pin,LOW);

    delay(0.005);

    while(1)
    {
      digitalWrite(step_pin,LOW);
      delay(1);
      digitalWrite(step_pin,HIGH);
      delay(1);
    }

}

stepper_motor.h
/* Class: stepper_motor
 * Info: contains the setup, and primary interface to control
 * the stepper motor
 *
 * stepper_motor(): constructor -  setup the connection to the control board
 * void step_pwm():  Moves the tilt - uses the bool to determine the direction.
 * bool alive_bool: Is either high (1) or low (0), used for the alive void.
 */

#ifndef stepper_motor_h
#define stepper_motor_h

#include "Arduino.h"
#include "pins_arduino.h"

#define step_pin  D1
#define dir_pin   D2
#define en_pin    D3
#define max_step  200

 class stepper_motor
{
  public:
    stepper_motor();
    void alive();
    void step_pwm();
  private:
    bool alive_bool;
    bool position_bool;
    int step_count;
};

#endif

main:
#include "stepper_motor.h"

stepper_motor motor;
int state = 0;
void setup() {
  // put your setup code here, to run once:
}

void loop() {

      motor.step_pwm();
}

The motor moves, so the step signal seem to be correct.
But enable and dir seem to incorrect, or are pretty sure that they are.
So what is wrong with those signal? do they not follow the required timing?

Check this statement "delay(0.005);"

See http://forum.arduino.cc/index.php?topic=317628.0

delay() works but not delayMicroseconds().. delay works due to the code overhead is around 12 ms

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


text:
Choosing Right Power Supply for Arduino - ESP8266 - HC-SR04
If I make connections like you see in picture below, will it work? Will I damage ESP or HC-SR04?
As I know;
HC-SR04 (VCC) -> 5V
ESP8266 (VCC) -> 3.6V
ESP8266 (RX/TX) -> has 5V tolerance ?
I have not taken into account the currents that will each pin draw. So, is everything OK?
I'm not good at this stuff, so I'll appreciate it if you guys give me advice
Image

Most of you suggest to use voltage regulator instead of external AA batteries. However, I have already ordered one but it takes too much time (nearly week) to get, due to delivery-shipping issues. So, I want to work on the coding part of my project.

The voltage regulator would be used in conjunction with not instead of the batteries. Regulators do not supply power by themselves.

Three freshly charged NiMH cells can easily exceed 3.6v, and if someone substitutes alkalines, potentially by a lot.

When you get the wiring sorted out, remove the batteries and plug in the USB, that should power it up and allow you to start writing your code.

GND seems dangling.
If you are going to use multiple power sources, make sure that all the minus/GND are connected together.
Whether the ESP8266 can use 5V or not should be checked against the actual unit you have. There are many variants and some might be more tolerant than others.
You do not show the power source for 5V - what is it?
By just typing on google HC-SR04 5V, you get a link to the manual, which has a section "4.0 PRODUCT SPECIFICATION AND LIMITATIONS": Min:4.5V Typ:5V Max:5.5V. You should at least give it a try and report your findings, asking for clarifications, if you need any, rather than just ask here for something that google can provide.

1- I didn't get what you mean by saying 'dangling'
2- I noticed that and connected them together.
3- I searched and checked it has 5 V tolerance.
4- No reason for connecting 5 V to board, I just made it if I need later.
I'll try now and let you notify the latest results. I hope I won't make something damage and useless.
thx for suggestions

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


text:
Control speed of linear actuator servo
I have a linear actuator that I want to be able to slow down. Right now, the shaft moves too quickly. I'm not sure how to do this. I was looking into varSpeedServo.h library but couldn't implement it.
//Includes
#include <Servo.h>

//Defines
#define LINEARACTUATORPIN 9        //Linear Actuator Digital Pin

const int button1Pin = 4;     // the number of the pushbutton pin

// variables will change:
int button1State = 0;         // variable for reading the pushbutton status

Servo LINEARACTUATOR;  // create servo objects to control the linear actuator

int linearValue = 10000;   //current positional value being sent to the linear actuator.

void setup()
{
  //initialize servo/linear actuator objects
  LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000);      // attaches/activates the linear actuator as a servo object

  // initialize the pushbutton pin as an input:
  pinMode(button1Pin, INPUT);

  //use the writeMicroseconds to set the linear actuators to their default positions
  LINEARACTUATOR.writeMicroseconds(linearValue);

}

void loop()
{

  // if the pushbutton is pressed set the linear value
  button1State = digitalRead(button1Pin);
  if (button1State == HIGH) {
    // set the position value
    delay(2000);
    linearValue = 1050;

  }

    if (button1State == LOW) {
    // set the position value
    linearValue = 2000;
  }

  //use the writeMicroseconds to set the actuator to the new position
  LINEARACTUATOR.writeMicroseconds(linearValue);
delay(3000);
}

Also see  Change Servo Speed With RedBearLabs BLE Shield

Have you tried something like the following?
#define STEP 50

void loop()
{

  // if the pushbutton is pressed set the linear value
  button1State = digitalRead(button1Pin);
  if (button1State == HIGH) {
    // set the position value
    if (linearValue > 1050)
       linearValue = max(linearValue-STEP,1050) ;

  }

    if (button1State == LOW) {
    // set the position value
    if (linearValue < 2000)
       linearValue = min(linearValue+50,2000) ;
  }

  //use the writeMicroseconds to set the actuator to the new position
  LINEARACTUATOR.writeMicroseconds(linearValue);
  delay(100);
}

By changing the STEP value (or the delay in the next-to-last line) you can change the speed of the servo.


text:
Is there any way I can light up a candle with an Arduino?
I want to make a candle flame light up triggered by a microcontroller. Is it possible? I only want to light it up. Not turn it down. Moreover, this is for a one-time use so the candle burning down and becoming shorter is not a problem.

Do you want it to get brighter and brighter in steps?

There are some pretty good responses on this subject at https://forum.arduino.cc/index.php?topic=70373. If one of those works for you please answer your own question.

You must summon the lord of the nether world to get the most prudent solution. I will spell his name with whitespace between each letter: M a j e n k o

Have someone hold the candle and a lighter.  Then, have the Arduino light an LED.  Once they see the LED, have them light the candle.  Once the LED is out, have them blow out the candle.  Problem solved.

@Samee87 Not at all. I just want to light it up once and that is it.

A simple solution is too use nichrome wire which when a current is passes through it will heat up. You could wrap some of this wire around the wick on the candle and then power it either straight from your arduino or you could include a capacitor.
This is much safer than some of the other methods which use potentially dangerous high voltages.
I tested the nichrome wire approach and it works! See following video clip. 2 Ohm resistance and 19V for 1 second.  https://1drv.ms/v/s!AvcBubMtAczvifYZwoESAhUodOoqRA

Even when nichrome is white-hot, it is dubious that it can light a wick. Did you try? It will also not autoadjust its length as the candle becomes lower.

@user400344 i have not lit a candle with nichrome wire but im sure if i was tightly wrapped at the bottom of the wick it would light. However as you stated it will not autoadjust obviously and so this is a problem. Maybe a complicated servo system could be used.

I think this is the solution that I am looking for if the wire is capable of becoming hot enough. I will try let know what happens!!

@ANANDAPADHMANABHANS yeah make sure you buy the correct wire. Look at the sellers details.

If you have a circuit, you can switch it on and off using a microcontroller.
So what you need is a circuit which can light a candle.  Have a look at these:
DIY arc lighter
CCFL Inverter becomes an Arc Lighter?
I predict your main problem will be dealing with the fact that candles get shorter as they burn.

Actually in my case that is not a problem as this is for a strict one time turning on. I am sorry I was not clear about that in my original post. I will try these out and see what happens!!

Use two rods at either side of the candle, and engineer two motors to slide op and down these rods. Meccano kung-fu.
Use limit switches to detect the highest and lowest positions for both motors. Mount a LED on one motor, and a laser (5 mW red is plenty). From the bottom, have both motors ascend, until the LED can receive data transmitted by the laser. Yes, you can most certainly use a laser diode for Serial.print.
When at the right height, engage gasburner. You can use an LDR (shielded against light from the sides with heatshrink) to check if the candle has been lit - shortly after disengaging gasburner. You will need a reading prior to each ignition.
Let me know how that works out.

This will not be a romantic candle.

Unless you're Bender from Futurama.  But he would prefer a 6502 instead of the Arduino.

Functioning proof of concept.
Ni-chrome wire from hair dryer, approximately 2 Ohms, powered by 19 V for about 1 second. video of proof of concept. Lots to work out still, but this obviously can work.

Have you considered using a servo with a high torque, and a piezo-electric butane lighter?
The high torque would be required to push the lighter button as these tend to be rather stiff. Also, they do not always work on the first press and so a few attempts by the servo may be required. A Dynamixel AX-12A could do the job, but pricey, and could be overkill.
To save some money and time, measure the torque required to push the lighter button first and then get a servo/actuator to match.
Alternatively, use a gas oven lighter, again in conjunction with a linear actuator.


text:
Connecting Mac to Adafruit Feather 32u4 Bluefruit LE over serial
The Adafruit board connects fine over USB serial, and fine over Bluetooth to a mobile app, but it will not connect to a Mac serial monitor over Bluetooth.
Is there any way to use the Adafruit's Bluetooth chip as a pass-through, to allow serial communication over Bluetooth from the Mac to the board itself?

Have you checked google for: "Mac bluetooth as COM port"? A lot of interesting articles can be found.

@Sakar did u ever figure this out?


text:
Using a potentiometer to control number of lit pixels on an NeoPixel strip
I'm working on controlling an Adafruit NeoPixel strip with an Arduino and a potentiometer. Specifically, I'm trying to use the potentiometer to control how many pixels are lit up on the strip. As I turn the potentiometer "up" (i.e., increasing the value), the number of lit-up pixels increases.
However, if I try to turn the potentiometer the other way and decrease the number of lit-up pixels, then the strip will stay at whatever the last value was.
I have a method below that's called during the 'void loop()' method that read in the potentiometer data:
void readAndSendPotentiometerDataIfChanged(void) {
 //Read data from analog pin 2, and scale it
 int newPotentiometerValue = analogRead(A2) / 5.68;
  if (newPotentiometerValue != lastPotentiometerValue) {
      Serial.print("POT. value");
      Serial.print(newPotentiometerValue);
      lastPotentiometerValue = newPotentiometerValue;

      /* The value of "colorVal" is determined by a switch, and seems to be
         working properly */
      if (colorVal == "RED") {
        //If the value is 0, we want to clear the pixel values to white
        if (lastPotentiometerValue == 0) {
          clearPixels();
        } else {
          colorWipe(strip.Color(255, 0, 0)); // Red
        }
      } else if (colorVal == "BLUE") {
        if (lastPotentiometerValue == 0) {
          clearPixels();
        } else {
          colorWipe(strip.Color(0, 0, 255)); // Blue
        }
      }
   }
}

The method below will clear out all 180 pixels on my strip to no color (clear).
void clearPixels() {
   uint16_t clearColor = (127, 127, 127);
   strip.setPixelColor(180, clearColor);
   strip.show();
}

Here's where the pixels on the strip get set...I'm sure the problem is in the for loop below, but I haven't been able to come up with a better way to set the pixels on the strip and then turn them on:
void colorWipe(uint32_t c) {

  /* Use the value of 'lastPotentiometerValue' to determine how many pixels
   on the strip should be lit up */
  for(uint16_t i=0; i<lastPotentiometerValue; i++) {
    strip.setPixelColor(i, c);
    delay(0.5);
  }
   strip.show();
}

Anyone have a pointer to how I could refactor my code so that the potentiometer works in both directions, and will light up or turn off the pixels on the strip as appropriate? Thank you!
EDIT Based on Ignacio's answer, I changed my colorWipe method to this:
void colorWipe(uint32_t c) {

  for (uint16_t i = lastPotentiometerValue; lastPotentiometerValue<180; i++){
      uint16_t clearColor = (127, 127, 127);
      strip.setPixelColor(i, clearColor);
  }

  for(uint16_t i=0; i<lastPotentiometerValue; i++) {
    strip.setPixelColor(i, c);
    delay(0.5);
  }

   strip.show();
}

However, now no strips are lit up.
EDIT 2
The condition was wrong; below is the code that works:
void colorWipe(uint32_t c) {

  for(uint16_t i = lastPotentiometerValue; i<180; i++){
      uint16_t clearColor = (0, 0, 0);
      strip.setPixelColor(i, clearColor);
  }

  for(uint16_t i=0; i<lastPotentiometerValue; i++) {
    strip.setPixelColor(i, c);
    delay(0.5);
  }

   strip.show();
}

You forgot to clear every other pixel in colorWipe(). Pixels that aren't sent a color retain their previous color.

That makes sense. So, something like (180-lastPotentiometerValue) would determine the pixels I need to clear, right?

No, everything from lastPotentiometerValue through 180.

That also makes sense; though I'm not sure how to keep that from resetting all the pixels (I made an edit to the question).

You goofed the condition.

How so? Apologies; not seeing what you're seeing :/

You need to compare i.


text:
Interface with mux-controlled LED rope
I'm working on using a GUI in Processing to control some LED rope from Adafruit, and using this multiplexer.
I've gotten the following Arduino code working the way I want to cycle through the various strands of LED rope and turn them on:
#include <SoftwareSerial.h>

//Mux1 control pins
int s0 = 8;
int s1 = 9;
int s2 = 10;
int s3 = 11;

//Mux2 control pins
int s4 = 12;
int s5 = 13;
int s6 = 14;
int s7 = 15;

//Mux in "SIG" pin
int SIG_pin = 3;

//Voltage vlaue to write to the LEDs
int testValue = 255;

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

  pinMode(s0, OUTPUT);
  pinMode(s1, OUTPUT);
  pinMode(s2, OUTPUT);
  pinMode(s3, OUTPUT);
  pinMode(s4, OUTPUT);
  pinMode(s5, OUTPUT);
  pinMode(s6, OUTPUT);
  pinMode(s7, OUTPUT);
  pinMode(SIG_pin, OUTPUT);

  digitalWrite(s0, LOW);
  digitalWrite(s1, LOW);
  digitalWrite(s2, LOW);
  digitalWrite(s3, LOW);
  digitalWrite(s4, LOW);
  digitalWrite(s5, LOW);
  digitalWrite(s6, LOW);
  digitalWrite(s7, LOW);
}

void loop(){

  for(int i = 0; i <= 19 ; i ++){
    Serial.println(i);
    testValue = 255;
    writeMux(i);
    delay(500);
//    testValue = 0;
//    writeMux(i);

  }

}

int writeMux(int channel){
  int controlPin[] = {s0, s1, s2, s3, s4, s5, s6, s7};

  int muxChannel[20][8]={
    //Mux 1
    {0,0,0,0,0,0,0,0}, //channel 0
    {1,0,0,0,0,0,0,0}, //channel 1
    {0,1,0,0,0,0,0,0}, //channel 2
    {1,1,0,0,0,0,0,0}, //channel 3
    {0,0,1,0,0,0,0,0}, //channel 4
    {1,0,1,0,0,0,0,0}, //channel 5
    {0,1,1,0,0,0,0,0}, //channel 6
    {1,1,1,0,0,0,0,0}, //channel 7
    {0,0,0,1,0,0,0,0}, //channel 8
    {1,0,0,1,0,0,0,0}, //channel 9

    //Max 2
    {1,1,1,1,0,0,0,0}, //channel 0
    {1,1,1,1,1,0,0,0}, //channel 1
    {1,1,1,1,0,1,0,0}, //channel 2
    {1,1,1,1,1,1,0,0}, //channel 3
    {1,1,1,1,0,0,1,0}, //channel 4
    {1,1,1,1,1,0,1,0}, //channel 5
    {1,1,1,1,0,1,1,0}, //channel 6
    {1,1,1,1,1,1,1,0}, //channel 7
    {1,1,1,1,0,0,0,1}, //channel 8
    {1,1,1,1,1,0,0,1}, //channel 9
  };

  //loop through the 4 sig
  for(int i = 0; i < 8; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
//    Serial.println("CHANNEL IS ");
//    Serial.println(muxChannel[channel][i]);

//    Serial.println("Control pin IS ");
//    Serial.println(controlPin[i]);
  }

  //write the value at the SIG pin
  analogWrite(SIG_pin, testValue);

//    Serial.println("Test value IS ");
//    Serial.println(testValue);

  //return the value
  return 0;
}

I'm working on converting this Arduino code to a Processing sketch so I can control the lights with a GUI. I've run the Standard Firmata sketch on my Uno before running my Processing sketch. However, nothing seems to happen...I know that my circuit is working (since it worked for the Arduino sketch), and most of my Processing code should be correct. Logging shows the sketch is trying to write the values I want. Anyone have any ideas? Below is the relevant part of the Processing sketch:
import cc.arduino.*;
import processing.serial.*;

int [] muxChannel;

//Mux1 control pins
int s0 = 8;
int s1 = 9;
int s2 = 10;
int s3 = 11;

//Mux2 control pins
int s4 = 12;
int s5 = 13;
int s6 = 14;
int s7 = 15;

//Mux in "SIG" pin
int SIG_pin = 3;

//Voltage vlaue to write to the LEDs
int testValue = 255;

void setup() {
  size(700,400);
  noStroke();
  cp5 = new ControlP5(this);
  println(Arduino.list());

  //// Set up Arduino and pin output modes
  arduino = new Arduino(this, Arduino.list()[1], 96000);

  arduino.pinMode(s0, Arduino.OUTPUT);
  arduino.pinMode(s1, Arduino.OUTPUT);
  arduino.pinMode(s2, Arduino.OUTPUT);
  arduino.pinMode(s3, Arduino.OUTPUT);
  arduino.pinMode(s4, Arduino.OUTPUT);
  arduino.pinMode(s5, Arduino.OUTPUT);
  arduino.pinMode(s6, Arduino.OUTPUT);
  arduino.pinMode(s7, Arduino.OUTPUT);
  arduino.pinMode(SIG_pin, Arduino.OUTPUT);

  arduino.digitalWrite(s0, Arduino.LOW);
  arduino.digitalWrite(s1, Arduino.LOW);
  arduino.digitalWrite(s2, Arduino.LOW);
  arduino.digitalWrite(s3, Arduino.LOW);
  arduino.digitalWrite(s4, Arduino.LOW);
  arduino.digitalWrite(s5, Arduino.LOW);
  arduino.digitalWrite(s6, Arduino.LOW);
  arduino.digitalWrite(s7, Arduino.LOW);
}

void draw() {
  background(bgColor);

    for(int i = 0; i <= 19 ; i ++){
    testValue = 255;
    writeMux(i);
    delay(500);
  }
}

int writeMux(int channel){
  int controlPin[] = {s0, s1, s2, s3};

  final int[][] muxChannels = {
    //Mux 1
    {0,0,0,0,0,0,0,0}, //channel 0
    {1,0,0,0,0,0,0,0}, //channel 1
    {0,1,0,0,0,0,0,0}, //channel 2
    {1,1,0,0,0,0,0,0}, //channel 3
    {0,0,1,0,0,0,0,0}, //channel 4
    {1,0,1,0,0,0,0,0}, //channel 5
    {0,1,1,0,0,0,0,0}, //channel 6
    {1,1,1,0,0,0,0,0}, //channel 7
    {0,0,0,1,0,0,0,0}, //channel 8
    {1,0,0,1,0,0,0,0}, //channel 9

    //Max 2
    {1,1,1,1,0,0,0,0}, //channel 0
    {1,1,1,1,1,0,0,0}, //channel 1
    {1,1,1,1,0,1,0,0}, //channel 2
    {1,1,1,1,1,1,0,0}, //channel 3
    {1,1,1,1,0,0,1,0}, //channel 4
    {1,1,1,1,1,0,1,0}, //channel 5
    {1,1,1,1,0,1,1,0}, //channel 6
    {1,1,1,1,1,1,1,0}, //channel 7
    {1,1,1,1,0,0,0,1}, //channel 8
    {1,1,1,1,1,0,0,1}, //channel 9
    };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    arduino.digitalWrite(controlPin[i], muxChannels[channel][i]);
  }

  //write the value at the SIG pin
  arduino.analogWrite(SIG_pin, testValue);

  int val = 0;
  return val;
}

EDIT: I put the project and a little explainer on GitHub to show what this type of project can or can't be useful for here: https://github.com/narner/Analog-LED-Multiplexing-Example

It makes no sense to have that stupid muxChannels[][] array, which wastes 128 bytes of RAM.  Comments in the bildr.org webpage you referenced pointed out that it's unnecessary, but the webpage author had a lame excuse for not fixing it.  Instead of for(int i = 0; i < 4; i ++)     arduino.digitalWrite(controlPin[i], muxChannels[channel][i]);, say
for(int i=0; i<4; ++i)     arduino.digitalWrite(controlPin[i], (channel>>i)&1); or alternately, PORTB = (PORTB & 0xF0)|channel;

Hey @jwpat7, I think I follow what you're saying there. I tried your suggestion; and it works for the lights connected to the first multiplexer, but nothing seems to happen with the lights on the second one.

I didn't see code for the second multiplexer, and don't know what channel numbers you will use for it, so didn't say how to treat it.    But if its list of control pins is in controlM2[] and the channels are 0 to 9, try for(int i=0; i<4; ++i) if (firstMux())  arduino.digitalWrite(controlPin[i], (channel>>i)&1); else  arduino.digitalWrite(controlM2[i], (channel>>i)&1); or you could say for(int i=0; i<4; ++i) arduino.digitalWrite( firstMux()?  controlPin[i] : controlM2[i], (channel>>i)&1); where firstMux() is true for the first mux but not the second

Comments are for clarifying the question. Please post answers as answers.

You're using a 16-channel analog multiplexer to talk to your devices (the LED ropes) via a single pin on your Arduino. "Multiplexer" is just a fancy name for a switch; "analog" means that it's switching analog connections, basically, wires that can have any voltage on them, as opposed to digital connections that carry only logic high (usually +5 volts) or low (0 volt) signals.
The first place to start is the datasheet. From the product link, we can see that the chip we're using is a CD74HC4067. Their datasheet links don't work, but searching in Octopart for just "74HC4067" eventally led me to an actual datasheet. These datasheets are the key source for information on the parts you're using and are always worth reading through. Even if you don't understand everything in them, they'll usually have the information you need, and reading them gets easier with practice.
Section 5 has a functional diagram (Fig. 1) which shows the important connections.

Z is what you'll hook up to an I/O pin on your Arduino. When the
chip is enabled, Z will be connected to one of the Y connections.
Y0 through Y15 are what you'll hook up to your individual devices;
one (and only one) of these at a time will be connected to Z,
connecting the device to your Arduino I/O pin.
(The other Y connections will be in a high impedance state.)
Ē is the "enable" signal, the bar over top indicating that it's
"active low." That is to say, when you ground (0 V) Ē the mux will
be active and the selected Y will be connected to Z. When you hold Ē
high (5 V) the mux will be inactive and all the Ys and Z will be
disconnected (high impedance again).
S0 through S3 are the select inputs to the mux; they determine which
Y is connected to Z (when the device is active) in a way we'll show
below.

Depending on the project, you may not want to switch the connection between the Z and Y pins (by changing S0-S3) while the devices connected to the Ys are active so that you don't accidentally get a a little bit of signal meant for one device going to another. The steps to do this would be as follows:

You start by having Z connected to, say, Y0, with the signal you
want to send to Y0 going through Z.
Disable the device by bringing Ē high. Now Y0 (and all other Ys)
are disconnected.
Change the value on S0-S3 to select, e.g., Y1.
Change the signal you're sending to Z to the correct signal for Y1.
Bring Ē low to enable the device and now Z will be connected to Y1.

In your project you likely don't need to worry about being this careful with your switching so long as you change S0-S3 and Z as closely together as possible, so I'm going to simplify the code I show here by leaving out the enabling and disabling step; you can just wire Ē to ground for the moment.
The key to the switch is what you send on S0-S3 to select which Y is connected to Z. This input is just a binary number, which you'll need to understand to use it effectively. Following is a short summary, but if you don't understand it completely (or the C code later on), there are plenty of tutorials on the web that can give you further help.
Counting in binary is just like counting in tens except you have only the numbers 0 and 1. So instead of counting 0, 1, 2, ..., 9, 10, 11 you count 0, 1, 10, 11, 100, 101, ... (which represent the numbers 0, 1, 2, 3, 4, 5, ... in decimal). The S0 input on the mux is the least signifcant bit (the one furthest right), the S1 in put the second least significant bit (second from the right) and so on.
So you need to hook up four digital ouput pins from your Arduino to the S0 through S3 inputs on the mux and then manipulate those pins to send the appropriate number to the mux to select your chosen Y that you want to connect to X.
The following program, which counts sequentially from 0000 (0) through 1111 (15) on the four output pins; shows you how to do this. It would be a good idea to build up a small circuit on a breadboard with four LEDs (remember to use a 330 Ω or so resistor in series with the LED) that you can hook to your four pins so you can see visually what your program is doing as you experiment.
We start by declaring some constants for the pins:
// Multiplexer control pins are assumed to be sequentially
// assigned from `mux_base` onward.
//
const int mux_base = 8;
const int mux_len = 4;                  // 2^4 values, 0 through 15
const int mux_max = (1 << mux_len) - 1;

mux_base is the first pin of the four sequental pins you'll hook up to the S0-S3 (or the LEDs); I use pin 8 here but you can use pretty much any pin you like. mux_len is the number of bits in the mux selector input; S0, S1, S2, S3 is 4 bits, so this determines that I'm using pins 8, 9, 10 and 11 on the Arduino to control the mux.
mux_max is purely a calculation (from the previous two constants) of the highest value you can select on the mux; in this case it's 15. The details of how I caculate it are a bit beyond the scope of this answer, but it's worth working out yourself how that C code works from what you learn later in the code and can find out elsewhere on the web.
We need, as usual, to set up our chosen pins as digital outputs; setup_mux() does just that:
void setup_mux() {
    for (int pin = mux_base; pin < mux_base+mux_len; pin++) {
        pinMode(pin, OUTPUT);
        digitalWrite(pin, LOW);
    }
}

We start with the first selector pin and loop through to the last one, for each one setting it to output mode and setting the current value to LOW so that we have known starting conditions.
For the selection of the Y to connect to Z on the multiplexer, it's convenient to have a function that takes an int indicating that Y and sets our selector pins to the correct values for this. Thus, set_mux(value) below. This is probably the most complex part of this answer, and bears detailed study.
void set_mux(int value) {
    for (int offset = 0; offset < mux_len; offset++) {
        int bit = (value >> offset) & 1;
        digitalWrite(mux_base + offset, bit ? HIGH : LOW);
    }
}

The first line loops through our mux_len (4 from above) selector
pins; each of these will have to be set to the correct HIGH or
LOW value for the desired Y selection.
The second line determines the binary bit from value for the
particular selector pin we're setting in this iteration of the
loop. We do this by doing a binary shift of the value to the right,
and then clearing all bits except the lowest one, leaving us with a
final value for bit of 1 or 0. For example, if we pass 14 to the
function, which is 1110 in binary, when the offset is 2 in the loop
we'll use the >> operator to shift that right two bits, through 0111
to 0011. (With each shift the right bit drops off and a 0 is added
at the left.) Doing a logcal AND (the & operator) of 0011
with 0001 keeps only the bits that are set in both, leaving us
with 0001. (Only the far right bit is set in both.)
We then need to set the output pin to HIGH if bit is 1 or LOW if
bit is 0; the ternary operator (condition ? when-true :
when-false) provides a concise way of doing this.

That's our core "library" code, if you will. In this simple example the only setup we need to do is to call setup_mux():
void setup() {
    setup_mux();
}

Our main program, for demonstration, will count upwards in binary on the selector outputs, delaying a half second between each count so you can see your LEDs blink:
int counter = 0;

void loop() {
    set_mux(counter);
    delay(500);
    counter++;
    if (counter > mux_max)
        counter = 0;
}

Once you understand this example, you have everything you need to start using your multiplexer with something more sophisticated than just counting.
One last important thing to emphasize: the mux allows you to use just one signal I/O (plus the four selector outputs) on your Arduino, but that signal I/O is connected to only one device at a time. This won't work if you must always be sending a signal to several devices at the same time, which it appears might be the case from your other question. That said, if there's any time at which you're sending 0 V to a device, that is time you could be spending sending a non-0 V signal to another device.
For example, holding Z at +5 V and cycling the signal outputs through Y0-Y3 quickly will give you what's effectively a +5 V PWM with 25% duty cycle on Y0-Y3. In some cases, this technique can be useful.
Oh, one additional note: this example controls just one multiplexer; you can easily control two with two sets of selector pins, but this starts to use up a lot of pins. Instead, you may wish to have one set of selector pins on the Arduino hooked up to both your muliplexors (and one I/O pin hooked up to both Zs) and use two more Arduino pins to control the Ē on each mux, having only one mux enabled at a time. This will save you three pins, at the cost of some complexity, but it's a good exercise to see if you really understand multiplexing technique since it's a straightforward extension of what you're doing with a single mux.

This is such an awesome answer - thank you for your time and input; this helped me a lot. Thank you!!!

I'm glad to hear it! The research to do this answer helped me learn, too, so thanks for the question!

Note that, if you don't mind direct port access (which is non-portable), set_mux() can be simplified to PORTB = PORTB & ~mux_max | value;. If you don't use pins 12 and 13, it can simplified further to PORTB = value;.

I put the project and a little explainer on GitHub to show what this type of project can or can't be useful for here: https://github.com/narner/Analog-LED-Multiplexing-Example

After reading your github page, I came to realize that:

you do not require full color control, but only setting the strips to
full red or full blue
you are using MOSFETs for driving them.

Given these conditions, I believe the project may be feasible with your
current setup. The trick is that MOSFETs have some gate capacitance: if
you set the gate either HIGH or LOW, and then disconnect it, it will
keep that state for some time, until the charge stored in the gate
leaks. This means you do not need to address each MOSFET continuously:
you can just periodically “refresh” them, and let the gate capacitance
“remember” the state between refreshes. This is similar to how DRAM
memory works.
I wrote the following code based on this idea. Note that I did not test
it, as I do not have the required hardware. It uses a timer interrupt
firing every 1024 µs to cycle through the ten used mux channels:
each channel gets then refreshed every 10.24 ms. It also uses
direct port access instead of digitalWrite(): not only it's way
faster (and you want to be fast in an ISR) but, more importantly, it
allows changing several outputs simultaneously. This is important in
order to avoid glitches.
/*
 * Patterns to send to the multiplexers. bit_patterns[mux][chann] is the
 * pattern to send to the multiplexer `mux' in order to update the
 * channel `chann'. Bits 0..3 hold the channel number, bit 4 is the
 * data. The data bits are all initialized to zero.
 */
volatile uint8_t bit_patterns[2][10] = {
    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
};

/*
 * Periodically cycle through the 10 used multiplexer channels, updating
 * the MOSFETs. The TIMER0_COMPA interrupt has to be enabled for this to
 * automatically run every 1024 microseconds.
 */
ISR(TIMER0_COMPA_vect)
{
    static uint8_t i;            // channel index
    PORTB = bit_patterns[0][i];  // update MUX 0
    PORTC = bit_patterns[1][i];  // update MUX 1
    if (++i >= 10) i = 0;        // cycle channels
}

void setup()
{
    DDRB   =  0x1f;         // set PB0..PB4 as outputs
    DDRC   =  0x1f;         // set PC0..PC4 as outputs
    TIMSK0 |= _BV(OCIE0A);  // enable TIMER0_COMPA interrupt
}

This code relies on Timer 0 being in the standard Arduino configuration,
where it loops every 1024 µs. It also needs a specific wiring,
where each multiplexer is connected to a single AVR port, as follows:
Arduino   multiplexers
----------------------
   8      S0 of MUX 0
       ...
  11      S3 of MUX 0
  12      SIG of MUX 0
  A0      S0 of MUX 1
       ...
  A3      S3 of MUX 1
  A4      SIG of MUX 1

In order to change the strip colors, you just have to update the stored
bit patterns:
/*
 * On each of PORTB and PORTC, bits 0..3 are wired to the address select
 * pins of a multiplexer, whereas bit 4 goes to the SIG pin of the same
 * multiplexer.
 */
const uint8_t SIG_BIT = 0x10;

/* These are the only available colors. */
typedef enum { BLACK, RED, BLUE, MAGENTA } color_t;

/* Set the color of a strip. Strips are numbered from 0 to 9. */
void set_color(uint8_t strip, color_t color)
{
    /* Find the relevant multiplexer and channels. */
    uint8_t mux, red_ch, blue_ch;
    if (strip < 5) {
        mux = 0;
        red_ch = 2 * strip;
    } else {
        mux = 1;
        red_ch = 2 * (strip - 5);
    }
    blue_ch = red_ch + 1;

    /* Update the bit patterns. */
    if (color == RED || color == MAGENTA)
        bit_patterns[mux][red_ch] |= SIG_BIT;
    else
        bit_patterns[mux][red_ch] &= ~SIG_BIT;
    if (color == BLUE || color == MAGENTA)
        bit_patterns[mux][blue_ch] |= SIG_BIT;
    else
        bit_patterns[mux][blue_ch] &= ~SIG_BIT;
}

The function set_color() assumes the following connections between the
multiplexers and the strips:
MUX  channel    strip  color
----------------------------
 0      C0        0     red
 0      C1        0     blue
 0      C2        1     red
 0      C3        1     blue
            ...
 0      C8        4     red
 0      C9        4     blue
 1      C0        5     red
 1      C1        5     blue
            ...
 1      C8        9     red
 1      C9        9     blue

Hardware considerations
All this scheme may or may not work depending on some hardware factors
such as the gate capacitance of your MOSFETs, the leakage current of the
multiplexers when in high-impedance and the timing characteristics of
the same multiplexers. If the gate capacitance is too weak to hold the
value for 9 ms, you may want to add capacitors in parallel, maybe
something in the 100 pF range. If you add more than that, you may
also want to put resistors in series with pins 12 and A4 of the Arduino,
in order to protect them from the inrush current. But then you may also
want to slow down the scanning of the channels, which would require
configuring a timer.


text:
Arduino -> Processing conversion: creating mux channels
As the title alludes to, I'm in the process of converting an Arduino sketch to a Processing sketch. So far, mostly pretty straightforward.
I'm running into an issue with creating an array of ints for the channels for two muxers. Below is the code that I currently have working for the Arduino sketch:
int writeMux(int channel){
  int controlPin[] = {s0, s1, s2, s3, s4, s5, s6, s7};

  int muxChannel[20][8]={
    //Mux 1
    {0,0,0,0,0,0,0,0}, //channel 0
    {1,0,0,0,0,0,0,0}, //channel 1
    {0,1,0,0,0,0,0,0}, //channel 2
    {1,1,0,0,0,0,0,0}, //channel 3
    {0,0,1,0,0,0,0,0}, //channel 4
    {1,0,1,0,0,0,0,0}, //channel 5
    {0,1,1,0,0,0,0,0}, //channel 6
    {1,1,1,0,0,0,0,0}, //channel 7
    {0,0,0,1,0,0,0,0}, //channel 8
    {1,0,0,1,0,0,0,0}, //channel 9

    //Max 2
    {1,1,1,1,0,0,0,0}, //channel 0
    {1,1,1,1,1,0,0,0}, //channel 1
    {1,1,1,1,0,1,0,0}, //channel 2
    {1,1,1,1,1,1,0,0}, //channel 3
    {1,1,1,1,0,0,1,0}, //channel 4
    {1,1,1,1,1,0,1,0}, //channel 5
    {1,1,1,1,0,1,1,0}, //channel 6
    {1,1,1,1,1,1,1,0}, //channel 7
    {1,1,1,1,0,0,0,1}, //channel 8
    {1,1,1,1,1,0,0,1}, //channel 9
  };

  //loop through the 4 sig
  for(int i = 0; i < 8; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //write the value at the SIG pin
  analogWrite(SIG_pin, testValue);

  //return the value
  return 0;
}

Below is the slightly varied version that I'm using for my Processing-equivelent sketch.
int readMux(int channel){
  int controlPin[] = {s0, s1, s2, s3};

  int muxChannel[20][8]={
    //Mux 1
    {0,0,0,0,0,0,0,0}, //channel 0
    {1,0,0,0,0,0,0,0}, //channel 1
    {0,1,0,0,0,0,0,0}, //channel 2
    {1,1,0,0,0,0,0,0}, //channel 3
    {0,0,1,0,0,0,0,0}, //channel 4
    {1,0,1,0,0,0,0,0}, //channel 5
    {0,1,1,0,0,0,0,0}, //channel 6
    {1,1,1,0,0,0,0,0}, //channel 7
    {0,0,0,1,0,0,0,0}, //channel 8
    {1,0,0,1,0,0,0,0}, //channel 9

    //Max 2
    {1,1,1,1,0,0,0,0}, //channel 0
    {1,1,1,1,1,0,0,0}, //channel 1
    {1,1,1,1,0,1,0,0}, //channel 2
    {1,1,1,1,1,1,0,0}, //channel 3
    {1,1,1,1,0,0,1,0}, //channel 4
    {1,1,1,1,1,0,1,0}, //channel 5
    {1,1,1,1,0,1,1,0}, //channel 6
    {1,1,1,1,1,1,1,0}, //channel 7
    {1,1,1,1,0,0,0,1}, //channel 8
    {1,1,1,1,1,0,0,1}, //channel 9
  };

  //loop through the 4 sig
  for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

  //write the value at the SIG pin
  arduino.analogWrite(SIG_pin, testValue);

  int val = 0;
  return val;
}

I'm currently getting an error of unexpected token: int error at the following line:
  int muxChannel[20][8]={

And, an error of The type of expression must be an array type but it resolved to int at this line:
digitalWrite(controlPin[i], muxChannel[channel][i]);

Thank you!

You don't need to be a Java expert, your code is C.

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html


text:
Save Circularbuffer in RTC memory of ESP32
I would like to save my Circular Buffer in the RTC memory of my ESP32 when I use deep sleep. So I have initialized it with RTC_DATA_ATTR but when I go into Deep Sleep I lose the data I've saved. Is there  a way to do this?
Here is my function:
RTC_DATA_ATTR CircularBuffer<Datas, 178> test_SensorsDatas;

void test_RTC_memory(){

    for(int i=1; i<=20; i++){
        test_SensorsDatas.push(Datas);
        ID_msg.value++;
    }

    for(int i=0; i<test_SensorsDatas.size(); i++){
        Serial.println(String(Datas.value));
    }

    esp_deep_sleep_start();
}

Thank you very much! Ask me questions if something isn't clear ;)
EDIT: I tried something much simplier:
RTC_DATA_ATTR sensorsRecord newrecord{20, ID_sensor, ID_msg, epochUnion, ValueUnion, intValue, 30};
RTC_DATA_ATTR CircularBuffer<sensorsRecord, 50> test_SensorsDatas;

void test_RTC_memory2(){
    newrecord.ID_msg.value++;
    ID_msg.value++;
    Serial.println(String(newrecord.ID_msg.value));
    test_SensorsDatas.push(newrecord);
    Serial.println("buffer size: " + String(test_SensorsDatas.size()));
    esp_deep_sleep_start();
}```

But still not working, the ID_msg is incrementing well but not the buffer size even if I push a new value at every wake up.
Any suggestion?

I would guess the object is stored in RTC memory but the memory used by the object isn't. You'll need to apply the RTC_DATA_ATTR to the array inside the object, not the object itself.

Yes tried to define the data using RTC_DATA_ATTR outside of the function and after I push it in the Circular Buffer, I was unable to find it after the deep sleep...

first figure out what is really going on.  test by storing a number- char, int, short etc.  your simpler test case was a good thought but go even simpler.


text:
Serial hangs on Arduino-Uno
I'm having issues with Arduino and RPI3 serial communication, it'll become unresponsive after a little time. Tried increasing BAUD rate and same issue, also happens on Windows as well so RPI is not at fault, and even after increasing the delay the hang still happens.
RPI3 python code
import serial
import time

if __name__ == '__main__':
  ser = serial.Serial('/dev/ttyACM0', 115200, timeout=1, writeTimeout=0)
  ser.flush()
  last = "on\n"

  while True:
    last = "on\n" if last == "off\n" else "off\n"
    ser.write(last.encode())
    print(last)
    time.sleep(0.5)

Arduino code
#define BAUD_RATE 115200
const int LED_PIN = 8;
String command;

void setup() {
  Serial.begin(BAUD_RATE);
  pinMode(LED_PIN, OUTPUT);
  delay(100);
}

void loop() {
  Serial.println("I was written in RPI");

  if (Serial.available()) {
    command = Serial.readStringUntil('\n');

    if (command.equals("on")) {
      digitalWrite(LED_PIN, HIGH);
    } else if (command.equals("off")) {
      digitalWrite(LED_PIN, LOW);
    }
  }

  delay(50);
}

after less than a minute I'll get this exception from python
BlockingIOError: [Errno 11] Resource temporarily unavailable
The Arduino TX and RX led's stay on when it becomes unresponsive rather than flashing like it normally does.

also happens on Windows as well so RPI is not at fault ... maybe, but it does not exclude python problems

what error do you get on the RPi if you run LED blink sketch on the arduino?

Just the resource temporarily unavailable, the Arduino TX and RX led's stay on when it becomes unresponsive rather than flashing like it normally does.

the if (!Serial) { } block belongs in setup()

remove the if (Serial.availableForWrite()) { } block  .... whittle the code to minimum

Adjusted the code to be minimal.

does it still hang up?

Yes, still hangs

Does it help if you remove the Serial.println() from the Arduino code?

Can you try to find out which resource is unavailable?

You are flooding the RPi/PC with "I was written in RPI" and don't read it. Does it work if you read ser regularly?

Does dmesg -w tell you anything at the moment it locks up?

Seems to work fine if all I do is read OR write on the Arduino even without reading from the serial in python.

@thebusybee you were correct, seems to be working with ser.readline() in the python code. Free points if you want to write the comment as an answer will accept.

Also, worth noting I had to increase the delay on the Arduino to be more than sleep in python. For me delay(50) and sleep(0.01) works fine, maybe has something to do with python being slow?

You are flooding the RPi/PC with "I was written in RPI" and don't read it. It will work if you read ser regularly.
On the delays: A message over a serial line has a transmission time, in your case 20 characters at 115200 baud from Arduino to RPi/PC. With the common 8n1 protocol, characters are sent at 11520 per second. With 20 characters this will take nearly 0.002 seconds, or 2 ms. The receiver needs a smaller delay than the sender to avoid overflows.
If the Arduino were using the USB directly (AFAIK it does not, between its USB interface and the actual AVR is a "real" serial line), the baudrate does not matter. A virtual serial line over USB is always really fast, independent of the announced baudrate. I once used 921600 baud with success. ;-) The baudrate is only used if a real serial line is involved.


text:
Preprocessing problem
I've a little problem, I'm trying to create a library with processor variables for tune it.
So in .ino I declared my preprocessor var, but preprocessor variables appear not defined in my library. (Notice that I've create a folder test/test.h in libraries directory of Arduino IDE)
Some code to reproduce the problem :
test.ino :
#define TEST

#include "test.h"

void setup() {}
void loop() {}

test.h (edited, reverse error message, this is solution)
#if defined(TEST)
  #error "DEFINED"
#else
  #error "NOT DEFINED"
#endif

If I compile it, I fall on #error "NOT DEFINED".
Somebody with an idea ?
Have a good day

What you are doing should work IMO, have you tried #define TEST (1) ?

Note that using #defines in your sketch will have no effect at all on any usage of those defines in source code (.c and .cpp files), or the header file included in said source code files, in your library. It will only affect the single instance of the header file that is included in your sketch. Using #define in your sketch to configure a library is seldom does what you actually intend it to when you set out.

You should understand the concept of the Translation Unit to get a better insight into why #define in the sketch won't affect your library's source code operation.

The code is working properly. You have mixed up your error messages. The code should be:

#if defined(TEST)
  #error "DEFINED"
#else
  #error "NOT DEFINED"
#endif

UPDATE: The question was edited after the time of this answer to correct the mixed up error messages.


text:
How to know physical address of XBee?
I have a system with a server (a personal computer with an XBee Dongle plugged in, running a Java program) and some Boe-Bots with XBees attached and Arduino programs. I know how to get the Boe-Bots to send a message to the server. I want the server to obtain the Boe-Bot's XBee's physical address so that it can send a message to that particular Boe-Bot with the Java method
com.digi.xbee.api.XBeeDevice.sendData(RemoteXBeeDevice remoteXBeeDevice, byte[] data)
knowing what argument to put for remoteXBeeDevice.
I can think of two ways this might be possible.
1) There might be a method in the Arduino XBee library to obtain an XBee's physical address. Then the Boe-Bot can get its own address and send it in a message to the server. I have not found such a method.
2) On the server side, there might be a method in the Java XBee library that allows it to automatically determine the physical address of a client that is communicating with the server. I thought that XBeeMessage.getDevice() was such a method, but it returned a RemoteXBeeDevice with an XBee64BitAddress of FFFFFF... which is not the proper address of the Boe-Bot's XBees.
Does anyone know the correct Arduino method for option 1 or the correct Java method for option 2?
Edit: XBee S1

What XBees are you using?

XBee S1 for both the server and robots.

First you can check the signal received from the xbee connected with the server by using coolterm or arduino serial monitor. This is to ensure there are connections between the two xbees.
Then, you will receive some funny characters which is normal, you need to change these characters into hexadecimal form which is more preferable to use coolterm as it has the ability to do so.
Laslty, the characters received will be about 21 characters long. It starts with 7E as a starting character. That is what I received when using XBee S2. These characters then can be translated into other form.
I would suggest a book entitled Wireless Sensor Network by Robert Faludi to understand more.

I am looking for a method where I could just load the Arduino code onto the robots and start the server and it would work. I don't want to find the address of each robot manually. Is such a thing possible?

It would be possible if there is the exact code that apply the same thing. However, there is high chances that there is not. You need to configure every pins that changes when a signal is sent. You need to understand the configuration and then apply it in your code.


text:
easy_install pip on Arduino Yun fails
I want to install pip on the Yún which is running Linino OS but every time I execute the standard steps for opkg i.e.
# opkg update
# opkg install distribute
# okpg install python-openssl
# easy_install pip

Error
Searching for pip
Reading http://pypi.python.org/simple/pip/
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')

What is the reason behind this?
Kernel Information
Linux Arduino 3.3.8 #1 Fri Nov 14 08:57:34 CET 2014 mips GNU/Linux

I think you mean: python setup.py install for your last line

Found this Arduino Forum Thread helpful.
# wget \
https://pypi.python.org/packages/source/p/pip/pip-6.0.8.tar.gz#md5=2332e6f97e75ded3bddde0ced01dbda3\
  --no-check-certificate
# easy_install pip-6.0.8.tar.gz

Apparently the PyPi Package Site is now HTTPS and hence --no-check-certificate option should be used. Also MD5 Checksum of the package needs to attached in the link in order to avoid a HTTP 404 Error

Try:
sudo wget https://pypi.python.org/simple/pip/pip-6.0.8.tar.gz
sudo tar xzvf pip-6.0.8.tar.gz
cd pip-6.0.8
python setup.py

Try to use:opkg update opkg install python-pip
or python-pip3


text:
Arduino Yun with PoE does not work when powered via PoE
I have a Arduino Yun with PoE with LininoOS version

Linux arduino 3.3.8 #1 Thu Jun 2 12:28:33 CEST 2016 mips GNU/Linux

I have the Version 4.0 of the module.
I often notice that when I connect the module via a USB cable and login via Serial the WAN and WLAN LEDs blink and I can SSH via both the mediums.
However I cannot do the same when the Yun is completely powered via an Ethernet Cable and the I see the Yun frequently restarting and becoming inaccessible via SSH.
I cannot troubleshoot this problem via software as whenever I connect the USB cable along with the Ethernet Cable the power supply switches completely to the USB and the PoE stops and everything suddenly works well again.
Has someone faced the same issue? Is it because of the High Frequency Whistle problem where I need to solder a 100µF Electrolytic Capacitor to the PoE adapter?
Update
I measured the 5 V and 3.3 V pins on the Yun they provide their respective voltages via a multimeter.
I have a Microsens fast ethernet switch with PoE which provides standard (minimum 44V DC)

Apparently, the WAN LED blinks indicating the Ethernet Connection is available however everytime I ping the Yun it goes down.

Do you have a multimeter? Try measuring the 5 Volt and 3.3 Volt supply voltages on the Yun.  What voltage are you supplying over the ethernet cable?

PoE Adapter
Silvertel AG9600 1R requires a 100µF 16V Electrolytic Capacitor between it's PIN 7 and PIN 8
According to the PoE Yún Thread the capacitor polarity should be as follows:

PIN 7 --> Capacitor_Negative. PIN 8 --> Capacitor_Positive

solved my problem. I think the default 470uF capacitor might not be able to charge-discharge appropriately with data signals in the PoE.


text:
limit length of the generated timestamp from ESP32 with DS3231 to 13
I am using ESP-WROOM-32 (Olimex ESP32-PoE) with DS3231. I have used the a patch from PR on RTClib to avoid the rollover from the DS3231.
Since the DS3231 RTC provides Unix Epoch Timestamps which have a precision of only seconds, I wish to concatenate the millis() to the above mentioned timestamps to provide millisecond precision.
This is critical since I want to store information to InfluxDB from the nodes with ms precision. For that the timestamps should always be 13 digits.
code
#include <RTClib.h>
#include <Wire.h>

// PoE setting for Olimex PoE board

#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define ETH_PHY_POWER 12

// Pins for I2C on Olimex PoE board
#define I2C_SDA 13
#define I2C_SCL 16

RTC_DS3231 rtc;
RTC_Millis software_time;

void setup() {
  // put your setup code here, to run once:
  Wire.begin(I2C_SDA, I2C_SCL, 400000);
  Serial.begin(9600);
  if (!rtc.begin()) {
    Serial.println("No RTC Detected");
  }
  // adjust RTC Time
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  // adjust software timer
  software_time.adjust(rtc.now());

}

void loop() {
  // put your main code here, to run repeatedly:
  DateTime rtc_now_time = rtc.now();
  DateTime software_now_time = software_time.now();
  Serial.println();
  Serial.print("RTC now: "); Serial.print(rtc_now_time.unixtime());
  Serial.println();
  Serial.print("millis: "); Serial.print(millis());
  delay(100);

}

Output
RTC now: 1538502183
millis: 28
RTC now: 1538502183
millis: 128
RTC now: 1538502183
millis: 228
RTC now: 1538502183
millis: 328
RTC now: 1538502183
millis: 428
RTC now: 1538502183
millis: 528
RTC now: 1538502183
millis: 628
RTC now: 1538502183
millis: 728
RTC now: 1538502183
millis: 828
RTC now: 1538502183
millis: 928
RTC now: 1538502184
millis: 1028

I will store the timestamps in String so I was thinking of concatenating the .unixtime() with millis(). However since I want all my timestamps to be of fixed lenght (13) with the increasing millis value seems to be difficult because as soon as the number goes more that 999 the a digit increases making the string length 14.
Side Effect
if the timestamps for ms do not match length of 13, InfluxDB rejects the data passed through
Epoch Time
the output provided above is of 10 digits which is the epoch time since 1970. The precision of the timestamps above is of seconds. If one wants to add milliseconds to it one needs to add 3 more digits behind it. If precision needs to be microseconds it should have 6 digits and so on..
One can check the timestamps above on [https://epochconverter.com]
Any suggestions on overcoming this issue ?

Please explain the 13 digits or give a link to the format. Is the format "1234567890123"? As readable text with a decimal number? Should it be the number of milliseconds since 1970? Epoch = 1538498157 which is 10 digits, that means three extra digits for milliseconds? Will it still work if you make the three digits for the milliseconds zero? This number: https://currentmillis.com/ ?

Yes. it can work even if the milliseconds are zero. unfortunately the rtc does not provide ms precision hence I am adding the millis which is ms from the beginning of the controller.

So making them zero solves all problems? This is a similar question: https://stackoverflow.com/questions/44644383/how-to-get-millisecond-resolution-from-ds3231-rtc You can do millis() % 1000.

I have seen the post. I just am not sure if I understood the work around it completely. I can try the millis() %1000 and push the information on influxdb and inform you if it works.

@Jot your suggestion of millis() % 1000 works. Influx does parses the timestamp in human readable RFC3339

but it can give in one second two timestamps in wrong ordering

@Juraj what is the solution? How to get some kind of synchronization? Perhaps set the sqw output to 1Hz and tie it to an interrupt. In the interrupt set a previousMillis. Shan-Desai, can you connect the sqw signal to an interrupt input?

@Jot So I did connect the SQW pin of the RTC to a GPIO pin and following this tutorial and set the SQW to 1kHz settings. The problem is serial port, i2c and the interrupt are messing everything up. the values are of the timestamps are not updated accordingly and Serial print provides the same values for long time. Rarely, I see any change in the timestamp values

For getting millisecond resolution out of an RTC, I think the only
viable solution is to sync with the 1 Hz square wave output, as
suggested by Jot in a comment. Note that, since you are only counting
seconds and milliseconds, you probably don't care about hours, minutes,
days, months, etc. So you won't use the RTC for timekeeping: only for
providing the 1 Hz reference signal and, maybe, an initial
timestamp at program startup.
Connect the SQW pin of the DS3231 to an interrupt-capable input of your
MCU. Add the following to your setup():
pinMode(SQW_PIN, INPUT_PULLUP);
rtc.writeSqwPinMode(DS3231_SquareWave1Hz);
attachInterrupt(digitalPinToInterrupt(SQW_PIN), tick, FALLING);

Use the interrupt routine to both keep track of the total second count
(seconds elapsed since the Unix epoch) and record the micros() value
of the last tick:
volatile uint32_t seconds_since_epoch;
volatile uint32_t micros_on_tick;

void tick() {
    seconds_since_epoch++;
    micros_on_tick = micros();
}

Now you can combine these two values to get a millisecond-resolved
timestamp as follows:
uint64_t millis_since_epoch() {
    noInterrupts();
    uint32_t seconds = seconds_since_epoch;
    uint32_t microseconds = micros_on_tick;
    interrupts();
    uint32_t extra_micros = micros() - microseconds;
    uint16_t extra_millis = extra_micros / 1000;
    if (extra_millis > 999)
        extra_millis = 999;
    return (uint64_t) seconds * 1000 + extra_millis;
}

The value returned from this function is the 13-digit number you want,
provided seconds_since_epoch has been sensibly initialized.

won't I need the RTC to provide me the initial epoch time in seconds?

@Shan-Desai: Yes, that's the easiest way to initialize seconds_since_epoch.

You sir are a Legend! Thank you for this solution. Works great. With a little function to make the uint64_t to String was needed but rest everything works like a charm.

the goal is to generate unique and ordered millis part of timestamps in one epoch second.
unsigned long thisNowMillis;
uint32_t thisNow;

-
 uint32_t now = rtc_now_time.unixtime();
 if (now != thisNow) {
   thisNow = now;
   thisNowMillis = millis();
 }
 Serial.print("millis: "); Serial.print(millis() - thisNowMillis);

not tested and it will not work for counting intervals between timestamps.

will check this and get back to you


text:
How to make a smooth serial print?
I have a code which make some calculations using sensor values and provide two comma separated values.
float x;// initialization
float y;// initialization
//some calculations here using sensor values
Serial.print(x);Serial.print(",");Serial.print(y);

but the issue is due to some unstable situations of the sensor readings, I don't receive sensor data in same time intervals (overall delay is 1 second). I send these values to my Android device through a Bluetooth connection. At that stage, android device cannot separate two values due to lack of smoothness of the Serial.print(). Is there any way to make it smooth (like saving to a buffer before serial print or something) ?

Can you show us your sketch please?

please explain this cannot separate two values due to lack of smoothness ... do not use a word like smooth without explaining what it means

I bet your problem has nothing to do with “smoothness” (whatever that
means), but is entirely due to lack of message framing. The serial and
bluetooth links do not transmit messages: they transmit only a stream of
bytes, with no built-in notion of where a message ends and the next one
starts. Relying on the timing of the received bytes to tell the messages
apart is very unwise. You should instead use some kind of delimiter for
your messages.
For text-based transmissions like yours, the most natural choice is to
send a line terminator at the end of each message. Typically a CR+LF
pair. The Serial object has the println() methods designed precisely
for this purpose: they send their arguments immediately followed by
CRLF:
Serial.print(x); Serial.print(","); Serial.println(y);

At the receiving end, you have to buffer all the incoming characters
until you see the line termination. Then you know the message is
complete and you can process it.

Are there any way to make it smooth. (like saving to a buffer before serial print or something) ?

you can use sprintf function
char buff[50];
sprintf(buff, "{i:%i,t:%lu,v1:%d,v2:%d,c:%u}", ix, events[ix].timestamp, events[ix].value1, events[ix].value2, events[ix].count);
s.print(buff);

but this will not help you, I think. if you do not print nothing else only those 3 prints, then your next loop will print the first number 'glued' to the last number from the previous loop. use for example prinln to separate them with a newline.
if you have an interrupt in work which can interrupt the execution of the loop and make the prints 'not smooth', it too will be not repaired by printing a buffer. because the interrupt disrupts the Serial too


text:
Sending data by nRF24L01 with Arduino
Can I send data using nRF24L01 with Arduino through multiple pipes?
As by using the RF24 library, I can send data through just one pipe and receive on the 6 pipes that nRF24L01 has.

Yes, but the nRF24L01 can only transmit one message at at time, since it only has one buffer.
So roughly speaking, for each message

Set the transmit pipe address (if different than the last one)
Send data
Wait for completion (and ack or failure, if in that mode)


text:
Pyserial serial.write() doesn't work
I need to communicate with an Arduino. When I use serial.readline() to read what Arduino has to say it works fine. But when I useserial.write('something') doesn't seem to do anything.
Interesting thing is that if I write the same code in the console or command-line, it works as expected...
Using Python 2.7.
Python code:
import serial
import time

arduinoSerialData = serial.Serial('com6', 9600)
time.sleep(1)

while True:
    arduinoSerialData.write('AAA')
    arduinoSerialData.flush()
    sleep(0.5)

Arduino code:
void loop() {

if (Serial.readString().startsWith("AAA")) {
    digitalWrite(7, LOW);
} else {
    digitalWrite(7, HIGH);
}

delay(500);

Again, Python code runs fine from the console, so no idea why this happens.

Your subject is Pyserial serial.write() doesn't work but you follow up by saying it runs fine from the console. So, the serial.write does in fact work. Try to stop using the words "doesn't work" and describe in more detail what is happening.

Cross posted on Arduino Forum and a second time.

please append what you did that worked - so the steps you did in the 'console' -

i think that your readString() can't reliably get all three AAAs in one catch - you have to send them at the right moment - otherwise it will read only first or last part or something else...

I'm having a similar problem with my raspberry pi, where sometimes it will work, sometimes it won't. I'm trying to send the sys.argv array, minus the first element, and display it on a screen, which I thought would be simple, but sometimes it will work and sometimes not. Code on the pi: import serial import sys ser = serial.Serial('/dev/ttyACM0',9600) args = str(' '.join(sys.argv[1:])) args = args.replace("'","") ser.write("test".encode()) print(args) Code on the arduino: String incomingByte; #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); //l

@voidUpdate, please delete your comment, it has nothing to do with the question that was asked, and nobody will answer it ... please post your own question instead

Closely related to To know the state of USB (Serial) connection (connected or not connected)

I would not be using Serial.readString() personally. How do you know where the string starts and ends? Just check for three "A" in a row.
Like this:
const unsigned long MESSAGE_TIMEOUT = 10UL * 1000;  // 10 seconds
const byte LED = 7;

void setup ()
{
  Serial.begin (115200);
  while (!Serial) ;  // wait for Serial to become active
  Serial.println ("Starting");
  pinMode (LED, OUTPUT);
}  // end of setup

unsigned long lastMessage;
unsigned int countOfA;

void processInput ()
{
  while (Serial.available ())
  {
    char c = Serial.read ();
    if (c == 'A')
      countOfA++;
    else
      countOfA = 0;
    // do something with the data
  }  // end of while loop
}  // end of processInput

void loop ()
{
  if (Serial.available ())
  {
    lastMessage = millis ();  // remember when we last got input
    processInput ();  // now handle the input
  }

  if (millis () - lastMessage >= MESSAGE_TIMEOUT)
  {
    countOfA = 0;
  }

  // warn if no keepalive received
  if (countOfA >= 3)
    digitalWrite(LED, LOW);
  else
    digitalWrite(LED, HIGH);

}  // end of loop

Note that this will fail (ie. it will light the LED) if it gets something other than "A" which would include newlines, etc.
What it does it count the number of times it gets the letter "A". If it gets something else it resets the count. If 10 seconds elapse without receiving something, the count resets.

It doesn't work though.

Well, it does, because I tested it. :P The words "doesn't work" do have a rather enraging quality (we hear them so often). Does the LED stay on? Stay off? Not go off after you type "AAA"? Not go on after a time-out? What Arduino are you using? Try to give details here.

Did you try from the console, or executed a py file? It works only from the console for some reason, like few others have experienced as well. I'm using a Nano.

What console? I am using the Arduino serial monitor. Make sure you get the baud rate right, I always use 115200 which is what I had in the code in my answer. I don't know why people limit themselves to 9600 baud.

The Python console. Issue is with Python, not Arduino

check the reference to serial.write - if i understanding it right you have to manually add a Line-ending to your string...
and additionally if i remember correctly it could have to do with permission of your py file..


text:
Erratic readings on Analogread with low voltages
I am using Arduino Uno for measuring sensor voltages. I am using multiplexer to switch between different sensors. The readings measured in the range of 800-900 mv are accurate, but at low millivolts (at about 20 mv) they are erratic. I read repeatedly to get average of 20 values. I get values such as 1.3, 1,4, 2,0, 3.8 etc.
Can any one help on why it is happening and how to avoid it.
Additional information: I am using reference voltage of 1.25 volt for better resolution.
I tried having delay between two readings, though there is some improvement, still the problem persists.
I appreciate the help by experts.
Thanks

May be this is because the voltages that you are trying to measure are way below the noise floor and the arduino is measuring the noise from the pin.

Noise problems always need multiple approaches / attacks: 1) Scope it to see what is any real noise needs to be dealt with. 2) Dive into the Atmel spec to see if the ADC can actually make such a measurement. 3) Use exponential smoothing and play with the alpha constant. 4) Try a different power supply or try something clean like a battery.

You need a stable power-supply. You need a stable measuring voltage. You could try adding the small capacitor to the output of the thing you try to measure. You could try using the ADC_sleep mode on the ATMega328. This will sleep the MCU during the measurement, keeping noise down.

Addition to the other comments, if that low voltages are common in your project, maybe you are using wheat-stone bridges with strain gauges or similar sensors, it might be the best option to use a good low noise instrumental amplifier between the sensor and the multiplexer. This setup will give you manageable voltage levels.


text:
How can i change "+" sign into spaces?
I'm working with esp8266.i am able to send text from webserver to arduino which is displayed on my 16*2 lcd display.but the problem is that when i send text including space i.e:john smith, the text show on my serial monitor and also in lcd  like that (john+smith)..the spaces i gave is converted into "+" sign..Can anyone suggest me how to overcome from that problem??
my code is given below:
  #include <SoftwareSerial.h>
  #include <LiquidCrystal.h>

 SoftwareSerial espSerial(2,3);

  LiquidCrystal lcd(12,11, 7, 6, 5, 4);

const bool printReply = true;
const char line[] = "-----\n\r";
int loopCount=0;

char html[50];
char command[20];
char reply[500];

char ipAddress [20];
char name[30];
int lenHtml = 0;
char temp[5];

void setup()
{
      Serial.begin(9600);
        lcd.begin(16,2);

      Serial.println("Start\r\n\r\n");

      lcd.print("WELCOME ");

      espSerial.begin(9600);

      Serial.println("reset the module");
      espSerial.print("AT+RST\r\n");

      getReply( 2000 );

      Serial.println("Change to station mode");
      lcd.clear();
      lcd.print("station mode");
      espSerial.print("AT+CWMODE=1\r\n");
      getReply( 1500 );

      Serial.println("Connect to a network ");
      lcd.clear();
     lcd.print("connecting...");

      espSerial.print("AT+CWJAP=\"ESP_E61A83\"\r\n");
      getReply( 6000 );

      Serial.println("Get the ip address assigned by the router");
      espSerial.print("AT+CIFSR\r\n");
      getReply( 1000 );

      int len = strlen( reply );
      bool done=false;
      bool error = false;
      int pos = 0;
      while (!done)
      {
           if ( reply[pos] == 10) { done = true;}
           pos++;
           if (pos > len) { done = true;  error = true;}
      }

      if (!error)
      {
            int buffpos = 0;
            done = false;
            while (!done)
            {
               if ( reply[pos] == 13 ) { done = true; }
               else { ipAddress[buffpos] = reply[pos];    buffpos++; pos++;   }
            }
            ipAddress[buffpos] = 0;
      }
      else { strcpy(ipAddress,"ERROR"); }

      Serial.println("Set for multiple connections");
      espSerial.print("AT+CIPMUX=1\r\n");
      getReply( 1500 );

      Serial.println("Start the server");
        lcd.clear();
      lcd.print("Server starts");
      espSerial.print("AT+CIPSERVER=1,80\r\n");
      getReply( 1500 );

      Serial.println("");

   lcd.clear();
      Serial.println("Waiting for page request");
      Serial.print("Connect to "); Serial.println(ipAddress);
      Serial.println("");
lcd.print("feed me more");
delay(1500);
        lcd.clear();

}

void loop()
{
      if(espSerial.available())

          bool foundIPD = false;
          for (int i=0; i<strlen(reply); i++)
          {
               if (  (reply[i]=='I') && (reply[i+1]=='P') && (reply[i+2]=='D')   ) { foundIPD = true;    }
          }

          if ( foundIPD  )
          {

              loopCount++;

              int nameStartPos = 0;
              for (int i=0; i<strlen(reply); i++)
              {
                   if (!haveName)
                   {
                         if (  (reply[i]=='n') && (reply[i+1]=='a') && (reply[i+2]=='m') && (reply[i+3]=='e')  && (reply[i+4]=='=') )
                         {
                             haveName = true;
                             nameStartPos = i+5;
                         }
                   }
              }

              if (haveName)
              {
                    int tempPos = 0;
                    bool finishedCopying = false;
                    for (int i=nameStartPos; i<strlen(reply); i++)
                    {
                         if ( (reply[i]==' ') && !finishedCopying )  { finishedCopying = true;   }
                         if ( !finishedCopying )                     { name[tempPos] = reply[i];   tempPos++; }
                    }
                    name[tempPos] = 0;
              }

              if (haveName) { lcd.clear(); lcd.print("TEACHERS INFO..");Serial.print( "name = ");lcd.setCursor(0,1);Serial.println(name);lcd.print(name);Serial.println("");lcd.print(""); }

              else          { Serial.println( "no name entered");   Serial.println("");lcd.print(""); }

              strcpy(html,"");
              strcpy(command,"AT+CIPSEND=0,25\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              strcpy(html,"
TEACHERS INFORMATION WEBSERVER
");
              strcpy(command,"AT+CIPSEND=0,40\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              strcpy(html,"
CREATED by jack
");
              strcpy(command,"AT+CIPSEND=0,31\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              strcpy(html,"
 Teachers Request number ");
              itoa( loopCount, temp, 10);
              strcat(html,temp);
              strcat(html,"
");

              // need the length of html
              int lenHtml = strlen( html );

              strcpy(command,"AT+CIPSEND=0,");
              itoa( lenHtml, temp, 10);
              strcat(command, temp);
              strcat(command, "\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

             if (haveName)
             {

                  strcpy(html,"
TEACHER name is "); strcat(html, name ); strcat(html,"
");

                  lenHtml = strlen( html );
                  strcpy(command,"AT+CIPSEND=0,"); itoa( lenHtml, temp, 10); strcat(command, temp); strcat(command, "\r\n");
                  espSerial.print(command);
                  getReply( 2000 );
                  espSerial.print(html);
                  getReply( 2000 );
             }

              strcpy(html,"<form action=\""); strcat(html, ipAddress); strcat(html, "\" method=\"GET\">"); strcat(command, "\r\n");

              lenHtml = strlen( html );
              itoa( lenHtml, temp, 10);
              strcpy(command,"AT+CIPSEND=0,");
              itoa( lenHtml, temp, 10);
              strcat(command, temp);
              strcat(command, "\r\n");

              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              strcpy(html,"Name:
<input type=\"text\" name=\"name\">");
              strcpy(command,"AT+CIPSEND=0,40\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              strcpy(html,"<input type=\"submit\" value=\"Submit\"></form>");
              strcpy(command,"AT+CIPSEND=0,43\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              strcpy(html,"");
              strcpy(command,"AT+CIPSEND=0,14\r\n");
              espSerial.print(command);
              getReply( 2000 );
              espSerial.print(html);
              getReply( 2000 );

              espSerial.print( "AT+CIPCLOSE=0\r\n" );
              getReply( 1500 );

              Serial.println("last getReply 1 ");
              getReply( 2500 );

              Serial.println("last getReply 2 ");
              getReply( 2500 );

          }
      }

      delay (100);

}

void getReply(int wait)
{
    int tempPos = 0;
    long int time = millis();
    while( (time + wait) > millis())
    {
        while(espSerial.available())
        {
            char c = espSerial.read();
            if (tempPos < 500) { reply[tempPos] = c; tempPos++;   }
        }
        reply[tempPos] = 0;
    }

    if (printReply) { Serial.println( reply );  Serial.println(line);     }
}

It is hard to understand what your code does. You said that arduino recives text from the server, but I see in the code is that the arduino is the http server, serving an html page with a form in it.
That is also the reason you recieve spaces replaced with "+", the http request is url encoded.
The problem with a search and replace solution of a "+" sign is that url encoding is more than a "+" sign. A space can also be encoded into %20 and there are several other characters that are being encoded as well.
What you will have to do is to implement a decoding function. It is not that hard but if you are lazy, there are plenty of C implementations available on the net. Here is a quick google search hit: https://gist.github.com/jmsaavedra/7964251

Two things:
+If you are using strings, try using the String built in object, it is very handy and useful
+when using String, you can use replace function

If you have your text in a character array, which it seems you have, then it is simple enough to iterate through that array changing whatever characters you want.
For instance, if the text is in reply then:
for (char *p = reply; *p; p++) {
    if (*p == '+') *p = ' ';
}

That is, starting at the beginning of reply, by creating a pointer p and pointing it at the start of reply, check to see if there is anything except the NULL character, run the code inside the brackets, and move to the next character (p++).
The code inside the brackets looks to see if the current character is a + and if so then set the current character to be a space.
Another way is to use an integer counter:
for (int i = 0; reply[i] != 0; i++) {
    if (reply[i] == '+') reply[i] = ' ';
}

i have already used ur second way (integer counter)..but it's only show the first word of the text...i.e:whether i write (my text) ,it shows only (my)..