texts: Generating digital positive (+5 V) and negative (-5 V) signal?

texts:
Problem in getting -5 V with Arduino.

void setup() {
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);
  delay(20);
  digitalWrite(13, LOW);
  delay(20);
}

Above code is generating below digital signal:

I want this type of digital signal output:

I read this for generating negative -5 V signal:

https://electronics.stackexchange.com/questions/10322/what-is-negative-voltage

but not able to understand very well WRT Arduino.

Also read this:

Negative voltage: How do I scale a 0 to 5 V signal to -10 V to +10 V?

seems to much complicated circuit diagram with TL802.

My questions:

How do I get above digital signal?
I was wondering if we can use some 1 microF capacitor or transistor to generate negative signal? (simplest way)


texts: Decimals missing when using radio.write(); with Arduino

texts:
I'm adapting a sketch I found to send sensor data over a wifi chip (Nrf2401), and although I get the message through, the value I send contains decimals (e.g. 24.59), but the received message will only be 24.

I'm sure there's something wrong on the transmitter part of the code, but I can't see what.

Here's my code:

#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>

OneWire oneWire(4);

DallasTemperature sensors(&oneWire);

// ce,csn pins
RF24 radio(8,7);

// init data buffer to hold a sensor type byte and one uint16_t sensor data
unsigned char data[3] = {
  0};
unsigned long count=0;
void setup(void)
{
  sensors.begin();
  Serial.begin(57600);
  Serial.println("**************V1 Send Sensor Data***********");
  radio.begin();
  radio.setPALevel(RF24_PA_LOW);
  radio.setChannel(0x4c);

  // open pipe for writing
  radio.openWritingPipe(0xF0F0F0F0E1LL);

  radio.enableDynamicPayloads();
  radio.setAutoAck(true);
  radio.powerUp();
  Serial.println("...Sending");
}

void loop(void)
{

  sensors.requestTemperatures();
  float currentTemp;
  currentTemp = sensors.getTempCByIndex(0);

  //assign 'T' to represent a Temperature reading
  data[0] = 'T';

  data[1] = currentTemp;

  count++;

  sprintf(data, "T %5.2f\n", currentTemp);  // build command in data[]
  radio.txMode(strlen(data));               // set # bytes to xmit
  radio.write(data);                        // send bytes

  // print and increment the counter
  Serial.print("Temperature sent:  ");
  Serial.println(currentTemp);
  // pause a second
  delay(500);
}

In this example, when I print currentTemp, it will display the decimals, but if I print data[1], it won't.

What am I missing?

EDIT:

I've modified the code to include the answer from JRobert (updated code above), but it comes back the following error:

nrf24SendSensorDataV1_ino.cpp: In function 'void loop()':
nrf24SendSensorDataV1_ino:56: error: invalid conversion from 'unsigned char*' to 'char*'
nrf24SendSensorDataV1_ino:56: error: initializing argument 1 of 'int sprintf(char*, const char*, ...)'
nrf24SendSensorDataV1_ino:57: error: 'class RF24' has no member named 'txMode'
nrf24SendSensorDataV1_ino:57: error: invalid conversion from 'unsigned char*' to 'const char*'
nrf24SendSensorDataV1_ino:57: error: initializing argument 1 of 'size_t strlen(const char*)'
nrf24SendSensorDataV1_ino:58: error: no matching function for call to 'RF24::write(unsigned char [3])'
C:\Users\Zuh\Downloads\arduino-1.0.1\libraries\RF24L01/RF24.h:281: note: candidates are: bool RF24::write(const void*, uint8_t)

Any thoughts?

EDIT 2

I've made a dirty fix that will solve the issue.

In the transmitter code I've added:

uint16_t sensorValue = currentTemp*100;
//do the bit shift to put uint16 into uint8 array
data[1] = sensorValue >> 8;
data[2] = sensorValue;
// print and increment the counter
radio.write(data, sizeof(uint16_t)+1);

This will send the (temperature value)*100

On the receiver end, I just convert the uint16_t to a float element and divide it by 100.

uint16_t sensorValue = data[2] | data[1] << 8;
float temp = (float) sensorValue/100;
Serial.print("T: ");
Serial.println(temp);

Dirty, but effective!

Many thanks guys for the help, it really pointed me and my lousy programming skills to the right direction.


texts:
Well I've just started learning the concept of multithreading with C++ and immediately a bunch of questions came to mind about the possibility of using multithreading with microcontrollers in general and Arduino specifically.

So, is it possible to use multithreading on any type of Arduino boards?


texts: Uno R3 connected via Ethernet shield becomes unreachable after a few minutes

texts:
I'm setting up an Elegoo Uno R3 with a Seeed 5200 ethernet shield to monitor water flow and temperature. It needs to run unattended for weeks at time (being called several times a day by a remote script).

I'm normally able to send and receive UDP packets for a few minutes when I've just reset/power-cycled the Arduino. After that, it stops responding to UDP messages. By adding some serial output I can see that it hangs unpredictably at different parts of loop(). Sometimes it seems that physically shifting the device will get it to wake up; or it will wake up on its own after a minute or two. Most of the time it works until it quits, then doesn't work until I reset it.

It does respond to ping while it's otherwise unresponsive.

Is there anything wrong with my code? This is my first Arduino project. Otherwise could it be a hardware problem? If I buy another, I'll buy a genuine Arduino. Is Seeed a reliable source for the ethernet shield?

(By the way--I think it's safe to disregard the PACKETLEN thing, which is a leftover artifact. In the end it's unnecessary to read the incoming message anyway, so the packetBuffer array is superfluous but doesn't seem to change anything one way or another.)

Thanks in advance. Best wishes,
Dan

#include <SPI.h>
#include <EthernetV2_0.h>

#define PACKETLEN 48

//Flow and temp globals
byte sensorInterrupt = 0;  // 0 = digital pin 2
byte flowPin       = 2;
byte tempPin = 0;

float calibrationFactor = 45; // we're going to measure for 10s intervals
float minFlow = 270;          // minimum 6 L/min, measured for 10 s
volatile byte pulseCount;
unsigned long startTime, timeDelta;

int tempReading;
float tempVoltage;
float temperature;

//Communication globals
IPAddress ip(xxx, xxx, xxx, xxx);
byte mac[] = {
  0xxx, 0xxx, 0xxx, 0xxx, 0xxx, 0xxx
};
EthernetUDP Udp;

unsigned int localPort = xxxx;
char packetBuffer[PACKETLEN+1];  //buffer to hold incoming packet,

int packetSize;
byte flowOk, tempOk;
IPAddress remoteIP;
unsigned int remotePort;

void pulseCounter()
{
  pulseCount++;
}

void setup()
{

  //Serial.begin(9600);
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  pinMode(flowPin, INPUT);
  digitalWrite(flowPin, HIGH);

  // attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}

void loop()
{

    delay(2000);

    if(packetSize = Udp.parsePacket())
    {
        remoteIP = Udp.remoteIP();
        remotePort = Udp.remotePort();

        //Measure the flow for 10 seconds
        flowOk = 0;
        pulseCount = 0;
        startTime = millis();
        attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
        while((timeDelta = millis() - startTime) <= 10000) ;
        detachInterrupt(sensorInterrupt);
        if (pulseCount >= minFlow)
            flowOk = 1;

        //Check the temperature
        tempOk = 0;
        tempReading = analogRead(tempPin);
        tempVoltage = tempReading * 5.0 / 1024.0;
        temperature = (tempVoltage - 0.5) * 100;
        if (temperature < 35.0)
            tempOk = 1;

        Udp.beginPacket(remoteIP, remotePort);
        if (flowOk && tempOk)
            Udp.write("Ok");
        else
            Udp.write("Not ok");
        Udp.endPacket();
    }

}


texts: Protocol options for data exchange between Arduino and ESP8266

texts:
I have a device built with an Arduino uno:

Arduino software installed on an Arduino uno
can be controlled via serial commands
can be controlled via physical buttons and sensors
on any button/sensor state change it writes the current state to serial
if no message has been sent within 5 seconds, it sends a no-change serial message

What is needed:

Use an ESP8266 to provide a bridge between current Arduino software and MQTT / web
I can program the ESP8266 as a web server, MQTT client, etc with the Arduino IDE or Lua (but I prefer the Arduino IDE since I can reuse parts of the code to generate / interpret communication).
the ESP8266 will handle everything that is required for wifi / web / MQTT; without the MQTT module the Arduino part will work stand-alone, only the remote control will be missing.
I would like to make minimal changes to the Arduino code (or none, if possible). Any changes would involve extensive re-testing, which I try to avoid.
the ESP8266 can be missing in some installs.

What options I found:

Serial

ESP8266 can read the serial output and be a bridge between web/MQTT and serial, will store the current state in memory to be sent when requested to avoid polling the device every time.

One of the benefits is no code changes / testing required for the Arduino part.

I2C

Make the Arduino the I2C master and the ESP8266 the slave (or the other way around) and implement bi-directional communication. Got the idea by reading this thread.

Some other information about the serial commands:

A data packet (command or state description) consists of 1 to 20 characters, with a possible peak of 20 packets in 5 seconds, and an average of one packet every 3 seconds. If needed, I can make this send 5 unsigned integers instead of alphanumeric characters.

If more than the I2C / serial pins are needed I can upgrade to an Arduino Mega (so the number of free pins is not an issue).

Are there any other options for this? (protocols, pre-made libraries for serial communication, etc). I'm trying not to reinvent the wheel..

Thank you for your time!


texts: Programming "Arduino" code to AT90S8515?

texts:
I found (from a previous life) an STK500 and a couple AT90S8515's in the recesses of my basement..  that I would like to put to use.

Is there a way in which I can write "arduino code" for the 8515?  I know that it's basically C/C++.

I also know that the 8515 doesn't have, or support, a bootloader like the Mega series of ICs do..  so I expect that I will need to program it using the STK500.

I downloaded AVR Studio, but I will admit, I became very lost, very quickly.

Thanks for any direction!


texts: On a motor after a continuous input of a certain amount of time

texts:
I would like to produce an output after a constant input is detected for a certain amount of time. Below is a simple code of what I am trying to do minus the time factor. Can someone help me on how to code out the duration of an input occurrence?  i.e.

if (sensorValue > threshold);
    //if this occurs for more than 4 hours, then
    digitalWrite (3, HIGH);


texts: Pass structure pointer as an argument to a function in c

texts:
I am developing a code in which I need to pass a structure pointer value to a function as a parameter. I am calling function "proto485Compare()" in "RS485TaskSlave()". "rs485Msg" contains my data for which I need to verify for checksum, I am checking it in "RS485TaskSlave()" using "if(proto485ValidCheckSum(rs485_message_t ((uint8_t*)message)))" but it is showing error on this line.

Please help me to get the values of "rs485Msg" & check for checksum on this line

Below is my code snippet:

 typedef struct
    {
      uint8_t AB;     ///< Address byte (Start byte)
      uint8_t CB;     ///< Command (index) "ASCII-byte"
      uint8_t SI;     ///< Action (sub index) "ASCII-byte"
      uint8_t PH1;    ///< Payload "ASCII-byte" of the high nibble of the high byte of the raw payload
      uint8_t PH0;    ///< Payload "ASCII-byte" of the low nibble of the high byte of the raw payload
      uint8_t PL1;    ///< Payload "ASCII-byte" of the high nibble of the low byte of the raw payload
      uint8_t PL0;    ///< Payload "ASCII-byte" of the low nibble of the low byte of the raw payload
      uint8_t CS1;    ///< Checksum "ASCII-byte" of the high nibble of the raw checksum
      uint8_t CS0;    ///< Checksum "ASCII-byte" of the low nibble of the raw checksum
    } rs485_message_t;

    uint8_t proto485ValidCheckSum(rs485_message_t message)
    {
      uint8_t rawChecksum = (message.CB - OFFSET_ASCII) + (message.SI - OFFSET_ASCII) +
        (message.PH1 - OFFSET_ASCII) + (message.PH0 - OFFSET_ASCII) +
          (message.PL1 - OFFSET_ASCII) + (message.PL0 - OFFSET_ASCII);

      uint8_t res = (((rawChecksum & 0xF0) >> 4) + OFFSET_ASCII) == message.CS1 &&
        ((rawChecksum & 0x0F) + OFFSET_ASCII) == message.CS0;

      return res;
    }

    void RS485TaskSlave(void *p_arg) //b - RS485 communication Task
    {
        uint8_t res;
        rs485_message_t rs485Msg;
        uint8_t command, action, value;

        (void)p_arg;
        while(1)
        {
          res = driver485Read((uint8_t *)&rs485Msg, RS485_MSG_LENGTH);
          if(RS485_MSG_LENGTH == 9)
         {
            res =  proto485Compare((uint8_t *)&rs485Msg, command, action, value);
         }
        }
    }

    int16_t proto485Compare(uint8_t* message, uint8_t* comparec, uint8_t* comparea, uint8_t* comaprev)
    { int j = 0;
      rs485_message_t rs485Msg;
      char res;
      uint8_t FWmsg[9] = {0x09,0x31,0x30,0x30,0x30,0x30,0x33,0x30,0x34};
      uint8_t arduinodata[9] = {0x09,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30};

     if(proto485ValidCheckSum(rs485_message_t ((uint8_t*)message))) //
/*GETTING ERRORVON THIS LINE please help how to pass message value to verify checksum at this line*/
      {
      printf("compare command..........");

        for (j=0; j<9; j++)
        {
          arduinodata[j] = message[j];
          printf("%d ",arduinodata[j]);
        }
        printf("\n");

        if(compareArray(FWmsg,arduinodata,7)==0)
        {
          uint8_t add, fwc, fwa;
          uint16_t fwv;
          res = GetABFWversion(&add, &fwc, &fwa, &fwv);
          res = proto485OnlyWrite(add,fwc, fwa, fwv);
        }
      }
      else
      {
        printf("Arrays have different elements.\n");
      }
      return res;
    }


texts: Addressing EACH of the 3x3x3 LEDs separately

texts:
I read a few 3x3x3 LED tutorials, e.g. let us take this one:

http://www.instructables.com/id/Making-an-Arduino-3X3-LED-Cube-in-Less-Than-30-Min/?ALLSTEPS

As far as I understand, you can address any of the 3x3 light columns:

*  *  *       1  2  3
*  *  *       4  5  6
*  *  *       7  8  9

and each of the three vertical layers:

top
middle
bottom

But can I address each of the 27 leds separately? In other words, can I light up:

1+  2   3         bottom layer
4   5+  6
7   8   9

1   2+  3         middle layer
4+  5   6
7   8   9


texts: How do I make a Servo Stop if it Hits Resistance?

texts:
I am trying to make a device which will turn a turn key with a servo.

However, I want it to stop turning the turn key if the resistance is too great (meaning it is locked and will not ever turn).

How do I do this? Would I just tell it to turn and then have it turn back after a time (because if it is locked or not it should be done within that time)?

I do not want to damage my servo by having it try to turn something that it can't turn.

I am using an Arduino Uno and the library "Servo.h". The servo being used is a Batan S1123.


texts: Arduino USB Power vs External Power Supply

texts: Why is the Arduino able to accept ~5V from the USB, but requires a min of 7V when using an external power supply?


texts:
I made a circuit that takes humidity and temperature from DHT22 sensor and displays it on Lcd Screen. Simple enough but i get this error "Failed to read from DHT". That happens because i have this code

 if (isnan(t) || isnan(h)) {
  delay(100);
    Serial.println("Failed to read from DHT");
  } else {
    delay(100);
    Serial.print("Humidity: ");
    Serial.print(h);
    Serial.print(" %\t");
    Serial.print("Temperature: ");
    Serial.print(t);
    Serial.println(" *C");
    //lcd.print("Temp: ") ;
    //lcd.print(t);
    //lcd.setCursor(0, 1);
    //lcd.print("Hum: ") ;
    //lcd.print(h);
  }

So the values are NaN . But 1 minute before it worked fine, and now again it doesnt. Everything is soldered the right way and nothing is false. Lcd is wired ok and it works but i dont get values from DHT22.

Here are some pics to help you out.

In the third Image we see its working. And now its not!
is the DHT sensor broken?

  #include "DHT.h"
#include <LiquidCrystal.h>`

#define DHTPIN 2
#define DHTTYPE DHT22   // DHT 22  (AM2302)

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHT22 test!");
  lcd.begin(16, 2)
  dht.begin();
}

void loop() {

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(t) || isnan(h)) {
    Serial.println("Failed to read from DHT");
  } else {

    lcd.print("Hum: ");
    lcd.print(h);
    lcd.setCursor(0, 1);

    lcd.print("Temp: ");
    lcd.print(t);

  }
}

