texts: LCD showing weird characters when using two 1-wire temperature sensors

texts:
I have a sketch to display a temperature obtained from 1-wire DS18B20 sensors. The sketch works fine, however when I connect two sensors to my board, the text on the LCD displays gets corrupted (### and other symbols shown instead of a temperature).

I have tried plugging each of the two DS18B20 sensors individually and it works with both of them, the problem shows only when I use both at the same time. I am connecting them both with black to ground, red to 5V and white to Dx and to 5V via a 4.7 kOhm pull-up resistor.

I have little idea how to check what is wrong - is it some kind of interference, insufficient voltage, or a SW problem?


texts: Custom board with ATMega32u4 having USB issues

texts:
I built a custom arduino based board (speciffically based off of Sparkfun's Pro Micro 3.3V 8Mhz and their Qduino mini boards) that uses the ATMega32u4-RC.

The board I built integrated an acceleromter (LSM6DS3) and a micro-SD card holder, and eleminated any uneeded GPIO. (This is basically a datalogger board for the LSM6DS3 accelerometer). It also inlcudes a usb-powered LIPO charging circuit, which is copied from the qduino mini.

A picture of the board I built,  with power LED indicating life.

The problem I am experiencing is that, after apparently sucessfull upload of the bootloader (I've tried the bootloader for the qduino mini, promicro 3.3v 8Mhz, even the Leonardo), my computer will not reconize the board. I've exauhsted all the information about driver installation from the sources for the boards my board is based on, and still can't make windows recognize my custom board.

Specifically, I've tried using a multitude of signed and unsigned drivers (on Windows 10 and 7), and can not get windows to pick anything other than usbfilt.sys as the driver.

Any advice would be greatly appreciated!

Edit: Added Eagle Schematic below


texts:
I found the .toFloat() but that's not accurate enough.

String StrEx = "57.10598";
float FloatEx = StrEx.toFloat();

Serial.println(String(FloatEx)); //outputs 57.11
Serial.println(StrEx);           //outputs 57.10598


texts: Looking to optimize this code and add a loop

texts:
So I want to optimize this code and add a loop to the two red LEDs. The process is green LED is flashing, press button, yellow LED blink for 3 secs and then alternate flashing between the two red LEDs until the button is released.
 int switchState = 0;
    int green = 3;
    int yellow = 4;
    int red1 = 5;
    int red2 = 6;
    int button = 2;

    void setup()
    {
      pinMode(green, OUTPUT) ;
      pinMode(yellow, OUTPUT) ;
      pinMode(red1, OUTPUT) ;
      pinMode(red2, OUTPUT) ;
      pinMode(button, INPUT) ;
    }

    void loop()

    { //start void loop 1
      switchState = digitalRead(button);

      if (switchState == LOW)         //button not pressed
      {
        digitalWrite(green, HIGH);      //green LED on
        digitalWrite(yellow, LOW);
        digitalWrite(red1, LOW);
        digitalWrite(red2, LOW);

        delay(500);

        digitalWrite(green, LOW);     //blink green LED

        delay(500);
      }//end if

      else        //Button pressed
      {

        digitalWrite(green, LOW);
        digitalWrite(yellow, HIGH);   //Blink yellow LED for 3 sec
        digitalWrite(red1, LOW);
        digitalWrite(red2, LOW);

        delay(250);

        digitalWrite(yellow, LOW);

        delay(250);

        digitalWrite(yellow, HIGH);

        delay(250);

        digitalWrite(yellow, LOW);

        delay(250);

        digitalWrite(yellow, HIGH);

        delay(250);

        digitalWrite(yellow, LOW);

        delay(250);

        digitalWrite(yellow, HIGH);

        delay(250);

        digitalWrite(yellow, LOW);

        delay(250);

        digitalWrite(yellow, HIGH);

        delay(250);

        digitalWrite(yellow, LOW);

        delay(250);

        digitalWrite(yellow, HIGH);

        delay(250);

        digitalWrite(yellow, LOW);

        delay(250);

        digitalWrite(yellow, HIGH);

        delay(250);

        digitalWrite(yellow, LOW);

        void loop()
        {

          digitalWrite(red1, HIGH);
          digitalWrite(red2, LOW);

          delay(250);

          digitalWrite(red1, LOW);
          digitalWrite(red2, HIGH);

          delay(250);

        }     //end void loop 2

      }     //end button press

    }     //end void loop 1


texts: Passing class member function as argument

texts:
I need to pass a class member function to server.on, unfortunately i get an error.

  error: no matching function for call to 'ESP8266WebServer::on

I have done some searching but could not understand anything I found. No simple explanation.

This works:

void handleRoot(){}
server.on("/", handleRoot);

This doesn't:

void myClass::handleRoot(){}
void myClass::setup(){
    server.on("/", handleRoot);
}

The second argument to server.on is

typedef std::function<void(void)> THandlerFunction;

Unfortunately I have no idea what it means.


texts: Serial.read(); and state machine for AT commands

texts:
I have a strange type of issue: the index of the array doesn't increment and when I print the value from the serialdata[pointingfinger] it just gives me an empty space.
This is a state machine (I guess) that should check what is the current char that's being written into the array and its position to avoid searching it later. When we have a finished line it changes the bigger state machine to another mode (that checks if four chars further is the command) when the processing is done it should get back getting the next line.

This is Arduino Leonardo and Serial is the USB and Serial1 is where I send and receive AT commands.

const long interval = 1000;
static long currentMillis;

char plussignpoint = 0; //To determine where is the + in +CCLK in the char array

char serialdata[256] = ""; //Array to store the chars before parsing

int rdpos = 0;

int pointingfinger = 0;

char timeen = 0;
byte stat0 = 0;
char futstat0 = 0;
char searchcharpos = 0;

char enabled = 0;

char searchchartype = 0;

char smsvalid = 0;

void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial1.write("ATE0\r");
}

void loop() {
    if (millis() - currentMillis >= interval)
    {
      Serial1.print("AT+CCLK?\r"); //ask for the time

      enabled = 1;

      currentMillis = millis();
    }

    if (enabled == 1) {
      if (stat0 == 0) {
        if (Serial1.available () > 0) {
          pointingfinger++;
          serialdata[pointingfinger] = Serial1.read();
          if (serialdata[pointingfinger] == '+') {

            searchcharpos = pointingfinger;
            searchchartype = 1;
            futstat0 = 1;
          }
          else if (serialdata[pointingfinger] == '$') {
            if (smsvalid = 1) {
              searchcharpos = pointingfinger;
              searchchartype = 2;
              futstat0 = 2;
            }
            if (smsvalid = 0) {
              stat0 = futstat0;
              pointingfinger = 0;
            }
          }
          else if (serialdata[pointingfinger] == '\n') {
            stat0 = futstat0;
            pointingfinger = 0;
            enabled = 0;
          }
          else if (serialdata[pointingfinger] == '\r') {
            stat0 = futstat0;
            pointingfinger = 0;
            enabled = 0;
          }
          else {
            stat0 = 0;
            pointingfinger = 0;
          }
        }

        if (pointingfinger == 255) {
          pointingfinger = 0;
          enabled = 0;
        }

      }
    }
}

EDIT: I forgot to include what AT commands it should parse:

Arduino: AT+CCLK?

SIM800H: +CCLK: "04/01/01,01:35:31+00"

         OK


texts:
Trying to figure out how to do this in millis. So right now the code works just fine, plays mp3_play(2) while a push button is closed then plays mp3_play(1) when its open. Lets say I want mp3_play(2) to play while the push button closed but after 4 seconds if the button is still closed another audio file will be triggered to play. Cant figure that one out.
thanks
Jason
void fire(){

  int reading = digitalRead(buttonPin);

  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }

  if ((millis() - lastDebounceTime) > debounceDelay) {

    if (reading != buttonState) {
      buttonState = reading;

      if (buttonState == HIGH) {
        mp3_play (1); //power down sound
      }

      if (buttonState == LOW) {
        mp3_play (2);  // fire sound
      }

    }
  }
  lastButtonState = reading;
}


texts:
I want to create a small LED strip driver/controller with 2 channels (Cold/Warm white) using Arduino Pro Mini (5V/16MHz). I have connected the parts per the following diagram
I have pins 5 and 6 setup as output, control them via analogWrite, and it all works great on Arduino UNO.
The problem comes with Arduino mini pro. When one channel is set to 255 and the other is 0, the LED strip does light only in one color, which is OK and when I swap the PWM channel's values, the other light color starts to shine. So far so good. When I set both to 0, the strip keeps on shining at about 30% (I don't have a scope, so I can't tell what the pwm signal is doing). Varying the channels' pwm in the range 0-255 does affect the light somehow but it never goes down to a complete off.
Looking at the arduino uno and pro mini I can't see anything obvious that should make them act differently from the hardware perspective so I'm guessing there's a problem in the libraries or perhaps my arduino pro mini (a clone) is somehow messed up.
Has anyone observed this kind of behavior in Arduino pro mini and has a solution for it?
Edit: Added some measurements per @Abel's request. I measured both DC and AC with and without the LED strip connected.
Connecting the LED strip really does mess things up, but WHY? UNO can handle it, but the pro mini can't! I thought mini was basically just shrunk down arduino uno (both have the same SMD version of MEGA328P), but apparently there are some differences.


texts: Arduino UNO and ESP8266-01 Wi-Fi cutting out after few seconds

texts:
I followed this tutorial: https://www.youtube.com/watch?v=2cjufbgOBYo

My serial output in Arduino editor is this:

AT
AT
AT
AT
AT
AT
AT
AT+RST
ATE0
AT+CWMODE=2
AT+CWDHCP=0,1
AT+CWSAP="RemoteXY","12345678",10,4
AT+CIPMODE=0
AT+CIPMUX=1
AT+CIPSERVER=1,6377
AT+CIPSTO=7
AT
AT
AT

The problem is the Wi-Fi is cutting out after a few seconds. I see the network pop up on my phone/on the RemoteXY app and then it disappears after a few seconds.

I have a suspicion it's something to do with the RX needing a voltage divider? But I am just following the tutorial and am new to electronics.

I also haven't wired up an LED yet (I am planning on using a mains relay instead)

All help appreciated,

Thanks.


texts: Can the arduino be recognized if the usb chip is broken?

texts:
My question might seem one of the million questions out there "Can't upload to arduino uno and receive error avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01" but as I probably read all the million questions and didn't find the answer I am looking for I decided to write my own.

So my arduino is properly detected in device manager and in the arduino IDE but cant upload sketches to it. The main chip (atmega328p) seems well (13-pin LED blinks 3 times on reset) but the usb chip (ATmega16u2) is what I suspect as the RX and TX LEDs don't blink while uploading (and don't blink in any other situation) but again the arduino is detected and I am sure I chose the right board and port.

The serial monitor is always empty and I tried the loopback test and didn't get any echo at all or even any error message but I think that what I should have expected as the RX and TX not blinking means that there is no data transmission in the first place. Or am I wrong?

So is the USB chip broken or maybe corrupt? How can I be sure? And if not then what could the problem be?

I saw a tutorial in the answer of this question to test the usb chip using another arduino but I don't have that in hand right now or an ICSP programmer for that matter.