Thats my code by the way


texts:
How do I write a program to wait (delay) until one out of two buttons pressed? I have written a program to wait until a single button is pressed. It's working fine. However, if I extend it to second button it's not working. Pls help on this.

while (digitalRead(bt_Select) == HIGH) {} -- working.
while (digitalRead(bt_Select) == HIGH || digitalRead(bt_Reject) == HIGH) {} -- Not working.

Complete code:
const int bt_Select = 2;
const int bt_Reject = 3;

void setup() {
  Serial.begin(9600);
  pinMode(bt_Select, INPUT_PULLUP);
  pinMode(bt_Reject, INPUT_PULLUP);
}

void loop() {
  Serial.println("Pl input:");

  while (digitalRead(bt_Select) == HIGH {} // This is the line I change

  if (digitalRead(bt_Select) == LOW) {
    Serial.println("Select Button pressed:");
    delay(250);
    Serial.println("");
  }

  if (digitalRead(bt_Reject) == LOW) {
    Serial.println("Reject Button pressed:");
    delay(250);
    Serial.println("");
  }
}


texts: Can I power the arduino UNO through the 5V pin while I use USB cable to collect data?

texts:
I understand that if the Arduino is powered by Jack or Vin when the USB cable is connected, the internal circuitry would inderdict the USB powering.
But what if I power the arduino througn 5V pin while the USB cable is connected? How does the internal circuit do the choice?
Did I just connect the 5V power supply directly with USB port of the laptop (since the 5V rail directly connects 5V pin and USB port)? Is this allowable? Is this dangerous?
Thank you!


texts: Reading multiple bytes from *software* serial

texts:
I have Arduino Leonardo board operating lots of AC relays in quite noisy environment. USB works unstable, which sometimes causes the board to hang, so I decided to use secondary serial connection as "debug console":

  Serial1.begin(115200);
  .....
  .....
  if (Serial1.available()) {
    char ch = Serial1.read();
    if ( isalnum(ch) ) {
      switch (ch) {
        case 'M': {
          turnOn_pin_Motor();
          break;
        }
        case 'm': {
          turnOff_pin_Motor();
          break;
        }
        .......

My problem is that noise affects Serial1 the same way it messes USB (but at least it doesn't cause it to freeze). I'd like to use some sort of error checking to prevent Leonardo from acting on "phantom" commands. I could, for example, prefix each keyboard command my Arduino should receive with special symbol, maybe "!".

So I must be reading one char, checking if it is "!" and reading second character.

Unfortunately, I can't modify my code so it would use 2-character buffer and shift its contents as characters arrive, without locking the main loop while waiting for the next char. Any hints on what should I do in this case?


texts: Arduino C, Led > binary alternative all lights

texts:
I'm trying to alternatively have a random int generate a binary number with 4 lights.

This is my current code, However, it seems that all the lights(leds) go on, I don't think the minus option works. As in, it won't take a value from the currently randomized digit. (randombinary = randombinary - x)

I also tried just "randombinary - x"

const int button = 2;
const int redone = 13;
const int redtwo = 8;
const int greenone = 12;
const int greentwo = 7;
int randomnumber = 0;
int randombinary = 0;

void setup() {

  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(2, INPUT);

}
  void loop() {

delay(1000);

  int randomnumber = (1, 15);
  randombinary = randomnumber;

  if (randombinary >=8){
    digitalWrite(redone, HIGH);
   randombinary = randombinary - 8;
  }
 else {
   digitalWrite(redone, LOW);
 }

  if (randombinary >=4){
    digitalWrite(greenone, HIGH);
   randombinary = randombinary - 4;
  }
  else {
    digitalWrite(greenone, LOW);
  }

  if (randombinary >=2){
    digitalWrite(redtwo, HIGH);
  randombinary =  randombinary - 2;
  }
  else  {
    digitalWrite(greentwo, LOW);
  }

  if (randombinary >=1){
    digitalWrite(greentwo, HIGH);
  randombinary =  randombinary - 1;
  }
  else  {
    digitalWrite(greentwo, LOW);
  }

  }

Would appreciate any help!


texts: Problem in interfacing EM18 reader with Arduino Mega

texts:
When we interfaced em18 reader with Arduino Uno it was properly working but with Arduino Mega it is not working but all other components are properly with Arduino Mega.

Receiver and transmitter LEDs are only not glowing when we upload code with Arduino Mega.

Arduino mega code:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1);

void setup()
{
  mySerial.begin(9600); // Setting the baud rate of Software Serial Library
  Serial.begin(9600);  //Setting the baud rate of Serial Monitor
}

void loop()
{
  if(mySerial.available()>0)
  {
    Serial.write(mySerial.read());
  }
}

Connection:

Arduino Mega GND to GND of EM18;
5V to 5V of EM18;
0(Rx) to Tx of EM18


texts: Servo issue, won't go into negative range

texts:
I'm trying to create a small laser "turret" with x-axis control. The arduino receives input through IR sensor. I'm having a problem where my servo will preform my up and reset function(moves and prints as intended), but When i preform the down function the servo does not move. I believe the function is executing (it outputs angle to LCD and text to serial monitor) but there is no movement.
Any help would be greatly appreciated!

#include <IRremote.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

int IRPIN = 3;
int angle = 0;
int test = 0;
IRrecv irrecv(IRPIN);
decode_results results;
Servo spinnything;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup()
{
    irrecv.enableIRIn();
    lcd.begin(16, 2);
    lcd.backlight();
    spinnything.attach(5);
    spinnything.write(angle);
    lcd.setCursor(0, 0);
    lcd.print("WARNING");
    lcd.setCursor(2, 1);
    lcd.print("!!!LASER!!!");
    delay(1500);
    lcd.clear();
}

void loop()
{
    if (irrecv.decode(&results)) {
        irrecv.resume();
    }
    if (results.value == 0xE172C837) {
        up();
        results.value = 0x00000000;
    }
    if (results.value == 0xE17228D7) {
        down();
        results.value = 0x00000000;
    }if (results.value == 0xE1724CB3) {
        reset();
        results.value = 0x00000000;
    }
    lcd.setCursor(0,0);
    delay(10);
}

void up() {
    if (angle < 180) {
        angle = angle + 18;
        spinnything.write(angle);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Current Angle");
        lcd.setCursor(3, 1);
        lcd.print("=");
        lcd.setCursor(5, 1);
        lcd.print(angle);
        Serial.print("up");
    }
}
void down() {
    if (angle > -180) {
        angle = angle - 18;
        spinnything.write(angle);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Current Angle");
        lcd.setCursor(3, 1);
        lcd.print("=");
        lcd.setCursor(5, 1);
        lcd.print(angle);
        Serial.print("down");
    }
}
int reset() {
    angle = 0;
    spinnything.write(angle);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Current Angle");
    lcd.setCursor(3, 1);
    lcd.print("=");
    lcd.setCursor(5, 1);
    lcd.print(angle);
    Serial.print("reset");

}


texts: How to understand the "power economy" of a voltage up-converter (boost converter)?

texts:
My online video Arduino instructor makes use of various devices to amplify signals, currents, and voltages. This seems like magic to me.

For instance, he has 4 AA batteries with 1.2V each. He says "that's not going to be enough for Arduino" so he then passes the power through a voltage up-converter and increases it to 9V.

I'm going to assume there must be some tradeoff here, because otherwise we can just use a giant string of these up-converters to give the world infinite energy from a single AA battery. I found the Wikipedia articles on this topic a little hard to understand, but basically gathered that if Voltage is boosted then it's at the expense of current. My questions are:

Is my understanding correct (higher voltage = lower current)?
If the current decreased then why was this still an adequate power source for Arduino? Does current not matter?
What are the practical limits of this type of conversion?

I would appreciate a plain-language (easy to understand) answer. I'm also kind of curious how the conversion works, but I assume that will be highly technical.


texts: The use of 4.7kOhm resistor with DS18B20 temperature sensor

texts:
I was using a temperature sensor DS18B20 with Arduino.

I've read that you should connect the digital input line and the 5V line with a 4.7kOhm resistor - like in the picture.

Can someone explain why do we need to do this? And why this resistance? What happens if we don't put a resistor at all or use a different resistance?


texts: Using an Arduino board to program an AVR

texts:
I think the arduino board is awesome.
Though I'm not interested in the library and IDE at all...
Is there a way, to use an AVR 328p, as you normally would, on an arduino board?

I like how arduino's can be programmed through serial, can get powered through serial and I often use serial as a debugging option. Making my own board (with ICSP programmer) would not be able to do this (withouth bootloader).

The Question

Do I have to use all the stuff from arduino?

Can I use my own compiler for an arduino board? (GNU-GCC / AVR)
Can I use my own IDE for an arduino board? (Eclipse / Atmel Studio)
Can I still program through serial then? (Does the bootloader care which compiler I used? Does Eclipse/AVR studio have the options to program through serial?)
Other stuff I should take in mind. (Annoying things like AVR studio not having a COM port window, though that's an easy fix.)

Edit: We've programmed an AVR 328P (GNU-GCC / Eclipse / ICSP) in school, so I know it takes quite some work to get the compiler set up, working with Eclipse. You don't have to completely describe the proces :) Just to avoid someone spending hours on an answer that's easily found on the internet.
(On my search for this subject I could only find people doing the other way around, getting an 328p chip to work with arduino)


texts: parallel communication simulation problem

texts:
Hi I am trying to send data(1 byte) from one arduino to another using parallel communication(a bus of 8 connections) and not using any library. However, the problem is the data gets corrupt all the time and what I am supposed to receive at receiver arduino is not what I send. The protocol that I made up is similar to uart protocol. There is ES pin and when it is low, transmission is started and when it is high, the transmission is ended. I think the problem could be related to wires that I use to connect two arduinos. There could be some noise induced that could flip bits in wires or the code is problematic. I am posting my code. Maybe you can help me get through this and help me to resolve my problem.
Sender code:
#define ES 8 //enable sampling
#define B0 0 //Bus 0
#define B1 1
#define B2 2
#define B3 3
#define B4 4
#define B5 5
#define B6 6
#define B7 7
const char dataToBeSent = 'C';
bool data_bit;

void setup() {
  pinMode(ES,OUTPUT);
  pinMode(B0,OUTPUT);
  pinMode(B1,OUTPUT);
  pinMode(B2,OUTPUT);
  pinMode(B3,OUTPUT);
  pinMode(B4,OUTPUT);
  pinMode(B5,OUTPUT);
  pinMode(B6,OUTPUT);
  pinMode(B7,OUTPUT);
  digitalWrite(ES,HIGH);
  delay(3000);
}
void loop() {

 digitalWrite(ES,LOW); //transmission is started
 delay(10);

 for(int i = 0 ; i<8 ; i++){
    data_bit = dataToBeSent & (0x80 >> i);
    digitalWrite(i,data_bit);
 }
  delay(10);
  digitalWrite(ES,HIGH); //end transmission
  while(true){}
}

Receiver code:
#define ES 8 //enable sampling
#define B0 0 //Bus 0
#define B1 1
#define B2 2
#define B3 3
#define B4 4
#define B5 5
#define B6 6
#define B7 7

char rx_data;
byte rx_byte= 0;
bool rx_pin;

void setup() {
  Serial.begin(9600);
  pinMode(ES,INPUT);
  pinMode(B0,INPUT);
  pinMode(B1,INPUT);
  pinMode(B2,INPUT);
  pinMode(B3,INPUT);
  pinMode(B4,INPUT);
  pinMode(B5,INPUT);
  pinMode(B6,INPUT);
  pinMode(B7,INPUT);
  delay(1000);

}

void loop() {

  byte rx_byte= 0;

  while(digitalRead(ES) == HIGH){}
  delay(15);

  for(int i = 0 ; i<8 ; i++){
    rx_pin = digitalRead(i);
    Serial.print(rx_pin);
    if(rx_pin == 1){
      rx_byte |= (0x80 >> i);
    }
  }

 rx_data = rx_byte ;

 Serial.print("Received data: ");
 Serial.println(rx_data);

 delay(15);

 while(digitalRead(ES)== HIGH){}

}


texts: Print connection password typed by user on NodeMCU Lua ESP8266 ESP-12E

texts:
I want to make a WiFi Access point created with the ESP8266. Let's say that the SSID is 'net_work' and the password is '12345678'.

When a client tries to connect with a wrong password, I want to print that wrong password in the serial console. But nowhere in the docu I can find an event listener or something to do this... The only thing i can find in the docu is how to start the AP and wait for a successfull connection.


texts: How to set counter for two ultrasonic sensors?

texts: This question has been asked many times in many sites but I am unable to find answer for my problem. I wanted to measure the speed of Vehicle using Ultrasonic sensors. Two sensors are placed along the side of the road and when a vehicle passes in front of first sensor(i.e echo1 is HIGH) then it should start counting until when the vehicle crosses the second sensor(i.e echo2=HIGH). So I will get the time. But I don't know how to set time counter. I searched in Internet a lot and I learnt about millis(). So I wrote code using millis(). But the problem is,it starts counting as the program runs. I also tried using array to save the values and subtract final reading from initial one but I'm unable to do that too. I cannot create large size of arrays. Please help me how do I set timer for it?


texts:
String getAPIData()
{
  char res_buffer[450];
  int numdata = inet.httpGET("myserver.com", 80, "/call.php?id=1&q=1&code=1001", res_buffer, 450);
  String result = String(res_buffer);
  Serial.println(result);
  Serial.println(numdata);
  return result;
}

Output on Serial:

15:52:07.208 ->
15:52:07.208 -> 393

But, When I print the buffer by loop I got the below output:

HTTP/1.1 200 OK
Date: Mon, 16 Sep 2019 06:28:59 GMT
Server: Apache
X-Powered-By: PHP/7.2.20
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: PHPSESSID=5b21eeac22dcf61f2e4d2efd579d437c; path=/
Upgrade: h2,h2c
Connection: Upgrade, close
Vary: Accept-Encoding,User-Agent
Content-Type: text/html; charset=UTF-8

-1

I am not sure why the char buffer is not converting to String in Arduino UNO.

Any known issues ? Please suggest if any correction required.


texts:
I am working on a specific project that requires a database.
I have done the 'connection' and the "write" of data using a PHP file.
I have even reconfigured everything so it would be possible to access the database through a different device that is connected to the same wifi network as my computer.
All tested and working properly.

The Arduino for some reason is not connecting to the server, where Serial.println(client.connect(serv, 8095)); is returning 0, I have tried every possible solution but nothing seems to work.
I am using xampp, and I changed the port to 8095.
any possible information would be much appreciated.

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
  0xFDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

byte sensorInterrupt = A2;
byte sensorPin       = A2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;
char valvestatus= 'ON';
byte ip[] = {192, 168, 1, 4 }; //Read the code explanation https://102.159.198.42/
byte serv[] = {192, 168, 1, 3} ; //Read the code explanation  192.168.1.3
EthernetClient client;

void setup() {
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
delay(1000);
   pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitres  = 0;
  oldTime           = 0;
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

}

void loop() {

  if((millis() - oldTime) > 1000) {
    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
    flowMilliLitres = (flowRate / 60) * 1000;
    totalMilliLitres += flowMilliLitres;
     unsigned int frac;
    Serial.print(int(flowRate));  ////////
    Serial.print(totalMilliLitres); /////////////
   pulseCount = 0;
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);

    }

    Serial.println(client.connect(serv, 8095));
    if (client.connect(serv, 8095)) { //Connecting at the IP address and port we saved before
client.print("GET /ost/write_data.php?"); //Connecting and Sending values to database
client.print(flowRate);
client.print(totalMilliLitres);
client.print(valvestatus);
 client.stop(); //Closing the connection
    }
 while(!client.available()){}

}

void pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}


texts:
I have a project that turns a LED strip on and off using capacitive touch.  The project uses an Arduino Micro as the brain and a 12v wall wart to power everything.  I have the Arduino ground and negative from the power supply running to a common ground.

Everything works as expected during testing and the Arduino is connected via USB to my computer; however, when I unplug the USB and connect the circuit to the light installation, the lights just flicker on and off.  When I touch my finger to the negative/ground (and presumably provide common ground), everything works as expected.

It seems obvious to me that I have a grounding issue, but really do not know how to proceed. Is there a specific technique for grounding from a wall wart? Do I need to somehow pull the ground/negative down? I feel like there is something obvious that I am missing.

Thank you in advance for any and all help.


texts:
I designed custom built Arduino board with atmel328p-au and I am trying to burn bootloader through Arduino Uno(Arduino As ISP). I am able to burn bootloader (getting message as done burning bootloader) and after burning bootloader, I am trying to upload basic heartbeat sketch blink.ino with same Arduino UNO as ISP, the sketch gets uploaded successfully but I don't see LED on pin no 13 in my custom board  blinking. Any idea what could be the issue and is there any other way to confirm that bootloader and sketch is uploaded correctly
Thanks


texts:
I do apologize for the constant posts on here.  However I ran into an issue and I cannot seem to find any solution to it.  The goal is to enter a username, through the Serial.read function, and if the username matches it simply responds "Welcome Steven", and lights a green LED, when the wrong username is submitted it responds "Access Denied" and lights a red LED.  So far the code works in response to access granted, and access denied, while also lighting the appropriate LEDs.  However the Serial Monitor does not wait until there is a user input, it automatically starts repetitively "access denied" and lights the red LED.  When the username is entered the red LED turns off, the green LED turns on, and Serial Monitor repetitively responds "Welcome Steven".  I can do this multiple times, and each time it will change state.  I have looked at many tutorials and read many posts on here concerning issues, but so far nothing has worked out. Even tried making changes NickGammon suggested in another post.  Would like to get rid of the repetitive issue, and wait for user input before access denied or granted appears.

int led1 = 9;
int led2 = 10;
String user_name;

void setup()
{
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  Serial.println("Enter Username");
}

void loop()
{
 if(Serial.available())
   user_name = Serial.readStringUntil('\n');
{

if(user_name == "Grantham1")
{
  Serial.println("Welcome Steven");
  digitalWrite(led1, HIGH);
  digitalWrite(led2, LOW);
}
else if(user_name != "Grantham1")
{
  Serial.println("Invalid Input");
  digitalWrite(led1, LOW);
  digitalWrite(led2, HIGH);
}
else
{
  Serial.println("Waiting Pateintly");
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
}
}
}


texts: Not showing output when using pins other than 10 and 11 with SoftwareSerial library on Arduino Mega

texts:
I am  trying to run below code on Arduino Mega using GPS module(skg13 bl). It is working fine with pins 10, 11 as rx, tx in the SoftwareSerial but it is not showing output when other pins such as 4, 5 are used.

I further have to send this data through RF module using virtual wire library.

Code is as follows:

#include <SoftwareSerial.h>
#include <TinyGPS++.h>
TinyGPSPlus gps;

SoftwareSerial mySerial(10, 11);

void setup() {
  mySerial.begin(9600);
  Serial.begin(9600);
  Serial.println("GPS start");
}

void loop() {
  while (mySerial.available()) {
    gps.encode(mySerial.read());
  }

  if (gps.location.isUpdated()) {
    double a = gps.location.lat();
    Serial.println(a);
    Serial.println(gps.location.lat(), 6);
    double b = gps.location.lng();
    Serial.println(gps.location.lng(), 6);
  }
}

Thanks in advance!!


texts:
I want to write a function that defines a serial port based on a flag but I'm not sure it's possible.
For example:
void writeToSerial(bool useSerial1)
{
   SerialPortClass serialPortObject; // Is there some way of defining a generic Serial port object and reusing it below?

   if (useSerial1)
   {
      serialPortObject = Serial1;
   }
   else
   {
      serialPortObject = Serial2;
   }

   serialPortObject.write("test123");
}


texts: Can Arduino Uno R3 board remove chip on the board

texts:
First off, got my Elegoo Uno board as Christmas gift, so this is all new to me.

Here is my problem, I built an motor project and the chip has been programmed. Can I remove the chip from the Uno board?

Or can I placing a new chip onto the Uno board?

Best regards.


texts: Are the GND pins of an Arduino identical to GND of its power supply?

texts:
What would happen if I connected a fan as shown in the following picture:

+12V is supplied by the power supply that also powers the Arduino.
GND, however, is connected to a GND pin of the Arduino instead of the power supply.

I guess that would not work? Or are GND from the Arduino and GND from the power supply identical in this case?

If you read the accepted answer, please also note the comments below. The power consumption of the consumer (fan) is important.


texts: Code runs, then doesn't run after I add some routine code

texts:
I am programming an ESP8266-01.

I have this code which I am using to operate an on-off switch, which is being used as an override switch for when the relay is turned on and off over the internet:

void loop() {

  // Connect to the cloud
  rest.handle(client);

  // put your main code here, to run repeatedly:
  int read3 = digitalRead(0);

  Serial.print(read3);
  Serial.println(" input (1 is off)");

  if(read3 == 0) {
    if(pressed2) {
      Serial.println("in on");
      digitalWrite(2, 1);
      pressed = true;
      pressed2 = false;
    }
  }
  else {
    Serial.println("in off");
    if(pressed) {
      Serial.println("in off once");
      digitalWrite(2, 0);
      pressed = false;
      pressed2 = true;
    }
  }
}

The above code never starts to run (nothing gets output on the serial) and the relay turns on. The thing is, this code works:

void loop() {

  // Connect to the cloud
  rest.handle(client);

  // put your main code here, to run repeatedly:
  int read3 = digitalRead(0);

  Serial.print(read3);
  Serial.println(" input (1 is off)");

  if(read3 == 0) {
    Serial.println("in on");
    digitalWrite(2, 1);
    pressed = true;
  }
  else {
    Serial.println("in off");
    if(pressed) {
      Serial.println("in off once");
      digitalWrite(2, 0);
      pressed = false;
    }
  }
}

Basically the way the code is set up, it is handling things so that the pin doesn't get read after the instance first instance that it is read (this is what the bool pressed is helping to do).

Why doesn't the first version work?

UPDATE

Whole working sketch:

/*
  This a simple example of the aREST Library for the ESP8266 WiFi chip.
  This example illustrate the cloud part of aREST that makes the board accessible from anywhere
  See the README file for more details.

  Written in 2015 by Marco Schwartz under a GPL license.
*/

// Import required libraries
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <aREST.h>

// Clients
WiFiClient espClient;
PubSubClient client(espClient);

// Create aREST instance
aREST rest = aREST(client);

// Unique ID to identify the device for cloud.arest.io
char* device_id = "ew1zard";

// WiFi parameters
const char* ssid = "MaisonBlanche";
const char* password = "7932gLBw";

bool pressed = true;

// Functions
void callback(char* topic, byte* payload, unsigned int length);

void setup(void)
{
  // Set input / output pin
  pinMode(0, INPUT);
  pinMode(2, OUTPUT);

  // Start Serial
  Serial.begin(115200);

  // Set callback
  client.setCallback(callback);

  // Give name & ID to the device (ID should be 6 characters long)
  rest.set_id(device_id);
  rest.set_name("esp8266");

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

  // Set output topic
  char* out_topic = rest.get_topic();
}

void loop() {

  // Connect to the cloud
  rest.handle(client);

  // put your main code here, to run repeatedly:
  int read3 = digitalRead(0);

  Serial.print(read3);
  Serial.println(" input (1 is off)");

  if(read3 == 0) {
    Serial.println("in on");
    digitalWrite(2, 1);
    pressed = true;
  }
  else {
    Serial.println("in off");
    if(pressed) {
      Serial.println("in off once");
      digitalWrite(2, 0);
      pressed = false;
    }
  }
}

// Handles message arrived on subscribed topic(s)
void callback(char* topic, byte* payload, unsigned int length) {

  Serial.print("request from interwebs: ");
  Serial.println(topic);
  rest.handle_callback(client, topic, payload, length);

}


texts: Playing audio files with sine wave from arduino

texts:
So, when searching for a way to play audio files through the Arduino, I came across this site: How to play WAV audio files with Arduino Uno and MicroSD card

This seems like a really good library (although I haven't had the time to really play around with it yet). Has anyone used this before, and, if so, is it a good library to use, or do you know of better ones out there which you would recommend?


texts:
I Am facing a problem measuring distance with an ultrasonic sensor. I am doing an IOT garbage system and dust levelling is measuring by the ultrasonic sensor.

But ultrasonic sensors not giving the accurate result, distance becomes high and low while putting papers in the bin. I tried putting sensors in different places but still same. Distance goes high and again low.

I Am processing data by nodemcu.

Should I process it arduino ? Or is there any other sensors for measuring dust level?


texts: Is it possible to run a monochrome LCD without driver circuit with an Arduino Uno?

texts:
I have an old monochrome LCD panel that I removed from a calculator. The LCD panel has no standard input pins, because it's directly connected to a driver on which the calculator software runs.

Is it possible to run the LCD without the calculator software? All pins of the LCD would be available (marked in blue). The pins marked in red were connected to the keyboard of the calculator.


texts: Problem with the GY-85s accelerator (ADXL345). Not sure if hardware or software

texts:
I have a GY-85 IMU (ITG3205 + ADXL345 + HMC5883L) hooked up to an arduino mega. When using the razor AHRS headtracking code, I have a problem where the accelerators z-axis doesn't change from 511.

  accel x,y,z (min/max) = -324.00/-318.00  -196.00/-192.00  511.00/511.00

Does any one know what causes this and how to fix it?


texts:
the board i use has 1MB Flash Size. My program however downloads 512K+ of data for processing.

Arduino Options i see are:

Ideally i would like to use 1MB of SPIFFS, is this even possible?

I don't use OTA, and compile with:

To minimise the footprint of the main sketch.

Thanks in advance.


texts: One time execution of a variable incrementation

texts:
As part of a larger script intended for a very simple arduino "synthesizer" I am trying to increment the amount of cycles a melody will be played once a key is pressed (the key in turn passes a value to the variable selectMel). The problem I encounter is that the moment I call my function in the main void loop() function, I cannot control the incrementation of the variable ncycles, which is intended to be only increased once per key press. I tried to solve this by creating a global switchVar variable as an "on/off" switch but that did not do much to solve the issue at hand.

Any tips or help will be greatly appreciated!

PS: I have of course googled and tried the solutions posted on similar stackExchange posts but to no avail, sadly.

      void playMan (int ncycles, int mSpeed) {

        switch (selectMel) {
        case 1:
          if (ncycles > 0) {
            tone(12, NOTE_B7, mSpeed);
            delay(100);
            tone(12, NOTE_B5, mSpeed);
            delay(100);
            tone(12, NOTE_B3, mSpeed);
            delay(100);
            tone(12, NOTE_B1, mSpeed);
            delay(100);
            ncycles--;
            break;
          case 2:
            if (millis() % 100 == 0) {
              if (switchVar == 1) {
                ncycles += 5;
                switchVar = 0;
              }
              Serial << ncycles << endl;
            }
            break;
          default:
            break;
          }
        }
      }


texts:
I have a SIM900 module connected to an Arduino Uno, using an AT command for listing the SMS I get this output, how can i split this based on (,) to store each data in an array?

AT+CMGL="ALL"

+CMGL: 2,"REC READ","+639321576684","Ralph Manzano","16/04/25,21:51:33+32"
Yow!!!

OK


texts:
I'm trying to control AD7091-8 using Arduino Due.

This IC calls for 16 bit SPI R/W. I'd read that I can change the transmit and receive bits of Arduino DUE by changing a register (bits 4-7 of SPI_CSR).

I was able to change the SPI of Due from 8 to 16 bits. Confirmed this by looking at SCLK and MOSI in the scope. However, the data I want to transfer is becoming intermittent.

I want to send 0x1000. On 8 bits, using the line

SPI.transfer(10,0x10,SPI_LAST);

I really can see this being sent on MOSI.

However, when I'm on 16 bits, the line

SPI.transfer(10,0x1000,SPI_LAST);

It's either becoming 0x0000 or 0x0008. I'm losing the bit or it's becoming LSB_FIRST. Not MSB_FIRST.

Below is the actual code.

#include <SPI.h>
#include "C:\Users\Smart Surface 2\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\component\component_spi.h"
#include "C:\Users\Smart Surface 2\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.11\system\CMSIS\Device\ATMEL\sam3xa\include\instance\instance_spi0.h"

#define CS 10

void setup() {

  pinMode(CONV,OUTPUT);

  Serial.begin(9600);
  SPI.begin(CS);
  SPI.setDataMode(CS, SPI_MODE0);
  SPI.setClockDivider(CS,21);

  REG_SPI0_WPMR=0x53504900;
  REG_SPI0_CR=0x1;
  SPI0->SPI_CSR[0]=0x00001580;

  SPI.setBitOrder(MSBFIRST);
  delay(1);
}

void loop() {

  SPI.transfer(CS,0x1000,SPI_LAST);

  int a = SPI.transfer(CS,0x0000, SPI_LAST);
  delay(1000);

  Serial.println(a);
}

How can I make my data reliable and the order still with MSB first?


texts: Is it possible to manually declare a global variable that is inside of a function. The only current way I know how to do so is to declare that variable within the setup() function or simply outside of any function, but I was hoping there was a way to manually declare a variable as global so that I may call one variable from within one function in another function.


texts: Why does my LCD display random characters?

texts:
I've been struggling with my LCD for hours, and after solving more different issues than I can remember, I'm out of ideas for this one.

My LCD is showing random characters, see the picture below (the last character blinks, some characters change and over time there are slowly more and more characters). I'm starting to wonder if the LCD I chose has a driver compatible with the LiquidCrystal library, what do you think? If so what can I do to avoid buying another one?

Here is the code:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
//RS EN D4 D5 D6 D7
LiquidCrystal lcd(2, 3, 4, 5, A2, A3);
//RW to GND, VSS to GND, VCC to 5V, V0 to wiper of 5V-to-GND 10k potentiometer

void setup() {
  Serial.begin(9600);
  Serial.println("Starting");
  lcd.begin(16, 2);
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 1000);
  Serial.println("Printing");
  delay(1000);
}

I'm using this Arduino and this LCD. Note that I'm using pins 10,11,12,13 for a SD (which works) and 6 7 8 for a MAX232 (which is disabled).

Any ideas?


texts: Motor shield power from Arduino pro mini 5v RAW Pin 150mAh cannot run servo

texts:
linked to my old question, Pro Mini 5v with Adafruit motor shield v1 power sharing problems

I figured out and use one 7.2v battery (6 AA cells), and link it with RAW pin to Pro mini and join its 5v pin to motor shield 5v. It works but as I have a servo on this shield, 2 distance sensors so servo does not work well all the times. Stops or does not move as directed, shaking etc. I figured out that pro mini output 5v but only 150mAh which is not sufficient to run a servo which while sharing same 5v for motor shield. I need to know if I want to supply 5v 2000mAh from AA cells or 5v regulator, should I use these pins on motor shield (5v, Gnd, 9v)? I tried but it did not work. I did not find it anywhere on net.

How can I use these pins shown in the picture.
What is the min/max mAh value of current I can provide at these pins?
If supplying input current at these pins, should I connect/disconnect power jumper?

I am totally stuck. Need help. And here is the quick diagram how things are attached. All other pins are attached at shield connects to UNO when stack on it.


texts: What is the use of reserved pins and SDD2, SDD3 pins of the NodeMCU?

texts:
How to use the reserved pins on the NODEMCU? What is their use? Also what is the use of SDD pins?

Thanks.


texts: Why am I getting "fatal error: SoftwareSerial.h: No such file or directory"

texts:
I downloaded the Adafruit_GPS library from Adafruit and I'm trying to compile the example code (due_parsing) but I can't seem to get past this silly error:

In file included from due_parsing.ino:15:

/Users/haddad/Documents/Arduino/libraries/Adafruit_GPS/Adafruit_GPS.h:24: fatal error: SoftwareSerial.h: No such file or directory
compilation terminated.

This is the location in the example Arduino Sketch where SoftwareSerial.h is mentioned:

#ifdef __AVR__
  #include <SoftwareSerial.h>
#endif

I noticed it's around an ifdef guard, so shouldn't it not even matter that I don't have this library?

I went into the .h and .cpp files and commented out the where it called SoftwareSerial.h, but I'm still getting that above error.

Does anybody know how to fix this?
I am using Arduino IDE v1.5.5

Update:

I didn't put the library in the library direct on my mac but I'm now getting tons of errors, all the errors are with SoftwareSerial.cpp. Is anybody else having similar issues when you go to compile?


texts: Arduino Uno as USB to Serial converter (bypass 328p)

texts:
I'm trying out computer to computer serial communication using 2 Arduino Unos (both connected to different computers).
Right now, I use the Software Serial library, which redirects data from the SoftwareSerial ports to the hardware Serial (over USB to the PC).

Is there any way to bypass the 328p chip, and only use the 16U2, which works as a USB to Serial converter?
Will the circuit in the diagram work? By connecting the GND to RST on both the Unos, the 328p gets disabled, which in theory should all me to directly tap into the serial line of the 16U2.


texts:
I am making a project where I need to communicate between two devices that are about 300-500 meters apart and might experience a lot of RF interference and obstacles. So I thought for initial testing the nRF24L01 modules will be good knowing that they are advertised at 500m. When I did a range test, I got only 10 meters and that too with no obstacles in between! This module seems to be the only choice I have so any suggestions on how to increase range will help immensely.
Stats:
nRF24L01+ module with PCB antennae and a socket adapter board.
I am using the nRFLite library and am transmitting at 2MBPS and have tried multiple channels!


texts: How would you connect multiple HC-SRO4 ultrasonic sensors to one arduino uno? As of now, I have a bunch of jumper cables, 3 u.s sensors, and one arduino uno board. How would one hook up 3 sensors? A schematic would be excellent!


texts:
I want to know if it is possible to set an alarm in DS3231.
I want to set the alarm every 6 AM in the morning. Is this possible?


texts: Why do ESP boards break out the SPI flash pins?

texts:
I have an ESP32 development board and a NodeMCU board here. Both breaking out the pins for the SPI flash of the ESP. These pins are mentioned in standard pinout descriptions as must/should not connect. This pinout description states, that they

  are not recommended for other uses. So, don’t use these pins in your projects

The answer to this question suggests, that you can somehow connect other SPI devices to the same bus as the SPI flash. The linked documentation from that answer states, that in that case you cannot control the chip select for the additional SPI device via a digital pin, but have to let the "hardware arbiter" (whatever that is) decide, when to connect to the additional SPI device.

That is the only use of these pins, that I could find, and even this seems pretty niche. It doesn't seem to be a standard way of usage for the pins and also rather difficult.

Considering the very limited and difficult use of the SPI Flash pins, why do ESP boards break these out to the user? Why aren't they just kept internal, making the board a little smaller?

Maybe there is another use of the pins or I just underestimate the importance of adding additional SPI devices to the bus.


texts:
I am playing with this basic example:

Arduino: Button

There're a lot of existing questions about why to connect button to the ground. I get the idea more or less. Is done to avoid "noise" during reading the input value.

However, what I don't understand is why to use resistor instead of a wire? If I remove resistor and put the wire instead the example stops working. Could someone explain me this?


texts:
i would like to measure some signals from arduino and send it to a pc using USART and display the results in a c# winform application. Does anyone have such a project example ?
Besides, i want to send the data in live time mode, each values should be directly transmitted and then the second measurement ( sample rate 100 kHz )
Thanks a lot


texts: Can't change pins in AM2320 code, types mismatch

texts:
I took a simple A2320 temperature sensor and connected it not to  A4/A5, but to A1/A0 pins. SDA => A1, SCL => A0. (In C code they are number 15 and 14). But I can't call the library to take these pins.
The basic example from the library uses the default values, probably from some tutorial.
I read the .h and .cpp files and see these definitions:
Adafruit_AM2320::Adafruit_AM2320(TwoWire *theI2C, int32_t tempSensorId,
                                 int32_t humiditySensorId)
    : _temp(this, tempSensorId), _humidity(this, humiditySensorId),
      _i2c(theI2C) {}

bool Adafruit_AM2320::begin() {
  _i2caddr = 0x5C; // fixed addr
  _i2c->begin();
  return true;
}

I just tried to make types match. Not even port number.
I declared a TwoWire instance and passed it to AM2320 constructor, but without success:
#include "Wire.h"
...
TwoWire mywire();
Adafruit_AM2320 am2320 = Adafruit_AM2320(mywire, -1, -1); // as the default values

Outputs in error log:
error: no matching function for call to 'Adafruit_AM2320::Adafruit_AM2320(TwoWire (*)(), int, int)'
    Adafruit_AM2320 am2320 = Adafruit_AM2320(&mywire, -1, -1);
In file included from testproj.ino:2:0:
...Adafruit_AM2320.h:52:3: note: candidate: Adafruit_AM2320::Adafruit_AM2320(TwoWire*, int32_t, int32_t)
   Adafruit_AM2320(TwoWire *theI2C = &Wire, int32_t tempSensorId = -1,
   ^~~~~~~~~~~~~~~
...Adafruit_AM2320.h:52:3: note:   no known conversion for argument 1 from 'TwoWire (*)()' to 'TwoWire*'

What am I doing wrong?


texts: Best way to determine if a 5 gallon water jug is getting empty

texts:
I have an espresso machine that gets its water from one of those 5 gallon blue water bottles (I would plumb it, but our water here is WAAAAY too hard).

If I ever accidentally let the bottle run out of water, the rotary pump in the espresso machine will be ruined, which would be a costly mistake.

I know that I can install some sort of magnetic float sensor inside the water bottle, but since I have to change it out once every few weeks, having another thing inside the bottle would make changing it out harder, and microbial contamination more likely.  The pump that pumps water out of the bottle forms a tight seal at the lid, and anything running under it or through it would compromise that seal.

Is there something I could use to detect if the water level is low from the outside of the bottle?  Like a laser sensor?


texts: How to get code to respond to a certain time from the DS3231 RTC?

texts:
I am trying to make a program that runs when it gets to five in the afternoon, so 17:00:00.

I am using this DS3231 library, but I can't figure out a way to get it to send "Woooopp" to the serial monitor at the specified time.

On the DS3231, the pin labeled SCL is connected to A5 on the Arduino and the pin labeled SDA is connected to A4 on the Arduino.

SCL -> A5
SDA -> A4

My code:

#include <DS3231.h>

// Init the DS3231 using the hardware interface
DS3231  rtc (SDA, SCL);

void setup() {
  // Setup Serial connection
  Serial.begin(115200);
  // Uncomment the next line if you are using an Arduino Leonardo
  //while (!Serial) {}

  // Initialize the rtc object
  rtc.begin();

  // The following lines can be uncommented to set the date and time
  // rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
  // rtc.setTime(19, 48, 50);     // Set the time to 12:00:00 (24hr format)
  // rtc.setDate(3, 6, 2017);   // Set the date to January 1st, 2014
}

void loop() {
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");

  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());

  // Wait one second before repeating :)

  if (rtc.getTimeStr() == "19:58:12") {
    Serial.println("Woooopp");
  }
  delay (1000);
}

No errors are thrown, however, the code simply does not work.

Any help would be greatly appreciated!


texts: Splitting DOUBLE in byte for save on EEPROM

texts:
I'm trying to save in memory (FRAM in this case) DOUBLE value, i try the same method with use of UNION for save FLOAT value, but don't go over the 2nd number after dot, why? Where I'm wrong? thank's for help .

 //---------------------------------------------------------

  union Scomp_double  // si utilizza union x double
  {
    double temp;
    char byte_s[8];
  } S_double;

  //---------------------------------------------------------

double mioDouble = 1234567.12345678;

//-------------------------DOUBLE--------------------------------

  Serial.println("DOUBLE");
  byte d0 = 0;  // contengono i byte del float
  byte d1 = 0;
  byte d2 = 0;
  byte d3 = 0;
  byte d4 = 0;
  byte d5 = 0;
  byte d6 = 0;
  byte d7 = 0;

  S_double.temp = mioDouble;
  d0 = S_double.byte_s[0];
  d1 = S_double.byte_s[1];
  d2 = S_double.byte_s[2];
  d3 = S_double.byte_s[3];
  d4 = S_double.byte_s[4];
  d5 = S_double.byte_s[5];
  d6 = S_double.byte_s[6];
  d7 = S_double.byte_s[7];

  Serial.println(d0);
  Serial.println(d1);
  Serial.println(d2);
  Serial.println(d3);
  Serial.println(d4);
  Serial.println(d5);
  Serial.println(d6);
  Serial.println(d7);

  fram.writeEnable(true);
  fram.write8(11, d0);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(12, d1);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(13, d2);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(14, d3);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(15, d4);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(16, d5);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(17, d6);
  fram.writeEnable(false);
  fram.writeEnable(true);
  fram.write8(18, d7);
  fram.writeEnable(false);

  S_double.byte_s[0] = fram.read8(11); // si ricompone il double
  S_double.byte_s[1] = fram.read8(12);
  S_double.byte_s[2] = fram.read8(13);
  S_double.byte_s[3] = fram.read8(14);
  S_double.byte_s[4] = fram.read8(15);
  S_double.byte_s[5] = fram.read8(16);
  S_double.byte_s[6] = fram.read8(17);
  S_double.byte_s[7] = fram.read8(18);

  double masterDouble = S_double.temp;
  Serial.println(masterDouble);
  //-------------------------DOUBLE-------------------------------

expected result 1234567.12345678 , result taken 1234567,12


texts: SD card initialize and fails when date changed

texts:
i am making a project using Arduino Uno that display data on 7 seg display which stored in SD card as day by day. when i make power ON to device then SD card initialization done & data shows correct as per date. Then after when i change the date SD card failed i.e. "show error opening database.txt" .
How can i overcome with this?
" When debugging my SD Card I had a software error that would put the
card into a state that required the microSD card to be powered down and then
powered up to work. It would work until the software error and then not
work again until the power was cycled. "


texts: How to set up "ESP8266 Wifi Bee" on "Gravity: IO Sensor Shield For Arduino Mega Due"

texts:
I'm new to sensors and Arduino, trying to send the live data from my hydroponic garden to Thingspeak. I obviously found tons of info and tutorials on how to connect to Thingspeak - that I can handle. Nethertheless, I'm somehow to stupid to understand the tutorials regarding setting up the Wifi Bee (https://www.dfrobot.com/product-1279.html) on the Gravity: IO Sensor Shield For Arduino Mega Due (Gravity: IO Sensor Shield For Arduino Mega Due).
First of all, do I need the xBee to USB adapter (FTDI ready) to set up the Wifi Bee like this one: https://www.dfrobot.com/product-72.html? Or the other way around, is the IO Sensor Shield I am using not capable to directly handle the Wifi Bee?
Secondly, could someone please give me a straight forward approach on which xBee-slot to use on the IO Extension Board (if there are differences) and how to speak to them via coding, what library to include and which set up code to use? Because I again found a lot of tutorials and examples, but either they seem incomplete (for such a dummy I still am), using different hardware or are not compatible to the current Arduino IDE... or I just did something wrong i.e. used incompatible hardware of course ;-)
Is there a tutorial out there for the hardware I'm using?

Thanks for your help, I really appreciate it!
Nico


texts:
I've been working with the PROGMEM function on my Arduino Uno and I'm thinking about changing to the bigger Arduino Due which is based on a ARM Cortex M3 processor instead of the AVR processor on the Uno.

The Arduino Reference now says:

  PROGMEM is part of the pgmspace.h library that is available in the AVR architecture only.

My question now is: Is it possible to store constants in program memory instead of flash on the Due?

If found this post on the Arduino forums, suggesting that this is done automatically. Does anyone know something about that?

EDIT: Arduino IDE doesn't give stats about RAM usage after compiling, so I can't just try.


texts: I power my Arduino Mini with 3 AA batteries on RAW input. Is it possible to get the voltage on RAW and therefore the expected longevity of the batteries?


texts: Molex power with USB serial Communication from the same PSU

texts:
Before I begin I just want to apologize for my mediocre understanding of things electrical and arduino. I know there are a lot of topics similar to this but I'm confused by the term external PSU
Question
Do I need to worry about any sort of issues (loops/grounding) if I use the molex connector to supply power to my arduino uno and continue to use the USB for serial communication at the same time? The source of both would be from the same PSU in my PC.
From what I understand the Uno when powered by DC should not exceed 7.5V for maximum efficiency. So it looks like the 5V from the molex would be more suitable than the 12V and sufficient for my needs of roughly 3.6A (60mA per LED * 60). Since USB can only supply a maximum of 2.0A and Molex appears to supply up to 5.0A from what I've read.
And I would connect it like so 5V molex powered Uno?
Background
Currently I'm using the arduino uno to power a single 5V strip of 30 rgb WS2812B leds, which works great when powered through the USB port, but since I need an additional strip of 30 leds and USB alone cannot supply enough amperage to power both I need a better source of current. I also needed the cleanest solution possible as it's for a PC tower and I don't want to use an external power source.
Edit - Alternative solution
If you have an Arduino board with USB, simply power the Arduino from your PC's USB via a standard cable and the LED strips from the Molex. The only connection between these two would need to be GND and led strip data line. No need to share a 5V between the LEDs and the Arduino


texts:
I am getting the following error message when compiling a program on my Arduino IDE. This does not happen when compiling the given example programs in the IDE.

The error message is as follows :

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware
C:\Program Files\Arduino\hardware -tools
C:\Program Files\Arduino\tools-builder -tools
C:\Program Files\Arduino\hardware\tools\avr -built-in-libraries
C:\Program Files\Arduino\libraries -libraries
C:\Users\mahim\OneDrive\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10805 -build-path
C:\Users\mahim\AppData\Local\Temp\arduino_build_361527 -warnings=none -build-cache
C:\Users\mahim\AppData\Local\Temp\arduino_cache_227236 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=
C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=
C:\Program Files\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=
C:\Program Files\Arduino\hardware\tools\avr -verbose
C:\Users\mahim\OneDrive\Documents\Arduino\3potpass\3potpass.ino
readlink
C:\Users\mahim\OneDrive\Documents\Arduino\3potpass\3potpass.ino: The system cannot find the file specified.

Error compiling for board Arduino/Genuino Uno.


texts: Arduino Uno with ESP8266-01 using PubSubClient with secure TLS

texts:
In my example, Arduino UNO (ATMEGA328p) connects using the SoftwareSerial library with the ESP8266-01 module.
Then I used the PubSubClient library to connect to the MQTT broker. The connection is to port 1883 and is not encrypted. Everything works fine.

How can this be done to make the connection encrypted (TLS) to port 8883 with the setting of my own CA certificate.

Example:

#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <SoftwareSerial.h>
#include <PubSubClient.h>

...

static const char ca_cert[] PROGMEM = R"EOF(
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
)EOF";

...

SoftwareSerial wifiSerial(WIFI_RX, WIFI_TX);
WiFiEspClient WIFI_CLIENT;
PubSubClient MQTT_CLIENT;

...

void setup() {
  wifiSerial.begin(9600);
  WiFi.init(&wifiSerial);
  if (WiFi.status() == WL_NO_SHIELD) {
    printLog("WiFi shield not present");
    // don't continue
    while (true);
  }
  printLog("Connecting to AP ...");
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  ???   WIFI_CLIENT.setCACert(ca_cert);   ???
  printLog("Connected to AP");
}


texts:
I was trying to play with Arduino this weekend and connected a DC motor to A0 and GND to measure the voltage it provides when I rotate it.

However,
when I rotate the DC motor with my fingers to test out the readings I see that when rotated clockwise it generates voltage that can be read in Arduino. But when I rotate it counter-clockwise the values I get are 0 - this is probably because DC motor generates negative voltage (?).

How do I fix this so that no matter the direction of the turn I get always positive value?

I am trying to build a simple anemometer, just for fun for kids and plot the values, however can't do much when I get 0 on analogRead when wind blows from the other direction..

thanks for any input into this.


texts: Button to stop a stopwatch not working correctly!

texts:
I'm trying to implement a stopwatch with an LCD display, and I'm supposed to be using the attachInterrupt command to catch the button press. The clock runs perfectly, but the button input isn't caught or acted upon at all.
In void setup(), I have set it up this way: attachInterrupt(digitalPinToInterrupt(buttonPin), buttonInterrupt, RISING);.
And the buttonInterrupt function only does start = !start, so in a sense just flipping the start variable.
This is the updated version of the code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int buttonPin = 7;
volatile int buttonState;
int lastButtonState;
long sec;
long startTime;

void setup() {
  lcd.begin(16, 2);
  pinMode(buttonPin, INPUT_PULLUP);
  lcd.setCursor(0,0);
  lcd.print("Push the button!");
  attachInterrupt(digitalPinToInterrupt(buttonPin),buttonInterrupt,HIGH);
}

void loop() {

  buttonState = digitalRead(buttonPin);
  if(buttonState == LOW){
    startTime = millis();
  }

  while(buttonState == HIGH){
    long time = millis();
    long z = (time - startTime);
    sec = (z/1000);
    long ms = z%1000;
    lcd.setCursor(0,1);
    lcd.print(sec);
    lcd.print(".");
    lcd.print(ms);
    lcd.setCursor(8,1);
    lcd.print("Secs");

    if(buttonState == LOW){
      break;
    }
  }
}

void buttonInterrupt() {
  if(buttonState == LOW){
    buttonState = HIGH;
  }else{
    buttonState = LOW;
  }
}

The loop function works as far as time counting is concerned, but doesn't work to stop the time with the button. Any help is appreciated, I'm extremely new to Arduino (literally started yesterday). My circuit looks like this: https://i.imgur.com/yCR9fhP.png
If there is any other way to print the numbers other than printString, more than happy to hear them!
Thanks!


texts: Which component is described as a "jumper" (NOT jumper wire) when working with a motor shield?

texts:
In this video I'm watching then instructor talks about using "jumpers". He's got a motor controller shield and at first he says that "during the making of this video we only had 1 jumper, thus only Pin 4 is working", and that as a result he could only move a motor/wheel in 1 direction.

He proceeds to find another jumper, uses it to make Pin 5 work, and then he can reverse polarity and change the direction the the wheel spins.

At first I thought that he must mean header pins, but when he holds the tiny component up, it looks like it's something else:

I read about a "power jumper" on an Adafruit page, but it only applied to one version of the Arduino and sounded like it was to do with Power joining (using the same power source for the motor and controller), so I really don't know if that's the same thing.


texts:
I tried to modify the basic "hello-world" sketch for the LCD that is a part of the examples section in the IDE. I intended to make a countdown timer using the LCD.
The original code simply prints "Hello World" in the first line, and then makes use of the millis() function to print the time elapsed in the next line.
So I tried a simple modification to make it count down from 20. Instead of printing millis()/1000 , I printed 20-millis()/1000, and also added a while() to only print till millis()<=20,000. (so that it does not go beyond 00)
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {

  lcd.begin(16, 2);

  lcd.print("time left");
}

void loop() {

  while(millis()<=20000){

    lcd.setCursor(0, 1);

    lcd.print(20- millis() / 1000);
  }

}

It seemed to work till 10. but instead of 9, it printed 90, and likewise 80,70.. for 8,7...etc till 00.
How can I get rid of these extra zeros?


texts: I2C master/slave maximum requestEvent message size

texts:
Using a NodeMCU master and an Arduino slave (Wire.h on both sides), is there a maximum message size (32 bytes?) for the answer that the slave sends from requestEvent()?

If so, is there any solution to circumvent such a restriction WITHOUT the use of other libraries (like I2C_Anything, for example)?


texts: Flow meter using Wemos Mini - ISR not in IRAM!

texts:
I'm trying to use a flow meter with Wemos Mini.
Most tutorials are using Arduino boards ( which code and HW work OK ), but since I want this device to send alerts over the internet when abnormal usage/leakage is detected, I want to use Wemos Mini using How to Use Water Flow Sensor - Arduino Tutorial. On top of if will add my code for notifications using Telegram.

BUT - after uploading the original code (before adding Telegram changes ), an error occurs during code run : ISR not in IRAM!

I tried to change Pin - but still getting this error,


texts:
I'm using an Arduino Uno to send HTTP requests to my local webserver. To communicate to the ESP8266 I created a SoftwareSerial which is set to a baud rate of 9600.

Whenever I send a HTTP request, the request looks like the following:

    192.168.2.132 - - [22/Dec/2017:12:22:57 +0100] "TP/1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:23:38 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:23:56 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:24:14 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:24:34 +0100] "\xE9\x09BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:25:06 +0100] "z\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:27:01 +0100] "\x02BQQA\xBD1.1" 400 173 "-" "-"
    192.168.2.132 - - [22/Dec/2017:12:28:11 +0100] "\x02BQQA\xBD1.1" 400 173 "-" "-"

The code to create GET request to send over TCP:

  char *hello = "GET / HTTP/1.1\r\nHost: 192.168.2.106\r\nConnection: close\r\n\r\n";

  if (wifi.send((const uint8_t*)hello, strlen(hello))) {
    Serial.print("Wifi send succesfull\r\n");
  } else {
    Serial.print("Wifi not send succesfully\r\n");
  }

The actual send method:

bool ESP8266::sATCIPSENDSingle(const uint8_t *buffer, uint32_t len)
{
    rx_empty();
    m_puart->print("AT+CIPSEND=");
    m_puart->println(len - 4);

    if (recvFind(">", 5000)) {
        Serial.println("found >");
        rx_empty();

        for (uint32_t i = 0; i <= len; i++) {
            m_puart->write(buffer[i]);
        }

        return recvFind("SEND OK", 30000);
    }
    return false;
}

This line:

m_puart->println(len - 4);

Was in the library actually just m_puart->println(len);

I had to shorten the length of the buffer for esp8266 to wait to, otherwise it wouldn't send the TCP command. The counting part of bytes looks fine to me. Not sure what's causing this behaviour.

The part above is just some extra unusual behaviour but isn't the main priority. So any ideas what's causing the odd HTTP requests?


texts: Is it possible to use AWS and Arduino Uno to upload data from Arduino to a website running on my localhost?