texts: SSD1306 - Is there a way to scroll a certain number of pixels only?

texts:
For a hobby project, I am trying to make some sort of little game with an ATtiny85 and an SSD1306 OLED display, mostly to see how much I can do with the least hardware possible. Something like Captain Rectangle rescues the Circle Princess from the Evil Triangles.

I have been seeing what I can do with an SSD1306 (datasheet), specifically horizontal scrolling. It has a feature to scroll the display horizontally (left or right) at a certain rate, i.e. 1 pixel per given number of frames. This is achieved by issuing three commands:

The first command sets up the scroll.
The second command starts the scroll.
The third command stops the scroll.

While letting the display unit take care of scrolling all by itself sure takes a load off the minimalist MCU, what I really want is to just scroll 1 pixel right away (OK if it takes the display milliseconds to do this). Is there a reliable way to do that?

Some things I have tried:

Draw a column of pixels, setup and start the scroll, stop the scroll right away, delay 10ms, repeat.  The screen does not do much scrolling--I think it only scrolls every x number of attempts, depending on the timing of when the OLED wants to do scrolling vs. when I tell it to stop.
Stop scrolling, draw a column of pixels, setup and start the scroll, delay 10ms. In a preliminary demo, this appears to mostly work, but obviously I will have to read more about the timing of the scrolling to really know, and besides this is a fragile solution--if the OLED scrolls 1 too many or too few pixels, then the MCU program's understanding of what should be on the screen will not line up with that of the display.
I also looked at the "Set Column Address" command, which specifies column start address and end address of the display data RAM, but that has no effect on data already displayed--it does not move visibly on the screen, but only affects subsequent writes--where the address pointer points, and what columns it may point to.

BTW, I am using vertical memory address mode, i.e. I send data one column of pixels at a time, since that is what would have to be drawn when scrolling horizontally 1 pixel.

I see there are more options to try with vertical scrolling, though my screen size (128x64) is not conducive to that.

I could also try re-writing everything on the display every 10ms, but first, did I overlook anything in the datasheet?


texts: I'd like to build a little voice recorder for my grandmother. She told me "I get a lot of idea when I'm driving but then I forget them. I want a necklace where I can just press a button and it'll record my voice and I can press a button and it'll stop recording." She wants each recording to save as a separate file. I was thinking of concealing a mini Arduino board or Rasberry Pi or something in a necklace, with a removable micro sd card. Or something like that. I just don't know where to start, I don't have much experience with this. Does anyone have any tips on what kind of device I could use or where to start? I suggested that she just have Siri take notes for her on her iPhone but she wants something around her neck, and she wants me to make it.


texts:
I'm attempting to compile this simple bounce.ino example with the ino tool, but it's giving me the error:

Bounce2.h: No such file or directory

I've placed it in the same directory as bounce.ino. Why can't it find the header?

Edit: I'm using Ubuntu.


texts: (HELP)How to read Physical Dimensions in datasheets

texts:
Sir/ Ma'am,
.
How to read the dimension labels of this IC?


texts:
Recently Ran the USBHID_DESC program on my Arduino Uno with a USB hub attached to my joystick. I wanted to be able to program my joystick to integrate with my project. Circuits@Home developed the code and have 2 articles dealing with understanding the report. But they are very sparse with details and only have a single example to go off of. Many of the fields that I got returned are not described at all in the tutorial. Further more, attempting to dig through the official documentation from USB.org itself has been extremely overwhelming. I don't really know how to start. Can anyone help me interpret the data fields for this controller?

This is the data that I recieved from the serial monitor:

  Start
  0000: 05 01 09 04 A1 01 09 01 A1 00 09 30 09 31 09 32
  0010: 09 BB 15 80 25 7F 46 FF 00 66 00 00 66 00 00 75
  0020: 08 95 04 81 02 C0 09 39 15 01 25 08 35 00 46 3B
  0030: 01 65 14 75 04 95 01 81 02 05 09 19 01 29 04 15
  0040: 00 25 01 75 01 95 04 81 02 95 08 81 01 05 08 09
  0050: 43 15 00 26 FF 00 35 00 46 FF 00 75 08 95 04 91
  0060: 82 55 00 65 00 55 00 65 00 55 00 C0
  Usage Page Gen Desktop Ctrls(01)
  Usage Game Pad
  Collection Application
  Usage Pointer
  Collection Physical
  Usage X
  Usage Y
  Usage Z
  Usage Undef
  Logical Min(80)
  Logical Max(7F)
  Physical Max(FF00)
  Unit(0000)
  Unit(0000)
  Report Size(08)
  Report Count(04)
  Input(00000010)
  End Collection
  Usage Hat Switch
  Logical Min(01)
  Logical Max(08)
  Physical Min(00)
  Physical Max(3B01)
  Unit(14)
  Report Size(04)
  Report Count(01)
  Input(00000010)
  Usage Page Button(09)
  Usage Min(01)
  Usage Max(04)
  Logical Min(00)
  Logical Max(01)
  Report Size(01)
  Report Count(04)
  Input(00000010)
  Report Count(08)
  Input(00000001)
  Usage Page LEDs(08)
  Usage Slow Blk On Time
  Logical Min(00)
  Logical Max(FF00)
  Physical Min(00)
  Physical Max(FF00)
  Report Size(08)
  Report Count(04)
  Output(10000010)
  Unit Exp(00)
  Unit(00)
  Unit Exp(00)
  Unit(00)
  Unit Exp(00)
  End Collection Game Pad Pointer X Y Z Undef(00)(00)(7F)(00)
  Hat Switch(00)
  Btn0001
  (00) Btn0002
  (00) Btn0003
  (00) Btn0004
  (00)
  (00)(00)(00)(00)(00)(00)(00)(00)
  Slow Blk On Time


texts: how to get text box values from webserver of esp32 and print them in to serial monitor by using  library

texts:
Actually I'm trying to get the values from esp32 server webpage. Suppose there is a web page containing some text box fields, user has to enter some details in it and this details I want to be print on serial monitor.

And didn't get any solution regarding that. Though it is working with ESPAsyncWebServer.h library, that i found here -- > https://randomnerdtutorials.com/esp32-esp8266-input-data-html-form/

but I want to do this task with webserver.h library, for some reason I don't want to use ESPAsyncWebServer.h library.. Hope you all guys can understand what I'm trying to ask and say. Thank You.


texts: NRF24l01 with Atmega 32u4 and internal clock

texts: Will the nrf24l01 work with the Atmega 32u4 if I am using the 32u4's internal clock, or must I have an external clock source?


texts: Nano clone failure, how to prevent it from happening again?

texts:
I'd made an LED driver, and fed both the LEDs and nano clone from 12V. The 12V switched power supply is of dubious quality. The nano itself read a pot, and wrote PWM values on three pins. It has run on-off for 2-3 months. Not long. Now it's dead - my PC does register the serial device on the nano, and the power LED comes on. Apart from that, there's nothing that works.

Before I replace it, I'd like to know if the most likely culprit was my feeding 12V into VIN. Overheating voltage regulator? The LEDs got a bit hot, ~40°, and the nano was in a box with no airflow.


texts:
I am working with a TOS-100 Stepper Driver Shield and am attempting to use the pre-written TMC26XMotorTester/Motor/Serial set of files to make it work.

I unzipped the files, copied the TMC26XStepper folder into the library directory in my Arduino folder, and restarted the Arduino IDE (as well as the Arduino and Driver Shield boards).  I also switched the DIR and STEP pins (6 and 7 swapped to match the wiring on my board).

In the TMC26XMotorTester file, I wrote

    #include <TMC26XStepper.h>

so I'm assuming (given everything I've done), that the functions should be available given this file inclusion.

However, I get the error

    TMC26XMotorTester:44: error: 'TMC26XStepper' does not name a type

along with the complete list of functions from the TMC26XStepper.h/.cpp file that were not identified.

Any thoughts?  I'm using Arduino-Uno version 1.6.9.


texts:
I recently downloaded the expressif ESP32 library and I'm trying to run the CameraWebServer example. Attempting to compile it results in the following error:
Sketch uses 2529577 bytes (192%) of program storage space. Maximum is 1310720 bytes.
Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.