texts:
I was wondering if it's possible to send data from my Arduino Uno (e.g. from the temperature sensor) to the Amazon Web Service RDS or anything there, which will then upload the data to a website on my localhost?

If yes, could someone give me guidance please?

I've been messing with this for a few weeks now, but I am just getting lost with linking it all up together.

Thanks.


texts: Increase PWM bit resolution on only one timer 2 output

texts:
I am new here and I know that this basic question has been answered in the past but what I want to know is this. And I cant figure out how to add this to one of those threads. Sorry in advance if I am posting this wrong.

Arduino Uno

I have a motor driven PWM off output 10 and output 9 is used for the display, can I change the resolution of output 10 only to 16 bit? or will both outputs need to be used as PWM when changing timer 2 to 16 bit? All of the coding samples I see are for changing both outputs.


texts: What is a simple way to measure the ambient light?

texts:
I want to install some LED stripes on my motorcycle, i.e. as brake light and indicators. I use WS2812 LED stripes which can be very bright - especially with many LEDs on at the same time.

I want to measure the ambient light so that in the bright sun I can light the LEDs with, let's say, 100%. But in the night maybe just with 30% intensity. I want to detect the ambient light to change the intensity.

I don't need high resolution and I don't need high speed. If the ambient light is measured i.e. once per second with 4 bit resolution that would be already good enough.

Which ambient light sensor (or photo diode or whatever) makes sense for this little project and how to connect it?
Does it make sense to use more than one light sensor for a better average ambient light value (just in case one sensor is in the shadow, another in the sun)?

I found these sensors form a Chinese supplier:

https://www.banggood.com/CJMCU-9930-APDS-9930-Digital-Proximity-And-Ambient-Light-Sensor-For-Arduino-p-1103139.html

https://www.banggood.com/GY-49-MAX44009-Ambient-Light-Sensor-Module-For-Arduino-p-1196674.html

But an I2C interface seems to be overkill for my simple project.

Any suggestions?


texts: What is the difference between delay() and delaymicroseconds()

texts: Does delaymicroseconds() provide something more than the time accuracy


texts: Libraries/classes using other libraries/classes

texts:
This is, hopefully, a simple issue!

I'm trying to access my fully working libraries (fully compiles, and works with the hardware perfectly) from another library (Computer.h) to abstract it away from the Sketch.ino file.

LLRelay, and all my other libraries, work flawlessly when instanced/constructed/built/etc within the main Sketch.ino; however, when called within "Computer.h", there's issues.

I've been at this for most of the day trying different things, from instantiating the libraries in the header files, the *.cpp files, to within functions, to changing the scope and publicity/privacy of them - still no luck.  See the (2 * "HERE -") comments for the errors.