I can reduce this number (192%) to 120% by changing partition scheme from "Default" to "No OTA (Large APP)". Online I've seen people using a partition scheme called "Huge APP", which I believe would solve my problem, but I don't see that option in Tools. Only "Default", "Large App" and "Minimal SPIFFS" (which doesn't work either).
How can I get the "Huge APP" partition scheme option in Arduino IDE?


texts:
I am in between of project where i am getting string like "hello world" via Bluetooth to arduino I want to list this string into individual character so that I can call any of the character when required, this is not working i am getting only zeros in serial monitor
please suggest what i am doing wrong

char s;
int k[10];

void setup () {
  Serial.begin(9600);
}
void loop () {
  if (Serial.available() > 0) {
    s = Serial.read();
  }
  k[10] = s;
  for (int x = 0; x < 10; x++) {
    Serial.println(k[x]);
    delay(200);
  }
}


texts:
There is blink project consisting 3 sections:

1 - regulation of the led brightness using a potentiometer

2 - whenever: the button is pressed - the led is on

-   the button is released - the led is off

3 - change state of a led statically

The question is that:

May I make this project on-board?
I am curious that, if I will try making this project on-board (Arduino UNO) will the Arduino damaged?


texts: Arduino 33 Nano BLE Sense not compatible with pulseIn()?

texts:
Preface
Currently, I'm making an application on a Arduino 33 Nano BLE Sense. I'm trying to measure the current humidity and send it via BLE to another device. The target is to send a precise value with a high frequency, 8-10 values every second.
For measuring the humidity I connected an external sensor, the P14 Rapid Capacitive Humidity Sensor (it's faster and more accurate than the onboard humidity sensor) with a NE555 Timer IC in Monostable Mode.
To read the output pulse (frequency: ca. 500Hz) I'm using pulseIn().
I managed to calculate the humidity correctly and also the BLE data transfer worked.

Problem
My (minified) sketch:
#include <ArduinoBLE.h>

void setup() {
    // some setup, takes around 10s
}

void loop() {
    BLE.poll(); // polling for new events, takes ca. 10 µs

    value = pulseIn(6, HIGH); // read the high pulse, takes around 500-4000 µs

    // calculating the average value, takes < 1 µs

    if (/* this if is executed every 1 second for testing purposes, targeted is every 100ms*/) {
        // humidity is calculated, takes ca. 20 µs

        characteristic.writeValue(/* calculated value */); // takes ca. 50 µs
    }
}

When I merged the features, the problems began. I couldn't connect to the Arduino anymore.
When I try to connect to it (with nrf Connect App), this happens. When I manage to connect to it before it stops working, I will be disconnected with a GATT_CONN_TIMEOUT exception.

When the Arduino is powered on, the setup is called and it's connectable while the setup is running. When pulseIn() is called for the first time the BLE connection stops working. But the programm keeps on running.
I already tried calling pulseIn() only every 10s or only once, the BLE connection stops working.
And yes, commenting out the pulseIn() makes BLE work again.

Possible Solution
Next thing I would try is to delete the pulseIn() and use interrupts for measuring the time.
My question is if there is a better way to fix this issue?


texts: Blynk.Begin(auth, ssid, pass) causing watchdog reset

texts:
I am trying to follow this tutorial and I keep hitting a problem repeatedly. I checked in my code that every time it hits the line Blynk.begin(auth, ssid, pass);, the serial monitor shows me that there was a cause:4, boot mode:(3,6) wdt reset. I looked it up a little bit and learned that this is a "hardware watchdog reset" but I am not sure why this problem is happening. Please let me know if you guys would like anymore info. Thank you!

here is my code:

#include <ESP8266WiFi.h>

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxx";

/* WiFi credentials */
char ssid[] = "xxx";
char pass[] = "xxx";

/* HC-SR501 Motion Detector */
#define ledPin 7
#define pirPin 2 // Input for HC-S501
int pirValue; // Place to store read PIR Value

void setup()
{
  Serial.begin(115200);
  Serial.println("here 1");
  delay(10);
  Serial.println("here stop?");
  Blynk.begin(auth, ssid, pass);
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);
  Serial.println("here 2");
  digitalWrite(ledPin, LOW);
}

void loop()
{
  getPirValue();
  Blynk.run();
  delay(10);
  Serial.println("here 3");
}

/***************************************************
 * Get PIR data
 **************************************************/
void getPirValue(void)
{
  pirValue = digitalRead(pirPin);
  if (pirValue)
  Serial.println("here 4");
  {
    Serial.println("==> Motion detected");
    Blynk.notify("===> Motion detected");
    Serial.println("here 5");
    delay(10);
  }
  digitalWrite(ledPin, pirValue);
  Serial.println("here 6");
}

Serial Monitor:

[6485] Connected to WiFi
[6486] IP: xx.x.x.xx
[6486]
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP8266

[6492] Connecting to blynk-cloud.com:80
[6584] Ready (ping: 38ms).

 ets Jan  8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
here 1  (Serial.println in line 19 of code)
here stop? (Serial.println in line 21 of code)

Specs:

Board: Generic ESP8266 Module
Upload Speed: 115200
CPU Frequency: 80MHz
Flash Frequency: 40MHz
Flash Mode: DOUT (compatible)
Flash Size: 512K (no SPIFFS)
Crystal Frequency: 26MHz
Reset Method: ck
Debug Port: Disabled
Debug Level: None
IwIP Variant: v2 Lower Memory
VTables: Flash
Exceptions: Disabled
Builtin LED: 2
Erase Flash: Only Sketch
Espressif FW: nonos-sdk 2.2.1 (legacy)
SSL Support: All SSL ciphers (most compatible)


texts: Arduino NOOB - Stepper Motor + Rotary Encoder Control

texts:
I have a very basic Arduino setup :

Arduino Uno
Rotary encoder
Nema 17 stepper motor + A4988 driver

How can I control the rotation of the motor with the rotary encoder? How can I get it to make one full rotation (200 steps) if I make a full rotation of the encoder (20 pulses)?

UPDATE : I managed to get the driver + motor setup going using this diagram and the code on this page : https://howtomechatronics.com/tutorials/arduino/how-to-control-stepper-motor-with-a4988-driver-and-arduino/

Now all i need is to properly wire the rotary encoder and add the code for syncing the motor with the encoder.

Can someone help me out with a diagram and a piece of code ?


texts: CIPSEND to ESP8266 returning bytes but no content

texts:
I am trying to send a GET request from an Arduino Uno connected to an ESP8266 through SoftwareSerial. I can't get it working directly in the code so I've stripped it down to a script that passes serial monitor queries like so:

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial esp8266 (rxPin, txPin);

void setup()
{
  Serial.begin(115200);
  esp8266.begin(115200);
  delay(1000);
}

void loop()
{
  if (esp8266.available()) Serial.write(esp8266.read());
  if (Serial.available()) esp8266.write(Serial.read());
}

I setup and connect the ESP8266 to my router like so from the serial monitor:

AT+RST
AT+CWMODE=3
AT+CWJAP="rwifi name","wifi password"
AT+CIFSR
AT+CIPMUX=0
AT+CIPSTART="TCP","www.abcdefg.com",80
AT+CIPSEND=61
GET /in-progress/ab/i.php?c=20 HTTP/1.0 Host: www.abcdefg.com

Everything works fine up until the CIPSEND, the GET request part, and the serial monitor output the following:

AT+CIPSEND=61

OK
> i.php?c=20 HTTP/1.0

busy s...
Recv 61 bytes
SEND OK

I know there is a 64 byte limit for the serial monitor. my GET is 61 bytes. I'm getting bytes back but not the content from the page (it should be the word "yes") and not even a content from a 404 page. Web side my php page is a counter that adds 1 to a number in a txt file - it doesn't increment (it does work if I call it from the web browser).

Where I am going wrong here with my CIPSEND? It looks like it is correctly formed to me.

-----edit-----

Based on comments below this is the latest GET request I have tried:

AT+CIPSEND=73
GET /i.php HTTP/1.1\r\nHost: www.abcdefg.com\r\nConnection: close\r\n\r\n

I have shortened my pathway to the php file as much as possible, added the carriage returns and newlines between request and each header, added the double carriage return and newline at the end. The request now returns +IPD,919:HTTP/1.1 400 Bad Request. This error 400 is not logged on my website.


texts:
A couple weeks ago I got my Arduino Nano after having experienced the Uno i wanted another one. The problem was that it wasn't ***** working. I searched a lot of the internet, but couldn't find a thing so that's why I'm here writing this post and stuff. I'm working on a Mac and I noticed something in the usb section, as visible above, when i plug in my Nano I get not a notification saying my Arduino is plugged in, but my computer telling me the driver has noticed "something". But the port itself is not displaying in the Arduino environment, but my Uno is!! I'm kinda pissed cuz I sent back another Nano before this but i was pretty sure that one didn't have the bootloader installed so let's just assume that's not the problem cuz the l led is blinking too.

Has anyone got an idea what is causing this and how I can fix this?


texts:
I'm trying to create a battery & solarpowered ESP32 for future use with sensors.
It connects to Wifi, MQTT, publishes some readings and status messages and go back to sleep. From time to time (can happen after few sleep cycles and sometimes after few hunderds cycles )I get 2 unexplained behaviours : 1) fail to connect to MQTT at boot, 2) fail to sleep.
Sometimes those behaviours happen simultaneously.
Is there a known issue with deepsleep and MQTT (using PubSubClient ) ? Most deepsleep example I see online, all code is outside loop()section - is it mandatory to be like that ?
I don't share code, since it is more a general question.
Guy
EDIT1

most of callback was commented out, remaining only printing incoming message.

LED was attached to a GPIO, generating a blink on loop() - when sleep succeeds - it goes off, when it fails, it stays on. This test shows that when this "error" happens, code actually stop running, but does not enters deep sleep ( power-wise )


texts: Uno r3 - Can't get USB Keyboards to work with an USB Host Shield

texts:
I'm a day 1 beginner to Arduino, and I am trying to obtain input from a USB keyboard. I've connected the USB keyboard to an Arduino USB host shield attached to an Arduino Uno r3, and I am using the example HID sketch (USBHIDBootKeyboard.ino) provided with the USB Host Shield libraries : https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/HID/USBHIDBootKbd/USBHIDBootKbd.ino

I am powering the Arduino Uno r3 + USB Host Shield via USB. Upon init, only Start is written to the Serial Monitor. Tests show that SetReportParser exits with 0. Yet the keyboards are silent. I've tried three keyboards, all of which work properly when connected to the computer.

When using USBHidBootMouse.ino with a mouse, movements & buttons are perceived and print messages as intended.

https://www.circuitsathome.com/mcu/hid-support-for-usb-host-shield-library-2-0-released/ states that

  Also, it is recommended to use external power supply while working with HID devices – I’ve seen many devices which would refuse to function when Arduino receives power from its USB port only.

EDIT : I tried to test if the power was the issue, so I used a 5V generator with intensity measurement. The results are : the Arduino Uno r3 uses 60mA, the keyboard uses 60 mA, connecting to the serial port uses 40 mA (much to my surprise).

This means the keyboard's power requirements shouldn't be the problem.

Then what would the problem be ? I'm helpless here. If the library linked on the official Arduino site doesn't work, then it should mean i'm using it wrong.


texts:
Is a buffer used for outputting data from the arduino?

OR

Is the output from the arduino buffered before sending it to Computer?

Is it the same buffer that is used to store the incoming data and the data that we send back from the arduino?

Eg- If am sending a text through the Serial Monitor to the arduino and I am also doing Serial.println("sth") then are they both using the same buffer?

How can i relate Serial buffer with these processes

Please Help!

Arduino Noob

EDIT-1

Can you please explain about the TX buffer overflow


texts: Arduino Nano ESP8266 software serial problems

texts:
I have a problem with my Arduino Nano ATmega328 and my ESP8266 01 module. I have connected the ESP8266 on my Arduino board without FTDI.

I have made the following connection:

I an using a 5V Arduino Nano which of course is 5V. The ESP8266 is a 3.3V device and so I am using a voltage divider to bring the Arduino's 5V down to 3.3V. If you are using a 3.3V Arduino then you do not need the voltage divider.

The wiring is very similar to the FTDI.
Arduino pin 3 to voltage divider and then to ESP8266 RX
Arduino pin 2 to ESP8266 TX
Arduino GND to ESP8266 GND
Pull CH_PD HIGH with a 10K resistor to +3.3V
+3.3V to Vcc

You only need the voltage divider on the Arduino TX pin. The 5V Arduino will read 3.3V as HIGH so you can connect the ESP8266 TX pin directly to the Arduino RX pin.

The problem I had and I can't handle is that when I start up the Arduino Tx and Rx LEDs work continuously so I can't have access to my serial monitor of the Arduino IDE. So with that problem I can't send or receive any command to/from the IDE. Also when I try to upload my program to the Arduino board, I have to disconnect the ESP. If I don't I can't upload it.

Any ideas guys? I would be grateful