Any help is greatly appreciated!

This is what I have managed to reduce it down to for debugging:

Sketch.ino

// Sketch.ino
#include "Computer.h"

Computer pc1;

void setup(){};

void loop(){
    pc1.update();
};

Computer.h

// "../customLibs/Computer.h"
#ifndef Computer_lib
#define Computer_lib
#if(ARDUINO > 100)
    #include "Arduino.h"
#else
    #include "WProgram.h"
#endif

class Computer {
    public:
        Computer();
        void update();
    private:
        void fans();
};
#endif

Computer.cpp

// "../customLibs/Computer.cpp"
#include "Computer.h"
#include "src/relay/LLRelay.h" /* Potential culprit, I have tried many variations and locations for this to go, all with the same, or similar compilation errors */

/* HERE - "undefined reference to `LLRelay::LLRelay(unsigned char)'" */
LLRelay fan1(13); // fan1(uint8_t relayPin);

Computer::Computer(){
    Serial.begin(9600);
};

void Computer::update(){
    fans();
};

void Computer::fans(){

    /* HERE - "undefined reference to `LLRelay::On()'" */
    fan1.On();

};

LLRelay.h

// "../customLibs/src/relay/LLRelay.h"
#ifndef LLRelay_lib
#define LLRelay_lib
#if(ARDUINO > 100)
  #include "Arduino.h"