I also try to implement code with AltSoftSerial but I have library issues - my laptop does not recognize it (I downloaded it and I put it in the same folder with my code).

  #include <SoftwareSerial.h>

    SoftwareSerial ESPserial(2, 3); // RX | TX
    void setup()
    {    Serial.begin(9600);     // communication with the host         computer

     // Start the software serial for communication with the ESP8266
     ESPserial.begin(9600);

     Serial.println("");
     Serial.println("Remember to to set Both NL & CR in the serial monitor.");
     Serial.println("Ready");
     Serial.println("");}

     void loop()
      {
      // listen for communication from the ESP8266 and then write it to the serial monitor
       if ( ESPserial.available() )   {  Serial.write( ESPserial.read();}  / / listen for user input and send it to the ESP8266
      if ( Serial.available() )       {  ESPserial.write( Serial.read()  );  }}


texts: I am entering a robot contest, and my bot requires 3 motors and 1 servo. I know I can control the motors with 2 L298N boards, and have an extra spot for a motor with the second board. I was wondering if it is possible, and so, if practical, to use this extra spot for the servo.


texts: fatal error ESP8266WiFi.h: No such file or directory

texts:
I want to turn my ESP8266 into an access point so that I can connect directly to it.
I use the following sketch, but when I select
GENERIC module ESP8266 from menu, the libraries ESP8266WiFi.h and ESP8266WebServer.h become available but I was unable to upload the sketch.
Also when I select board as Arduino Uno (Which i have really) and then what to upload then the above two files becomes unavailable and says fatal error no such file... no idea what to do next.
#include <ESP8266wifi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include<WiFi.h>
#include<SoftwareSerial.h>
SoftwareSerial esp(2,3);
IPAddress local_IP(192,168,4,22);
IPAddress gateway(192,168,4,9);
IPAddress subnet(255,255,255,0);
 String ssid="Wisal";
 String pass="12345678";
 ESP8266WebServer server(80);
 boolean isAccessPointCreated=false;
void setup(){
  esp.begin(115200);
  Serial.begin(115200);

  WiFi.mode(WIFI_AP);
  Serial.print("Setting soft-AP configuration ... ");
  Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");

  Serial.print("Setting soft-AP ... ");
  Serial.println(WiFi.softAP("ESPsoftAP_01") ? "Ready" : "Failed!");
  Serial.print("Soft-AP IP address = ");
  Serial.println(WiFi.softAPIP());

}

void loop(){
  while(esp.available()>0){
    char a = esp.read();
      if(a == '\0')
        continue;
      if(a != '\r' && a != '\n' && (a < 32))
        continue;
      Serial.print(a);
   }
}


texts: Can an Arduino Pro Mini interface with a full-sized WiFi shield?

texts:
We have an Arduino Pro Mini on a breadboard connected to a 9V battery and a sensor, reading data. We also have a full-sized Adafruit WINC1500 WiFi Shield with PCB Antenna. I would like to know if they can be connected and, if so, how.

I understand that a shield is usually stacked on a similarly sized board, but can we place the shield on the breadboard with the Mini and use jumper wire to connect the necessary pins so the Mini can use the WiFi (actually, we want to write to the SD card on the WiFi shield)? If so, how would we know which pins are used, and would we need to provide additional power? Or is connecting a Mini to a full-sized shield a ridiculous idea?


texts: How many stepper motors can a motor shield control?

texts:
I have an application that calls for controlling two stepper motors. One motor does a constant speed scan, while the other would kick in at certain scanning positions of the first motor.

Can this be done with only one motor shield? The motors are relatively large, running on 12V.
Thank you!


texts: Does setting a value always mean setting a Arduino pin?

texts:
One thing that always confused me was why we use int or other commands to set the variables to have pin numbers as if those commands were always restricted to pin numbers only. For example
int ledPin = 13;

Does putting a random number in place of 13 that isn't a pin number cause an error? Right now I haven't checked yet.
I've only begun to realize that if you want to use variables in relation to pins or push buttons you have to set values first and then do associated functions like digitalRead. The commands like int are not like in other programming languages where you can set any values and do mathematical computations. I know it might seem obvious to someone who is used to Arduino, but this perspective is something that helped me grasp things better. Before that, I totally could not understand how things worked because of being confused with how int or other similar variables worked.


texts: Can an Arduino power itself off [not low power mode] via software?

texts:
I'm working on a sketch where an Arduino UNO performs no useful work after the first 10 minutes following power on.  It is not needed again until power to it is shut down, then re-enabled.  This may not happen for hours or even days.  No wake-up function is required, or deemed useful.

Of course, the Arduino could simply be left on as long as it's connected to its power source, but it will be placed remotely, and it seems [to me] safer to have it powered off. when not in use.

In essence, the Arduino is powered by a wall wart and plugged in with other devices fed by a switchable 120v power source.

I found a couple of possible hardware/software solutions to the problem but it isn't clear whether they would work in this situation.  Power consumption is not the issue here.


texts: verification error, first mismatch at byte 0x3895 0xdf != 0x44?

texts:
I bought a SainSmart Arduino Mega 2560. I uploaded a small sketch to it, and it uploaded fine. When I upload a larger sketch though, I get this error:

verification error, first mismatch at byte 0x3895
         0xdf != 0x44

So obviously there's nothing wrong with my bootloader because I can upload smaller files. Why is this happening?


texts: I need an example of how to send AT COMMANDS to SIm7000E GPS+LTE module from ESP32 and reading those response in Serial monitor

texts:
Actually I need to make HTTPS post request using SIM7000 and ESP32 but the available libraries don't have a function for HTTPS post request, I wanna make this request using AT Commands. I need a example code to send AT Commands to sim7000e using esp32 hardware serial or software serial whichever is the best.
I am using the botlectics library but it has function only for HTTP GET/POST not HTTPS. I am looking for HTTPS request using Sim7000. As there is no function for HTTPS in botletics I thought of sending AT Commands using hardware serial from esp32 to SIM7000 . For example,
HardwareSerial mySerial(1) ,
mySerial.begin(9600,Serial_8N1,13,12)
And I have connected SIM7000 TX RX with esp32 GPIO 13,12.
then I send AT commands like
mySerial.print("AT+HTTPINIT\r");
And I connect FTDI to UOR AND UOT of esp32 which makes Serial.... So no anything done with Serial is with esp32 and writing to mySerial means Sim7000.
I have done this before but with arduino and GSM module through Software Serial and it worked fine.
I think I am missing something in case of ESP32 and Sim7000. In which I need help.


texts: My GY-MAX30100 pulse oximeter issue with Arduino Uno

texts:
I connected the purple oximeter (GY-MAX30100) to the Arduino Uno with the following connections.

OXIMETER       ARDUINO UNO
VIN              5V
GND              GND
SCL              SCL
SDA              SDA
INT              D2

It shows me inaccurate measurements.

13:16:02.851 -> Pulse oxymeter test!
13:16:02.851 -> BEAT
13:16:02.851 -> BPM: 8616.35 | SaO2: 92.01%
13:16:03.055 -> BEAT
13:16:03.055 -> BPM: 4313.73 | SaO2: 92.66%
13:16:03.089 -> BEAT
13:16:03.089 -> BPM: 1209.15 | SaO2: 92.74%

I used this sketch from github
https://github.com/xcoder123/MAX30100/blob/master/max30100.ino

This is the sensor

EDIT

I have run an I2C scanner and this is the result: I2C device found on address 0x57. The library has the same address hard coded in it.


texts: External access to Yun - request not recognised as HTML

texts:
I am trying to access my Yun externally.

My router recognises traffic on Port XXXXX and forwards it to my Arduino Yun.

I have the below code working internally and now trying to adapt this to work for external (adapted from http://arduino.cc/en/Tutorial/TemperatureWebPanel).

To access the Arduino Yun over the network I type:

http://XXX.XXX.XXX.XXX:XXXXX/arduino/on

When using this script locally, i.e. myArduinoName.local/arduino/on, the onboard light turns on (and off if URL changed accordingly).

Adapting this working code, I have changed to "noListenOnLocalhost" and put in my port number (XXXXX).

The code is reached (see below for the response).

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

// Listen on default port 5555, the webserver on the Yun
// will forward there all the HTTP requests for us.
YunServer server(XXXXX);
String startString;
long hits = 0;

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

  // Bridge startup
  pinMode(13,OUTPUT);
  digitalWrite(13, LOW);
  digitalWrite(13, HIGH);

  Bridge.begin();
  Console.begin();

  // Listen for incoming connection only from localhost
  // (no one from the external network could connect)
  //server.listenOnLocalhost();
  server.noListenOnLocalhost();
  server.begin();

}

void loop() {
  // Get clients coming from server
  YunClient client = server.accept();

  client.println("hello");

  // There is a new client?
  if (client) {
    // read the command
    String command = client.readString();

    command.trim();        //kill whitespace

    client.println(command); // why does this return a full GET request instead of "on"?

    if (command == "on") {
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);
    }

    if (command == "off") {
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);              // wait for a second
    }

    // Close connection and free resources.
    client.stop();
    hits++;
  }

  delay(50); // Poll every 50ms
}