#else
    #include "WProgram.h"
#endif

class LLRelay {
  public:
    LLRelay(uint8_t relayPin);
    void On();
    void Off();
  private:
    uint8_t _relayPin;
};
#endif

LLRelay.cpp

// "../customLibs/src/relay/LLRelay.cpp"
#include "LLRelay.h"

LLRelay::LLRelay(uint8_t relayPin){
  _relayPin = relayPin;
  pinMode(_relayPin, OUTPUT);
  digitalWrite(_relayPin, LOW);
};

void LLRelay::On(){
  digitalWrite(_relayPin, HIGH);
};

void LLRelay::Off(){
  digitalWrite(_relayPin, LOW);
};


texts:
so , just bought some pre-bootloaded ATmega328(p/pu) to which I need to upload sketches on a breadboard using uno TX and RX pin as FTDI
Here is what I am to do.

I connected Uno GND and Reset .

Arduino Tx to Standalone Atmega Tx

Arduino Rx to Standalone Atmegaa Rx

Connected Crystal , capacitor to standalone pin 9, 10 (XTAL) then grounded it with 2 coupling capacitor.

Standalone vcc to arduino 5v
Standalone GND to Uno GND

Is it possible to do what I need to or i need to buy some USB to TTL devices from the Amazon again?
Thanks for your precious time...


texts: How do I read from an SD card on the Yun?

texts:
I'm trying to read a small file off the SD card installed in a Yun. Here's the sketch:

#include <FastLED.h>
#include <FileIO.h>

#define WIDTH 32
#define HEIGHT 1
#define NUM_LEDS (WIDTH * HEIGHT)

#define DATA_PIN 9

CRGB leds[NUM_LEDS];

void setup() {
  // put your setup code here, to run once:
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  Bridge.begin();
  Serial.begin(115200);
  FileSystem.begin();
}

void loop() {
  File f = FileSystem.open("/mnt/sd/single-line-testpattern.ppm", FILE_READ);
  f.seek(29); // seek past the header bytes
  Serial.print("position = "); Serial.println(f.position());
  for (int i = 0; i < NUM_LEDS; i++) {
    uint8_t r = f.read();
    uint8_t g = f.read();
    uint8_t b = f.read();
    Serial.print("r = "); Serial.print(r, HEX);
    Serial.print(", g = "); Serial.print(g, HEX);
    Serial.print(", b = "); Serial.println(b, HEX);
    leds[i] = CRGB(r, g, b);
  }
  f.close();
  FastLED.show();
}

Here's the contents of the PPM file:

50 36 0A 23 20 3A 20 62 79 20 54 6F 79 56 69 65 77 65 72 0A 33 32 20 31 20 32 35 35 0A FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF 00 00 FF

This looks pretty straightforward to me, but the output I'm getting is absolutely baffling:

position = 5888
r = 6, g = A9, b = A
r = B9, g = 0, b = 5
r = 0, g = E9, b = 5
r = 0, g = 0, b = 4
r = 8, g = 21, b = 0
r = 0, g = 0, b = 0
r = 0, g = E5, b = A
r = E0, g = A, b = 0
r = 0, g = 0, b = 0
r = A, g = DA, b = 0
r = 0, g = 0, b = 0
r = 0, g = 0, b = A
r = E5, g = 0, b = 4
r = 2, g = 71, b = 5
r = 1, g = 32, b = 80
r = 9, g = 12, b = 58
r = 58, g = 31, b = 30
r = 30, g = 58, b = 58
r = 58, g = 58, b = 58

WAT?! Where are those numbers even coming from? What does file.read() think a byte is? How come it's trying to read from 5888 bytes into a 125 byte file?

Note this is the FileIO library from the Yun Bridge package to read from the SD card built into the Atheron side of the Yun. The "normal" Arduino SD card library isn't relevant here.


texts: Stacking 3 of the same shields on top of each other and instructing them in sync

texts:
Context:
I have an audio track separated into individual channels grouped by frequency and speaker location. I need to play all three of these channels simultaneously and perform instructions like play, stop, repeat, skip across all channels to keep them in sync.
This is part of an outdoor installation so the solution must be modular and robust.
If possible, the most elegant solution I could come up with is to use an Arduino Leonardo and stack 3 Adafruit Music Maker Shield on each other.
Reasons why I think it might be technically feasible:
1. Each shield can share communication over I2C

Looking at the VS1053b Datasheet (the IC used in the shield) the chip at max load consumes Maximum 60mA, and typically 37mA. Arduino can drive a max of 500mA so these three shields should consume a small portion of that.
The Arduino will also be powered via 12v power supply.

Details i'm not so clear on:

How will I differentiate between each shield when sending instructions or do I need to even need consider this if I want them to function as one?


texts: Cisco Switch not receiving serial communication from Arduino

texts:
So I have an issue that I can't really think of a reason why it would be happening. I have an Arduino Mega connected on Serial3 to a RS232 breakout board with a male DB9 connector on it. I then have two female breakout boards connected. One is connected to the RS232 breakout board and the other to a Cisco DB9 to roll over cable, which is connected to my Cisco Switch, or if it is, it is being ignored.

For some reason no data sent from the Arduino is making it to the Cisco switch that I can tell. I did confirm that it is sending data using a USB to DB9 adapter and PUTTY. I can send and receive data from both the Arduino and PUTTY correctly to the other.

I can receive data from the switch perfectly. Cisco's default settings are the same as the Arduino's, 9600, 8bits, no parity, 1 stop bit etc...

I can also connect the switch to the USB to DB9 adapter directly and send and receive fine through it / PUTTY as well.

Does anyone have any suggestions why I'd be able to send data to and from Putty, but only receive data from the switch, or why the data going to the switch is failing?

void setup() {
  Serial.begin(9600, SERIAL_8N1);
  Serial3.begin(9600, SERIAL_8N1);
  Serial.println("Ready....");
  Serial.println();
}

void loop() {
  // read from Serial3, write to Serial
  if (Serial3.available()) {
    int inByte = Serial3.read();
    Serial.write(inByte);
  }
  // read from Serial, write to Serial3
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial3.write(inByte);
  }
  Serial3.println(); // Added just to test if a cr could be passed
  Serial3.write(98); // Added just to test if a character could be directory passed
  Serial3.write(10); // Added just to test if a cr could be passed
}


texts:
I want to monitor the temperatur around the house and outside. I want to save the data to mysql and then create some kind of webapplication that displlays the data. It is pretty easy to find temperature sensors that transmitts over 433Mhz, and I have thought about Telldus tellstick to receive data and store them. This receiver costs about 30 - 40 $ and 10 - 20 $ for each sensor.

But since I just learned that Arduino can be used for everything, I would love to hear more about it.

Can someone please give me an introduction to what I would need to make this solution? The arduino should basicly receive data from 433 Mhz sensors and store it to MySQL.

What woulds be the challanges when doing something like this?


texts:
I am making a 2-wheeled Arduino car controlled by T.V. remote for a science fair tomorrow. I have found a tutorial for the IR part. I brought this  L293D motor driver to control a 2-wheeled car. I am facing a problem. I know where to connect the motors (because there are indications stating M1 and M2) but I don't know where to connect the motor driver to the Arduino and to the batteries.

I checked over the net but couldn't find any tutorial for this kind of board. Also I have no experience in all this so I don't want to risk it. I don't want any code or anything, just where to connect what.

Any help is appreciated.


texts:
A couple of days ago, I purchased a pulse sensor online for a project. Before actually doing anything with it, I wanted to capture and view its analogue waveform output. One while placing my finger on it and one when in the default state, so that I can see the trend or difference in the two waveforms. But when I captured the output, it seems like there is not much difference. Just some random noise I guess. Also, I checked the company website who may have made this one and it all looks good to me.

The image below shows the waveform captured when no finger is placed on the sensor.

The image below shows the waveform captured when my index finger is placed on the sensor.

This is my setup for the sensor for measuring pulses.

This image shows the face of the sensor.

I need some insights from folks here regarding this sensor. Is it showing some junk output? or my understanding is wrong and there's a better way to figure this out/ work with this sensor.


texts:
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


texts: How can BMP180 measure a temperature too?

texts:
I got the following device

(sorry for imperfect focus)

and found, that it can measure not only pressure, but also a temperature too. The code was taken from common sketches for Adafruit BMP085 and they were working. I checked, that temperature value rises if I touch sensor with finger.

Simultaneously, on Bosch site for BMP180 I can't find any notes it can measure temperature, only pressure.

How can it be?

1) Bosch's BMP180 has undocumented feature to measure a temperature

2) The device on picture has additional component to measure temperature

3) The device on picture has completely different sensor, which has the name of "BMP180" just by coincidence.

4) Something else....


texts:
I have 2 nodes: one is a PC+arduino mega+xbee the other one is arduino micro+xbee.
The 2 xbees are communicating fine, I have tested this with 2 separate arduinos.
My problem is that when the second xbee hooked up to the micro it seems it does not try to send or receive data from the serial lines.
It is connected to the first RX/TX pins in proper order (RX->Tx, Tx->Rx) on the micro.

This is obvious for me because if I start my program's setup section on the ardu with:

void setup()

{
  Serial.begin(9600);
  while (!Serial);

The whole main program won't be running because the serial just never gets ready only if I plug my PC in.

When I try to send data from the PC->micro through xbee I see the Xbee receives it (led goes on the board) but nothing happens on the micro.

The micro right now is set to periodically send some debug data through the serial, I don't get that back either otherwise I would see the serial TX led on the micro blinking that it is sending the data. It only works when the PC is connected through USB.

Do I need some additional code for the xbee or is it require a hardware modification? I use a 5V-3V ttl converter as an extra hardware.


texts: Attempted to disable autoreset - now the voltage regulator only outputs 4.0v

texts:
I followed the guide from the Arduino website, by placing a 10uF capacitor between GND and Reset. However, now the voltage regulator only provides 4v (Vin=13V). It correctly has 5V when being powered via USB.

What happened? Isn't there a 10k resistor between +5V and Reset that should prevent the chip from being overloaded? Or did the Reset pin sink the entire energy of the capacitor?


texts: Buttons for LED strip only work when held down

texts:
I am trying to make a 24 button board that assigns different methods to each button. When a button is pressed, it should interrupt the method of the previous button and begin the new method. Currently, the button has to be held down in order to work. I'm not sure why since the methods should continue without being held down. All 24 methods are similar to the one posted below.

loop(){
  if (digitalRead(inPin(5)) == HIGH){
    fifthButtonTheatreChaseRedSlow(strip.Color(127,   0,   0), 100); // Red
  }

void fifthButtonTheatreChaseRedSlow(uint32_t c, uint8_t wait) {
  for (int j=0; j<100; j++) {  //do 100 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3)
      {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();
      delay(wait);

      // give up if switches pressed
      if (digitalRead (inPin(1)) == HIGH ||
             digitalRead (inPin(2)) == HIGH ||
             digitalRead (inPin(3)) == HIGH ||
             digitalRead (inPin(4)) == HIGH ||
             digitalRead (inPin(6)) == HIGH ||
             digitalRead (inPin(7)) == HIGH ||
             digitalRead (inPin(8)) == HIGH ||
             digitalRead (inPin(9)) == HIGH ||
             digitalRead (inPin(10)) == HIGH ||
             digitalRead (inPin(11)) == HIGH ||
             digitalRead (inPin(12)) == HIGH ||
             digitalRead (inPin(13)) == HIGH ||
             digitalRead (inPin(14)) == HIGH ||
             digitalRead (inPin(15)) == HIGH ||
             digitalRead (inPin(16)) == HIGH ||
             digitalRead (inPin(17)) == HIGH ||
             digitalRead (inPin(18)) == HIGH ||
             digitalRead (inPin(19)) == HIGH ||
             digitalRead (inPin(20)) == HIGH ||
             digitalRead (inPin(21)) == HIGH ||
             digitalRead (inPin(22)) == HIGH ||
             digitalRead (inPin(23)) == HIGH ||
             digitalRead (inPin(24)) == HIGH)
               return;

      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

Not sure if it's a hardware issue or a software issue.


texts:
I am behind a problem of controling multiple leds with multiple push buttons. Lets say that I have 5 push buttons and 3 leds. Led1 turns on if at least 1 out of the 5 push buttons is pressed. Led2 turns on if at lest 3 push buttons are pressed and Led3 turns on if at least 4 push buttons are pressed.
How can this be solved ? With if else ?arrays?
here is my code that i have

 const int led1 = 2;
 const int led2 = 3;
 const int led3 = 4;
 const int bp1 = 9;
 const int bp2 = 8;
 const int bp3 = 7;
 const int bp4 = 6;
 const int bp5 = 5;
 int state;

void setup()
 {
 Serial.begin(9600);
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(bp1, INPUT);
 pinMode(bp2, INPUT);
 pinMode(bp3, INPUT);
 pinMode(bp4, INPUT);
 pinMode(bp5, INPUT);
}

void loop()
{
 state = digitalRead(bp1);
 state = digitalRead(bp2);
 state = digitalRead(bp3);
 state = digitalRead(bp4);
 state = digitalRead(bp5);
if (state = HIGH)
{ digitalWrite(led1, HIGH); }

if (state = 3 )
{ digitalWrite(led2, HIGH);
if (state >= 4);
{ digitalWrite(led3, HIGH); }
}
else { digitalWrite(led1, LOW); }
}


texts: How do I read from /dev/ttyACM0 in Linux without a terminal emulator?

texts:
I just bought an Arduino Due and I'm having trouble reading from a simple serial IO program.

I have a SparkFun RedBoard which is like an Uno. With that, I just ran a "stty" command to configure the baud rate and other terminal settings, and then I could do "cat /dev/ttyUSB0". Actually I have a C++ program which opens "/dev/ttyUSB01" and reads from it like a normal file.

Now, with the Due, the device is "/dev/ttyACM0" and there have been a few snags. One of them is that after programming the Due, and running stty, I have to open /dev/ttyACM0 using the screen program:

screen /dev/ttyACM0 115200

and then kill screen, before cat /dev/ttyACM0 will work. Otherwise, cat prints out one byte and exits; rarely it prints out 10 bytes or a line, or sometimes it prints nothing.

This is a bit annoying and I can't figure out what screen is doing to the device which I can't seem to accomplish using stty. My stty command is:

sudo stty -F /dev/ttyACM* 115200 -parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts \
-ignbrk brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon -ixoff -iuclc \
-ixany -imaxbel -iutf8 \
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 \
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl \
echoke -flusho -extproc

I got this by running stty -a < /dev/ttyACM0 after using screen to initialize as above.

I thought it might have something to do with serial auto-reset, so I tried using a resistor between 3.3V and RESET, but this did not fix the problem.

I should note that cu from the uucp package is able to read continuously from /dev/ttyACM0, but unlike screen it does not leave the terminal set up in such a way that a subsequent cat command will work.

$ cu -l /dev/ttyACM0 -s 115200
<continuous stream of data>
$ killall cu             # (from another shell)
$ cat /dev/ttyACM0 | hexdump -c
<e.g. 7 bytes>
$

With screen, cat would have printed an infinite stream. Any ideas how to accomplish this setup without using screen?