The response I get is (I have replaced my IP and port with X's):

  hello

  GET /arduino/off HTTP/1.1 Host: XXX.XXX.XXX.XXX:XXXXX
  Connection: keep-alive Pragma: no-cache Cache-Control: no-cache
  Accept:
  text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36
  (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
  Accept-Encoding: gzip, deflate, sdch Accept-Language:
  en-GB,en-US;q=0.8,en;q=0.6

I expected

  hello

  on

So it would seem that because I'm using a different port (other than 80 or 5555) the response is no longer being interpreted as an HTTP request.

I have also tried to edit the uhttpd file via SSH to provide a specific address and port for both my external IP address and my fixed internal IP address.

Then tried to restart the device and also a uhttpd restart i.e.:

/etc/init.d/uhttpd restart

I have attempted to access the URL using my mobile phone (i.e. not on the same network).

Any ideas why my request is not being treated as HTTP?


texts:
I have a question regarding the ARDuino uno and some shields. I currently have a shield on my Uno, which takes the pins 0 to 7. However, on top of that board there is an extension of those 8 pins. If they were always in use, I suppose that the extra ports wouldn't be on top of the board, right?

Here's how it looks:

So it seems like you're able to "share" them. Is it possible to do so in real-time or is that there so you can use the ports when you disable the shield?

If its possible in real-time, how would I go about doing that? I've searched a little but couldn't find anything. I suppose i'd need some kind of clock to make the switch between the shield and the other components on pins 0-7, but not sure how to do that.

I'm kind of an electrics newbie, so hence the question might be a little silly :)


texts: Why do we need a transistor with a dc motor while we don't need one with a servo motor?

texts: I was wondering why do we need to attach a transistor as we don't need one while we connect the Arduino with the servo motors. I am using mini servos.


texts: How to work with WS2812B 16x16 matrix panel from aliexpress

texts:
I'm completely new to Arduino, and I want to build the project using an LED 16x16 matrix, but I don't know where to start. On the internet, I keep finding these custom matrix panels and they aren't similar to mine. So I'm asking here. Does anyone have experience with this Arduino-compatible RGB LED matrix panel? This is the link to the Aliexpress product.

Will I need an additional power supply? What will I need to install to make it work? Where do i plug what wire into my arduino? Thanks for any answer!


texts: Can i create a function inside of void setup()?

texts:
Can i create a function inside of void setup()
to recall in loop() function


texts:
How do I enable debugging using Adafruit CC3000?

I am using the Adafruit_CC3000_Library.  I've followed the WebClient.ino example sketch.  I'm able to make 300 to 400 HTTP requests, but eventually the connection will hang.

I have looked at the CC3000 source and utilities and found that the Adafruit_CC3000_Library has a &Printer reference in a local variable called CC3KPrinter.  I can't figure out how to enable or activate CC3KPrinter, as it is in a code block contingent on CHECK_PRINTER.  I thought that #define-ing some variables in my sketch would help:

// None of these flags seem to enable debug within the CC3000 code.
#define _CC3000_DEBUG  1
#define DEBUG_MODE     1
#define ENABLE_CC3K_PRINTER 1

An example code snippet within the CC3000 library that I'm trying to enable is at line 916:

  CHECK_PRINTER {
    CC3KPrinter->println(F("Timed out waiting to connect"));
  }


texts: Trouble making TMP102 work with any ADD0 other than ground

texts:
I'm trying to get an Arduino Uno to run four sensors (all I2C). The first two are TMP102 temperature sensors. The address is controlled by tying the ADD0 pin to GND, VCC, SDA, or SCL (four possible addresses, without multiplexing). I get it to receive data just fine through the GND setting.

I wrote some code to collect from two, but before I was even talking to the second one, plugging it in causes the data stream from the GND one to stop. Unplugging it from the breadboard makes it work again. Either sensor in either location on the breadboard will work fine, as long as it's addressed as ground. Neither sensor will, even by itself, work with any other address. I tried some other sketches from the net (one attached below that should read from any of four different sensors), but all have the same issue.

#include <Wire.h>
byte res;
byte msb;
byte lsb;
int val;

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

void loop()
{
  res = Wire.requestFrom(72,2);
  if (res == 2) {
    msb = Wire.read(); /* Whole degrees */
    lsb = Wire.read(); /* Fractional degrees */
    val = ((msb) << 4);   /* MSB */
    val |= (lsb >> 4);    /* LSB */
    Serial.print( "72:");
    Serial.println(val*0.0625);
    delay(1000);
  }
  res = Wire.requestFrom(73,2);
  if (res == 2) {
    msb = Wire.read(); /* Whole degrees */
    lsb = Wire.read(); /* Fractional degrees */
    val = ((msb) << 4);   /* MSB */
    val |= (lsb >> 4);    /* LSB */
    Serial.print( "73:");
    Serial.println(val*0.0625);
    delay(1000);
  }
  res = Wire.requestFrom(74,2);
  if (res == 2) {
    msb = Wire.read(); /* Whole degrees */
    lsb = Wire.read(); /* Fractional degrees */
    val = ((msb) << 4);   /* MSB */
    val |= (lsb >> 4);    /* LSB */
    Serial.print( "74:");
    Serial.println(val*0.0625);
    delay(1000);
  }
  res = Wire.requestFrom(75,2);
  if (res == 2) {
    msb = Wire.read(); /* Whole degrees */
    lsb = Wire.read(); /* Fractional degrees */
    val = ((msb) << 4);   /* MSB */
    val |= (lsb >> 4);    /* LSB */
    Serial.print( "75:");
    Serial.println(val*0.0625);
    delay(1000);
  }
}

Breadboard:
(image link: the forum kept crashing when I tried to upload the image directly)
https://www.sugarsync.com/pf/D333436_95042359_6938296

Thanks!


texts: Triggering Sound - Arduino + Contact Mic

texts:
I previously created a sound installation using contact mics and computer (ableton+max msp) where sound would be triggered when people touched/tapped on the object/surface. Now I want to do something similar but want to get rid of the computer as it will be at a night club space where people will be walking around so I don't want to leave the computer there.
What I exactly want to do is to be able to load some sounds into arduino and again use contact mic on the object and when people touch it, the sound will be triggered. I know it won't be as creative as doing it with ableton where there is live-editing possibility but I'm happy with one type of sound in this one. I can probably find some codes here and there but I'm not sure what I exactly need to use to be able to do this.
I have few uno boards and lots of other bits that I've collected but haven't used before, so I would be very happy if you could help me as a novice.

Thank you


texts: How do I code the release of a momentary touch sensor in IDE?

texts:
I am a performing musician and quite new to the Arduino community.  Just learning as I go.  I am interested in using a momentary touch sensor with Adafruit's MP3 shield or Wave Shield.  I have successfully connected a touch sensor to the MusicMaker MP3 shield (which is sitting on the Adafruit Metro).  I combined some code from two independently working code sequences: one, to play MP3s and, two, to trigger with the sensor.  This works successfully except that the music starts but does not stop when I lift my finger off the sensor.  I want the music to stop when the touch sensor is not being touched.  When the sensor is touched again, I want the music file to start again from the beginning.  I'm printing the code IDE is running below and attaching an image of the touch sensor I am using.  I appreciate any advice on the code!  Thank you.

/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

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

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// define the pins used
//#define CLK 13       // SPI Clock, shared with SD card
//#define MISO 12      // Input data, from VS1053/SD card
//#define MOSI 11      // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins.
// See http://arduino.cc/en/Reference/SPI "Connections"

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer =
  // create breakout-example object!
  //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  // create shield-example object!
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }
  Serial.println(F("VS1053 found"));

   if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }

  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  if(sensorValue > 100) {
    Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("/track001.mp3");
  }
 else(sensorValue < 100); {
    Serial.println(F("Paused"));
  musicPlayer.pausePlaying("/track001.mp3");
 }      }


texts: I'm designing a lightweight circuit, but the ATtiny85 micro-controller I'm using to power it doesn't have nearly enough flash memory to store the code for the devices I'll have hooked up to it (It has 8kb of flash). I was wondering if it'd be possible to have the ATtiny use compiled code from an external flash memory chip of larger capacity elsewhere on the board like its own internal memory. Thanks in advance.


texts: Using SD shield for extra external memory?

texts:
I am an Arduino beginner and I am planning to make a musical instrument with it. I want to add record and playback functionalities into the instrument.

I figure I will have to store lots of data to meet this feature, but the Arduino I'm using (Uno/Nano) probably won't have enough memory to hold lots of songs.

My question is, is using an SD card with an SD shield a good way to expand memory? If not, what should I use to do so?

Thanks


texts:
I want my C# application to automatically select the correct COM port by way of a string equality check against a 'GetInfo'-type request to the Arduino board.

I know the Arduino IDE can get info from the board;

Tools > GetBoardInfo

But I don't know how to get it using a sketch or if it is even possible for that matter.

Is this something that can be read from the board, or is it a USB-thing. If it's a USB thing, I'd have to get the info from GetUSBDevices.DeviceID or whatever, then get the serial port used by the USB Device, which would probably work, but I'd rather do it all via a serialPort.


texts: Where is a simple program that demonstrates unidirectional data transmission over a pair of nRF24L01+ radios?  It should have adequate output so that a beginner can determine that the transmission is working properly.


texts: Arduino ESP8266 - wifi evt: 3 and wifi evt: 7 meaning?

texts:
I'm getting these in my serial port, but what does wifi evt 3 and 7 mean?
I am trying to complete this tutorial. https://youtu.be/4Z0gBG8dkqw

The PHP file is on my hosting, and the ESP reads out the temperature and humidity from the sensor so that's fine.

The serial code:

Connecting
wifi evt: 3
Connected
Temperature:
24.10
Humidity:
39.70
[hostByName] request IP for: lucasdebelder.be
[hostByName] Host: lucasdebelder.be IP: 185.182.57.81
connected
HTTP/1.1 200 OK
Date: Fri, 11 May 2018 13:14:17 GMT
Server: Apache/2
Upgrade: h2,h2c
Connection: Upgrade, close
Vary: User-Agent
Content-Length: 0
Content-Type: text/html; charset=UTF-8

�
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7

The code that I am running in Arduino.

#include <ESP8266WiFi.h>
#include "DHT.h"

const char* ssid     = "bbox2";      // SSID of local network
const char* password = "azerty";   // Password on network

WiFiClient client;
char servername[]="lucasdebelder.be";  // remote server we will connect to
String result;

float temperature;
float humidity;

#define DHTPIN 14

#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  dht.begin();
  delay(2000);
  Serial.begin(115200);
  Serial.println("Connecting");
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
  }
  Serial.println("Connected");
  delay(1000);
  readSensor();
  String temperatureString = String(temperature,1);
  String humidityString = String(humidity,1);
  sendDataToServer(temperatureString,humidityString);
}

void loop() {

}

void sendDataToServer(String temperature, String humidity)
{
  if (client.connect(servername, 80)) {  //starts client connection, checks for connection
    Serial.println("connected");
    client.println("GET /send_email.php?temperature="+temperature+"&humidity="+humidity+" HTTP/1.1"); //Send data
    client.println("Host: lucasdebelder.be");
    client.println("Connection: close");  //close 1.1 persistent connection
    client.println(); //end of get request
  }
  else {
    Serial.println("connection failed"); //error message if no client connect
    Serial.println();
  }

 while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) { //connected or data available
    char c = client.read(); //gets byte from ethernet buffer
      result = result+c;
    }

  client.stop(); //stop client
  Serial.println(result);

}

void readSensor()
{

  humidity = dht.readHumidity();
  temperature = dht.readTemperature();
  Serial.println("Temperature:");
  Serial.println(temperature);
  Serial.println("Humidity:");
  Serial.println(humidity);

}


texts: nRF24L01 with antenna transmitter and receiver

texts: I am trying to use nRF24L01 with antenna  in my project, but when I do test with getting start from rf24 master is showing a serial monitor like in the picture abov e. What is the problem here?


texts: Using an esp8266, how can I create a circuit to measure 2 different analog inputs (not simultaneously) with only one ADC pin available (A0)

texts:
I'm currently using a circuit with 2 separate transistors that can be switched on or off to measure 2 separate voltage inputs.

The reason for this is because I'm using an esp8266 which has only one ADC input at pin A0 and I need to measure light intensity from an LDR as well as voltage from a solar panel.

The LDR is wired with a voltage divider. The voltage input from the solar panel is 0 - 5v, so I have that wired with a voltage divider to output a max of 3.3v (pin A0 is 0 - 3.3v). The problem is that in complete darkness, the ADC is still reading the LDR with a value of around 260 (should be close to zero) and with bright light reading around 850 (should be close to 1023). Also, the voltage measured from the solar panel (divided to 3.3v) is returning anywhere from 600 (0v) to around 840 (3.3v).

I've tried these input measurements separately with expected results. It's having the option to switch inputs is what is tripping me up.

So, is my approach correct or is there another way to do this?

Note: I would have included a circuit diagram if I knew anything about circuits and making diagrams.


texts:
I noticed timing inconsistencies in my project, and further debugging pinpointed it to the problem below. The text should be updating every second, but the returned values are >> 1000ms.

To clarify, the text is not showing up every second.  The delays between texts vary according to fluctuating start and finish values.

I'm using a Teensy 3.2. Changing the baud rate doesn't help.

Is my timing crystal busted? Is there a serial buffering issue? I don't know how to fix either of these.

Any help would be appreciated!

Edit:

Here's the code if anyone wants to test.  I found that adding more delay functions screws the output up in completely unlinear ways.

unsigned long start, finished, elapsed;

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

void loop() {
  Serial.println("Start...");
  start = millis();
  Serial.println(start);
  delay(1000);
  finished = millis();
  Serial.println(finished);
  Serial.println("Finished");
  elapsed = finished - start;
  Serial.print(elapsed);
  Serial.println(" milliseconds elapsed");
  Serial.println();
}

Edit #2:

I thought it was worth showing everyone this screenshot.  It looks like delay(1000) just isn't functioning at all.

Edit #3:

I debugged it with an LED and it blinked at exactly 1s intervals.  It seems like delay(1000) works, so the problem must be related to the serial buffering.  I also updated my software but that didn't help.

Edit #4:

New developments from further debugging:

The problem is not reproducible on a different computer.  The Arduino serial monitor on other computers displays correctly.
Updating to the latest OSX, arduino IDE, and teensyduino did not help.
Terminal 'screen' command surprisingly prints correct serial communication.
Serial monitors from 3rd party apps, like CoolTerm and Arduino IDE do not work.


texts:
As far as I understand, yield() is used when you have long code (e.g. loop) so the background processing required by the esp8266 is not suspended for long time.

I have application where some sound should be running all the time and in the same time the program has to do other things which may includes long loops (that I call yield() inside them). Those long loops cause the sound to be discontinues.

What is the best idiomatic way of imitating the yield() function in my program so I do some thing like this:

for(int i=0;i<10000;++i){
    yield();
    customeYield();
    someFunction(i);
}

Where customeYield() contains the necessary instruction for playing the sound. It is exactly like this (I am using ESP8266Audio):

if (mp3_->isRunning()) {
    if (!mp3_->loop()) {
        mp3_->stop();
        return true;
    }
    return false;
}
return true;

Of course, I can just call it like I did (making it global or something). However, I was wondering if there is a standard way for such a task.


texts: Help with parts identification from arduino starter kit from aliexpress

texts:
Ordered an arduino starter kit from aliexpress Link

The parts list they provide (as a jpg on the order page) is vague and not very descriptive, I've gone through most of the parts and am down to three they did not list.

Capacitor? -- Looks to be a capacitor, labeled HDX and nothing else, rattles when I shake it.

Black LED -- I think this is a flame sensor; if it is, what's the difference between this and an infrared receiver (like a 1838B) or photoresistor?

They also list something as 'a digital control' near the bottom of the list, not sure what that is? Every other part from the list is matched up and I don't see anything different in the first picture (not parts list picture) from what I have received in the order.


texts: Can I have Arduino to read and write data using SDcard?

texts:
I'm doing a project and I have a simple doubt. I want a code so that whenever a admin rfid card is read it takes the next rfid card and stores it to a database like excell sheet or any other way of storing data on the sd card. And whenever a normal card is shown it checks the database or excell sheet or anything else to see if the the rfid code exists if it does open the door something like that .
I want to do all the reading and writing using a sd card and storing rfid is limited to one or two ways give all the possible methods you can think of and connecting to internet and using any internet based database is also an option but I do not know how to create a web based database and write or read data from it


texts:
I'm using a dual h bridge to control two dc motors on an inverted pendulum (cart-pole system).  At the moment, I have to send two different pulse width modulated signals to the two enable pins to control the two motor speeds and four digital write commands to control the directions.

Ideally, I want to switch the two motors simultaneously in the same direction and with the same speed.  So, I'd like to be able to control both motors' speeds with only one pulse width modulation signal and control both motor directions with only two digital write commands.

Is there a way I can do with with Arduino?  Can one PWM signal from a single arduino pin be sent to two enable pins at the same time? Can the same be done for a single digital output pin?  If so, how can I accomplish this?


texts: Understanding SAM3x8e boot program. Misunderstanding the datasheet

texts:
I'm trying to make my own firmware uploader for the Arduino DUE by using an ESP32.

While reading through the datasheet I saw that once there's data transmitted over the UART port, the sam3x8e will go into the SAM-BA monitor mode. The flowchart that the datasheet provides is as follow:

How does this make sense, since you can obviously communciate with the DUE over UART?
Do you have to avoid certain hex combinations, or does it get out of this loop automatically?


texts: Need help to send serial data from arduino to XBee and to another XBee wirelessly?

texts:
I try to send serial data RPM to XBee series1 and then from XBee to another XBee wirelessly in API with Escapes Mode. I think I have to send the data Frame.But not very sure.
Any help?

Following is the code to read RPM and send to XBee?

#include <XBee.h>
#include <SoftwareSerial.h>
/* Serial communication with Xbee.
On Arduino pin 9 is Rx connect to Xbee Tx,
pin 8 is Txconnect to Xbee Rx*/
SoftwareSerial xbeeSerial(9, 8); // RX, TX

XBee xbee = XBee();

int pin = 7;  //7
float rpm;
float duration;
float y;

unsigned long val,time;
float rps;
float read_rpm;

uint8_t start_data[] = { 0x7E, 0x00, 0x50, 0x01, 0x01, 0xff, 0xff,0x00, 0x05, 0x00,0x01,0x03, 0x84, 0x00 };

void setup()
{
  Serial.begin(9600);
  pinMode(pin, INPUT);
  Serial.println("I am ready to send some RPM!");
  xbeeSerial.begin(9600);
  time = millis();
}

void loop()
{

void loop()// run over and over
{
 val =  pulseIn(pin, LOW,70000000);

 duration=(float)val/1000000.00;
 rps= 1.00/duration;
rpm=60.00*rps;

/* Sending float to Xbee
Float is 4 byte size*/
serialFloatPrint(rpm);

int floatToInt = (int)rpm;

/* To send INT to XBEE
Int is 2 byte size*/
xbeeSerial.write(highByte(floatToInt));
xbeeSerial.write(lowByte(floatToInt));

  Serial.write(0x03);

  delay(2000);
}

void serialFloatPrint(float f) {
  byte * b = (byte *) &f;

  //xbeeSerial.print("f:");
  xbeeSerial.print(b[0]);
  xbeeSerial.print(b[1]);
  xbeeSerial.print(b[2]);
  xbeeSerial.print(b[3]);
  /* DEBUG */
  Serial.println();
  Serial.print(b[0],BIN);
  Serial.print(b[1], BIN);
  Serial.print(b[2], BIN);
  Serial.println(b[3], BIN);
  //*/
}
}


texts:
I'm designing a shield for the Arduino Uno with some sensors that require +5V, +3V3 and +3V Vdd. I want to power everything with a single DC adapter so I have a voltage regulator that converts the DC input (+12 - +26V DC) to 5V DC with a maximum current of 1A. That output goes into the 5V sensors, 3V3 and 3V regulators.

Since this is already regulated power can I connect the 5V 1A output to the +5V pin on the Arduino, bypassing the voltage regulator on the Arduino? Or is it better to have another +10V voltage regulator parallel to the 5V regulator that goes into the 9-12V Vin on the Arduino (that than goes to the 5V voltage regulator on the Arduino)?

If I do the first option, is it then save to have the USB connector plugged in?


texts:
Here are three use cases. Are all preferred or is the use of the F() macro pointless on some?

1.

Serial.println(F("some string"); // definitely useful here

2.

String str = F("some string");
Serial.println(str);

3.

int num = 5;
String str = F("some string with int ");
str += (String)num;
Serial.println(str);


texts: Can I apply a Kalman filter to DHT11 data?

texts:
I want to apply a Kalman Filter to the humidity data which I retrieve of the DHT11.

How can I do that?


texts: Getting current epoch time in seconds and milliseconds

texts:
Using Arduino Yun.

My code:

time_t today;
time_t now;
...
void setup() {
  time(now);
...
  Serial.println( asctime(gmtime(&now)));

What I get is:

  Sat Jan 01 00:00:00 2000

I am expecting something like this:

  1507572195.825

How do I get the number of seconds and milliseconds since the Linux Epoch?


texts:
I'm learning how to use the millis() function. Instead of having it in the main body of the program I wanted to place it in a function so I can change the time interval with which an led will flash. I modified the code blinkWithoutDelay. My code is below. The output I get is an LED that is always on. I did print the output of the ledState to the serial monitor. Its changing from on to off repeatedly. So I think the led is really flickering too fast to see. I took a screenshot from the serial monitor. The output is below.

const int LED2 = 2;
int ledState2 = LOW;

void timeCheck(int interval)
{
    unsigned long cMillis = millis();
    unsigned long pMillis;

    if (cMillis - pMillis > interval)
    {
        pMillis = cMillis;

        if (ledState2 == LOW)
        {
            ledState2 = HIGH;
        }
        else
        {
            ledState2 = LOW;
        }
        digitalWrite(LED2, ledState2);
        Serial.println(ledState2);
    }
}

void setup()
{
    Serial.begin(9600);
    pinMode(LED2, OUTPUT);
}

void loop()
{
    unsigned long flashtime = 1000;
    timeCheck(flashtime);
}


texts: Generally an Android phone has all the basic sensors like accelerometer, light, proximity, magneto, gyro, sometimes pressure etc. So is there a way to use Android's built-in sensors with an Arduino board (Uno) instead of buying the different sensor shields.


texts:
I am creating my own library for the Arduino and I have the following code:

#include <Arduino.h>
#include <Servo.h>

class ServoMotorController {
    public:
        ServoMotorController(int servoPin, int motorPin, int angle);
        void setAngle(int angle);
        void setSpeed(int speed);
    private:
        Servo servo;

        int servoPin;
        int servoAngle;
        int motorPin;
        int motorSpeed;
};

I am getting the error that Servo does not name a type; however if I do

#include <Servo.h>
#include <ServoMotorController.h>

in my actual Arduino code then I do not get the error. Why is the include statement not working in my C++ lib?


texts:
I run an Arduino Pro Mini on ATMega328 3.3V 8MHz, and I am unable to send data over HC-05 breakout board on this frequency, and on 5V 16Mhz, it has no issues.

The Arduino code is down below:

#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial BT(10, 11);
byte value;
unsigned long pmillis_bt = 0;

void setup() {
  Serial.begin(19200);
  BT.begin(9600);
}
///////////////////main///////////////////

void loop () {
  if (millis() - pmillis_bt >= 100) {
    byte Data[3];
    byte cmmd[20];
    int insize;
    char str[256];
    int i = analogRead(A0);
    value = BT.read();
    Data[0] = 'a';
    Data[1] = i / 256;
    Data[2] = i % 256;
    sprintf(str, "%d", i, Data[0], Data[1], Data[2]);
    Serial.println(str);
    if (value == 49) {
      for (int j = 0; j < 3; j++)
        BT.write(Data[j]);
      value = 0;
    }
    pmillis_bt = millis();
  }
}


texts: How does electricity flow in an arduino?

texts: :) I know this is probably a really stupid question but I need help. I’m new to arduino and can’t figure out how to arrange my circuits. I have no idea what ground does, where the energy comes from, or how the ground rails work. Any simple explanation would be very appreciated just so I can arrange my own circuits that I make up myself. Thanks!


texts: Use MQ2 Sensor with Arduino Uno without breadboard?

texts:
I want to make a small and compact gas sensor using the Arduino Uno and MQ2 sensor. However all sites list a breadboard as a requirement.

Now, the MQ2 has A0, D0, GND, VCC, pins and the Uno also has A0, GND, 3.3V and 5V connectors.

So can I use Male to Female Jumper Wires to directly connect these? I am not using anything else like LEDs or speakers.

My code keeps the inbuilt LED ON when smoke level is LOW and blinks when the Level is HIGH. Also will I need any resistor for it?


texts: What info should I look for when choosing a solid state relay for arduino?

texts:
I want to control a phone using an arduino board by connecting each pin of the arduino to a button on the phone using relays to simulate a button being pressed or release by switching a relay (on/off). I am using relays because from what I have seen (Use Arduino to Switch Power On and Off! ) relays are controlled swiches and I am using SSR because I want to use the less space possible.

I'm trying to buy a relay at mouser.com but I don't know what are the values I should look for, for those parameters (Control Voltage Range, Load Voltage Rating, Load Current Rating, Input Current).


texts:
recently i bought this oled display .

http://www.wvshare.com/product/0.96inch-OLED-A.htm

how can i connect it with arduino . Driver Chip is SSD1306 . Supported Interface are 3-wire SPI, 4-wire SPI, I2C . it's can display two colors Yellow and Blue.

i need some guidance on how to hook it up with arduino lets say using i2c protocol . and is there any existing library ?

Note : on the wvshare website there's only code sample for STM32 Microcontrollers .


texts: Hardware to measure velocity via string/wire attatchment? beginner

texts:
This is a broad question but I want advice on what type of hardware I should look for to make a device that could measure the velocity of an object attached via a string/wire to some sort of rotary wheel.

The purpose of this is to attach it to a barbell and measure mean-velocity for weightlifting atheletes.

I'm a software engineer by trade but know nothing about hardware. I will obviously need to start with simple projects to learn, but I would like to know which hardware I should lean towards buying, so I don't have to re-buy anything?


texts: Where can I find out how to make a hex file for arduino firmware?

texts: I have followed this tutorial on flashing my Arduino R3 to turn it into a "USB keyboard", but the article doesn't explain how the hex works, it's just for granted. Where can I learn about how to make my own hex file so that I can learn how to make my Arduino mimic any USB device?


texts:
I am trying to connect an ADXL355 digital sensor to an Arduino. The wiring and the code I think are OK because the system returns the correct values sometimes and partly correct answers mostly. The code checks the device register, and the correct data is printed to serial most of the time. The code also checks for temperature but only returns the correct value occasionally. The values are polled every few seconds. The values are correct all of the time if they are correct the first time after restart but never if they are incorrect on restart. I thought it might help to unplug the sensor when uploading the program or powering up the Arduino through USB to the computer but there is no clear pattern.

It is not a defective sensor because I have 2 that behave the same way. What could be the problem? Is this a problem with the Arduino?

I only wire VDD, VDDIO, ground,chip select, sclk, MOSI and MISO.

code:

#include <SPI.h>

    const int ID = 0x00;
    const int FIFO = 0x11;
    const int TEMP = 0x06;
    const int TEMP1 = 0x07;
    const byte FIFO_WATERMARK = 0x29;
    const int chipSelectPin = 7;

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

        SPI.begin();

        pinMode(dataReadyPin, INPUT);
        pinMode(chipSelectPin, OUTPUT);

        // writing 0 to to enable sensor
        writeRegister(0x2D, 0x00);

        delay(100);

        Serial.println(readRegister(ID));
        Serial.println(readRegister(FIFO_WATERMARK));
    }

    void loop() {
        int temp = (readRegister(TEMP)); // << 8) | (readRegister(TEMP1))) ;
        temp = (temp<<8)|(readRegister(TEMP1));
        Serial.println(((1852 - temp)/9.05) + 19.21);
        Serial.println(readRegister(ID));

        delay(1000);
    }

    byte readRegister (byte thisRegister){
        byte inByte = 0 ;
        SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0)); // 500khz clock
        digitalWrite(chipSelectPin, LOW);
        SPI.transfer((thisRegister << 1) | 1);
        inByte = SPI.transfer(0x00);
        digitalWrite(chipSelectPin, HIGH);
        return inByte;
    }
    void writeRegister (byte thisRegister, byte value){
        SPI.beginTransaction(SPISettings(500000, MSBFIRST, SPI_MODE0)); // 500khz clock
        digitalWrite(chipSelectPin, LOW);
        SPI.transfer(thisRegister << 1);
        SPI.transfer(value);
        digitalWrite(chipSelectPin, HIGH);
    }

Some one suggested it might be signal bounce on the SPI and the clock rate was set to 500kHz but it didn't work.

Update:
Not long ago, the correct device ID would be read consistently (173 for 0xAD); now that returns 0. The temperature would either return 0 from the register or changing values between -1 and -5 that may have been wrongly calibrated temperature. But sometimes the correct temperature would return. Now it also only returns 0 from the registers.


texts: Arduino Pro Micro TX and RX leds flash quikly while power drawn from VCC pin

texts:
I just got a 5V Arduino Pro Micro, which I connected to an RC RX powered from the VCC and GND pins of the board.

However, whenever I do so and power on the board from a computer USB connection or a wall adapter USB connection, the board goes into an odd mode where the red RX and TX leds flash rapidly (~0.5s on and ~0.5s off) and USB serial ceases functionality. (presumably, because the MCU isn't on anymore)

If I remove the load and power the board again, everything works as normal.

This is an odd behavior, especially since I read online that the VCC pin is rated for ~150ma max and my device (FS-iA6b) isn't a very high power device, tested by me to draw 30-50ma max.

What is happening here? I haven't even connected the 5v signal pin yet!


texts: Why do I get “ stray '#' in program ” error?

texts:
I am making an Arduino program with SIM800L module and would like to check credit status of the SIM card.
When I manually enter the command: AT+CUSD=1,"*123#" into Serial Monitor, it works fine.

But in the Arduino (1.8.7) I am receiving an error
      stray  "#" in program

when compiling this line of sketch:
      SIM800.print("AT+CUSD=1,"*123#"\r");

I am not experienced enough to fix this problem.
Could somebody help me, please?

Thank you.
Marko


texts:
I'm playing with the standard L298N motor board and Arduino MKR 1000. However something strange happens: when I upload a new firmware and when I turn on the Arduino power supply (every time Arduino resets) the motors unexpectedly move for 2 seconds.

From what I've seen in other questions, it should be enough to pull down the pwm signal (in fact it seems that the floating status of these pin in the reset procedure produces this problem). I used a 10k resistor as suggested, but with no effect.

I've tried also a 100 ohm resistor: in this case the motor makes some noise but it doesn't move. However, it won't move when it is supposed to in the loop section.

I've also tried to pull down all the three signals (enable, in1, in2) of the motor but with no difference. I've also tried to pull up to 5V, instead of pulling down: same issue at reset, but the motor spinning in the other direction.

I've also tried to put a relay controlling the motor external supply. However the reset procedure also turn 'on' the relay (no progress on the problem).

It isn't a software issue because it happens with an almost empty sketch. Same software+circuit on Arduino UNO doesn't cause the problem.
What should I do?


texts: LCD displays bad character while counting rotation

texts:
I have been practicing RPM and rotation counter in arduino using infrared optocoupler. I try to implement number of rotation for drill machine but whenever drill starts to rotate, LCD prints bad characters instead of displaying rotation.
Here is my code:

#include<LiquidCrystal.h>

 LiquidCrystal lcd(A0,A1,A2,A3,A4,A5);
             int SensorPin=      13;

             int Counter = 0;
void setup() {
  lcd.begin(16,2);
  pinMode(SensorPin,INPUT);
    lcd.setCursor(0,0);

}

void loop() {

           lcd .setCursor(0,0);

          if(digitalRead(SensorPin))
  {
    Counter = Counter+1;
    while(digitalRead(SensorPin));

  }
  lcd.setCursor(0,1);
     lcd.print(Counter);
  // put your main code here, to run repeatedly:

}

Here is my lcd at initial step:

When I start my drill, LCD changes to this:


texts: Arduino wrap or subclass print() to work with multiple Serial

texts:
I am writing an Arduino program that uses Bluetooth on Serial1 to print text to a Bluetooth terninal on an Android phone and also normal Serial to print text to the serial monitor on a laptop. I would like to wrap the Serial.print() and Serial.println() functions so that they work with either or both Serial and Serial1. For example the code below works fine depending on the values of the global variables. But this only works for single chars, but print() and println() can take a very wide variety of datatypes. If I also define overloading functions for int and String types it works fine, but that is a very verbose and maybe fragile solution, it also ignores the optional inputs to the underlying functions. What is the proper way to do this ?

void print(char x) {
  if (g_use_Serial)
    Serial.print(x);
  if (g_use_Serial1)
    Serial1.print(x);
}

void println(char x) {
  if (g_use_Serial)
    Serial.println(x);
  if (g_use_Serial1)
    Serial1.println(x);
}

I have implemented the solution suggested and it works nearly perfectly. There seems to be a problem with the new line characters on the bluetooth (Serial1) connection.

The code is:

class DualPrint : public Print
{
public:
    DualPrint() : use_Serial(false), use_Serial1(false) {}
    virtual size_t write(uint8_t c) {
        if (use_Serial) Serial.write(c);
        if (use_Serial1) Serial1.write(c);
        return 1;
    }
    bool use_Serial, use_Serial1;
} out;

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

void loop() {

  out.use_Serial = true;
  out.print("Printed to USB only.\n");
  out.use_Serial1 = true;
  out.print("Printed to both USB and BT.\n");
  out.use_Serial = false;
  out.print("Printed to BT only.\n");
  out.use_Serial1 = false;

  delay(3000);
}

The output on the USB Serial monitor is as expected:

Printed to USB only.
Printed to both USB and BT.
Printed to USB only.
Printed to both USB and BT.

The output on the Bluetooth terminal is not as expected, the new lines are not in the right position:

Printed to both USB and BT.Pri
nted to BT only.
Printed to both USB and BT.Pr
inted to BT only.
Printed to both USB and BT.Pr
inted to BT only.
Printed to both USB and BT.Pr
inted to BT only.

Any suggestions on how to fix this. Are there other function members that need to be re-implemented to make this work properly?

Many thanks for high quality answers so far.


texts: How can I see the mySerial.print( ) through the serialmonitor on IDE?

texts:
I made an object named "mySerial" like this.

SoftwareSerial mySerial(2,3) //pin 2 = RX, pin 3 = TX

also I made pin 13 periodically(0.5 seconds) blink(HIGH/LOW),
then the signal from pin 13 goes directly to pin 2 and pin 0(basic RX pin of UNO). I connected pin 0,2,13 directly with jumper wire.

and in the setup(), I wrote

Serial.begin(9600);

mySerial.begin(9600);

and in the loop(), I wrote

digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
delay(500);

if(mySerial.available()){
    mySerial.println("mySerial!");
}
if(Serial.available()){
    Serial.println("Serial!");
}

when I compile this code and operate arduino,
I can only see the "Serial!" on the serialmonitor.
I think this means that the pin 0 can recognize the signal but the pin 2 cant'
How can I solve this problem?

I can't find what I've missed. Please help me guys!


texts:
i write a code for Arduino + SIM800 for connecting to server.
but it don't work!

SerialGsm.println("AT+CIPSEND=63\r\n");
delay( 1000 );
receive_message();
SerialGsm.print( "GET http://sasasas.ir.ir/hadi/signal.php?value=10" );
delay( 10000 );
receive_message();

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

AT

OK

Call Ready

SMS Ready
AT+CSTT="mtnirancell"

OK
AT+CIICR

OK
AT+CIFSR

100.65.157.141
AT+CIPSTART="TCP","sasasas.ir",80

OK

CONNECT OK
AT+CIPSEND=63

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

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


texts: Using millis() to toggle an LED every 500 milliseconds

texts:
I thought the code below would toggle an LED every 500 milliseconds. But it does not work. I'm not able to catch the mistake, which must be very silly.

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

void loop() {
  unsigned long cnt=millis();
  if(!(cnt % 500)) {
    PORTD^= (1<<PD3);
  }
}

Anyhow the code below works. But why not the previous code?

void loop() {
  static unsigned long prev=0;
  // Note: First time case is not handled. As soon as we want to toggle,
  // we must store millis() in prev. In this case this happens after reset and may not be an issue.
  unsigned long current = millis();
  if((unsigned long)(current - prev) >= 500) {
    PORTD^= (1<<PD3);
    prev = current;
  }
}


texts:
I am trying to burn bootloaders to Atmega2560V and when I hit burn bootloaders it shows me this error

  avrdude: Device signature = 0x1e9803
  avrdude: Expected signature for ATmega2560 is 1E 98 01

I know this device should have 0x1e9801, But I don't know why it's showing me this error.

I tried my luck by starting threads at AVRFREAKS but no joy.

One of my friend told to try changing the device signature in the avrdude from 0x1e9801 to 0x1e9803 for a temporary try.

How can I do that.? please please please anyone help.

Thanks


texts:
I’m using an Arduino-uno
I'm trying to read an PWM signal being output by pin 6.
I'm attempting to read it with pin A0.
5 volts are being supplied from pin 6 to a 300 ohm resister in series with one led.
This circuit returns to the analog input pin A0.
It'll admit it's a strange set up and I was told to use a pass through filter to read the signal.
At this point I'm not concerned with whether the program reads the right values,
so despite the code involving the serial monitor I'm just trying to figure out why the led won't turn on anymore.
As I stated in the sketch, this exact set up was working fine yesterday. The led was on and (accurate or not) there were consistent values being printed to the serial monitor.
I'm trying to figure out now what changed after I unplugged it last to create a now open circuit.

```

void setup() {

  Serial.begin(9600);
  pinMode(6, OUTPUT);
  // I  also tried setting the A0 pin as an input even though I thought you didn't have to and it didn't change anything.

}

void loop() {

  analogWrite(6, 255); // This pin is working as an output, I tested it to ground and led lights.

  int value = analogRead(A0); // I realize inputs are typically used for things like potentiometers
                              // But just as an example the LED should still turn on when connected here, correct?
                              //And it did the first few times I did it... maybe that was the problem?

  Serial.println(value);  // This was  all working previously. It just randomly stopped.
                          // Now this just prints random numbers and the circuit remains incomplete.
                          // Even if the input pins are not supposed to be used with 5 volts, Why was it working before then...
                          // ALSO it does not matter which pins you use for what...
                          // No current is running through the digital inputs with digital output set to HIGH.
                          // And No current runs through the analogInput pins when analogWrite is set to 255.
                          // Once again, I apologize if my terminology is off.

}
```

This is what I did to trouble shoot:
With the same sketch running on the board...
I connected a jumper from pin A0 to ground and the serial monitor switched from a bunch of random values to a solid 0. So it recognizes input still... in a sense.
Then I modified the sketch...
void setup() {

Serial.begin(9600);
pinMode(6, OUTPUT);
pinMode(8, INPUT);

}

void loop() {

// now I'm attempting to read a digital signal with the same circuit...
// Pin 6 is connected to a 300 ohm resistor in series with an led which returns to pin 8.

digitalWrite(6, HIGH);

int value = digitalRead(8);

Serial.println(value);

}

This gave the same result. The led wont turn on anymore unless the circuit ends are connected from a voltage source to ground.
Previously, any pins configured as INPUT would not only read consistent values but also complete the circuit, turning the led on.
Now the pins only recognize zero volts and do not complete any circuits. You can't even use a simple potentiometer if you wanted.
Each pin that can be configured as an INPUT acts the same way.
The only thing I did between the times when it was working and wasn't was unplug and plug in the board...


texts:
I'm quite a newbie using C ++. I am trying to implement in C ++, the state machine described in this link for C language:
https://barrgroup.com/Embedded-Systems/How-To/Coding-State-Machines.

I have created an Fsm class, which implements the behavior of the state machine, and a Machine class, whose methods will be the states.

The code works, but it generates a warning (-Wpmf-conversions) when I try to save the memory address of a Machine method, in State state__

class Fsm
{
public:
    typedef void (*State)();
private:
    State state__;
public:
    Fsm(State state);
    void dispatch();
};

Fsm::Fsm(State state)
{
    state__ = state ;
} //Fsm

void Fsm::dispatch()
{
    (*state__)() ;
}

class Machine : public Fsm
{
public:
    Machine() : Fsm((State)&Machine::initial) {}       // ctor
};

I'm using an Atmega2560, with AVR-GCC compiler.


texts:
I am making a line follower robot. My code is like this

#define motI1 10
#define motI2 6
#define motI3 5
#define motI4 3

int left=9;   // left sensor
int right=1;  // right sensor

void setup() {
  pinMode(motI1, OUTPUT);
  pinMode(motI2, OUTPUT);
  pinMode(motI3, OUTPUT);
  pinMode(motI4, OUTPUT);
  pinMode(left, INPUT);
  pinMode(right, INPUT);
  Serial.begin(9600);
}

void loop() {
  if(((digitalRead(left))==HIGH)&&((digitalRead(right))==HIGH)) {
    digitalWrite(motI1, HIGH);
    digitalWrite(motI2, LOW);
    digitalWrite(motI3, HIGH);
    digitalWrite(motI4, LOW);
    Serial.println("FORWARD");
    delay(1);
  } else if(((digitalRead(left))==HIGH)&&((digitalRead(right))==LOW)) {
    // turn right
    digitalWrite(motI1,HIGH);
    digitalWrite(motI2,LOW);
    digitalWrite(motI3,LOW);
    digitalWrite(motI4,LOW);
    Serial.println("Right turn Right Sensor LOW");
    delay(1);
  } else if(((digitalRead(left))==LOW)&&((digitalRead(right))==HIGH)) {
    // turn left
    digitalWrite(motI1,LOW);
    digitalWrite(motI2,LOW);
    digitalWrite(motI3,HIGH);
    digitalWrite(motI4,LOW);
    Serial.println("Left turn Left Sensor LOW");
    delay(1);
  } else if(((digitalRead(left))==LOW)&&((digitalRead(right))==LOW)) {
    digitalWrite(motI1,LOW);
    digitalWrite(motI2,LOW);
    digitalWrite(motI3,LOW);
    digitalWrite(motI4,LOW);
    Serial.println("Stop");
    delay(1);
  }
}

Only pin 1 of the Arduino is working but other pins are not working for the IR sensor. But the pins for the motor are working just fine. What is the real problem?


texts: Is it possible to upload a private root certificate to an Arduino Nano33?

texts:
I'm trying to connect an Arduino Nano 33 to an mqtt broker with TLS authenticaton on the broker side. To do that I need my Arduino board to have access to the the root certificate.
My understanding is that unlike ESP32, the Nano's NINA wifi module does not have a WiFiSSLClient object with a setCACert method that you can use to pass the root certificate. Instead, the NINA's client has a connectSSL() method which uses whatever root certificate you have uploaded to the Nano using Arduino's IDE. However, as it can bee seen in this tutorial, it looks like it is only possible to upload public domain root certificates by entering the website.
But what if I wanted to upload a root certificate that I have generated using OpenSSL. Would that be possible?


texts: LCD shows wrong value from MQ-135 sensor and the txt is stuck on screen

texts:
i am using a MQ-135 gas sensor and 20x4 LCD screen and it shows different values on the serial
monitor it shows 756 PPM and on the LCD screen it is stuck below 320PPM the text BAD is also stuck on the screen and doesn't update on the
lowering of PPM value of CO2

this is my code
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#define sensor A0
int gas, co2lvl;
#define updateDisplay();

void setup()
{
pinMode(sensor,INPUT);
Serial.begin(9600);
lcd.begin(20,4);
  lcd.clear();
}

void loop()
{
co2lvl=gas-255;
co2lvl=map(co2lvl, 0,1024,400,5000);
Serial.print(co2lvl);
Serial.print("ppm");
Serial.println();
delay(200);
if(co2lvl>=699){
updateDisplay();
lcd.setCursor(0,0);
lcd.print("CO2 IN THE AIR");
lcd.setCursor(0,1);
lcd.print(analogRead(co2lvl));
lcd.setCursor(6,1);
lcd.print("EXCELLENT");
}
else if(co2lvl<=700){
updateDisplay();
lcd.setCursor(0,0);
lcd.print("CO2 PRESENT IN THE AIR");
lcd.setCursor(0,1);
lcd.print(analogRead(co2lvl));
lcd.setCursor(4,1);
lcd.print("GOOD");}
else if(co2lvl<=900){
  updateDisplay();
  lcd.setCursor(0,0);
lcd.print("CO2 PRESENT IN THE AIR");
lcd.setCursor(0,1);
lcd.print(analogRead(co2lvl));
lcd.setCursor(5,1);
lcd.print("FAIR");}
else if(co2lvl<=1100){
  updateDisplay();
  lcd.setCursor(0,0);
lcd.print("CO2 PRESENT IN THE AIR");
lcd.setCursor(0,1);
lcd.print(analogRead(co2lvl));
lcd.setCursor(5,1);
lcd.print("MEDIOCRE");
}
else(co2lvl<=1600);{
  updateDisplay();
  lcd.setCursor(0,0);
lcd.print("CO2 PRESENT IN THE AIR");
lcd.setCursor(0,1);
lcd.print(analogRead(co2lvl));
lcd.setCursor(5,1);
lcd.print("BAD");}
}


texts: Do I really need Ramps 1.4 for laser engraver

texts:
I'm making 2-axis laser engraver like system. Arduino waits command from pc, on receive moves laser to next coordinate and send current coordinate to pc.

I have 3 step motors and I'm controlling them with Arduino Uno which is connected to A4988 drivers which is on breadboard. But almost all samples using Ramps. Do I miss something?


texts: Why does MKRZero code read value off of wire on A0, even though there is no voltage/current?

texts:
I have a MKR Zero running the code from the official Arduino site :
https://www.arduino.cc/en/Tutorial/AnalogToMidi

The circuit wasn't working (always reading a value of 0 on A0 -- as detailed in another of my questions : What might be some reasons this MKRZero circuit and sketch fail to read frequency?

I have never gotten any value above zero, so I built a separate circuit to create some current (providing 18mA) and I connected the wire into A0.  When I did that I saw that I was receiving values in A0.
Here's the important part of the code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.print("out!");
  pinMode(11, OUTPUT);
  meter.setBandwidth(75.00, 600.00);          // Set available bandwidth between 75Hz and 600Hz
  meter.begin(A0, 45000);                     // Intialize A0 at sample rate of 45kHz
}

void loop() {
  float frequency = meter.getFrequency();

  if (frequency > 0)
  {
    Serial.println(frequency);

However, then I removed the power and eventually just had the wire sticking out of A0 (like an antenna) and the code reads values when that wire is hanging loose on A0.

Here's the data (obviously random) that is read :

Pull Wire Out

If I pull that wire out, no values are printed in Serial Monitor because the values are never greater than 0.

Can you explain why I see values when the wire is just stuck in there?
I'm guessing that this is some effect occurring like an antenna or something, but I'm not sure.

I'm also wondering how I can tell that false values aren't read when the wire comes from the circuit shown in the original Arduino sketch (at that first link at the top).